Jump to content
Sign in to follow this  
Killer_KF

Help with scripting

Recommended Posts

How do you get the ai to reload when they have low ammo?

I know it has something to do with a trigger but i cant quite figure out how to so it from there. I need the reload to go dynamically with the guy so right after he is done fighting he goes to an ammo box and reloads.

Share this post


Link to post
Share on other sites

well, I was kinda stuck on that my self.

it's easy to check if he's running low on ammo, but you can't simply ask him to pick up magazines...

you could always use the "ammo" command and if he's running low, make him go to the boxes, and then you give him the ammo.

something like this:

create a trigger and use this for condition:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">my_soldier ammo "M16" ==0<span id='postcolor'>

this means that he's out of ammo.

now, in the activation field put this:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">my_soldier domove getpos ammo_box<span id='postcolor'>

ammo_box is the name you'll give to the ammo crate you want him to go and reload

then use another trigger with a 2x2 radius, group it to the player using F2, and select "any member","present".

then place it exactly over the ammo crate. this will activate everytime your soldier moves over the ammo.

put this in the activation field:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">my_soldier addmagazine "M16";my_soldier addmagazine "M16"; my_soldier domove getpos his_place <span id='postcolor'>

this will give him 2 M16 mags (add the command again for more) and move him back to the positon his_place is. "his_place" can be a marker, an object, or a game logic but you'll have to define it.

make both triggers repeatedly, and it should work good biggrin.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×