Jump to content
Sign in to follow this  
killshot

respawn_west defines player's start position?!

Recommended Posts

Hi there,

so I want my playable units to start the mission where I have positioned them, but as soon as I create the "respawn_west"-marker, the start position is == the marker's position.

Since when does the respawn marker affects the player's start position, because, as far as I remember, In A2 it didn't?

my description.ext

respawn = 3;
respawnDelay = 120;
respawnOnStart = 0;
respawnTemplates[] = {"MenuPosition"};

Regards

Share this post


Link to post
Share on other sites

Respawn=3 // base respawning

It is also defining starting position for your units

Share this post


Link to post
Share on other sites
Respawn=3 // base respawning

It is also defining starting position for your units

You might think that, but

respawnTemplates[] = {"MenuPosition"};

is the reason for that behaviour. If you ask me, there's no reasonable explanation for this "feature". The respawnTemplates haven't gotten the attention they deserved and are, unfortunately, 'buggy by design'.

Share this post


Link to post
Share on other sites

I guess you are right Belbo.

So how am I supposed to have individual starting positions for my units and still use the respawnTemplates-entry? I do need it to make the vanilla rallypoints (Empty->Respawn) work, don't I?

Share this post


Link to post
Share on other sites

I suppose with MenuPosition you can only offer different respawn_west-markers. I don't exactly know if the rallypoints work as respawn points if they're placed in the editor. Problem with MenuPosition is that the players can choose where they want to spawn. That might influence your mission heavily.

Share this post


Link to post
Share on other sites

I just tested the rallypoints on local dedicated server and they do work properly - of course only after deployment.

You are able to select them in your respawn dialog window, just like the respawn_west-markers.

But why in the world is the respawn_west marker defining the starting positions? :(

Seems like there is an open ticket for the issue:

http://feedback.arma3.com/view.php?id=18823

Workaround solution for now, as seen in the link above.

Description.ext

allowFunctionsRecompile = 1;

Playable Unit's Init

BIS_fnc_initRespawn = {true};

Regards

Edited by killshot
Link added, Workaround added

Share this post


Link to post
Share on other sites

Rather than overwriting the BIS function you can move the player back by finding his original waypoint position.

When a unit is spawned the first waypoint in his list is actually his starting position (not true for script spawned units only editor placed). The BIS respawning code then moves you to a new location but your first waypoint still reports the original so..

init.sqf

sleep 0.1;   //wait for briefing to finish
waitUntil {!isNull player && time > 0};  //wait for the player to be spawned in
player setPosATL (waypointPosition (waypoints player select 0));   //reset player to original position

Will immediately place you back to the position that was choosen in the editor.

________________________

And something along these lines should work .. also including JIP

initPlayerLocal.sqf

_h = _this spawn {
_JIP = [_this, 1, false] call BIS_fnc_param;
if ( isNumber (missionConfigFile >> "respawnOnStart") && { getNumber (missionConfigFile >> "respawnOnStart") == 0 } ) then {
	if (!_JIP) then {
		sleep 0.1;  //wait for briefing to finish
	};
	waitUntil {(player getVariable ["bis_fnc_selectRespawnTemplate_respawned",false])};  //wait for respawning script to finish
	waitUntil { getPosATL player distance (waypointPosition (waypoints player select 0)) > 0.5 }; //wait for player to have been moved
	player setPosATL (waypointPosition (waypoints player select 0));   //reset player to original position
};
};

Although waiting for the respawning script to finish seems a bit of a waste as we are monitoring for the players position i left it in there as it just makes sense to make sure its done.

Think that looks about right , done a little testing on a dedicated with and without JIP, but as always with MP there maybe other problems that have been overlooked

Edited by Larrow

Share this post


Link to post
Share on other sites

Yes, that did the trick for me too :)

So it's better to use your method instead of the function overwriting?

I will test the JIP script too tomorrow.

Thanks for sharing.

Share this post


Link to post
Share on other sites
So it's better to use your method instead of the function overwriting?
Well to do the ovewrite version you are using allowFunctionsRecompile = 1; which is going to leave your mission open to abuse as anyone connected could inject code and overwrite functions, part of the reason why functions are compileFinal to begin with.

