0 registered members (),
1,119
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147318
08/11/07 18:53
08/11/07 18:53
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
ok tried that but no joy, the sprite still will not appear, Code:
function c_ship { player = my; my.scale_x = 1.0; my.scale_y = my.scale_x; my.scale_z = my.scale_x; you = null ; while(1) { if(!you) { c_scan(player.x, temp, vector(360, 60, 1000), ignore_me); wait(-0.25); }wait(1); } }
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147320
08/11/07 19:36
08/11/07 19:36
|
Joined: Sep 2002
Posts: 700 Orange County, CA
LogantheHogan
Developer
|
Developer
Joined: Sep 2002
Posts: 700
Orange County, CA
|
Haha okay. I have a tendency to write really buggy code and then slowly debug it over time. It always ends up working, but I NEVER do it right the first time. In any case, here's your whole code, which should work like magic. Code:
function c_ship { player = my; my.scale_x = 1.0; my.scale_y = my.scale_x; my.scale_z = my.scale_x; while(1) { if(you == null) { c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you); } wait(-0.25); } }
function event_scn(); function got_target();
function f_ship { 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; }
var enemy_handle; // a global handle we can use for transferring pointers function event_scn() { if (event_type == event_scan) { enemy_handle = handle(me); ent_create("cross.pcx", my.x, got_target); } }
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); } ent_remove(me); }
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147321
08/11/07 19:51
08/11/07 19:51
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
i`m getting a parameter unknown event_scn bad keyword in {} here is the event_scn it is the same as your code above is`nt it? Code:
event_scn() { if (event_type == event_scan) { enemy_handle = handle(me); ent_create(lockon, my.x, got_target); } }
o and thanks for all this help btw
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: a query about c_scan
[Re: jigalypuff]
#147322
08/11/07 20:37
08/11/07 20:37
|
Joined: Sep 2002
Posts: 700 Orange County, CA
LogantheHogan
Developer
|
Developer
Joined: Sep 2002
Posts: 700
Orange County, CA
|
Yeah, it's the same, except yours just says event_scn, not function event scan. Was that just a post typo?
EDIT: And did you include the function protoypes from my code up there? ^^ Those are very important.
Last edited by LogantheHogan; 08/11/07 20:39.
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147323
08/11/07 20:59
08/11/07 20:59
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
man i`m a dunce, i forgot to write function, however the target sprite still is not appearing, here is all the code from the test level Code:
string stars_mdl = "stars.mdl"; string galor_mdl = "galor.mdl"; string excelsior_mdl = "excelsior.mdl";
entity* enemy;
string lockon = "lockon+3.tga"; string cphaser_mdl = "cphaser.mdl";
bmap hempire_tga = "hempire.tga";
function stars(); function c_ship(); function f_ship(); function event_scn(); function got_target(); //function beam_weapons();
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(100,0,0), f_ship); ///ent_create (excelsior_mdl, vector(200,40,0), f_ship); ///ent_create (jungle_mdl, vector(1500, 10000, 0), planets); ///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 c_ship { player = my; my.scale_x = 1.0; my.scale_y = my.scale_x; my.scale_z = my.scale_x; while(1) { if(you == null) { c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you); } wait(-0.25); } } function f_ship { 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; }
var enemy_handle; // a global handle we can use for transferring pointersfunction
function event_scn() { if (event_type == event_scan) { enemy_handle = handle(me); ent_create(lockon, my.x, got_target); } }
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); } ent_remove(me); }
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147325
08/11/07 21:42
08/11/07 21:42
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
ok tried the you = null; still no joy, i also made the scale of the sprite bigger so i`d see it regardless of were it was, but it does not appear, here is the player function now i think i put the you = null in the right spot Code:
function c_ship { player = my; my.scale_x = 1.0; my.scale_y = my.scale_x; my.scale_z = my.scale_x; you = null; while(1) { if(you == null) { c_scan(player.x, temp, vector(360, 60, 1000),ignore_me+ignore_you); } wait(-0.25); } }
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: a query about c_scan
[Re: jigalypuff]
#147326
08/11/07 22:28
08/11/07 22:28
|
Joined: Sep 2002
Posts: 700 Orange County, CA
LogantheHogan
Developer
|
Developer
Joined: Sep 2002
Posts: 700
Orange County, CA
|
It's weird, I have your exact code running in SED and it works fine. The only other thing I can think of is that your player function has something else that's changing the YOU pointer for some reason. Try this. entity* target_entity; And then, in the player action, change the while loop to this: Code:
while(1) { if(target_entity == null) { target_entity = c_scan(player.x, temp, vector(360, 60, 50),ignore_me); } wait(-0.25); }
That might work?
|
|
|
Re: a query about c_scan
[Re: LogantheHogan]
#147327
08/11/07 22:48
08/11/07 22:48
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
i think it must be me, what i have done is compile the level and zipped it, would you be good enough to dl it and look over the code, perhaps you`ll see were i`ve gone wrong, i know it`s a lot to ask mate. http://www.4shared.com/file/21849860/893a13a5/test_level.html
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
|