Jump to content
Sign in to follow this  
cornhelium

Script to swap out hd mags for non-ai

Recommended Posts

Hi,

Does anyone know if it would be possible to do some scripting that would make the following happen?

--------------------------------

1. Player is using non-HD ammunition in an MP mission where all AIs are using HD.

2. Player runs out of ammo and picks up a fallen FAL HD. >>Script executes to removeAllMagazines from FAL and then add the same number of non-HD mags to the FAL<<

3. Player then gets shot and killed >>Another script executes to removeAllMagazines from the FAL and add the same number of -HD mags<<

4. Just then, an AI rearms from the dead player's FAL. No script executes, the AI is rearmed and keeps blasting away with HD.

--------------------------------------------

I guess these scripts would have to be part of the weapon .cpp in the .pbo? (Sorry have no idea what I'm talking about crazy_o.gif  )

Do any scripting experts think this is do-able?

Thanks,

Share this post


Link to post
Share on other sites

If you made it work you would still have a problem. If the player dies with 5 magazines with 3 bullets each in them the AI will get his hands on 5 full magazines and vice versa.

Share this post


Link to post
Share on other sites

;Quick Fix loadout

;written in under 30 seconds by Harkonin

;Loadout.sqs

;usage

;[This] exec "Loadout.sqs"

;unit to be armed

_unit = _this Select 0

;side of unit and if player can be adjusted to west east and guer

? (Side _unit != west):Exit

? (_unit == player):goto "player"

;remove units current loadout

RemoveAllWeapons _unit

;add new mags and weapons, to add more ammosimply add another ammo line

;

_unit AddMagazine "HD Mag name"

_unit AddWeapon "HD weapon name"

_unit selectWeapon "HD weapon name"

_unit AddMagazine "secondary weapons magazine name"

_unit AddWeapon "Secondaryweapon name"

_unit AddMagazine "sidearm mag name"

_unit AddWeapon "sidearm name"

_unit AddWeapon "Binocular"

_unit AddWeapon "NVGoggles"

Exit

#player

RemoveAllWeapons _unit

_unit AddMagazine "normal mag name"

_unit AddWeapon "normal weapon name"

_unit selectWeapon "normal weapon name"

_unit AddMagazine "secondary weapon ammo name"

_unit AddWeapon "secondary weapon name"

_unit AddMagazine "sidearm ammo name"

_unit AddWeapon "sidearm name"

_unit AddWeapon "Binocular"

_unit AddWeapon "NVGoggles"

Exit

Share this post


Link to post
Share on other sites

Wow - thanks Harkonin.

Good point InqWiper - but as HD AI are gonna be firing like crazy I feel it's not too much of an issue.

Then again, another human player could shoot you and pick up 5 full mags from your body when you died with only 3 rounds in each mag...

...oh HarkOOOnin... smile_o.gif

Share this post


Link to post
Share on other sites

I guess there are a few problems with making it a universal script:

1. To execute universally, without being manually entered in the initialisation field for each unit in the mission editor, the script would have to be part of the .pbo of the weapon in question and execute automatically each time that weapon is used. (eg M16.pbo)

2. It needs to either a) only affect the mags of the pbo weapon in question or b) get the full current loadout of the player/AI carrying the weapon (ie. the dead unit and the player picking up the weapon/mags), and then replicate that loadout, minus/plus HD mags.

Otherwise you could have problems with the script changing the player's/AI's secondary weapons, sidearms, binoculars etc.

I'm thinking about the type of scripts used in the JAM2NAM and LSR2JAM projects.

Thanks very much for your input,

Cornhelium

Share this post


Link to post
Share on other sites

Thats a mission only script and I don't know much about addon coding at all. Thats a pretty easy way to give a untis in a player controlled group either HD or normal weapons. You can always extend it for types and classes with the man and counttype commands. Then add different loadouts depending on type of soldiers.

ie Soldierwb, Soldiereb, soldiergb and so forth.

I did'nt actually finish the rest but yes you can do everything else with an eventhandler in a trigger with something like -

{_x addEventHandler ["killed",{_this exec "removeweapons.sqs"}]} forEach thislist;

you can also try something like -

@!(alive _unit) or ?(not alive _unit)

for swapping ammo on dead guys you'll need to define the HD and non HD ammo and weapons then add the desired effect to that script.

For an addon however you'll have to talk to someone else since my cpp and config knowledge is nil.

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  

×