Jump to content
Sign in to follow this  
Winters

Is there anyway to make your squad rearm?

Recommended Posts

Hello,

I want to make my squad i am leading re-arm. Is there a way to make them re-arm without going through all the radio commands?

I would like to make it work like this "All, re-arm at (X)" with X being the ammo crate. Instead of telling each soldier to go to the ammo crate and get a mag individually. This is a real pain in the buttocks when you got Gooks shooting at you.

Thanks for the help

Share this post


Link to post
Share on other sites

try to run a script containing the following:

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

[units mygroup] action "rearm"  crate

<span id='postcolor'>

mygroup: name of group

crate: crate to rearm at

Share this post


Link to post
Share on other sites

thanks i will give it a shot.

this is my 200th spa...errr i mean post. Yippee for me tounge.gif

Share this post


Link to post
Share on other sites

ACTION "REARM" is not working for me. sad_o.gif Here's what I'm doing:

I have a Russian AA soldier and US planes flying in circles overhead. After he fires his Strela launcher, I want him to take another "9K32Launcher" magazine from an ammo crate, loaded with 99 such magazines. The crate is located about 3 meters from the soldier.

So I tried coding the following in soldier "Eaa1"'s INIT line to trigger the rearming:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler [""fired"",{Eaa1 action [""Rearm"",CrateEaa1]}]

Nothing happens. I'm standing right next to him and he doesn't budge. I've even killed him  ghostface.gif just to take his Strela and tripple check whether he's got another Strela round, which he doesn't.

What's a mother to do?! crazy_o.gif

Now, all I want accomplished here is to rearm the AA soldier. It can be done by black magic for all I care. It doesn't have to rearm from a crate. I also tried this but it didn't work either:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler [""fired"",{Eaa1 addMagazine ""9K32Launcher""}]

Any suggestions? rock.gif

TIA! smile_o.gif

Share this post


Link to post
Share on other sites

Why not just DoMove the unit over to the crate and then use AddMagazine? Same thing really...

e.g.

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

_unit = _this select 0

_crate = _this select 1

? damage _crate >=1: hint "crate damaged"; exit

_unit domove getpos _crate

@ unitready _unit

? _unit distance _crate <2: goto "takeweapon"

; Unit must have been ordered elsewhere

exit

#takeweapon

_unit playmove <whatever the anim name is for taking weapon from crate>

~2

_unit addmagazine [whatever]

exit

Share this post


Link to post
Share on other sites
Why not just DoMove the unit over to the crate and then use AddMagazine? Same thing really...

If AddMagazine is not working in the event handler, why should it work after a DoMove? rock.gif

Share this post


Link to post
Share on other sites

I know these things can drive you insane. I have stumbled across this as well with a LAW launcher: once the thing is ingame, it seems you can't reload it by script.

untested: maybe you can put the black magic solution in a script with a slight delay in front of it (and a nice fake rearm switchmove). I don't know if it really makes a difference, but maybe the engine doesn't recognize the weapon as empty because the EH trigger is very fast.

I have failed any attempts to use the rearm command. AI units will not rapidly go to the crate to rearm anyway, they are mostly concerned with cover, so it takes them ages to rearm. if someone could post a mission.sqm with a working AI rearm solution, i would be very grateful too.

Share this post


Link to post
Share on other sites

Why are you using "" (2 double quotes) - it should be one double quote on the weapon name.

e.g.

""9K32Launcher"" becomes "9K32Launcher"

- what do you think this is? Visual Basic? biggrin_o.gif

Straight from script reference:

player addEventHandler ["killed",{_this exec "playerKilled.sqs"}]

Share this post


Link to post
Share on other sites

double quotes ==> theavonlady edits in .sqm files directly (at work, I guess?)

Share this post


Link to post
Share on other sites

This works - I tried it:

removeAllWeapons this; this addWeapon "9K32Launcher"; this addMagazine "9K32Launcher"

You do have to reload though, before you fire.

Share this post


Link to post
Share on other sites
You do have to reload though, before you fire.

this is exactly the problem: we are talking about an AI unit that needs to reload without being issued to do so by the player ...

