Home   Help Search Login Register  

Author Topic: Universal script to swap out HD mags?  (Read 770 times)

0 Members and 1 Guest are viewing this topic.

cornhelium

  • Guest
Universal script to swap out HD mags?
« on: 14 Nov 2003, 00:46:37 »
Hi - I posted this question over on the BIS forums and Harkonin was kind enough to post an example script. I was just wondering if anybody had anything to add to this. I quote:

=============
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   )

Do any scripting experts think this is do-able?

Thanks,
Cornhelium

===============

Harkonin replies:
======================
;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
======================
Cornhelium replies:
=======================
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.

[3. Also, Inqwiper identified a potential problem in that if the magazines were replaced whole you could have a situation in MP where one human player shoots another  who had 5 mags with 3 rounds each, then gets 5 full mags when s/he picks up the dead player's weapon. I guess the script would also have to get the ammo level of each mag and reproduce that too - would this be possible?]

I'm thinking about the type of scripts used in the JAM2NAM and LSR2JAM projects.
============================
Harkonin replies:
==============================
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.
===================================

If anyone has anything to add to the groundwork done by Harkonin, I'd be eternally grateful  ;D

Cheers,
Cornhelium

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Universal script to swap out HD mags?
« Reply #1 on: 14 Nov 2003, 11:01:49 »
Perhaps This will help.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

cornhelium

  • Guest
Re:Universal script to swap out HD mags?
« Reply #2 on: 14 Nov 2003, 19:48:45 »
This looks great - many thanks Toadlife.

All the best,
Cornhelium