Jump to content
bangabob

Insurgency style respawn

Recommended Posts

OK another Request :)

Would it be possible to Stop spawning if Enemy is near by say 100m ?

I have tweaked your code slightly to now allow Spawning to any Alive Unit , but sometimes we spawn in right on the action and get shot so is there something like If EAST is nearby do not allow them to spawn onto that Man ? and display a message ?

Cheers

Edited by psvialli

Share this post


Link to post
Share on other sites

Would there be any reason for this script to work one day and not the next?

I'll explain, I have tried this script in Ironfront. I put a few playable units down, a respawn_west marker, I pasted and copied the xhandle init to each on my playable units, i codied the 2 scripts and put in my mission folder, i created a description.ext with respawn = "base"; and then exported to multiplayer, i played and it worked, so I was happy.

Then one week later I retried the mission in my multiplayer game and i respawned instantly at the respawn_west marker everytime. I deleted the mission and remade it and every time now i just respawn at the respawn_west marker, has anyone any ideas?

Share this post


Link to post
Share on other sites

Bardosy. I have updated your script so it is suitable with Arma 3. I removed the addweapons ect so it doesn't interfere with the get/set loudout scripts.

Just one question. How can i get the script to show the players name. I've been playing about with this

TitleText [format["Squadmate: %1", _currentmate], "PLAIN DOWN"];

But i can't get it to work :(

lackoRespawn.sqf

_unit = _this select 0;

if (_unit == player) then {

 setPlayerRespawnTime 999;

 _squad = group player;
 lck_livingmates = [];
 {
   if (alive _x) then {lck_livingmates = lck_livingmates + [_x];};
 } foreach units _squad;

 lck_actualmate = 0;
 _elozoactual=lck_actualmate;
 keyout = 0;

 openMap false;
 0 fadesound 0;
 disableserialization;
 keyspressed = compile preprocessFile "lackoRespawn_keydown.sqf";
 _displayID = (findDisplay 46) displaySetEventHandler ["KeyDown","_this call keyspressed"];

 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
 _cam camsettarget (lck_livingmates select lck_actualmate);
 _cam camsetrelpos [0,-5,2.5];
 _cam camcommit 0;

 _ido=0;
 while {_ido<=500} do {

   if (_ido mod 10 == 0) then {
     TitleText["\nOCCUPATION RESPAWN\nRight Arrow = next squadmate\nLeft Arrow = previous squadmate\nEnter = respawn","PLAIN DOWN"];
    };

   if (keyout > 0) exitwith {};

   _currentmate = lck_livingmates select lck_actualmate;
   _tempcnt=0;

   lck_livingmates = [];
   {
     if (alive _x and _x!=player) then {
       lck_livingmates = lck_livingmates + [_x];
       if (_x==_currentmate) then {lck_actualmate = _tempcnt;};
       _tempcnt = _tempcnt + 1;
     };
   } foreach units _squad;

   if (count lck_livingmates == 0) exitwith {};
 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    

   waituntil{camCommitted _cam};
   _ido = _ido + 0.02; 
   sleep 0.02;
 };


 (findDisplay 46) displayRemoveAllEventHandlers "KeyDown";
 setPlayerRespawnTime 10;

 _ido=0;
 while {_ido<=5} do {
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    

   waituntil{camCommitted _cam};
   _ido = _ido + 0.5; 
   sleep 0.02;
 };


 _newpos = getPos glbase;

 if (keyout > 0) then {
   _newpos = getPos (lck_livingmates select lck_actualmate);
   //player globalchat format ["cel=%1, x=%2, y=%3", name (lck_livingmates select lck_actualmate),(_newpos select 0),(_newpos select 1)];

   if ((_newpos select 0)>50 and (_newpos select 1)>50) then {
         } else {
           _newpos = getPos glbase;
   };
 } else {
           _newpos = getPos glbase;
 };


 player cameraEffect ["terminate","back"];
 camdestroy _cam;
 0 fadesound 1;  




 waituntil {alive player};


 player setPos _newpos;

 _unit = player;


}; 

Edited by BangaBob

Share this post


Link to post
Share on other sites

As far as I know TitleText don't work in loop. I don't know why and I hope some script expert will explain (and solve) it.

I tried to write at the bottom of the screen the hint (left/right arrow change teammate, enter respawn), but in the loop it doesn't show. If you saw the hint it's only because I TitleText it before the loop, but after a few secs, it vanished. And I cannot rewrite it again. So this is why your TitleText (with name) doesn't show...

If you find a solution, please share it here!

Share this post


Link to post
Share on other sites

Okay thanks for getting back to me. BTW i have updated the script so it will switch to Night vision when the player is wearing night vision

_unit = _this select 0;

