OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Panther on 12 Jul 2003, 13:12:05

Title: Respawn with chosen weapon.
Post by: Panther on 12 Jul 2003, 13:12:05
Good day, i want to let players to choose a weapon pack in the brieffing and then in game respawn with the same weapon pack. I have no idea how to do this i only know how they can pick a weapon in brieffing. The respawn wth that weapon is the problem.

Can anyone help me :-\ ?
Title: Re:Respawn with chosen weapon.
Post by: Terox on 17 Jul 2003, 21:53:33
In your init.sqs, typoe the following

[Player] exec "Reload.sqs"

Then create the following script
_________________________________________________________________________

;;;;Reload.sqs

?(local server):exit
@time > 1
_weapArray = weapons player
_magArray = magazines player
_primary = primaryweapon player
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"

#START
@alive player
removeAllWeapons player
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
goto "START"

___________________________________________________________________

Script is untested but should work

What it does is waits till (@time > 1) more than 1 second has passed in the gam,e, then it looks at what weapons and ammunition the player is carrying.
It saves theis loadout in arrays

It then waits for the player to die and respawn   (@alive player)

It then removes the default weapon loadout that BIS gives soldiers of that particular weapon class (removeAllWeapons player), so that there is enough space to reload the player with the loadout he had at the 1 second point

You can adjust the (@time > 1) to allow players more time to take weapons from crates before the script stores their loadout


There are other ways, such as reloadguy.sqs which will load players with a specific pre designed loadout of a mapmakers choosing. (This can be found in the Editors depot)

Many options available
Title: Re:Respawn with chosen weapon.
Post by: Panther on 18 Jul 2003, 14:25:46
Wel i've tryed it but there is something wrong it keeps replacing the weapons every time without respawning. ???

Scripting is not my best side.
Ido know it's something with the loop but don't know what it is.

#START
@alive player
   "
   "
goto "START"

Can anyone help me furter ??
Title: Re:Respawn with chosen weapon.
Post by: Terox on 19 Jul 2003, 14:03:52
Silly me


#START
@alive player
removeAllWeapons player
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
@! alive player
goto "START"



modify the script with
@! alive player
as shown above
Title: Re:Respawn with chosen weapon.
Post by: Panther on 20 Jul 2003, 12:06:10
thx men atlast i can complete my map   :D
and GREAT script !!!
greetzz Panther
Title: Re:Respawn with chosen weapon.
Post by: Mr.BoDean on 21 Jul 2003, 21:59:40
Can this script be adapted to allow player to respawn with weapons they had at time of death? (i.e., not necessarily what they started with)
   Also, does using [player] exec "Reload.sqs" exempt the need for having to name each actual player here? Thx.  :)
Title: Re:Respawn with chosen weapon.
Post by: toadlife on 21 Jul 2003, 23:46:05
Can this script be adapted to allow player to respawn with weapons they had at time of death? (i.e., not necessarily what they started with)

Yes.

http://www.ofpec.com/editors/resource_view.php?id=301
Title: Re:Respawn with chosen weapon.
Post by: toadlife on 21 Jul 2003, 23:57:03
Here is a super-simple version of my weapons respawn script that would give a player the same weapons he had when he died upon respawning. THe only problem would be that if the player had a rifle with a grenade launcher, it wouldn't be selected upon respawning - this is a bug with selectweapon. My respawn script accounts for the selectWeapon bug with grenade launcher rifles and does a bunch of other neato things, but this shoud be OK for most maps.

Code: [Select]
#START
@!alive player
_magArray = magazines player
_weapArray = weapons player
@alive player
removeAllWeapons player
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
goto "START"
Title: Re:Respawn with chosen weapon.
Post by: Mr.BoDean on 24 Jul 2003, 23:14:15
Here is a super-simple version of my weapons respawn script that would give a player the same weapons he had when he died upon respawning. THe only problem would be that if the player had a rifle with a grenade launcher, it wouldn't be selected upon respawning - this is a bug with selectweapon. My respawn script accounts for the selectWeapon bug with grenade launcher rifles and does a bunch of other neato things, but this shoud be OK for most maps.

