Jump to content
Sign in to follow this  
kamaradski

respawnTemplates different per player side ?

Recommended Posts

hi all,

In my Description.ext i'm using a

respawnTemplates[] = {"Wave","Counter","MenuPosition"};

However this should be valid only for the west faction. While east should just use the normal respawn BASE without templates etc...

How could i set this up ?

Share this post


Link to post
Share on other sites

Was thinking you might be able to use PreProcessor commands to have different templates based on side but there's no player object when that's processed so not sure how you'd do that. But for static options it's kinda neat. :)

Share this post


Link to post
Share on other sites
hi all,

In my Description.ext i'm using a

respawnTemplates[] = {"Wave","Counter","MenuPosition"};

However this should be valid only for the west faction. While east should just use the normal respawn BASE without templates etc...

How could i set this up ?

if i look at http://community.bistudio.com/wiki/Arma_3_Respawn

class CfgRespawnTemplates
{
// Class used in respawnTemplates entry
class myTag_beacon
{
	// Template name
	displayName = "Beacon";
	// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file
	onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";
	// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file
	onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf";
	// Default respawn delay (can be overwitten by description.ext entry of the same name)
	respawnDelay = 20;
};
class Spectator
{
	displayName = "Spectator";
	onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
};

.......onPlayerKilled .........onPlayerRespawn

Share this post


Link to post
Share on other sites
.......onPlayerKilled .........onPlayerRespawn

The question is though, can you define description.ext things inside the onPlayerKilled script? Or would you have to custom code the whole respawn process?

Share this post


Link to post
Share on other sites

Thanks both the the replies so far.

I will investigate what can be done with the preprocesser commands, however highly doubt the solution is in there.

@LoonyWarrior: you describe the process of writing your own respawn templates. however i would like to use the default 'MenuPosition' type respawn for GREEN, while BLUE only have 1 spawnpoint does not need this extra option.

The optimal solution would be to do already the side switch inside description.ext.

example:

switch (playerSide) do
{
   case west: 
   {
    respawnTemplates[] = {"Wave","Counter","MenuPosition"};
   }

   case resistance: 
   {
    respawnTemplates[] = {"Wave","Counter"};
   }
}

But that i dont even have to try, as it will obviously not work from the Description.ext :D

Share this post


Link to post
Share on other sites
Thanks both the the replies so far.

I will investigate what can be done with the preprocesser commands, however highly doubt the solution is in there.

@LoonyWarrior: you describe the process of writing your own respawn templates. however i would like to use the default 'MenuPosition' type respawn for GREEN, while BLUE only have 1 spawnpoint does not need this extra option.

The optimal solution would be to do already the side switch inside description.ext.

example:

switch (playerSide) do
{
   case west: 
   {
    respawnTemplates[] = {"Wave","Counter","MenuPosition"};
   }

   case resistance: 
   {
    respawnTemplates[] = {"Wave","Counter"};
   }
}

But that i dont even have to try, as it will obviously not work from the Description.ext :D

its just theory but u should be able to create new template and use the same dialog as in menuposition template..

Share this post


Link to post
Share on other sites

Was thinking that, but not sure where the original templates are stored so i can read or change them....

I am not at all any good with dialog creation :P

Share this post


Link to post
Share on other sites

:p

class CfgRespawnTemplates
{
//--- Defaults
respawnTemplatesNone[] = {"None"};
respawnTemplatesBird[] = {"Spectator","EndMission"};
respawnTemplatesInstant[] = {"Instant","Counter"};
respawnTemplatesBase[] = {"Base","Counter"};
respawnTemplatesGroup[] = {"Group","EndMission"};
respawnTemplatesSide[] = {"Side","EndMission"};

class None
{
	displayName = "None";
	onPlayerKilled = "BIS_fnc_respawnNone";
};
class Spectator
{
	displayName = "Spectator";
	onPlayerKilled = "BIS_fnc_respawnSpectator";
	onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
class Instant
{
	displayName = "Instant";
	onPlayerKilled = "BIS_fnc_respawnInstant";
	onPlayerRespawn = "BIS_fnc_respawnInstant";
};
class Base
{
	displayName = "Base";
	onPlayerKilled = "BIS_fnc_respawnBase";
	onPlayerRespawn = "BIS_fnc_respawnBase";
};
class Group
{
	displayName = "Group";
	onPlayerRespawn = "BIS_fnc_respawnGroup";
};
class Side
{
	displayName = "Side";
	onPlayerRespawn = "BIS_fnc_respawnSide";
};

//--- Custom
class EndMission
{
	displayName = "EndMission";
	onPlayerRespawn = "BIS_fnc_respawnEndMission";
};
class Seagull
{
	displayName = "Seagull";
	onPlayerRespawn = "BIS_fnc_respawnSeagull";
};
class Wave
{
	displayName = "Wave";
	onPlayerKilled = "BIS_fnc_respawnWave";
	onPlayerRespawn = "BIS_fnc_respawnWave";
};
class TimePenalty
{
	displayName = "Time Penalty";
	onPlayerKilled = "BIS_fnc_respawnTimePenalty";
	onPlayerRespawn = "BIS_fnc_respawnTimePenalty";
};
class Counter
{
	displayName = "Counter";
	onPlayerKilled = "BIS_fnc_respawnCounter";
	onPlayerRespawn = "BIS_fnc_respawnCounter";
};
class Confirm
{
	displayName = "Confirm";
	onPlayerKilled = "BIS_fnc_respawnConfirm";
	onPlayerRespawn = "BIS_fnc_respawnConfirm";
};
class MenuPosition
{
	displayName = "Select Position";
	onPlayerKilled = "BIS_fnc_respawnMenuPosition";
	onPlayerRespawn = "BIS_fnc_respawnMenuPosition";
};
class MenuInventory
{
	displayName = "Select Inventory";
	onPlayerKilled = "BIS_fnc_respawnMenuInventory";
	onPlayerRespawn = "BIS_fnc_respawnMenuInventory";
};
};

Share this post


Link to post
Share on other sites

try change

if (playerrespawntime < 1 || !isplayer _unit) exitwith {};

if (playerrespawntime < 1 || !isplayer _unit || side (group _unit) != resistance) exitwith {};

BIS_fnc_respawnMenuPosition

disableserialization;

_unit = [_this,0,objnull,[objnull]] call bis_fnc_param;
_respawnDelay = [_this,3,0,[0]] call bis_fnc_param;

if (!alive _unit) then {
if (playerrespawntime < 1 || !isplayer _unit) exitwith {};
setplayerrespawntime (playerrespawntime + 3);

sleep 2;
cutText ["","black out",0.5];
sleep 1;
cutText ["","black in"];

///////////////////////////////////////////////////////////////////////////////////////////
//--- onPlayerKilled
///////////////////////////////////////////////////////////////////////////////////////////

BIS_fnc_respawnMenuPosition_draw = {
	_ctrlMap = _this select 0;
	_display = ctrlparent _ctrlMap;
	_ctrlList = _display displayctrl BIS_fnc_respawnMenuPosition_ctrlList;
	_selected = _ctrlList lbvalue lbcursel _ctrlList;

	//--- Draw icons on respawn positions
	_color = playerside call bis_fnc_sidecolor;
	_icon = "selector_selectedFriendly" call bis_fnc_textureMarker;
	_iconSelected = "selector_selectedMission" call bis_fnc_textureMarker;
	{
		_colorLocal = if (_foreachindex == BIS_fnc_respawnMenuPosition_selected) then {[1,1,1,1]} else {_color};
		_iconLocal = if (_foreachindex == _selected) then {_iconSelected} else {_icon};
		_ctrlMap drawicon [
			_iconLocal,
			_colorLocal,
			_x call bis_fnc_position,
			48,
			48,
			time * 16,
			"",
			1
		];
	} foreach BIS_fnc_respawnMenuPosition_positions;
};

BIS_fnc_respawnMenuPosition_mouseMoving = {
	_ctrlMap = _this select 0;
	_mX = _this select 1;
	_mY = _this select 2;
	_dis = 0.048;
	_selected = -1;
	{
		_pos = _ctrlMap ctrlmapworldtoscreen (_x call bis_fnc_position);
		if (_pos distance [_mX,_mY] < _dis) then {
			_selected = _foreachindex;
		};
	} foreach BIS_fnc_respawnMenuPosition_positions;
	BIS_fnc_respawnMenuPosition_selected = _selected;
};

BIS_fnc_respawnMenuPosition_mouseButtonClick = {
	_ctrlMap = _this select 0;
	_button = _this select 1;
	if (_button == 0 && BIS_fnc_respawnMenuPosition_selected >= 0) then {
		_display = ctrlparent _ctrlMap;
		_ctrlList = _display displayctrl BIS_fnc_respawnMenuPosition_ctrlList;
		//BIS_fnc_respawnMenuPosition_systemSelect = true;
		//_ctrlList lbsetcursel (BIS_fnc_respawnMenuPosition_selected + 1);

		BIS_fnc_respawnMenuPosition_respawn = BIS_fnc_respawnMenuPosition_positions select BIS_fnc_respawnMenuPosition_selected;
		BIS_fnc_respawnMenuPosition_systemSelect = true;
		_ctrlList lbsetcursel (BIS_fnc_respawnMenuPosition_selected + 1);
	};
};


[
	"Select Respawn Point",
	{
		scriptname "BIS_fnc_respawnMenuPosition";
		_fnc_scriptName = "BIS_fnc_respawnMenuPosition";
		disableserialization;
		_mode = _this select 0;
		_ctrlListBackground = _this select 1;
		_ctrlList = _this select 2;
		_ctrlContentBackground = _this select 3;
		_ctrlContentGroup = _this select 4;
		_ctrlContent = _this select 5;
		_ctrlMap = _this select 6;

		switch _mode do {
			case "init": {
				_ctrlContentBackground ctrlshow false;
				_ctrlContentGroup ctrlshow false;
				_ctrlContentGroup ctrlenable false;
				_ctrlMap ctrlshow true;

				BIS_fnc_respawnMenuPosition_ctrlList = ctrlIDC _ctrlList;
				BIS_fnc_respawnMenuPosition_selected = -1;
				BIS_fnc_respawnMenuPosition_positions = [];

				_ctrlMap ctrladdeventhandler ["draw","_this call BIS_fnc_respawnMenuPosition_draw;"];
				_ctrlMap ctrladdeventhandler ["mouseMoving","_this call BIS_fnc_respawnMenuPosition_mouseMoving;"];
				_ctrlMap ctrladdeventhandler ["mouseHolding","_this call BIS_fnc_respawnMenuPosition_mouseMoving;"];
				_ctrlMap ctrladdeventhandler ["mouseButtonClick","_this call BIS_fnc_respawnMenuPosition_mouseButtonClick;"];
			};
			case "select": {
				if (lbsize _ctrlList == 0) exitwith {};
				if (BIS_fnc_respawnMenuPosition_systemSelect) exitwith {BIS_fnc_respawnMenuPosition_systemSelect = false;};

				_commitTime = 0.5;
				_positionID = _ctrlList lbvalue lbcursel _ctrlList;
				if (_positionID < 0) then {
					BIS_fnc_respawnMenuPosition_respawn = "";

				} else {
					_position = BIS_fnc_respawnMenuPosition_positions select _positionID;

					_ctrlMap ctrlmapanimadd [_commitTime,(ctrlmapscale _ctrlMap) max 0.1,_position call bis_fnc_position];
					ctrlmapanimcommit _ctrlMap;
					BIS_fnc_respawnMenuPosition_respawn = _position;
				};
			};
			case "update": {
				_selected = _ctrlList lbdata lbcursel _ctrlList;
				if (_selected == "") then {_selected = missionnamespace getvariable ["BIS_fnc_respawnMenuPosition_respawn",""];};

				//--- Preload the selected scene
				if (str _selectedPos != """""") then {
					preloadcamera (_selected call bis_fnc_position);
					if (typename _selected == typename objnull) then {1 preloadobject _selected};
				};

				_respawnPositions = (playerside call bis_fnc_getRespawnMarkers) + (player call bis_fnc_getRespawnPositions);
				if (str _respawnPositions == str BIS_fnc_respawnMenuPosition_positions) exitwith {};

				BIS_fnc_respawnMenuPosition_positions = _respawnPositions;
				BIS_fnc_respawnMenuPosition_systemSelect = !isnil {BIS_fnc_respawnMenuPosition_systemSelect};

				if (count _respawnPositions > 0) then {
					lbclear _ctrlList;
					_lbAdd = _ctrlList lbAdd "<Random>"; //--- ToDo: Localize
					_ctrlList lbsetvalue [_lbAdd,-1];

					_cursel = 0;
					{
						_text = "";
						_picture = "";
						_canAdd = true;
						switch (typename _x) do {
							case (typename ""): {
								_text = markertext _x;
								_picture = (markertype _x) call bis_fnc_textureMarker;
							};
							case (typename objnull): {
								_text = (configfile >> "cfgvehicles" >> typeof _x) call bis_fnc_displayName;
								_picture = gettext (configfile >> "cfgvehicles" >> typeof _x >> "icon") call bis_fnc_textureVehicleIcon;
								_canAdd = !isnull _x;
							};
							case (typename []): {
							};
						};
						if (_canAdd) then {
							if (_text == "") then {_text = format ["Grid %1",mapgridposition (_x call bis_fnc_position)]}; //--- ToDo: Localize
							if (_picture == "") then {_picture = "#(argb,8,8,3)color(0,0,0,0)";};
							_lbAdd = _ctrlList lbadd _text;
							_ctrlList lbsetvalue [_lbAdd,_foreachindex];
							_ctrlList lbsetpicture [_lbAdd,_picture];
							if (str _x == str _selected) then {_cursel = _lbAdd;};
						};
					} foreach _respawnPositions;
					_ctrlList lbsetcursel _cursel;
				} else {
					["No respawn positions found"] call bis_fnc_error;
				};
			};
		};
	}
] call bis_fnc_showRespawnMenu;
} else {

///////////////////////////////////////////////////////////////////////////////////////////
//--- onPlayerRespawn
///////////////////////////////////////////////////////////////////////////////////////////

if (isplayer _unit) then {

	//--- Player - teleport to selected position
	[] call bis_fnc_showRespawnMenu;

	_respawn = BIS_fnc_respawnMenuPosition_respawn;
	if (str _respawn == """""") then {_respawn = BIS_fnc_respawnMenuPosition_positions call bis_fnc_selectrandom;};
	[_unit,_respawn] call bis_fnc_moveToRespawnPosition;

	//--- Clean-up
	BIS_fnc_respawnMenuPosition_draw = nil;
	BIS_fnc_respawnMenuPosition_mouseMoving = nil;
	BIS_fnc_respawnMenuPosition_mouseButtonClick = nil;
	BIS_fnc_respawnMenuPosition_systemSelect = nil;
	BIS_fnc_respawnMenuPosition_positions = nil;
	with uinamespace do {
		BIS_fnc_respawnMenuPosition_ctrlList = nil;
		BIS_fnc_respawnMenuPosition_positions = nil
	};

	setplayerrespawntime _respawnDelay;
} else {

	//--- AI - teleport to random position
	_respawnPositions = (side group _unit) call bis_fnc_respawnBaseMarkers;
	if (count _respawnPositions > 0) then {
		_respawn = _respawnPositions call bis_fnc_selectrandom;
		switch (typename _respawn) do {
			case (typename ""): {
				_unit setpos markerpos _respawn;
			};
		};
	};
};
};

Share this post


Link to post
Share on other sites

Priceless stuff LoonyWarrior !! Looks like you just made my day :)

Can't wait to get home tonight and play with this :)

Will post back! thanks !!

Share this post


Link to post
Share on other sites

Ok thanks LoonyWarrior !!

This actually solved my problem perfectly :)