if (currentVisionMode player == 1) then
{
camUseNVG true;
} else {
camUseNVG false;

};

if (_unit == player) then {

 setPlayerRespawnTime 999;

 _squad = group player;
 lck_livingmates = [];
 {
   if (alive _x) then {lck_livingmates = lck_livingmates + [_x];};
 } foreach units _squad;

 lck_actualmate = 0;
 _elozoactual=lck_actualmate;
 keyout = 0;

 openMap false;
 0 fadesound 0;
 disableserialization;
 keyspressed = compile preprocessFile "lackoRespawn_keydown.sqf";
 _displayID = (findDisplay 46) displaySetEventHandler ["KeyDown","_this call keyspressed"];

 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
 _cam camsettarget (lck_livingmates select lck_actualmate);
 _cam camsetrelpos [0,-5,2.5];
 _cam camcommit 0;

 _ido=0;
 while {_ido<=500} do {

   if (_ido mod 10 == 0) then {
     TitleText["\nOCCUPATION RESPAWN\nRight Arrow = next squadmate\nLeft Arrow = previous squadmate\nEnter = respawn","PLAIN DOWN"];

    };

   if (keyout > 0) exitwith {};

   _currentmate = lck_livingmates select lck_actualmate;
   _tempcnt=0;

   lck_livingmates = [];
   {
     if (alive _x and _x!=player) then {
       lck_livingmates = lck_livingmates + [_x];
       if (_x==_currentmate) then {lck_actualmate = _tempcnt;};
       _tempcnt = _tempcnt + 1;
     };
   } foreach units _squad;

   if (count lck_livingmates == 0) exitwith {};
 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;   

   waituntil{camCommitted _cam};
   _ido = _ido + 0.02; 
   sleep 0.02;
 };


 (findDisplay 46) displayRemoveAllEventHandlers "KeyDown";
 setPlayerRespawnTime 10;

 _ido=0;
 while {_ido<=190} do {
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    

   waituntil{camCommitted _cam};
   _ido = _ido + 0.5; 
   sleep 0.02
 };


 _newpos = getPos glbase;

 if (keyout > 0) then {
   _newpos = getPos (lck_livingmates select lck_actualmate);
   //player globalchat format ["cel=%1, x=%2, y=%3", name (lck_livingmates select lck_actualmate),(_newpos select 0),(_newpos select 1)];

   if ((_newpos select 0)>50 and (_newpos select 1)>50) then {
         } else {
           _newpos = getPos glbase;
   };
 } else {
           _newpos = getPos glbase;
 };


 player cameraEffect ["terminate","back"];
 camdestroy _cam;
 0 fadesound 1;  




 waituntil {alive player};


 player setPos _newpos;

 _unit = player;


}; 

Share this post


Link to post
Share on other sites

@BangaBob will you be able to upload an example mission for this? I've also noticed that the text when you respawn is cut off at the bottom if you could fix it, that would be great. Thank and keep up the good work.

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

I've been using this for Arma 3. But everything you need for Arma 2 has being created by Bardosy and is available on page 2.

Sorry i cant be more help. Btw if you want to add night-vision mode to the camera simply put this

 if (currentVisionMode player == 1) then
{
camUseNVG true;
} else {
camUseNVG false;

}; 

At the top of the lackoRespawn.sqf

Share this post


Link to post
Share on other sites

Bardosy. Is it possible to have this script run when a player joins the game. So they have a choice to spawn right on the squad without needing to respawn.

Maybe there is a simply workaround like spawning as dead?

Share this post


Link to post
Share on other sites

@BangaBob:

There is a base ArmA2 (without Arrowhead) version of this script (probably you can find here in this topic). It's easier to rework for JIP, because in base ArmA2 there is no command to change the respawn time, so that script respawn the player to a specific, predefined, safe place (GameLogic) far away from the fight and then player have lot of time to choose the playmate where he want to respawn and then simply teleport the player to the choosen soldier. If you use that script you can recycle the most part of the code (left the respawn part) to create a new script what is call after JIP (join in progress) and looks like the respawn but without respawn. Is it enough suggestion? If you need more help, ask freely.

Share this post


Link to post
Share on other sites

@bardosy

I have updated the script so it works without needing to be killed

JIPspawn.sqf

