Home   Help Search Login Register  

Author Topic: equiping weapons on respawn  (Read 2668 times)

0 Members and 1 Guest are viewing this topic.

Offline punisher

  • Members
  • *
equiping weapons on respawn
« on: 24 Dec 2005, 18:42:51 »
how do i get east respawned soldiers to not have the default AK when respawning?
The Gimp clan- pushing the limits of OFP
http://www.youtube.com/user/Pigdogmeat

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:equiping weapons on respawn
« Reply #1 on: 25 Dec 2005, 18:29:26 »
add a killed eventhandler to the unit
by placing the following in the units init field

this  addEventHandler ["killed", {_this exec "unitkilled.sqs"}]



and have that event script run code something like the following

UNITKILLED.SQS
the following will rearm the unit with the weapons it died with
Quote
_unit = _this select 0
_weapons = weapons _unit
_mags = magazines _unit
_primary = primary weapon _unit
@ alive _unit
_unit removeAllEventHandlers "Killed"
removeallweapons _unit
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]


or if you want to rearm it specifically by the classtype of the unit, then do something like the following

UNITKILLED.SQS
the following will rearm a specific class of unit wioth a loadout for that class
Quote
_unit = _this select 0
@ alive _unit
removeallweapons _unit
_typeof = typeof _unit
_unit removeAllEventHandlers "Killed"
goto _typeof
;; eg goto label that is same as classtype of unit

#SoldierWB
_mags = ["G36aMag", "G36aMag", "G36aMag", "G36aMag"]
_weapons = ["Binocular","NVGoggles","G36a"]
goto "REARM"

#SoldierWSniper
_mags = ["M21", "M21", "M21", "M21"]
_weapons = ["Binocular","NVGoggles","M21"]
goto "REARM"


#REARM
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Seven

  • Members
  • *
  • Am I a llama?
Re:equiping weapons on respawn
« Reply #2 on: 26 Dec 2005, 01:06:53 »
Hi Terox,

This seems very cool but guess I'm to new at it...
Could you tell me what I'm doing wrong?
Added the eventhandler to the init field of each soldier & made unitkilled.sqs like this but all respawn with ak47 / 1clip

Quote
_unit = _this select 0
@ alive _unit
removeallweapons _unit
_typeof = typeof _unit
_unit removeAllEventHandlers "Killed"
goto _typeof
;; eg goto label that is same as classtype of unit

#fdf_ww2_jaakariOfficer
_mags = ["FDF_L35Mag","FDF_L35Mag","FDF_L35Mag","FDF_L35Mag"]
_weapons = ["Binocular","FDF_L35"]
goto "REARM"

#fdf_ww2_jaakariKasapanos
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"

#fdf_ww2_jaakariPzSchreck
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_PanzerSchreckMag","FDF_PanzerSchreckMag"]
_weapons = ["FDF_ukkopekka","FDF_PanzerSchreck"]
goto "REARM"

#fdf_ww2_jaakariSVT
_mags = ["FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag","FDF_SVT40Mag"]
_weapons = ["FDF_SVT40"]
goto "REARM"

#fdf_ww2_jaakariLMG
_mags = ["FDF_emmaMag","FDF_emmaMag","FDF_emmaMag","FDF_emmaMag"]
_weapons = ["FDF_emma"]
goto "REARM"

#fdf_ww2_jaakariMedic
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"

#fdf_ww2_jaakariSMG
_mags = ["FDF_suomikpMag","FDF_suomikpMag","FDF_suomikpMag","FDF_suomikpMag","FDF_stickGrenade","FDF_stickGrenade"]
_weapons = ["FDF_suomikp"]
goto "REARM"

#fdf_ww2_jaakariMessanger
_mags = ["FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag","FDF_ukkopekkaMag"]
_weapons = ["FDF_ukkopekka"]
goto "REARM"


#REARM
{_unit addMagazine _x} forEach _mags
{_unit addWeapon _x} forEach _weapons
;;;;;;;;;; BIS Standard
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"
_unit selectWeapon _primary
_unit addEventHandler ["killed", {_this exec "unitkilled.sqs"}]

Thx in advance   ::)

Offline Seven

  • Members
  • *
  • Am I a llama?
Re:equiping weapons on respawn
« Reply #3 on: 26 Dec 2005, 10:10:26 »
Also tried the 1st unitkilled.sqs you posted & it returns this error:
Quote
'_primary = primary |#|weapon _unit': Error Unknown operator weapon

so removed the space between primary & weapon & get no error msg; but still the units respawn with ordenary ak's :s

Once again,
thanks in advance!
Seven  8)

*edit* This script did the job for me; although I would love to know where I was wrong
« Last Edit: 26 Dec 2005, 11:40:06 by Seven »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:equiping weapons on respawn
« Reply #4 on: 26 Dec 2005, 12:21:35 »
oops my mistake

primary weapon

should be one word

primaryweapon _unit



also on the second example script, place the following line just after the
@ alive _unit
hint "I am alive"

I have a feeling you probably wont see the Hint line
Reason being that the newly created _unit will be a copy of the dead _unit

and therefore you would have to use the "name _unit" as a check to see if the unit is onmce again alive

I have to go out right now, but when i get back early this evening, i will dig the system out and post it


2 questions
1) The unit you want to rearm on respawn, is that a player only / any unit in a players group, or server controlled enemy AI
 can you give more info
2) Do you want the unit to have the weapons it started with or a custom loadout or the weapons it died with
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Seven

  • Members
  • *
  • Am I a llama?
