Jump to content
Sign in to follow this  
SugarDad

addMagazine causes AI to run to vehicle?

Recommended Posts

Hi all. First post here. Just started testing out the editor and looking at script commands. My situation is this:

I want an AI sitting down with a Makarov (not drawn) and 1 mag for it. I want a rubber boat on the shore.

I have a small rubber boat at the shore (which has a default loadout I noticed). One AI rifleman (not grouped with boat) is placed some meters away and given this in his init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="removeAllWeapons this;{this removeMagazine _x} forEach magazines this;this addWeapon ""Makarov"";this addMagazine ""8Rnd_9x18_Makarov"";this setBehaviour ""safe"";this switchMove ""AmovPercMstpSnonWnonDnon_AmovPsitMstpSnonWnonDnon_ground"";";

What happens is that he stands up, runs to the boat and kneels down, as if he's taking ammo from there.

If I remove the addMagazine, he stays sitting down. So, the addMagazine causes him to run to the boat. I tried removing the addWeapon but it didn't change anything. It's the mag that does it.

I wondered what would happen if I removed all the magazines from the boat, so I did that. What happened then is that the AI stood up and just did nothing. So, the addMagazine seems to break his "sitting down", even though "sit" is the last command given.

Is this because he's loading the pistol with the mag automatically? Is there a simple workaround?

Grateful for any help smile_o.gif

Share this post


Link to post
Share on other sites

welcome.gif

One Magazine just is not enough for him, he stands up running to the boat in an attempt to pick up more. But as I tried it here with giving him 8 Mags, he still stands up.

If the guy never needs any loaded weapon at all, e.g. for an intro, then just don't give him one so he stays down.

Or give him a name, remove the magazine and add it when he could need it, e.g. when enemy is approaching him with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">name add addMagazine "8Rnd_9x18_Makarov"

Another attempt is to make a little script which forces him into the sit down animation, but first it eats resources and second you need to end the script once you want to make him stand up or run.

Unless someone else comes up with a better idea, removing the mags would be the best choice.

Share this post


Link to post
Share on other sites

He is probably trying to collect hand grenades from the boat, since he has low ammo.

If you give him the magazine before giving him the weapon, he will remain seated.

Share this post


Link to post
Share on other sites
Or give him a name, remove the magazine and add it when he could need it, e.g. when enemy is approaching him with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">name add addMagazine "8Rnd_9x18_Makarov"

Another attempt is to make a little script which forces him into the sit down animation, but first it eats resources and second you need to end the script once you want to make him stand up or run.

Unless someone else comes up with a better idea, removing the mags would be the best choice.

Hi and thanks smile_o.gif

You meant a while-true-loop to make him sit? Yeah that doesn't sound like a good solution.

He will be in an intro cutscene but he's supposed to be attacked later so I guess I can make a trigger to give him the mag at a later point. Need to learn how to do triggers sooner or later anyway wink_o.gif

Oh, I also noticed if I do setBehaviour "careless", then he won't run off to the boat either, but he doesn't seem to mind getting an M4-barrel against his face either. He just sits there, although he spins to face you. Was thinking of leaving him in "careless" and later putting him in "safe" mode, but I still have this feeling that he'll just stand up instantly when going to "safe"like he does now if I would.

So, I'll try a trigger to give him the mag later. Thanks smile_o.gif

Share this post


Link to post
Share on other sites
He is probably trying to collect hand grenades from the boat, since he has low ammo.

If you give him the magazine before giving him the weapon, he will remain seated.

Pretty sure I tried it. The order didn't matter. As long as he had the gun, only not giving him the mag kept him sitting.

Thanks anyway!

Share this post


Link to post
Share on other sites

Try again, it worked for me using your exact init line...

Share this post


Link to post
Share on other sites
Try again, it worked for me using your exact init line...

Really? Maybe he wasn't close enough to the boat? smile_o.gif I don't know how far their magic inventory detection reaches but maybe my dude was closer to the boat than yours. I tried like 10 times and switched order, behavior and so on. The only thing I didn't try was placing the boat 1km away to see if that helped smile_o.gif

Share this post


Link to post
Share on other sites

The soldier is within 1m of the boat. As long as their is no vehicle (or crate) carrying hand grenades or makarov mags as cargo within detection distance (~45m??), and the makarov magazine is added to the soldier before the weapon, he will not get up.

beach.jpg

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">removeAllWeapons this; {this removeMagazine _x} forEach magazines this; this addMagazine "8Rnd_9x18_Makarov"; this addWeapon "Makarov"; this setBehaviour "safe"; this switchMove "AmovPercMstpSnonWnonDnon_AmovPsitMstpSnonWnonDnon_ground"

Share this post


Link to post
Share on other sites

Hm, that's odd. I gotta try it later tonight and see what happens. I'll be back with an update later smile_o.gif

Share this post


Link to post
Share on other sites

Or instead of trying all those tricks you could just disable them from changing anims:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit disableAI "ANIM"

And to reenable him to change anims:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit enableAI "ANIM"

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">removeAllWeapons this; {this removeMagazine _x} forEach magazines this; this addMagazine "8Rnd_9x18_Makarov"; this addWeapon "Makarov"; this setBehaviour "safe"; this switchMove "AmovPercMstpSnonWnonDnon_AmovPsitMstpSnonWnonDnon_ground"

Wow I must have been drunk.

I could put money on betting I tried that sequence. I guess I had messed something else up while trying that.

Ah well. It worked at least smile_o.gif Thanks!!!

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  

×