_unit = _this select 0;
if (currentVisionMode player == 1) then
{
camUseNVG true;
} else {
camUseNVG false;

};
if (_unit == player) then {

 player setPos getPos glbase;

 _squad = group player;
 lck_livingmates = [];
 {
   if (alive _x and _x!=player) then {lck_livingmates = lck_livingmates + [_x];};
 } foreach units _squad;

 lck_actualmate = 0;
 _elozoactual=lck_actualmate;
 keyout = 0;
 //player globalchat format ["sq db=%1, act=%2", count lck_livingmates, name 

(lck_livingmates select lck_actualmate)];


 openMap false;
 0 fadesound 0;
 disableserialization;
 keyspressed = compile preprocessFile "lackoRespawn_keydown.sqf";
 _displayID = (findDisplay 46) displaySetEventHandler ["KeyDown","_this call 

keyspressed"];

 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
 _cam camsettarget (lck_livingmates select lck_actualmate);
 _cam camsetrelpos [0,-5,2.5];
 _cam camcommit 0;

 _ido=0;
 while {_ido<=500} do {

   if (_ido mod 10 == 0) then {
      TitleText["\nOCCUPATION RESPAWN\nRight Arrow = next squadmate\nLeft Arrow = previous 

squadmate\nEnter = respawn","PLAIN DOWN"];
   };

   if (keyout > 0) exitwith {};

   _currentmate = lck_livingmates select lck_actualmate;
   _tempcnt=0;

   lck_livingmates = [];
   {
     if (alive _x and _x!=player) then {
       lck_livingmates = lck_livingmates + [_x];
       if (_x==_currentmate) then {lck_actualmate = _tempcnt;};
       _tempcnt = _tempcnt + 1;
     };
   } foreach units _squad;

   if (count lck_livingmates == 0) exitwith {};

   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    

   waituntil{camCommitted _cam};
   _ido = _ido + 0.02; 
   sleep 0.02;
 };

 (findDisplay 46) displayRemoveAllEventHandlers "KeyDown";

 _ido=0;
 while {_ido<=190} do {
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    
TitleText["","PLAIN DOWN"];
   waituntil{camCommitted _cam};
   _ido = _ido + 1; 
   sleep 0.02;
 };

 _newpos = getPos glbase;

 if (keyout > 0) then {
   _newpos = getPos (lck_livingmates select lck_actualmate);
   //player globalchat format ["cel=%1, x=%2, y=%3", name (lck_livingmates select 

lck_actualmate),(_newpos select 0),(_newpos select 1)];

   if ((_newpos select 0)>50 and (_newpos select 1)>50) then {

   } else {

     _newpos = getPos glbase;
   };
 } else {

     _newpos = getPos glbase;
 };


 player cameraEffect ["terminate","back"];
 camdestroy _cam;
 0 fadesound 1;  

 player setPos _newpos;


};

I currently have it set to run with this in the init.

[] spawn {sleep 0.5;null = [player] execVM "EOS\JIPspawn.sqf";};

@Bardosy

I know you said looping titletext doesnt seem to work. Is there any way to make the instructions stay on screen until you press enter. Maybe each time you press left or right it refreshes the titletext information?

Edited by BangaBob

Share this post


Link to post
Share on other sites

Complete version for ArmA 3

Inside the Init.sqf

[] spawn {sleep 0.5;null = [player] execVM "JIPspawn.sqf";};
xhandle = player addEventHandler ["killed", "_this execvm 'JIPspawn.sqf'"];

JIPspawn.sqf

_unit = _this select 0;
//-------------------Night Vision-----------------------------//
if (currentVisionMode player == 1) then
{
camUseNVG true;
} else {
camUseNVG false;

};
////////////////////////////////////////////////////////////////
//------------------------------------------------------------//
if (_unit == player) then {
 waituntil {alive player};
 player setPos getPos glbase;

 _squad = group player;
 lck_livingmates = [];
 {
   if (alive _x and _x!=player) then {lck_livingmates = lck_livingmates + [_x];};
 } foreach units _squad;

 lck_actualmate = 0;
 _elozoactual=lck_actualmate;
 keyout = 0;
 //player globalchat format ["sq db=%1, act=%2", count lck_livingmates, name (lck_livingmates select lck_actualmate)];


 openMap false;
 0 fadesound 0;
 disableserialization;
 keyspressed = compile preprocessFile "lackoRespawn_keydown.sqf";
 _displayID = (findDisplay 46) displaySetEventHandler ["KeyDown","_this call keyspressed"];

 _cam = "camera" camcreate [0,0,0];
 _cam cameraeffect ["internal", "back"] ;
 showCinemaBorder true;
 _cam camsettarget (lck_livingmates select lck_actualmate);
 _cam camsetrelpos [0,-5,2.5];
 _cam camcommit 0;

 _ido=0;
 while {_ido<=500} do {

   if (_ido mod 10 == 0) then {
     TitleText["\n \n \nRight Arrow = next squadmate\nLeft Arrow = previous squadmate\nEnter = respawn","PLAIN DOWN",10];
   };

   if (keyout > 0) exitwith {};

   _currentmate = lck_livingmates select lck_actualmate;
   _tempcnt=0;

   lck_livingmates = [];
   {
     if (alive _x and _x!=player) then {
       lck_livingmates = lck_livingmates + [_x];
       if (_x==_currentmate) then {lck_actualmate = _tempcnt;};
       _tempcnt = _tempcnt + 1;
     };
   } foreach units _squad;

   if (count lck_livingmates == 0) exitwith {};

   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    

   waituntil{camCommitted _cam};
   _ido = _ido + 0.02; 
   sleep 0.02;
 };

 (findDisplay 46) displayRemoveAllEventHandlers "KeyDown";

 _ido=0;
 while {_ido<=90} do {
   _cam camsettarget (lck_livingmates select lck_actualmate);
   _cam camsetrelpos [0,-5,2.5];
   _cam camcommit 0;    
TitleText["","PLAIN DOWN"];
   waituntil{camCommitted _cam};
   _ido = _ido + 1; 
   sleep 0.02;
 };

 _newpos = getPos glbase;

 if (keyout > 0) then {
   _newpos = getPos (lck_livingmates select lck_actualmate);
   //player globalchat format ["cel=%1, x=%2, y=%3", name (lck_livingmates select lck_actualmate),(_newpos select 0),(_newpos select 1)];

   if ((_newpos select 0)>50 and (_newpos select 1)>50) then {

   } else {

     _newpos = getPos glbase;
   };
 } else {

     _newpos = getPos glbase;
 };
//-----------------Vehicle Spawn-----------------------------//
IF (vehicle (lck_livingmates select lck_actualmate) != (lck_livingmates select lck_actualmate)) THEN 
{
if ((vehicle (lck_livingmates select lck_actualmate)) emptyPositions "cargo"==0) 			
then 
{
	null = [player] execVM "JIPspawn.sqf";
		}else{
		player moveincargo vehicle (lck_livingmates select lck_actualmate);
		camdestroy _cam;player cameraEffect ["terminate","back"];0 fadesound 1;

};

	} else {
//////////////////////////////////////////////////////////////////
//------------------Set Unit Stance-----------------------------//
_return = stance (lck_livingmates select lck_actualmate);

if (_return == "stand") then {_return = "amovpknlmstpsraswrfldnon";};
sleep 0.02;
if (_return == "crouch") then {_return = "amovpknlmstpsraswrfldnon";};
sleep 0.02;
if (_return == "prone") then {_return = "AmovPpneMstpSrasWrflDnon";};

player switchMove _return;
//////////////////////////////////////////////////////////////////
camdestroy _cam;
player cameraEffect ["terminate","back"];
 	0 fadesound 1;

//------------------Show spawning screen-----------------------------//
titleText [format ["Spawning on %1", lck_livingmates select lck_actualmate], "BLACK FADED"];sleep 2;
titleText [format ["Spawning on %1", lck_livingmates select lck_actualmate], "BLACK in",2];
///////////////////////////////////////////////////////////////////////
	player setPos _newpos;

};//if vehicle
};

lackoRespawn_keydown.sqf

_key = _this select 1;

//player globalchat format ["key=%1", _key];


//right arrow
if (_key == 205) then { 
 lck_actualmate = lck_actualmate + 1; 
 if (lck_actualmate >= count lck_livingmates) then {
   lck_actualmate = 0;
 };
}; 
//left arrow
if (_key == 203) then { 
 lck_actualmate = lck_actualmate - 1; 
 if (lck_actualmate < 0) then {
   lck_actualmate = (count lck_livingmates)-1;
 };
}; 



if (_key == 76) then {
 TitleText["Right Arrow = next squadmate\nLeft Arrow = previous squadmate\nEnter = respawn","PLAIN DOWN"];
};


//Enter key
if (_key == 28) then { keyout = _key };

Edited by BangaBob

Share this post


Link to post
Share on other sites

Hey guys great work on the script. My problem is, when I start a mission on my own, I can't start the mission, all I see is the sea? I have respawn_west marker down and have the scripts in the right places. It works fine when i am playing with friends and I can only choose to spawn on them at the start, I have no option to spawn at base. What am I doing wrong? Any help would be great. Thanks.

Share this post


Link to post
Share on other sites

Sorry for ressurecting this rather old thread, but wondering if there is a way to stop the player from respawning when he first joins the game?

 

I guess it happens because of the code below getting run by init.sqf at the start, activating the script right away.

Is there a way  to not do it on mission start, but on all the following killed events and respawns ?

Btw, using the version from BangaBob's last post above.

[] spawn {sleep 0.5;null = [player] execVM "JIPspawn.sqf";};
xhandle = player addEventHandler ["killed", "_this execvm 'JIPspawn.sqf'"];

Share this post


Link to post
Share on other sites

that's realy good, thank's.

 

But after respawn ace menu not respawn?

 

Some one have a idea?

 

Thank's

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

×