Re:equiping weapons on respawn
« Reply #5 on: 26 Dec 2005, 13:18:38 »
2 questions
1) The unit you want to rearm on respawn, is that a player only / any unit in a players group, or server controlled enemy AI
 can you give more info
2) Do you want the unit to have the weapons it started with or a custom loadout or the weapons it died with

Lo Terox ;)

1) It's a MPmission with one group of 9 players; AI should not be involved but the option is there to take them with you.

2) The weapons it started with (as I tried in your 2nd unitkilled.sqs found out the units classnames & classes of their weapons; so thought that would do the thing)

3) respawn happens at respawn_guerilla


Greetz,
Seven

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:equiping weapons on respawn
« Reply #6 on: 29 Dec 2005, 14:56:53 »

I take it you only want this respawn rearming for players
then

That makes it a whole lot easier

____________________________________________________

so to rearm with the weapons they started with use the following

INIT.SQS

Quote
tx_mags = magazines player
tx_weps = weapons player
tx_prim = primaryweapon player
tx_Kevent = Player  addEventHandler ["killed", {_this exec "unitkilled.sqs"}]

UNITKILLED.SQS
Quote
Player removeEventhandler tx_Kevent
@ alive Player

removeallweapons Player
{Player addMagazine _x} forEach tx_mags
{_unit addWeapon _x} forEach tx_weps
;;;;;;;;;; BIS Standard
?(tx_prim == "M16GrenadeLauncher"): tx_prim = "M16Muzzle"
?(tx_prim == "Ak74GrenadeLauncher"): tx_prim = "AK74Muzzle"
?(tx_prim == "Ak47GrenadeLauncher"): tx_prim = "AK47Muzzle"
Player selectWeapon tx_prim
tx_Kevent = Player  addEventHandler ["killed", {_this exec "unitkilled.sqs"}]


Each player will reload on respawn with the weapons they started with
All you need to do is add to the ?(tx_Prim == XXXX)
any fdf grenade launcher weapons

« Last Edit: 29 Dec 2005, 14:59:19 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Seven

  • Members
  • *
  • Am I a llama?
Re:equiping weapons on respawn
« Reply #7 on: 29 Dec 2005, 22:50:13 »
Hi again Terox,

This just won't work  :-\
I know get this error when I kill myself or another player to test the script

Quote
'Player removeEventhandler tx_Kevent|#|': Error removeeventhandler: Type Number, expected Array

If I tk another player for testing that is, I also loose all my weapons...

eh  ???

ps: replaced the prim with ?(tx_prim == "FDF_HK69"): tx_prim = "HK69A1"

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:equiping weapons on respawn
« Reply #8 on: 30 Dec 2005, 20:14:34 »
Quote
ps: replaced the prim with ?(tx_prim == "FDF_HK69"): tx_prim = "HK69A1"

I dont think you understand what i meant by restating tx_prim
Basically weapons like the M16GL and the AK74GL have more than one muzzle mode

For these specific type of weapons, you have to state which muzzle mode you need to select when selecting the weapon as primary otherwise as a player, you have to press spacebar to get a weapon mode, be it gl or auto, semi auto etc

so if the FDF_HK69 was an assault rifle/grenade launcher you would probably have to type

?(tx_prim == "FDF_HK69"): tx_prim = "HK69muzzle"
what you are actually stating is
if my primary weapon is a fdf_hk69 then i need to select it in "Muzzle mode" not grenade launcher mode

If its a standard, 1 ammo type weapon, then you dont need to add it to the
 ?(tx_Prim == "XXXXX"):

as there is only 1 muzzle to select and that will be done automatically










I Have changed the killed event handler lines (I cant remember how to specifically remove a certain eventhandler, but as it would appear that you havent used any yourself, the script simply removes all of them on death







INIT.SQS

Quote
tx_mags = magazines player
tx_weps = weapons player
tx_prim = primaryweapon player
Player  addEventHandler ["killed", {_this exec "unitkilled.sqs"}]

UNITKILLED.SQS
Quote
Player removeallEventhandlers "Killed"
@ alive Player

removeallweapons Player
{Player addMagazine _x} forEach tx_mags
{_unit addWeapon _x} forEach tx_weps
;;;;;;;;;; BIS Standard
?(tx_prim == "M16GrenadeLauncher"): tx_prim = "M16Muzzle"
?(tx_prim == "Ak74GrenadeLauncher"): tx_prim = "AK74Muzzle"
?(tx_prim == "Ak47GrenadeLauncher"): tx_prim = "AK47Muzzle"
Player selectWeapon tx_prim
Player  addEventHandler ["killed", {_this exec "unitkilled.sqs"}]
« Last Edit: 30 Dec 2005, 20:29:34 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Seven

  • Members
  • *
  • Am I a llama?
Re:equiping weapons on respawn
« Reply #9 on: 31 Dec 2005, 18:38:43 »
Quote
I dont think you understand what i meant by restating tx_prim
I do now thx :)

Will try the script next week after all the food & drink madness...  :-X

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:equiping weapons on respawn
« Reply #10 on: 05 Jan 2006, 22:25:51 »
There are lots of scripts in the Ed Depot that respawn players with different weapons (such as the ones they died with, for example).

Search for 'respawn' and here is what you get:

http://www.ofpec.com/editors/browse.php?browseon=&browsewhat=-1&catselected=-1_-1&catagory=-1&subcategory=-1_-1&numreturn=25&displayformat=0&ofpv=1&searchwhat=1&searchlevel=0&searchwhat=1&searchopts=&searchstring=respawn&x=0&y=0
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!