Share this post


Link to post
Share on other sites

Ok, so I will implement your code, although we only play on password protected servers, but that's good to know for sure!

Share this post


Link to post
Share on other sites

We tried a similar setpos workaround, but it wasnt working properly. setPos workaround is also problematic if your units start inside a vehicle (obviously). I now added a check right to BIS_fnc_moveToRespawnposition.

Replace the function using cfgFunctions (no recompile allowance needed):

class cfgFunctions {

class A3 {

	class Respawn {

		class moveToRespawnPosition { file = "YOURDIR\fn_moveToRespawnPosition.sqf"; };

	};

};

};

fn_moveToRespawnPosition.sqf

/*
Author: Karel Moricky

Description:
Move a unit to the respawn position.

Parameter(s):
	0: OBJECT
	1:
		STRING - move to marker position
		OBJECT - move inside a vehicle (when seats are empty and not locked) or around it
		ARRAY - move to precise [X,Y,Z] position

Returns:
BOOL
*/


if (isNil "glt_respawn_fix_exit") exitWith {
glt_respawn_fix_exit = true;
};


_unit = [_this,0,player,[objnull]] call bis_fnc_param;
_position = [_this,1,_unit,[[],"",objnull,grpnull]] call bis_fnc_param;
_init = [_this,2,!isserver && time == 0,[true]] call bis_fnc_param;

_fnc_setPos = {
_posOrig = (_this select 0) call bis_fnc_position;
_dummy = (typeof player) createvehiclelocal _posOrig;
_pos = position _dummy;
deletevehicle _dummy;
_unit setpos _pos;
if (count _this > 1) then {
	_unit setdir (_this select 1);
} else {
	_unit setdir ([_pos,_posOrig] call bis_fnc_dirto);
};
};

switch (typename _position) do {
case (typename grpnull);
case (typename objnull): {
	if (typename _position == typename grpnull) then {_position = leader _position;};

	_obj = vehicle _position;
	_objPos = _obj call bis_fnc_position;
	if (
		(
			{_obj emptypositions _x > 0} count ["driver","commander","gunner","cargo"] > 0
			||
			{{isnull (_obj turretunit _x)} count ([_obj,[]] call bis_fnc_getTurrets) > 0}
		) && (
			getnumber (configfile >> "cfgvehicles" >> typeof _obj >> "isUav") == 0
		)
	) then {
		//--- Inside
		[_position,direction _obj] call _fnc_setPos; //--- Move near the vehicle in case moving in fails
		_unit moveinany _obj;
	} else {
		//--- Outside
		if ((_objPos select 2) > 20) then {
			//--- Parachute
			_para = createvehicle ["Steerable_Parachute_F",_objPos,[],0,"none"];
			_para setpos _objPos;
			_para setdir direction _obj;
			_unit moveindriver _para;
		} else {
			_objPosATL = getposatl _obj;
			if ((_objPosATL select 2) > 1 && (_objPos select 2) < 1) then {
				//--- Building
				_unit setposatl _objPosATL;
				_unit setdir direction _obj;
			} else {
				//--- Ground
				[_obj,direction _obj] call _fnc_setPos;
			};
		};
	};
};
case (typename ""): {
	_direction = markerdir _position;
	if (_direction > 360) then {_direction = _direction / 360;};
	[_position,_direction] call _fnc_setPos;
};
case (typename []): {
	if ((_position select 2) > 20) then {
		//--- Parachute
		_para = createvehicle ["Steerable_Parachute_F",_position,[],0,"none"];
		_para setpos _position;
		_unit moveindriver _para;
	} else {
		//--- Position
		_unit setposatl _position;
	};
};

};
true

I only added this on top:

if (isNil "glt_respawn_fix_exit") exitWith {
glt_respawn_fix_exit = true;
};

So the function will simply exit upon first call. This will however break start-position selection for JIP (if you're using that).

We are using this as PBO (Addon), so it doesn't have to be added to all the missions. Download here if you're interested: glt_startpos_fix.rar

Edited by sxp2high

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
Sign in to follow this  

×