Code: [Select]
#START
@!alive player
_magArray = magazines player
_weapArray = weapons player
@alive player
removeAllWeapons player
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
goto "START"

Ok, thanks, Toad!  

 2 Q's :  
1.) Would this be just a solo script that would need to be called from individual triggers for each player?  i.e., 8 triggers for each of P1 thru P8 set up as follows:

Trigger
Condition: !alive P1
On Activation: P1 exec "Weap.sqs"

Or could that be condensed somehow?

2.) Since you mentioned it, if the player happens to have a grenade-launching rifle, would they get the same rifle without grenades or would they get default?

Okay, I just re-read your Universal Weapons respawn script and  realized it is for 1.85 and may not work with my V.1.46.  But I also saw how you can list the players in Init.sqs .  Hmm.
Title: Re:Respawn with chosen weapon.
Post by: Mr.BoDean on 25 Jul 2003, 11:01:10
hmm... got errors on this one. Tried modifying with:

_player = _this

and

 player = _this

and tried changing all of the player variables to _player


All errors. Let me guess, another 1.85 or above only script?  :-\     ::)

My only Resistance to converting to RESISTANCE is knowing how many buddies on GS don't have it and some don't even have PC's that can run it!   :-X   :o
Title: Re:Respawn with chosen weapon.
Post by: toadlife on 25 Jul 2003, 11:17:30
Sorry dude. The "weapons" and "magazines" commmands are resistance commands, so even the condensed version that I posted won't work for you. Your only respawn option is predfined weapon loadouts, like the one posted by Terox.
Title: Re:Respawn with chosen weapon.
Post by: Mr.BoDean on 25 Jul 2003, 11:41:03
Sorry dude. The "weapons" and "magazines" commmands are resistance commands, so even the condensed version that I posted won't work for you. Your only respawn option is predfined weapon loadouts, like the one posted by Terox.

In your best Fat Bastard accent: "Well, ain't that just a steamin' pile o' crap!"

Okay, well, I figured as much.    :-[  Bummer. Guess all those poor bastards I leave behind with 1.46 will have to suffer with an M16 and 1 clip till they can get safe!  ;D  

Thanks, toadster.   8)
Title: Re:Respawn with chosen weapon.
Post by: Panther on 25 Jul 2003, 14:04:49
I've got it all working but in the brieffing only the Group leader can pick the weapon for everyone.  ::)

Can enyone tell me how or if you can set it so that every group member set pick his own weapon ?   ???
Title: Re:Respawn with chosen weapon.
Post by: toadlife on 25 Jul 2003, 23:05:49
Can't do that in the Briefing. Only the leader of a group can pick em in the briefing..and that includes resiatance...you could try splitting all of the players up into seperate groups and then joining them whenthe mission starts.
Title: Re:Respawn with chosen weapon.
Post by: Panther on 28 Jul 2003, 14:55:19
Good idea men THX  :D
Title: Re:Respawn with chosen weapon.
Post by: aazell on 31 Jul 2003, 14:54:32
Would this work for the addaction removeaction commands.

In my MP map I have added a Take Cyanide action to all players using a trigger for each player to test that they are alive or not.

It acts very strangly though adding and removing the action about 5 times for each player when they respawn.

Any ideas would be really helpful.

Thanks

aaz
Title: Re:Respawn with chosen weapon.
Post by: Terox on 31 Jul 2003, 16:20:41
if you have an addaction added every time a player respawns, then you must have a remove action when he dies, or he may end up with 2 addactions the second time he becomes alive again
Title: Re:Respawn with chosen weapon.
Post by: aazell on 31 Jul 2003, 19:10:54
I think I found the answer.

In my script I was using the "this" operator which is global. I think I should be using "_this" so that it's local to that script and that player only.

I'll let you know what I find.