Description.ext:

class CfgRespawnTemplates
{
   class TA_green_Respawn
   {
       displayName = "something here";
       onPlayerKilled = "Misc\TA_fnc_greenrespawnMenuPosition";
       onPlayerRespawn = "Misc\TA_fnc_greenrespawnMenuPosition";
   };
};

TA_fnc_greenrespawnMenuPosition

if (playerrespawntime < 1 || !isplayer _unit || side (group _unit) != resistance) exitwith {};

Very sweet, now experimenting to use the same trick to make respawn menu only kick-in after =BTC= Revive script did it's thing :)

Thanks again !!

Share this post


Link to post
Share on other sites

Based on your feedback here, I added an ability to define side specific templates:

respawnTemplatesWest[] = {"MenuInventory"};
respawnTemplatesEast[] = {"Counter"};
respawnTemplatesGuer[] = {"Tickets"};
respawnTemplatesCiv[] = {"Spectator"};

It should appear in the next dev branch update.

Please don't modify the original functions. When we update them, you would still be using the old mirrored version.

Share this post


Link to post
Share on other sites

Hi Moricky,

That will be very helpful, thanks for taking this onboard :)

Share this post


Link to post
Share on other sites
respawnTemplatesGuer

Why Guer there when it doesn't work everywhere else? :)