Share this post


Link to post
Share on other sites

Right.

In that case the only other ways I can think of, where the unit would automatically reload, would either be:

unit action "RELOAD 9K32 Launcher" (or whatever)

Or:

CreateUnit another 9K32-armed soldier (deleting the unit who has run out of ammunition)

Using AddMagazine to a soldier that has just fired the 9K32 doesn't make the soldier reload. Strange.

Share this post


Link to post
Share on other sites
This works - I tried it:

removeAllWeapons this; this addWeapon "9K32Launcher"; this addMagazine "9K32Launcher"

You do have to reload though, before you fire.

This does not work for me. How did you test this? rock.gif

Not only does the AI not reload but when I kill the AI, he's only got the launcher but no rocket magazine.

Yes, I'm pasting from MISSION.SQM but I do have OFP with me at work, too. Though now I'm home. smile_o.gif Supper time! wow_o.gif  crazy_o.gif

EDIT: Yes, I was thinking of using CreateUnit as a last resort.

Share this post


Link to post
Share on other sites
This works - I tried it:

removeAllWeapons this; this addWeapon "9K32Launcher"; this addMagazine "9K32Launcher"

You do have to reload though, before you fire.

This does not work for me. How did you test this? rock.gif

Not only does the AI not reload but when I kill the AI, he's only got the launcher but no rocket magazine.

Yes, I'm pasting from MISSION.SQM but I do have OFP with me at work, too. Though now I'm home. smile_o.gif Supper time! wow_o.gif  crazy_o.gif

EDIT: Yes, I was thinking of using CreateUnit as a last resort.

I tested it by using the mission editor, creating a trigger activated by alpha radio, and then pasting the code into the on activation.

I pressed alpha radio after I fired my first 9K32

Share this post


Link to post
Share on other sites

Adding the magazine before adding the weapon should ensure the weapon does not need loading.

removeAllWeapons this; this addMagazine "9K32Launcher"; this addWeapon "9K32Launcher";

RED

Share this post


Link to post
Share on other sites
Adding the magazine before adding the weapon should ensure the weapon does not need loading.

removeAllWeapons this; this addMagazine "9K32Launcher"; this addWeapon "9K32Launcher";

I had already seen that and it made no difference.

Share this post


Link to post
Share on other sites

Right, just use CreateUnit then. I can't think of any other way if addMagazine and addWeapon don't work for you.

If you want to obscure the view when the change is done then camcreate some smoke, like a rabbit being pulled out of a hat biggrin_o.gif

God, what a difficult bloody question! smile_o.gif

Share this post


Link to post
Share on other sites
This works - I tried it:

removeAllWeapons this; this addWeapon "9K32Launcher"; this addMagazine "9K32Launcher"

You do have to reload though, before you fire.

This does not work for me. How did you test this? rock.gif

Not only does the AI not reload but when I kill the AI, he's only got the launcher but no rocket magazine.

Yes, I'm pasting from MISSION.SQM but I do have OFP with me at work, too. Though now I'm home. smile_o.gif Supper time! wow_o.gif  crazy_o.gif

EDIT: Yes, I was thinking of using CreateUnit as a last resort.

I tested it by using the mission editor, creating a trigger activated by alpha radio, and then pasting the code into the on activation.

I pressed alpha radio after I fired my first 9K32

OK that helped. Got the following working:

Soldier Eaa1 has the following INIT line code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{eaa1fired = true}]

Added the following trigger and this guy just keeps on ticking:

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

{

position[]={8818.864258,193.877274,7908.520020};

a=0.000000;

b=0.000000;

repeating=1;

age="UNKNOWN";

expCond="eaa1fired";

expActiv="removeAllWeapons Eaa1; Eaa1 addMagazine ""9K32Launcher""; Eaa1 addWeapon ""9K32Launcher""; eaa1fired = false";

class Effects

{

};

};

};

In other words, a repeating trigger that simply checks for condition "eaa1fired". On activation, refresh the soldier's Strela and rocket and reset the "eaa1fired" variable.

That's it!

Thanks a bunch! wink_o.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  

×