Jump to content
[GLT] Legislator

[Solved]BIS_fnc_addRespawnInventory causing random loadout at mission start

Recommended Posts

Hi guys,

 

I have some issues using the respawn manager.

 

Situation:

- in multiplayer players are starting together in one group on the same side

- the default inventory layout of the original unit is ignored e.g. B_Soldier_SL_F suddenly becoming an AT soldier, B_Medic_F becoming an engineer and so on

 

description.ext

- only refering to my main mod file

#include "\glt_core\description.hpp"
 

description.hpp

- includes configuration for most of the missions

- example only shows one loadout, the others are defined the same way

// Respawn Settings
respawnOnStart = 0;
respawnTemplatesWest[] = {"MenuInventory", "MenuPosition"};
respawnTemplatesGuer[] = {"MenuInventory", "MenuPosition"};
reviveDelay = 30;
reviveForceRespawnDelay = 5;
reviveBleedOutDelay = 120;

// Loadout
class CfgRespawnInventory {
     class NATO_Squadleader_Day {
          displayName = "$STR_GLT_Loadout_Teamleader_Day";
          icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
          role = "Teamleader";
          
          weapons[] = {
                "arifle_MX_GL_F",
                "hgun_Pistol_heavy_01_F",
                "Rangefinder"
          };
          magazines[] = {
               "100Rnd_65x39_caseless_mag_Tracer",
               "100Rnd_65x39_caseless_mag_Tracer",
               "30Rnd_65x39_caseless_mag",
               "30Rnd_65x39_caseless_mag",
               "30Rnd_65x39_caseless_mag_Tracer",
               "30Rnd_65x39_caseless_mag_Tracer",
               "11Rnd_45ACP_Mag",
               "11Rnd_45ACP_Mag",
               "1Rnd_HE_Grenade_shell",
               "1Rnd_HE_Grenade_shell",
               "1Rnd_HE_Grenade_shell",
               "1Rnd_HE_Grenade_shell",
               "MiniGrenade",
               "HandGrenade",
               "SmokeShellBlue",
               "SmokeShellGreen",
               "SmokeShellRed",
               "SmokeShell",
               "SmokeShell"
          };
          items[] = {
               "FirstAidKit",
               "GLT_Item_Bandage", 
               "GLT_Item_Epinephrine", 
               "GLT_Item_Morphine", 
               "GLT_Item_Canteen"
          };
          linkedItems[] = {
               "V_PlateCarrierSpec_mtp",
               "H_HelmetB_sand",
               "optic_Arco",
               "optic_MRD",
               "bipod_01_F_snd",
               "ItemMap",
               "ItemCompass",
               "ItemWatch",
               "ItemRadio"
          };
          uniformClass = "U_B_CombatUniform_mcam";
          backpack = "B_AssaultPack_mcamo";
     };
};

class CfgRoles {
     class Teamleader {
          displayName = "$STR_GLT_Units_Men_Teamleader";
          icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
     };	
};



init.sqf

- there is other code in the init.sqf, but I tracked the issue down to BIS_fnc_addRespawnInventory; that's why I'm focusing on the multiplayer respawn part only

if (isMultiplayer) then {

	// Define respawn points
	if (isServer) then {
		[] spawn {
			{ [west, _x] call BIS_fnc_addRespawnPosition; } forEach [Mobile_Respawn];	
		};
	};
	
	// Add respawn loadouts
	[west, "NATO_Autorifleman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Autorifleman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Engineer_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Engineer_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Explosive_Specialist_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Explosive_Specialist_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Grenadier_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Grenadier_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Marksman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Marksman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Medic_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Medic_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AA_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AA_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT2_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT2_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Squadleader_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Squadleader_Night"] call BIS_fnc_addRespawnInventory;
} else {

};

Now my questions:

1. Is the mentioned behaviour a bug of the respawn manager?

2. Did I call the respawn inventory function incorrectly?

3. Did I apply wrong settings in the description.ext / description.hpp ?

