Stop killing when no bullets, if ammo = 0

Game Editor comments and discussion.

Stop killing when no bullets, if ammo = 0

Postby scythe » Fri May 04, 2007 4:10 pm

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
scythe
 
Posts: 37
Joined: Wed Apr 11, 2007 2:50 pm
Location: Australia
Score: 0 Give a positive score

Postby makslane » Fri May 04, 2007 4:29 pm

Use:

Code: Select all
if(ammo == 0)
{
  //Your actions
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby scythe » Tue May 08, 2007 10:32 am

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
scythe
 
Posts: 37
Joined: Wed Apr 11, 2007 2:50 pm
Location: Australia
Score: 0 Give a positive score

Postby Rufus 01 » Tue May 08, 2007 1:05 pm

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);
}
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score

Postby scythe » Tue May 08, 2007 1:57 pm

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
scythe
 
Posts: 37
Joined: Wed Apr 11, 2007 2:50 pm
Location: Australia
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron