Jump to content
Melody_Mike

Respawn on team member (simple)

Recommended Posts

Alright-

Let the record show that I realize I am reinventing the wheel/beating a dead horse. And *yet* I can't find a simple premade solution, so I have made my sloppy version, for which I am asking feedback on.

Aim: I would like a respawn script that allows me to respawn on a specific object, vehicle, or player (as per the BASE respawn type). 
 

Background: This feature is in the Zeus game mode. It is in Bohemia Interactives' Escape and Boot-camp COOP missions. But when I un-PBO'd those, I had a very difficult time digging out the specific respawn code.
Of course there are several scripts on team respawn in this forum that I have looked into. Some notable examples:

- Bangabob's Battlefield Respawn System (link: http://forums.bistudio.com/showthread.php?173436-Battlefield-Re-spawn-System-(BRS) ) The demo mission had my mouth gaping, but I couldn't get it to work in any of my multiplayer missions.
- BFD Respawn (link: http://www.armaholic.com/forums.php?m=posts&q=32699 ) Works great, but only on infantry teammates, and only ALL infantry teammates.

My attempt: Extremely simplistic and ugly, but then this is the second thing I have ever coded from scratch. I create a respawn position and delete the old one, every few seconds:
init.sqf:

[] execVM "GroupSpawn.sqf";

Groupspawn.sqf:
 

sleep 10;

for "_i" from 0 to 1 step 0 do {
	Alpharespawn call BIS_fnc_removeRespawnPosition;
	Alpharespawn = [west, getpos RESPAWNUNIT, "Alpha"] call  BIS_fnc_addRespawnPosition;
	sleep 21;
};

Where RESPAWNUNIT is a variable name I give a vehicle or player in the Editor. By making copies of this script, and changing the variable names, you can nominate as many objects and players as wanted.

Problem: This code sort of works, but doesn't always remove the old positions. As the mission progresses, the RESPAWNUNIT will leave a trail of respawn locations behind it. 

So how do I make sure there's only 1 spawn point? Is this a question of multiplayer desynch (it is init.sqf after all)? Does it have to do with scheduled vs unscheduled execution? Am I going about this wrong entirely?

Thanks already for reading,

- MeM 

Share this post


Link to post
Share on other sites

On the unit's init you want able to respawn:

this addMPEventHandler ["MPRespawn", {
	params ["_unit", "_corpse"];
	getPos RESPAWNUNIT
}];

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#MPRespawn

 

edit: not sure how this relates to description.ext respawn definition.

If "NONE" doesn't work maybe use "BASE" and create a respawn_SIDE marker anywhere on the map.

 

edit2: also might need to return a safePos on the EH since you're using a vehicle/unit.

Edited by RCA3

Share this post


Link to post
Share on other sites

Senpai!

I am probably not explaining my intentions very well. 

Here's a screenshot that illustrates what I am going for: 
https://ibb.co/PmVC693

If I understand your suggestion, the Event Handler would just assign a respawn position instantly, without any player input. 

There have got to be user missions with a selectable respawn position that follows players. Does anyone know an example on this forum?

Share this post


Link to post
Share on other sites
22 hours ago, Melody_Mike said:

I create a respawn position and delete the old one, every few seconds:
init.sqf:


[] execVM "GroupSpawn.sqf";

Groupspawn.sqf:
 


sleep 10;

for "_i" from 0 to 1 step 0 do {
	Alpharespawn call BIS_fnc_removeRespawnPosition;
	Alpharespawn = [west, getpos RESPAWNUNIT, "Alpha"] call  BIS_fnc_addRespawnPosition;
	sleep 21;
};

Where RESPAWNUNIT is a variable name I give a vehicle or player in the Editor.

Don't add getPos to the RESPAWNUNIT, as that will add a specific position. Instead just use RESPAWNUNIT, then the position will be where ever that unit is. So no need to move it around.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you so very much. It would never have occurred to me that the BIS_fnc_addRespawnPosition function would take objects themselves as arguments(!).

Hopefully the next new Arma mission designer will find my forum post before asking!

Cheers. 

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

×