4. Did I miss a parameter to disable random loadout selection?

 

Share this post


Link to post
Share on other sites

I don't think that function actually changes any loadouts, just sets them as available options for the respawn menu.  Is there no where else you set the loadouts for units?  initplayerlocal.sqf or anywhere?

Share this post


Link to post
Share on other sites

No other init files or something like that. The only other code that might have something to do is loaded later (arsenal), but you have to press a key combination in order to activate it anyway. Just in case I missed something, here is the complete init.sqf

 

The old respawn loadout safe/load function has been disabled, but it would load the previous inventory before player death anyway and not select a random loadout.

// Wait until player is loaded
waitUntil {(isDedicated) || !(isNull player)};

// Variables
if (isNil "go") then {go = false};
if (isNil "obj1") then {obj1 = false};
if (isNil "obj2") then {obj2 = false};
if (isNil "obj3") then {obj3 = false};
glt_breath_enabled = nil;

// Load main mission configuration
nul = [] execVM "\glt_core\scripts\startup\main.sqf";

// Start the loading screen
startLoadingScreen ["GLT: Meet the Spartans"];

// Set mission parameters
waitUntil {!(isNil "paramsArray")};
if (isServer) then {setDate [2033,3,5,(paramsArray select 0),15];};
setViewDistance (paramsArray select 1);

// if ((paramsArray select 2) == 1) then {	
	// if (isServer) then {[(random 1)] call BIS_fnc_setOvercast;};
// };

if ((paramsArray select 2) == 1) then {

	// Server decides weather
	if (isServer) then {

		// Set and broadcast
		glt_mission_weather = if ((random 1) > 0.5) then { (random 1); } else { (random 0.5); }; 
		publicVariable "glt_mission_weather";
		glt_mission_wind = (random 1); publicVariable "glt_mission_wind";

		// JIP flag
		[] spawn { sleep 5; glt_mission_weather_jip = true; publicVariable "glt_mission_weather_jip"; };

	} else {

		// Client wait for server
		waitUntil {!(isNil "glt_mission_weather")};
		waitUntil {!(isNil "glt_mission_wind")};

	};
	
	// Onyl set on mission start (weather is synced for JIP by engine)
	if (isNil "glt_mission_weather_jip") then {
		0 setOvercast glt_mission_weather;
		0 setLightnings glt_mission_weather;
		0 setWindForce glt_mission_wind;
		0 setGusts glt_mission_wind;
		forceWeatherChange;
	};

};

if ((paramsArray select 3) == 1) then {	
	if (!isDedicated) then {[] execVM "\glt_core\scripts\marker\icons.sqf";};
};

// Set group IDs
(leader group player) setgroupid ["Sparta"];
{[_x, "GLT_Patch_Sparta"] call BIS_fnc_setUnitInsignia;} foreach (playableUnits + switchableUnits);

// Set Alliances
CIVILIAN setFriend [WEST, 1];
CIVILIAN setFriend [EAST, 1];
 
 // BTK Multiplayer Framework
btk_fnc_getPos = compile (preprocessFileLineNumbers "functions\btk_fnc_getPos.sqf"); 
btk_fnc_getPosRandom = compile (preprocessFileLineNumbers "functions\btk_fnc_getPosRandom.sqf"); 
btk_fnc_getPosFlatEmpty = compile (preprocessFileLineNumbers "functions\btk_fnc_getPosFlatEmpty.sqf"); 
btk_fnc_getBuildings = compile (preprocessFileLineNumbers "functions\btk_fnc_getBuildings.sqf"); 
btk_fnc_getBuildingPos = compile (preprocessFileLineNumbers "functions\btk_fnc_getBuildingPos.sqf"); 
btk_fnc_mpf = compile (preprocessFileLineNumbers "functions\btk_fnc_mpf.sqf"); 
btk_fnc_taskAI = compile (preprocessFileLineNumbers "functions\btk_fnc_taskAI.sqf"); 
btk_fnc_taskPatrol = compile (preprocessFileLineNumbers "functions\btk_fnc_taskPatrol.sqf");

