Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
still stuck with my phasers #148425
08/16/07 19:48
08/16/07 19:48
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
ok i am so very close to the effect i`m after for my game, but i have tried so many different things and all i have managed is to give myself a headache, although that may have been caused by banging my head off mm desk lol, i am going to post all the test code in the hopes that someone can tell me, how to scale a model on it`s x axis to an enemy model and not pass through it. i know this is a lot of code to ask you guys to look through, but believe me when i say i have tried my best but just can`t figure it out. thanks for any help.
Code:

var video_mode = 8;
var video_depth = 32;
var video_screen = 1;

sound beam_wav = <beam.wav>;

string stars_mdl = "stars.mdl";
string galor_mdl = "galor.mdl";
string excelsior_mdl = "excelsior.mdl";
string fphaser_mdl = "fphaser.mdl";

var distance_to;
var enemy_handle; // a global handle we can use for transferring pointers
var target_entity;
var scan_indicator;
var target_on;
var in_p;
var freeze_switch;
var camera_move_to[3];
var camera_distance = 200;
var camera_pan;
var camera_tilt;

entity* enemy;

define _target = 1;
define phaser skill12;
define ammo skill21;

string lockon = "lockon+3.tga";
string cphaser_mdl = "cphaser.mdl";

bmap hempire_tga = "hempire.tga";
bmap charge_pan_tga = "charge_pan.tga";
bmap charge_tga = "charge.tga";
bmap effect_tga = "effect.tga";

function stars();
function c_ship();
function f_ship();
function event_scn();
function got_target();
function c_phaser();
function got_shot();

panel Phaser_pan
{
bmap = charge_pan_tga;
pos_x = 945;
pos_y = 567;
window = 3, 2, 74, 7, charge_tga, player.phaser, 0; // can range from 0 to 74
flags = refresh, visible;
}

var phaser_decreasing = 0;
function init_player_startup()
{
while (player == null)
{
wait (1);
}
player.phaser = 74;
while (1)
{
if(phaser_decreasing == off)
{
player.phaser += 0.4 * time_step; // increase power slowly
player.phaser = min(74, player.phaser); // limit phaser power 74
}
wait (1);
}
}

function beam_weapons
{
while ((mouse_left == 1))
{
if(player.phaser <= 0) { break; }
phaser_decreasing = on;
player.phaser -= 3*time_step;
snd_play (beam_wav, 50, 0);
{
vec_for_vertex(temp,player,3894);
ent_create (fphaser_mdl, temp, c_phaser);
wait(1);
}
phaser_decreasing = off;
}
}

function c_phaser
{
///this needs to scale a model from the players vertex to the targeting sprite
///and run the got shot function
}

on_mouse_left = c_phaser;

function main
{
///init_radar();
mouse_map = hempire_tga;
mouse_mode = 1;
level_load ("new_beginings.wmb");
wait(1);
ent_create (stars_mdl, nullvector, stars);
ent_create (galor_mdl, vector(0, 0, 0), c_ship);
ent_create (excelsior_mdl, vector(300,0,0), f_ship);
// ent_create (excelsior_mdl, vector(200,40,0), f_ship);
//ent_create (excelsior_mdl, vector(-200, 40, 0), f_ship);
//ent_create (clouds_mdl, vector(1500, 10000, 0), clouds);
//ent_create (jungle_mdl, vector(25000, 10000, 0), planets);
//ent_create (clouds_mdl, vector(25000, 10000, 0), clouds);
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (5);
}
}

function target_detect()
{
enemy = my;
distance_to += 1;
if(event_type == event_detect && scan_indicator == _target && target_on == 0 && vec_dist(my.x,your.x) < distance_to)
{
target_on = 1;
enemy_handle = handle(you);
target_entity = handle(you);
ent_create(lockon, your.x, got_target);
}
}

function scan_targets()
{
while(1)
{
wait(-0.25);
if(target_entity != 0) { continue; }
scan_indicator = _target;
distance_to = c_scan(player.x, player.pan, vector(360, 60, 1000),ignore_me+ignore_you+scan_limit);
}
}

function c_ship()
{
in_p = 0;
freeze_switch = 0;
player = me;
my.ammo = 50;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
///my.transparent = on;
you = null;
my.enable_detect = on;
my.event = target_detect;
var ship_speed;
scan_targets();
while (1)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 10.0 * time;
}
}
else
{
if (ship_speed.x >= 0)
{
ship_speed.x -= 0.05 * time;
}
}
if (ship_speed.x < 0) {ship_speed.x = 0;}
if (key_a == on)
{
my.pan += 3 * time;
}
if (key_d == on)
{
my.pan -= 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_q == on)
{
my.tilt + = 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_e == on)
{
my.tilt - = 3 * time;
}
ent_move (ship_speed.x, nullvector);
if
(key_p)
{
if (in_p == 0)
{
in_p = 1;
freeze_switch = 1 - freeze_switch;
}
}
else
{
in_p = 0;
}
if (freeze_switch == 0)
{
camera.pan -= mouse_force.x * 12 * time;
camera.tilt += mouse_force.y * 8 * time;
camera.tilt = clamp(camera.tilt,-30,10);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera.tilt,-camera_distance)));

vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.

trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp.x); //trace from the player to 16 quants behind the camera.
IF (result > 0) {
vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}

}
wait(1);

}
}



function f_ship
{
enemy = my;
my.scale_x = 2.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
my.enable_scan = on;
my.event = event_scn;

}

function event_scn()
{
wait(1);
}

function got_target
{
my.scale_x = 0.1;
my.scale_y = my.scale_x;
my.oriented = on;
my.facing = off;
you = ptr_for_handle(enemy_handle); // now YOU is the enemy

while(you != null)
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // turn the target toward the player
vec_set(temp,nullvector);
temp.x = 20; // change this if you need to - the distance in front of the enemy
vec_rotate(temp,my.pan);
vec_add(temp,your.x);
vec_set(my.x,temp);
wait(1);
}
target_entity = 0;
target_on = 0;
ent_remove(me);
}

function got_shot()
{
if (event_type == event_block
|| event_type == event_entity
|| event_type == event_impact) {
my._hull -= 10;
}
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: still stuck with my phasers [Re: jigalypuff] #148426
08/16/07 20:26
08/16/07 20:26
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Hey man, sorry I didn't reply to your PM sooner, and the reply I did send was kind of lame. I've been learning how to program in C# the past couple days and it's taking all my focus (and energy) so I didn't really have a good answer for you.

Here are my two thoughts on this.

1. I have never tried to do what you are doing with weapons, i.e. scale a model to a certain size instead of move it to a certain point. The reply I sent you mentioned vec_dist(), which I know you'll need to use, but I honestly have no idea how to scale a model on its X axis so that it spans a certain number of quants. All I know is my.scale_x = ?. I'm not even sure if this is entirely possible, which leads to my next thought.

2. I don't think using a model is the best way to be doing this. You can write a particle function that does the same thing as what you're trying to do with a model, and frankly using particles would probably be a lot faster and look a lot cooler as well.

So, there ya go. That's another reason why I wasn't being too reply-happy; you stumped me.

But seriously. I'd download EasyParticle 3 or look at the template particle scripts and get an idea of how to write a particle function to do what you're trying to do. Unless you NEED a model, in which case, well... yeah.

So there ya go. God bless.

Re: still stuck with my phasers [Re: LogantheHogan] #148427
08/16/07 20:39
08/16/07 20:39
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
the reason i was useing a model is because i saw it used in the star wars demo posted a while back in showcase 1 and it seemed to be just what i was after, i have tried doing this with particles but i failed miserably at that as well. i`ll try doing a partical function and hope for the best, if anyone can help solve this you`ll have my eternal gratitude, either useing particals or a model.
good luck with your studies logan, and thank you.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: still stuck with my phasers [Re: jigalypuff] #148428
08/16/07 20:56
08/16/07 20:56
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Then I stand corrected; it is possible. Regardless, I still have no clue how to do it. When you find out, let me know. Haha.

And don't hesitate to ask me any more questions. C# is easy enough to learn, I think I've definitely got the hang of it. So that won't be distracting be anymore.

Re: still stuck with my phasers [Re: LogantheHogan] #148429
08/17/07 07:37
08/17/07 07:37
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
if i ever find out i`ll post it in user contributions so noone ever has to go through this again lol, i`ll keep pluging away at it and hope someone out there knows how to achieve this and come save my sanity lol


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: still stuck with my phasers [Re: jigalypuff] #148430
08/17/07 10:13
08/17/07 10:13
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
The only thing i can think of is to have a block that is as big as the gun ever gets and have it follow around at the same position the gun is, invisible...


Wait, there isn't a "Make My Game Now" button?
Re: still stuck with my phasers [Re: Bot190] #148431
08/17/07 10:55
08/17/07 10:55
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
well it`s not a gun lol, it`s a spaceship. i`m not to sure what you mean though, i thought if i declared an entity like entity* enemy then i could use that as a pointer for the mesh to go to like my_scale.x = enemy.x; but that fails, eve nwhen it hits the enemy it passes through. and if the enemy is movewing as i will be then it wont be possible to use a block would it? i`d get the same problem of the beam passing through the enemy and seeing it passing out the other side.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: still stuck with my phasers [Re: jigalypuff] #148432
08/17/07 11:28
08/17/07 11:28
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
well, in the manual it says that the collision hull doesn't change im guessing thats your problem, the engine doesn't know that it hit the other model becuase collision detection doesn't work, so i thought if you have a box thats as big as the beam(im guessing thats what your scaling?)and use that for collision detection. oh and wouldn't that just make it scale so the beams x is the same as the enemys x? tonight I'll look at the code and see if i can come up with something.


Wait, there isn't a "Make My Game Now" button?
Re: still stuck with my phasers [Re: Bot190] #148433
08/17/07 12:27
08/17/07 12:27
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
well i hope to god you can, i am so stuck i`m like the king of stuck in stucktown on stuckday lol, everything i have tried has failed and now i can`t even get the damn thing to scale anymore lol, i dunno were i went wrong lol


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: still stuck with my phasers [Re: jigalypuff] #148434
08/17/07 21:09
08/17/07 21:09
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
could you post what you have tried? if you have it still.


Wait, there isn't a "Make My Game Now" button?
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1