Home   Help Search Login Register  

Author Topic: AI AA Reload  (Read 698 times)

0 Members and 1 Guest are viewing this topic.

B-2-0

  • Guest
AI AA Reload
« on: 21 May 2003, 18:25:55 »
Hi, ok, i have a stinger site with 4 AI AA soldiers in and an ammo crate filled with AA missiles........now seing as u can only carry 1 AA missile, this makes having a stinger site kinda pointless if the AI won't rearm........How do i make them rearm once they have fired??........I tried removing their AK's hoping that they would call ammo low and the leader would tell them to rearm but it doesn't work ???

Thanx in advance!! :thumbsup:

Iwesshome

  • Guest
Re:AI AA Reload
« Reply #1 on: 21 May 2003, 18:52:06 »
You could run a script that always rearms wether you fire or not.... For "West" soliders

;[unitname] exec "rearm.sqs"

_man1 = _this select 0

#start
?!(alive _man1): exit
_man1 addMagazine "AALauncher"
~10
goto "start"


I hope this works for you.... IW

B-2-0

  • Guest
Re:AI AA Reload
« Reply #2 on: 21 May 2003, 23:01:58 »
Thanx for your reply Iwesshome! :)

The script doesn't seem to work tho........i don't get an error, he just doesn't receive the new AA missile........you said it was for West soldiers, it is actually for Resistance although i tried it with West and it still doesn't work........i also thought that the _man1 part may need to be changed to my units name, am i right in thinking this, even though it didn't work??
« Last Edit: 21 May 2003, 23:04:40 by B-2-0 »

Iwesshome

  • Guest
Re:AI AA Reload
« Reply #3 on: 21 May 2003, 23:32:33 »
Did you try to change the parameters of the script to apply it to the correct ammo you are looking for?


deaddog

  • Guest
Re:AI AA Reload
« Reply #4 on: 22 May 2003, 00:59:23 »
Does the guy not get the ammo or does he not reload his weapon with it?

Try it on one of your squad mates.  That way, you can easily check for the presence of the new missle.

B-2-0

  • Guest
Re:AI AA Reload
« Reply #5 on: 22 May 2003, 01:36:39 »
Iwesshome: There was no need to change ammo type, you had put AA Launcher in there already.  Also, do i need to change _man1 to the name of my unit or leave it as is??

DeadDog:  Thanx for your reply, i placed myself (US) and a fellow US AA soldier along with a few Hinds in the vicinity....as soon as we start he blasts one, so i wait for a minute or so, telling him to target and attack Hind but he still won't fire....so i pop a cap in his ass and run to check the corpse, no AA....any ideas?

Iwesshome

  • Guest
Re:AI AA Reload
« Reply #6 on: 22 May 2003, 02:23:31 »
Nope... don't change _man1.

That is part of the script and recognizes the person using it leading to this example

_man1 = _this select 0

This is the code in the script that recognizes the unitname

[unitname] exec "rearm.sqs"

If my guy was name Bob this is how I would have the script launched...

[Bob] exec "rearm.sqs"

- So it is one of these three things

1. Ammo type is wrong
2. Script is written wrong
3. It was executed wrong during gameplay

I am home now so I will take a look at it and see if I can get it to work.

IW

Iwesshome

  • Guest
Re:AI AA Reload
« Reply #7 on: 22 May 2003, 03:50:37 »
:help:

- I know this setup works (Blue)
- Questionable (Orange)

;[unitname] exec "rearm.sqs"

_man1 = _this select 0

#start
?!(alive _man1): exit

_man1 addMagazine "AALauncher"
~10
goto "start"



Test 1

;[unitname] exec "rearm.sqs"

_man1 = _this select 0

#start
?!(alive _man1): exit
_man1 addMagazine "AALauncher"; _man1 AddWeapon "AALauncher"
~10
goto "start"

Issues

- Will restock the ammo but also creates a new AA Launcher in which you have to figure how to discard the original.

Anyone know how to fix this?  ???


deaddog

  • Guest
Re:AI AA Reload
« Reply #8 on: 22 May 2003, 04:55:37 »
I've been playing around with this and found something interesting.

An AA Soldier starts with 5 magazines:  4 m16 and 1 AALauncher.

After he fires the stinger, he still has 5 magazines.  ???

The following works but is not exactly elegant:

Put this in the init line of your AA guy:
AE=this addEventHandler ["fired",{_this exec "rearm.sqs"}]

Rearm.sqs:
_man1 = _this select 0

?(count _this)!=5:exit

~15

removeallweapons _man1

_man1 addmagazine "m16"
_man1 addmagazine "m16"
_man1 addmagazine "m16"
_man1 addmagazine "m16"
_man1 addweapon "m16"

_man1 addmagazine "AALauncher"
_man1 addweapon "AALauncher"

_man1 removeeventhandler ["fired",AE]

This works but only if the removeallweapons command is there.  I tried to just remove the AAlauncher and then re-add it but this did not work.  The ~15 represents a reasonable time to acquire a new stinger (since it's one shot).  You can change that to anything.

The removeeventhandler gives you only one reload.  If you want more then you could probably use a global variable as a counter and increment it each time this script is called.

Hope this helps.
« Last Edit: 22 May 2003, 05:01:20 by deaddog »

B-2-0

  • Guest
Re:AI AA Reload
« Reply #9 on: 22 May 2003, 19:29:16 »
Ok, i've cracked it!! ;D

I am a total scripting n00b but it works.......correct me if i am wrong but from what i can gather, the script checks if he has less than 5 mags and if so, disarms him and then rearms him, right??

U said that once dude has fired, he still has 5 mags......so i set the script to only give him 3 M-16 mags, therefore the script only counts 4 mags (including the AA) and rearms him.

I remembered  how to loop a cam script in order to get the cam to follow the vehicle, so i applied the same thing to this and by jove it works old boy!!! ;D

---------------------------------------------------------
#loop
_man1 = _this select 0

?(count _this)!=5:exit

~30

removeallweapons _man1

_man1 addmagazine "m16"
_man1 addmagazine "m16"
_man1 addmagazine "m16"
_man1 addweapon "m16"

_man1 addmagazine "AALauncher"
_man1 addweapon "AALauncher"

_man1 removeeventhandler ["fired",AE]

goto "loop"
------------------------------------------------------------

Now my stinger site has an endless supply of missiles!!

I have upped the delay time tho, 15 seconds is pretty quick to reload a Stinger, especially as OFP seconds are slightly shorter than real-time ;)

Thanx for your help with the initial script DeadDog....much aprieciated!! ;)
(Darn, the extra smileys aint working!!)

[Edit] Whoops, sorry Iwesshome, i forgot u gave the initial script :-[

Thanxs to both of u for your help!! ;D
« Last Edit: 22 May 2003, 19:35:55 by B-2-0 »