// Air Support
_null = [] execVM "btk_airSupport.sqf";

// Triggers
if (isServer) then {

	// Task 1
	[] spawn { 
		 waitUntil {(east countSide list trg1 < 2)}; 
			nul = ["task1", "Succeeded"] execVM "\glt_core\scripts\tasks\task.sqf";
			 
			"Jay Cove Port" setMarkerColor "ColorBlue";
			"Jay Cove Port" setMarkerText "Jay Cove";
			"Jay Cove Port" setMarkerType "mil_triangle";
			"CSAT1" setMarkerType "flag_USA";
			
			obj1 = true;
			publicVariable "obj1";
		
			if (isServer) then {
				[] spawn {
					{ [west, _x] call BIS_fnc_addRespawnPosition; } forEach ["Jay Cove Port"];	
				};
			};
		{_null = _x createDiaryRecord ["Diary", [localize "STR_GLT_briefing_respawn", localize "STR_respawn2_meet_the_spartans"]]; } forEach (playableUnits + switchableUnits);
	};
	
	// Task 2
	[] spawn { 
		 waitUntil {(east countSide list trg2 < 2)}; 
			nul = ["task2", "Succeeded"] execVM "\glt_core\scripts\tasks\task.sqf";
			 
			"LZ Connor" setMarkerColor "ColorBlue";
			"LZ Connor" setMarkerText "LZ Connor";
			"LZ Connor" setMarkerType "mil_triangle";
			
			obj2 = true;
			publicVariable "obj2";
			
			if (isServer) then {
				[] spawn {
					{ [west, _x] call BIS_fnc_addRespawnPosition; } forEach ["LZ Connor"];	
				};
			};
		{_null = _x createDiaryRecord ["Diary", [localize "STR_GLT_briefing_respawn", localize "STR_respawn3_meet_the_spartans"]]; } forEach (playableUnits + switchableUnits);
	};	
	
	// Task 3
	[] spawn { 
		 waitUntil {(east countSide list trg3 < 2)}; 
			nul = ["task3", "Succeeded"] execVM "\glt_core\scripts\tasks\task.sqf";
		 
			"Camp Maxwell" setMarkerColor "ColorBlue";
			"CSAT2" setMarkerType "flag_USA";
		
			obj3 = true;
			publicVariable "obj3";
	};	
	
	
	// Trigger
	[] spawn { 
		// waitUntil {({(_x in list trg4)} count (units gw1) == {alive _x} count (units gw1))}; 
		waitUntil {(west countSide list trg4 > 1)}; 
		go = true; 
		publicVariable "go";
		nul = [] execVM "us_spawn.sqf";  
		"Houses" setMarkerType "mil_triangle";

		if (isServer) then {   
			[] spawn {
				{[west, _x] call BIS_fnc_addRespawnPosition;} forEach ["Houses"];
			};
		}; 
		{_null = _x createDiaryRecord ["Diary", [localize "STR_GLT_briefing_respawn", localize "STR_respawn4_meet_the_spartans"]]; } forEach (playableUnits + switchableUnits);
	};
};


// End loading screen
endLoadingScreen;

