OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: fabrik on 24 Jul 2006, 18:25:30

Title: Adding Randoms to progressive Respawn, HELP NEEDED!
Post by: fabrik on 24 Jul 2006, 18:25:30
I have successfully implemented a respawn point that follows the player during the mission
now I would add a random feature..
I mean, ok the respawn marker gets the position of where the player dies than I would add some random amount of meters so you will respawn "near" your dead body but not exaclty upon it.. so

- how can I do that?
- how generate a random number like X, with  30meters < X < 100meters

the respawn script is the one found in the tutorial section:


Init.sqs - player addEventHandler ["killed", {_this exec "myrespawn.sqs"}]


;MyRespawn.sqs
Player removealleventhandlers "Killed"
@ alive player
Player setpos (getmarkerpos "respawn_west")

player addEventHandler ["killed", {_this exec "myrespawn.sqs"}]



Thank you
Title: Re: Adding Randoms to progressive Respawn, HELP NEEDED!
Post by: BigDawgKS on 24 Jul 2006, 18:48:04
Code: [Select]
_x = 1
_y = 1
? random 1 > 0.5 : _x = -1
? random 2 > 0.5 : _y = -1
"respawn_west" setmarkerpos [(getpos player select 0)+(_x*(30 + random 70)),(getpos player select 1)+(_y*(30 + random 70))]

And I you don'y really need to setpos the player to the respawn_west marker when he dies, he'll respawn at that point automatically (if he's on West).
Title: Re: Adding Randoms to progressive Respawn, HELP NEEDED!
Post by: fabrik on 24 Jul 2006, 22:27:37
thanks a lot!!!!!
Title: Re: Adding Randoms to progressive Respawn, HELP NEEDED!
Post by: fabrik on 24 Jul 2006, 23:11:26
ops another problem....
this string u posted works but it always ADD a number to my postion so it "PUSH" the player always FORWARD
(I can't say exactly but looks like this add a positive number to the postion coordinates so u proceed east,west and north but never to south...

how can I put a random + or - sign infront the random number so the new respawn position  will be really randomized but not too far from where u died?