Page 1 of 1

Stop killing when no bullets, if ammo = 0

PostPosted: Fri May 04, 2007 4:10 pm
by scythe
if (Slash==1){ DestroyActor("Event Actor"); Score.textNumber = Score.textNumber + 30; Slash=0; }

I have created this type of code (with help from you guys) for the collision and scoring its working great, but need to add something that tells it not to destroy or collide with the NME actors if the ammo = 0.

I have tried a few ways even an actor with script if (ammo=0); and then various things like CollisionState("Event Actor", DISABLE); and others, but cannot get it to work, any help?

I'm sure its something pretty simple along these lines.. I hope :)

Thanks,
scythe

PostPosted: Fri May 04, 2007 4:29 pm
by makslane
Use:

Code: Select all
if(ammo == 0)
{
  //Your actions
}

PostPosted: Tue May 08, 2007 10:32 am
by scythe
Thanks makslane, I made an actor called noammo and tried this, but still can't get it to work, I tried 'else' and other ways, but no luck.

Do I have my code in the wrong place, is another actor taking over maybe, i'll look into it more.

Code: Select all
if (ammo==0)
{
     CollisionState("Event Actor", DISABLE);
}
if (ammo>0)
{
     CollisionState("Event Actor", ENABLE);
}




Although you have helped me understand the structure of scripting more thanks, ive also been tidying up my code instead of having 1 or 2 big lines :)

Any suggestions, I just want it to stop killing enemies when out of bullets.

Scythe

PostPosted: Tue May 08, 2007 1:05 pm
by Rufus 01
Hey scythe your code is a little bad wrong I thing, u should try this:
Code: Select all
if (ammo == 0)
{
     CollisionState("Event Actor", DISABLE);
}
else if (ammo >= 0)
{
     CollisionState("Event Actor", ENABLE);
}

PostPosted: Tue May 08, 2007 1:57 pm
by scythe
Thanks guys, you were right Rufus it was the missing else if. :)

Strange thing is I had to add the code in the collision for some enemy actors, but not others?

Scythe