E1513 fehler?

Posted By: Patrick92

E1513 fehler? - 12/17/13 16:30

hallo

Ich möchten eine kanonen kugel abschiessen die von der schwerkraft beeinflust wird und die dann nach gewisser zeit verschwindet aber sobalt ich denn ent_remove(me) benutzte kommt der fehler E1513(soweit ich weis ist das der fehler das er was löschen will was nicht existiert aber die kugel seh ich ja fliegen also existierst sie ja?)

hier mein code[code]
var high;


function sh()
{
my.emask |= ENABLE_ENTITY;
my.event = bounce_event; //macht querschläger

vec_set(my.x,camera.x);
vec_set(my.pan,camera.pan);
my.skill1 = 80;
while(1)
{

c_move(my,vector(my.skill1*time_step,0,0),vector(0,0,-9.1*time_step),IGNORE_PASSABLE+IGNORE_ME+IGNORE_MODELS);
my.skill1 -= 0.5*time_step;
high = my.z;
if(my != NULL)
{
if(my.skill1 < 0)
{

ent_remove(me);


}
}
wait(1);
}
}

//in der function zum erstellen der kanonen kugel steht das
if(key_lastpressed == 57)
{
ent_create("shoot.mdl",camera.x,sh);

key_lastpressed = 0;
}

/code]

danke im voraus für eure hilfe
Posted By: Ch40zzC0d3r

Re: E1513 fehler? - 12/17/13 16:33

...
while(me)
...
wait(1);
ent_remove(me);
...
Posted By: Superku

Re: E1513 fehler? - 12/17/13 16:53

What I normally do is the following:

action dummy()
{
...
my.skill1 = 5*16; // 5 seconds
while(my.skill1 > 0)
{
...
my.skill1 -= time_step;
wait(1);
}
effect...
ptr_remove(me);
}

Then you can easily use events (for impact detection and the like) where you set skill1 to 0.
Posted By: Patrick92

Re: E1513 fehler? - 12/17/13 17:02

danke jetzt funktionierts
Posted By: WretchedSid

Re: E1513 fehler? - 12/17/13 20:29

Did return become uncool or what's up with that?

Edit: Also, every sane compiler will optimize the `if(my != NULL)` away because it can safely assume it's not NULL since you've already used the pointer previously. Not vouching for the Lite-C compiler here, but yeah, it's highly superfluous.
Posted By: Superku

Re: E1513 fehler? - 12/17/13 20:44

Quote:
Did return become uncool or what's up with that?

If you deal with objects in a game (world), then yes. It's always better (at least from my experience) to let the entity function end at it's last bracket where it oftentimes gets removed and plays death animations, effects and or sounds before that (and after its main loop).
© 2024 lite-C Forums