// Separation of SP and MP code
if (isMultiplayer) then {

	// Define respawn points
	if (isServer) then {
		[] spawn {
			{ [west, _x] call BIS_fnc_addRespawnPosition; } forEach [Mobile_Respawn];	
		};
	};
	
	// Add respawn loadouts
	[west, "NATO_Autorifleman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Autorifleman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Engineer_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Engineer_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Explosive_Specialist_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Explosive_Specialist_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Grenadier_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Grenadier_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Marksman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Marksman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Medic_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Medic_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AA_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AA_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT2_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Rifleman_AT2_Night"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Squadleader_Day"] call BIS_fnc_addRespawnInventory;
	[west, "NATO_Squadleader_Night"] call BIS_fnc_addRespawnInventory;

	// Respawn Loadout Code
	// if !(isDedicated) then {
          // player addEventHandler ["killed", { [] spawn { waitUntil {(alive player)}; [] call GLT_fnc_loadGear; }; }];
	
		 // [] spawn { 
			 // while {true} do { 
				  // sleep 5.238; 
				  // if (alive player) then { call GLT_fnc_saveGear; } else { waitUntil {(alive player)}; }; 
				// }; 
			// };
		// };
		
	// Intro Text
	[] spawn {
		sleep 10;
		_null = [] execVM "\glt_core\scripts\text\glt_introText.sqf";  
		
		sleep 7;
		// Arsenal
		execVM "\glt_core\scripts\startup\arsenal_nato.sqf";
	};


} else {
	
	// Hide respawn marker
	"respawn_west" setMarkerType "Empty";
	
	// Intro
	[] spawn {
		scriptName "initMission.hpp: mission start";
		["\glt_core\videos\GLT.ogv", ""] spawn BIS_fnc_titlecard;
		waitUntil {!(isNil "BIS_fnc_titlecard_finished")};
		[getPos p1, localize "STR_desc2_meet_the_spartans"] spawn BIS_fnc_establishingShot;	
	};
	
	// Intro Text
	waitUntil {!(isNil "BIS_missionStarted")};
	[] spawn {
		sleep 5;
		_null = [] execVM "\glt_core\scripts\text\glt_introText.sqf";  
		
		sleep 7;
		// Arsenal
		execVM "\glt_core\scripts\startup\arsenal_nato.sqf";
	};
};


// Print Mission version to RPT
glt_mission_version = "1.19";
diag_log text format["### Starting GLT: Meet the Spartans %1 ###",glt_mission_version];

Share this post


Link to post
Share on other sites

Ive never seen the description ext used for such things, seems very strange. Much better off using something in initplayerlocal.sqf for simplicity (not tested obviously from the classnames)

If you're making a mod, why not just config your own units in using the BIS base classes?

Everything about that seems slightly backwards to me, but thats me.

 

if (typeof player == "Classname here") then {

removeallweapons player;
removevest player;
removebackpack player;
removeuniform player;

player addweapon "lazor";
Player addweapon "smaller lazor";
player addbackpack "something";
player addvest "something else";
player adduniform "Prom dress";
player addMagazine ["some mags",10];
player addMagazine ["some frags",3];
for "_i" from 1 to 5 do {
   player additem "turkey dinner";
};
};

Share this post


Link to post
Share on other sites

The goal is not to create new units or alter the configs of existing units. Players should be able to decide which weapons and items they want to play with. That's why there's the arsenal feature included but that's not the point. The problem is that for whatever reason a random loadout from BIS_fnc_addRespawnInventory is selected for each player and I don't know why.

Share this post


Link to post
Share on other sites

I think your problem is the respawnOnStart setting in description.ext.

respawnOnStart = 1;//Respawn on start. Run respawn script on start.
respawnOnStart = 0;//Dont respawn on start. Run respawn script on start.
respawnOnStart = -1;//Dont respawn on start. Don't run respawn script on start.

You have it set to 0, so at start they aren't respawning but they are running the respawn script.  Setting it to -1 will have them start with editor set loadout.

Share this post


Link to post
Share on other sites

I think your problem is the respawnOnStart setting in description.ext.

respawnOnStart = 1;//Respawn on start. Run respawn script on start.
respawnOnStart = 0;//Dont respawn on start. Run respawn script on start.
respawnOnStart = -1;//Dont respawn on start. Don't run respawn script on start.

You have it set to 0, so at start they aren't respawning but they are running the respawn script.  Setting it to -1 will have them start with editor set loadout.

 

By the hand of David Armstrong, you are right! Changing to respawnOnStart = -1; fixed the issue! Oh god, I was already checking config files for changes, searched for example missions ... tried so many things, but I never thought of something so simple. Thank you, very much kylania!  :) 

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

×