Example:

if (side player == guer) then { hint "yup"};

results in no hint.

if (side player == independent) then { hint "yup"};

results in yup hint.

Is that incorrect side check just a bug? (independent and resistance both both for checking the "guer" side, just confusing having so many possible words for the same thing and not all of them work. People will see east/west/guer and think those are sides but they aren't interchangable. Maybe we should take the plunge and just switch all commands over to blufor/opfor/indfor/civfor :) )

Share this post


Link to post
Share on other sites

Hi all!

I'm beginning to edit missions, and I want to learn to use the respawn templates in description.ext file.

I have a lot of wasted hours trying to get that respawn templates work, but I only got that it works partially. I have looking for this in the forum, but I haven't found the solution.

My idea is that Blufor have multiple respawn positions in base and menu inventory, and Opfor have one life and then, soldiers dead can be spectators of their side. If no players, end mission.

What I need to get this? I mean to code, files and code in the differents files, etc.

The part of Blufor, works, but in the case of Opfor, when the soldier dead, the spectator mode appear, but the soldier respawn instantly, at the same time, and I can control him, and spectator mode doesn't work.

Blufor have 2 markers, and Opfor none.

 

 

Description.ext

respawn = 3;
respawnDelay = 5;

respawnTemplatesWest[] = {"MenuPosition","MenuInventory"};
respawnTemplatesEast[] = {"Spectator","EndMission"};


class CfgRespawnInventory
{
	class WEST1
	{
		displayName = "Light"; // Name visible in the menu
		icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa"; // Icon displayed next to the name
		show = "side group _this == west";
		vehicle[] = {
			"B_soldier_AT_F"
		};
		// Loadout definition, uses same entries as CfgVehicles classes
		weapons[] = {
			"arifle_MXC_F",
			"Binocular"
		};
		magazines[] = {
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"SmokeShell",
			"HandGrenade"
		};
		items[] = {
			"FirstAidKit"
		};
		linkedItems[] = {
			"V_Chestrig_khk",
			"H_Watchcap_blk",
			"optic_Aco",
			"acc_flashlight",
			"ItemMap",
			"ItemCompass",
			"ItemWatch",
			"ItemRadio"
		};
		uniformClass = "U_B_CombatUniform_mcam_tshirt";
		backpack = "B_AssaultPack_mcamo";
	};
	class WEST2
	{
		displayName = "Zapador"; // Name visible in the menu
		icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa"; // Icon displayed next to the name
		show = "side group _this == west";
		// Loadout definition, uses same entries as CfgVehicles classes
		weapons[] = {
			"arifle_MXC_F",
			"Binocular"
		};
		magazines[] = {
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"30Rnd_65x39_caseless_mag",
			"SmokeShell",
			"HandGrenade"
		};
		items[] = {
			"FirstAidKit",
                        "MineDetector"
		};
		linkedItems[] = {
			"V_Chestrig_khk",
			"H_Watchcap_blk",
			"optic_Aco",
			"acc_flashlight",
			"ItemMap",
			"ItemCompass",
			"ItemWatch",
			"ItemRadio",
			"ItemGPS",
			"MineDetector"
		};
		uniformClass = "U_B_CombatUniform_mcam_tshirt";
		backpack = "B_AssaultPack_mcamo";
	};
};
class CfgRespawnTemplates
{
	
	
	class Spectator
	{
		displayName = "Spectator";
		onPlayerKilled = "BIS_fnc_respawnSpectator";
		onPlayerRespawn = "BIS_fnc_respawnSpectator";
	};
	class EndMission
	{
		displayName = "EndMission";
		onPlayerRespawn = "BIS_fnc_respawnEndMission";
	};
};

corpseManagerMode = 1;
corpseLimit = 5;
corpseRemovalMinTime = 60;
corpseRemovalMaxTime = 90;

Init.sqf

setviewdistance 2000;
setObjectViewDistance 2000;

// Wait until player is initialized
if (!isDedicated) then {waitUntil {!isNull player && isPlayer player};};

[west, "WEST1"] call BIS_fnc_addRespawnInventory;
[west, "WEST2"] call BIS_fnc_addRespawnInventory;

onPlayerKilled and onPlayerRespawn are empty.

 

 

Thanks and regards.

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  

×