updates to login system and hitpoints

- No longer track hitpoints from client side, now saved server side only
and pushed to clients on login.
https://community.bistudio.com/wiki/getAllHitPointsDamage
- Changed use set / getUnitLoadout and should still have legacy player
data support that will upgrade automatically on first save.
- Default loadout can be controlled via new variables in epochconfig.hpp
- Made data validation check dynamic using isEqualTypeParams as it does
type checking and still fails if input is shorter than the default.
https://community.bistudio.com/wiki/isEqualTypeParams
- Added back server side damage protection for the new player body. If
the new unit dies before the player switch it could cause login issues
and should not cause issues with scripted setdamage or hitpoints as
first thought. https://community.bistudio.com/wiki/allowDamage
This commit is contained in:
vbawol 2017-08-15 14:19:03 -05:00
parent 7cbcb2c530
commit 1a211407b9
8 changed files with 280 additions and 261 deletions

View File

@ -30,7 +30,8 @@ antagonistChanceLoot = 0.09; //9% chance when player click "SEARCH" on a loot ob
// Player Related // Player Related
cloneCost = 100; // debt incurred on player death cloneCost = 100; // debt incurred on player death
MaxBankDebitforTrade = -50000; // If Player has less money on Bank, Crypto from Trade goes directly to Bank instead to Player MaxBankDebitforTrade = -50000; // If Player has less money on Bank, Crypto from Trade goes directly to Bank instead to Player
// Start Leadout
// Default Loadout
defaultUniformFemale = "U_Test_uniform"; defaultUniformFemale = "U_Test_uniform";
defaultVestFemale = "V_F41_EPOCH"; defaultVestFemale = "V_F41_EPOCH";
defaultUniformMale = "U_Test1_uniform"; defaultUniformMale = "U_Test1_uniform";
@ -38,47 +39,14 @@ defaultVestMale = "V_41_EPOCH";
defaultGoggles = ""; defaultGoggles = "";
defaultHeadgear = ""; defaultHeadgear = "";
defaultBackpack = ""; defaultBackpack = "";
linkedItems[] = {"ItemMap","EpochRadio0"}; // {"Item1","Item2",...}; These Items will be linked to the Players Inventory defaultprimaryWeapon[] = {}; // {"arifle_MX_pointer_F","","acc_pointer_IR","",{"30Rnd_65x39_caseless_mag",29},{},""};
itemsInContainers[] = {}; // {"Item1","Item2",...}; These Items will be put in the Players Cargo(s) defaultsecondaryWeapon[] = {}; // {"launch_NLAW_F","","","",{"NLAW_F",1},{},""};
weaponsInContainers[] = {}; // {"Weapon1","Weapon2",...}; These Weapons will be put in the Players Cargo(s) defaulthandgunWeapon[] = {}; // {"hgun_P07_F","","","",{"16Rnd_9x21_Mag",16},{},""};
normalMagazines[] = {}; // {{"Magazine1",Ammocount1},{"Magazine2",Ammocount2},...}; defaultuniformItems[] = {}; // {{"FirstAidKit",1},{"30Rnd_65x39_caseless_mag",2,30},{"Chemlight_green",1,1}};
weaponsAndItems[] = { defaultvestItems[] = {}; // {{"30Rnd_65x39_caseless_mag",3,30},{"16Rnd_9x21_Mag",2,16},{"SmokeShell",1,1},{"SmokeShellGreen",1,1},{"SmokeShellBlue",1,1},{"SmokeShellOrange",1,1},{"Chemlight_green",1,1}};
/* defaultbackpackItems[] = {}; // {{"Medikit",1},{"FirstAidKit",10},{{"hgun_P07_F","","","",{"16Rnd_9x21_Mag",16},{},""},1}};
"srifle_EBR_F", // Active Weapon (in hand) defaultassignedItems[] = {}; // {"Rangefinder","","","",{},{},""}
{ // Full equipped Weapons (put here equipped Weapons that should be in the Weapons Slots) defaultlinkedItems[] = {"ItemMap","","EpochRadio0","","",""}; // {"ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"};
{
"srifle_EBR_F", // Weapon 1
"muzzle_snds_B", // Suppressor 1
"acc_pointer_IR", // Laser 1
"optic_DMS", // Optics 1
{"20Rnd_762x51_Mag",20}, // Magtype + ammo count 1
{}, // 2nd Magtype + ammo count 1 (Only needed for GL-Mags)
"bipod_02_F_blk" // Bipod 1
},
{
"Plunger", // Weapon 2
"", // Suppressor 2
"", // Laser 2
"", // Optics 2
{"stick_swing",1000}, // Magtype + ammo count 2
""
},
{
"ruger_pistol_epoch",
"", // Suppressor 3
"", // Laser 3
"", // Optics 3
{"10rnd_22X44_magazine",10}, // Magtype + ammo count 3
"" // Bipod 3
}
},
{
"srifle_EBR_F", // Primary Weapon
"Plunger", // Secondary Weapon
"ruger_pistol_epoch" // Handgun Weapon
}
*/
};
// vehicles - Max vehicle slots is calculated from per vehicle limits below. Warning! Higher the number lower the performance. // vehicles - Max vehicle slots is calculated from per vehicle limits below. Warning! Higher the number lower the performance.
disableAutoRefuel = "true"; // Removes auto refuel from all buildings at server startup. disableAutoRefuel = "true"; // Removes auto refuel from all buildings at server startup.

View File

@ -1,7 +1,7 @@
/*%FSM<COMPILE "C:\Program Files (x86)\Steam\steamapps\common\Arma 3 Tools\FSMEditor\scriptedFSM.cfg, Epoch Login">*/ /*%FSM<COMPILE "F:\Program Files (x86)\Steam\steamapps\common\Arma 3 Tools\FSMEditor\scriptedFSM.cfg, Epoch Login">*/
/*%FSM<HEAD>*/ /*%FSM<HEAD>*/
/* /*
item0[] = {"INIT",0,250,-25.000000,-375.000000,75.000000,-325.000000,0.000000,"INIT"}; item0[] = {"INIT",0,4346,-25.000000,-375.000000,75.000000,-325.000000,0.000000,"INIT"};
item1[] = {"FINISH",1,250,-149.463196,1518.792480,-49.463196,1568.792480,0.000000,"FINISH"}; item1[] = {"FINISH",1,250,-149.463196,1518.792480,-49.463196,1568.792480,0.000000,"FINISH"};
item2[] = {"true",8,218,-150.000000,-125.000000,-50.000000,-75.000000,0.000000,"true"}; item2[] = {"true",8,218,-150.000000,-125.000000,-50.000000,-75.000000,0.000000,"true"};
item3[] = {"Version_Check",2,250,-25.000000,-75.000000,75.000000,-25.000000,0.000000,"Version Check"}; item3[] = {"Version_Check",2,250,-25.000000,-75.000000,75.000000,-25.000000,0.000000,"Version Check"};
@ -18,7 +18,7 @@ item13[] = {"ERROR_PlayerUID",2,250,275.000000,125.000000,375.000000,175.000000,
item14[] = {"",7,210,471.000061,145.999908,478.999939,154.000092,0.000000,""}; item14[] = {"",7,210,471.000061,145.999908,478.999939,154.000092,0.000000,""};
item15[] = {"Timeout_No_Respo",4,218,125.000000,875.000000,225.000000,925.000000,0.000000,"Timeout" \n "No Response"}; item15[] = {"Timeout_No_Respo",4,218,125.000000,875.000000,225.000000,925.000000,0.000000,"Timeout" \n "No Response"};
item16[] = {"Response",4,218,-150.000000,825.000000,-50.000000,875.000000,0.000000,"Response"}; item16[] = {"Response",4,218,-150.000000,825.000000,-50.000000,875.000000,0.000000,"Response"};
item17[] = {"Setup_Player_Var",2,4346,-25.000000,1075.000000,75.000000,1125.000000,0.000000,"Setup Player" \n "Variables"}; item17[] = {"Setup_Player_Var",2,250,-25.000000,1075.000000,75.000000,1125.000000,0.000000,"Setup Player" \n "Variables"};
item18[] = {"Request_Hive",2,250,-25.000000,575.000000,75.000000,625.000000,0.000000,"Request Hive"}; item18[] = {"Request_Hive",2,250,-25.000000,575.000000,75.000000,625.000000,0.000000,"Request Hive"};
item19[] = {"Timeout_No_Respo",4,218,125.000000,575.000000,225.000000,625.000000,0.000000,"Timeout" \n "No Response"}; item19[] = {"Timeout_No_Respo",4,218,125.000000,575.000000,225.000000,625.000000,0.000000,"Timeout" \n "No Response"};
item20[] = {"ERROR_Server_not",2,250,275.000000,875.000000,375.000000,925.000000,0.000000,"ERROR" \n "Server not" \n "Response"}; item20[] = {"ERROR_Server_not",2,250,275.000000,875.000000,375.000000,925.000000,0.000000,"ERROR" \n "Server not" \n "Response"};
@ -183,8 +183,8 @@ link93[] = {82,76};
link94[] = {83,16}; link94[] = {83,16};
link95[] = {83,22}; link95[] = {83,22};
link96[] = {84,31}; link96[] = {84,31};
globals[] = {0.000000,0,0,0,0,640,480,1,247,6316128,1,-374.618774,303.072205,1651.411377,653.207275,573,844,1}; globals[] = {0.000000,0,0,0,0,640,480,1,247,6316128,1,-406.572662,335.025604,359.874329,-776.300476,577,884,1};
window[] = {2,-1,-1,-1,-1,863,96,1080,96,3,595}; window[] = {2,-1,-1,-32000,-32000,871,104,1088,104,3,595};
*//*%FSM</HEAD>*/ *//*%FSM</HEAD>*/
class FSM class FSM
{ {
@ -209,7 +209,10 @@ class FSM
"EPOCH_loginFSM = _thisFSM;" \n "EPOCH_loginFSM = _thisFSM;" \n
"EPOCH_playerLoginInit = {" \n "EPOCH_playerLoginInit = {" \n
" EPOCH_loginFSM setFSMVariable [_this select 0, _this select 1];" \n " EPOCH_loginFSM setFSMVariable [_this select 0, _this select 1];" \n
"};"/*%FSM</STATEINIT""">*/; "};" \n
"" \n
"// init vars " \n
"_hitpoints = [];"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/; precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links class Links
{ {
@ -893,11 +896,10 @@ class FSM
" player addEventHandler [_x,([""CfgEpochClient"", _x, """"] call EPOCH_fnc_returnConfigEntryV2)];" \n " player addEventHandler [_x,([""CfgEpochClient"", _x, """"] call EPOCH_fnc_returnConfigEntryV2)];" \n
"} forEach ([""CfgEpochClient"", ""addEventHandler"", []] call EPOCH_fnc_returnConfigEntryV2);" \n "} forEach ([""CfgEpochClient"", ""addEventHandler"", []] call EPOCH_fnc_returnConfigEntryV2);" \n
"" \n "" \n
"if (count EPOCH_playerHitPoints isEqualTo count ((getAllHitPointsDamage player) param [0,[]])) then {" \n "// set inital hitpoints" \n
" {" \n "{" \n
" player setHitIndex [_forEachIndex, _x];" \n " player setHitIndex [_forEachIndex, _x];" \n
" }forEach EPOCH_playerHitPoints;" \n "}forEach _hitpoints;" \n
"};" \n
"" \n "" \n
"true call EPOCH_fnc_Weather;" \n "true call EPOCH_fnc_Weather;" \n
"[5,100] spawn EPOCH_niteLight;" \n "[5,100] spawn EPOCH_niteLight;" \n
@ -1400,6 +1402,7 @@ class FSM
"Epoch_personalToken = _C_SET deleteAt 0;" \n "Epoch_personalToken = _C_SET deleteAt 0;" \n
"Epoch_my_Group = _C_SET deleteAt 0;" \n "Epoch_my_Group = _C_SET deleteAt 0;" \n
"_communityStats = _C_SET deleteAt 0;" \n "_communityStats = _C_SET deleteAt 0;" \n
"_hitpoints = _C_SET deleteAt 0;" \n
"" \n "" \n
"_extraPayload = _C_SET deleteAt 0;" \n "_extraPayload = _C_SET deleteAt 0;" \n
"" \n "" \n

View File

@ -27,7 +27,6 @@ private ["_customVars","_lastSave","_time"];
_time = if (_this) then [{15},{80}]; _time = if (_this) then [{15},{80}];
_lastSave = missionNamespace getVariable["EPOCH_lastSave", diag_tickTime]; _lastSave = missionNamespace getVariable["EPOCH_lastSave", diag_tickTime];
if ((diag_tickTime - _lastSave) >= _time) then { if ((diag_tickTime - _lastSave) >= _time) then {
EPOCH_playerHitPoints = ((getAllHitPointsDamage player) param [2,[]]);
_customVars = []; _customVars = [];
{ {
_customVars pushBack (missionNamespace getVariable format["EPOCH_player%1",_x]); _customVars pushBack (missionNamespace getVariable format["EPOCH_player%1",_x]);

View File

@ -60,7 +60,6 @@ EPOCH_customVarsDefaults = [
["Toxicity",0,[100,0]], ["Toxicity",0,[100,0]],
["Stamina",100,["EPOCH_playerStaminaMax",0]], ["Stamina",100,["EPOCH_playerStaminaMax",0]],
["Crypto",0,[250000,0]], ["Crypto",0,[250000,0]],
["HitPoints",[0,0,0,0],[1,1,1,1]],
["BloodP",100,[190,0]], ["BloodP",100,[190,0]],
["SpawnArray",[],[]], ["SpawnArray",[],[]],
["Karma",0,[50000,-50000]], ["Karma",0,[50000,-50000]],
@ -142,4 +141,4 @@ if(_dynSimToggle)then
"Vehicle" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "vehicleDynSimDistance"); "Vehicle" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "vehicleDynSimDistance");
"EmptyVehicle" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "emptyVehicleDynSimDistance"); "EmptyVehicle" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "emptyVehicleDynSimDistance");
"Prop" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "propDynSimDistance"); "Prop" setDynamicSimulationDistance getNumber(_cfgDynamicSimulation >> "propDynSimDistance");
}; };

View File

@ -56,7 +56,7 @@ class CfgEpochClient
niteLight[] = {1,1.88,22}; //Set ambient lighting at night: {Brightness of light,Height of light}. Default (Low Ambient): {1.88,22} | Twilight: {7.2,88} | Distant: {12.8,142} niteLight[] = {1,1.88,22}; //Set ambient lighting at night: {Brightness of light,Height of light}. Default (Low Ambient): {1.88,22} | Twilight: {7.2,88} | Distant: {12.8,142}
ryanZombiesEnabled = "true"; ryanZombiesEnabled = "true";
antagonistSpawnIndex[] = {{"Epoch_Cloak_F",1},{"GreatWhite_F",2},{"Epoch_Sapper_F",2},{"Epoch_SapperG_F",1},{"Epoch_SapperB_F",1},{"I_UAV_01_F",2},{"PHANTOM",1},{"B_Heli_Transport_01_F",1},{"EPOCH_RyanZombie_1",12},{"I_Soldier_EPOCH",1}}; // {"type", limit} antagonistSpawnIndex[] = {{"Epoch_Cloak_F",1},{"GreatWhite_F",2},{"Epoch_Sapper_F",2},{"Epoch_SapperG_F",1},{"Epoch_SapperB_F",1},{"I_UAV_01_F",2},{"PHANTOM",1},{"B_Heli_Transport_01_F",1},{"EPOCH_RyanZombie_1",12},{"I_Soldier_EPOCH",1}}; // {"type", limit}
customVarsDefaults[] = {{"Temp",98.6,{106.7,95,102,105,96,95}},{"Hunger",1500,{5000,0,5001,5001,1250,0}},{"Thirst",750,{2500,0,2501,2501,625,0}},{"AliveTime",0,{-2,0}},{"Energy",0,{2500,0}},{"Wet",0,{100,0,35,55,-1,-1}},{"Soiled",0,{100,0,35,55,-1,-1}},{"Immunity",0,{100,0}},{"Toxicity",0,{100,0,35,55,-1,-1}},{"Stamina",100,{"EPOCH_playerStaminaMax",0}},{"Crypto",0,{250000,0}},{"HitPoints",{0,0,0,0},{1,0,0.5,1,-1,-1}},{"BloodP",100,{190,0,120,140,70,50}},{"SpawnArray",{},{}},{"Karma",0,{50000,-50000}},{"Alcohol",0,{100,0,35,55,-1,-1}},{"Radiation",0,{100,0,35,55,-1,-1}},{"Nuisance",0,{100,0}},{"MissionArray",{},{}}}; // EPOCH_player + varName, default value, {max,min,high-warn,high-critical,low-warn,low-critical} customVarsDefaults[] = {{"Temp",98.6,{106.7,95,102,105,96,95}},{"Hunger",1500,{5000,0,5001,5001,1250,0}},{"Thirst",750,{2500,0,2501,2501,625,0}},{"AliveTime",0,{-2,0}},{"Energy",0,{2500,0}},{"Wet",0,{100,0,35,55,-1,-1}},{"Soiled",0,{100,0,35,55,-1,-1}},{"Immunity",0,{100,0}},{"Toxicity",0,{100,0,35,55,-1,-1}},{"Stamina",100,{"EPOCH_playerStaminaMax",0}},{"Crypto",0,{250000,0}},{"BloodP",100,{190,0,120,140,70,50}},{"SpawnArray",{},{}},{"Karma",0,{50000,-50000}},{"Alcohol",0,{100,0,35,55,-1,-1}},{"Radiation",0,{100,0,35,55,-1,-1}},{"Nuisance",0,{100,0}},{"MissionArray",{},{}}}; // EPOCH_player + varName, default value, {max,min,high-warn,high-critical,low-warn,low-critical}
// add any stats and their starting number here for better community integration and neat stats tracking too! // add any stats and their starting number here for better community integration and neat stats tracking too!
defineCommunityStats[] = {{"Murders",0},{"Deaths",0},{"Suicides",0},{"Revives",0},{"TraderMissions",0},{"AIKills",0},{"AntagonistKills",0},{"ZombieKills",0}}; defineCommunityStats[] = {{"Murders",0},{"Deaths",0},{"Suicides",0},{"Revives",0},{"TraderMissions",0},{"AIKills",0},{"AntagonistKills",0},{"ZombieKills",0}};
hudConfigs[] = {{{"BloodP","","",{"getPlayerDamage",">=",0.7}},"topRight","x\addons\a3_epoch_code\Data\UI\bleeding_ca.paa",{"forceUpdate"}},{{"Oxygen","getPlayerOxygenRemaining","",{},{1,0,2,2,1,0.55}},"topRight","x\addons\a3_epoch_code\Data\UI\oxygen_ca.paa"},{"Hunger","topRight","x\addons\a3_epoch_code\Data\UI\hunger_ca.paa",{"forceBloodRise"}},{"Thirst","topRight","x\addons\a3_epoch_code\Data\UI\thirst_ca.paa",{"forceBloodRise"}},{"Temp","topRight",{"x\addons\a3_epoch_code\Data\UI\hot_ca.paa","x\addons\a3_epoch_code\Data\UI\cold_ca.paa"},{"forceFatigue"}},{"Toxicity","topRight","x\addons\a3_epoch_code\Data\UI\hazzard_ca.paa"},{"Alcohol","topRight","x\addons\a3_epoch_code\Data\UI\drunk_ca.paa"},{"Soiled","topRight","x\addons\a3_epoch_code\Data\UI\soiled_ca.paa"},{"Radiation","topRight","x\addons\a3_epoch_code\Data\UI\rads_ca.paa"},{{"HitPoints","getPlayerHitPointDamage","HitLegs"},"topRight","x\addons\a3_epoch_code\Data\UI\broken_ca.paa"}}; hudConfigs[] = {{{"BloodP","","",{"getPlayerDamage",">=",0.7}},"topRight","x\addons\a3_epoch_code\Data\UI\bleeding_ca.paa",{"forceUpdate"}},{{"Oxygen","getPlayerOxygenRemaining","",{},{1,0,2,2,1,0.55}},"topRight","x\addons\a3_epoch_code\Data\UI\oxygen_ca.paa"},{"Hunger","topRight","x\addons\a3_epoch_code\Data\UI\hunger_ca.paa",{"forceBloodRise"}},{"Thirst","topRight","x\addons\a3_epoch_code\Data\UI\thirst_ca.paa",{"forceBloodRise"}},{"Temp","topRight",{"x\addons\a3_epoch_code\Data\UI\hot_ca.paa","x\addons\a3_epoch_code\Data\UI\cold_ca.paa"},{"forceFatigue"}},{"Toxicity","topRight","x\addons\a3_epoch_code\Data\UI\hazzard_ca.paa"},{"Alcohol","topRight","x\addons\a3_epoch_code\Data\UI\drunk_ca.paa"},{"Soiled","topRight","x\addons\a3_epoch_code\Data\UI\soiled_ca.paa"},{"Radiation","topRight","x\addons\a3_epoch_code\Data\UI\rads_ca.paa"},{{"HitPoints","getPlayerHitPointDamage","HitLegs"},"topRight","x\addons\a3_epoch_code\Data\UI\broken_ca.paa"}};
@ -92,13 +92,13 @@ class CfgEpochClient
playerDisableRevenge = 0; playerDisableRevenge = 0;
playerRevengeMinAliveTime = 900; playerRevengeMinAliveTime = 900;
bankTransferTime[] = {0.0006,1.2,0.06}; bankTransferTime[] = {0.0006,1.2,0.06};
// Favorite Bar // Favorite Bar
Fav_enableFavoriteBar = "true"; // If disabled, players will not be able to use favorite bar Fav_enableFavoriteBar = "true"; // If disabled, players will not be able to use favorite bar
Fav_DropIfOverflow = "false"; // If enabled and inventory full, equipped weapon will be dropped on ground in favor for the new selected weapon, otherwise action will fail with message and weapon will not be equipped Fav_DropIfOverflow = "false"; // If enabled and inventory full, equipped weapon will be dropped on ground in favor for the new selected weapon, otherwise action will fail with message and weapon will not be equipped
Fav_FastWeaponSwitching = "false"; // If enabled, same slot weapons from favorites bar are equipped instantly, otherwise reload action is played (recommended for immersion) Fav_FastWeaponSwitching = "false"; // If enabled, same slot weapons from favorites bar are equipped instantly, otherwise reload action is played (recommended for immersion)
Fav_BannedItems[] = {"FAK"}; // Items that users are not allowed to pin Fav_BannedItems[] = {"FAK"}; // Items that users are not allowed to pin
// Advanced Vehicle Repair // Advanced Vehicle Repair
UseAdvancedVehicleRepair = "true"; // Switch On / Off Advanced Vehicle Repair (Does not effect SuppressedCraftingItems !) UseAdvancedVehicleRepair = "true"; // Switch On / Off Advanced Vehicle Repair (Does not effect SuppressedCraftingItems !)
DisallowSellOnDamage = "false"; // Prevent from selling Vehicles with one or more fully damaged wheel or engine DisallowSellOnDamage = "false"; // Prevent from selling Vehicles with one or more fully damaged wheel or engine
@ -122,7 +122,7 @@ class CfgEpochClient
{"HitWinch",0.33,0.91,"ItemCables","ItemCables"}, {"HitWinch",0.33,0.91,"ItemCables","ItemCables"},
{"HitAvionics",0.33,0.91,"CircuitParts","CircuitParts"} {"HitAvionics",0.33,0.91,"CircuitParts","CircuitParts"}
}; };
// include configs // include configs
#include "CfgEpochClient\Altis.hpp" #include "CfgEpochClient\Altis.hpp"
#include "CfgEpochClient\australia.hpp" #include "CfgEpochClient\australia.hpp"

View File

@ -13,7 +13,7 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_checkPlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_checkPlayer.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_apperance","_arr","_class","_dead","_deadPlayer","_hitpoints","_isMale","_medical","_playerUID","_response","_vars","_communityStatsArray"]; private ["_apperance","_arr","_class","_communityStatsArray","_dead","_deadPlayer","_defaultData","_instanceID","_isMale","_medical","_playerUID","_response","_return","_vars"];
//[[[end]]] //[[[end]]]
params [["_playerObj",objNull]]; params [["_playerObj",objNull]];
if (_playerObj isEqualType objNull) then { if (_playerObj isEqualType objNull) then {
@ -26,12 +26,19 @@ if (_playerObj isEqualType objNull) then {
_dead = false; _dead = false;
_isMale = true; _isMale = true;
_instanceID = call EPOCH_fn_InstanceID;
_class = "Epoch_Female_F";
_arr = []; _arr = [];
if ((_response select 0) == 1 && (_response select 1) isEqualType []) then { if ((_response select 0) == 1 && (_response select 1) isEqualType []) then {
_arr = (_response select 1); _arr = (_response select 1);
}; };
if (count _arr < 11) then { // empty default data format, if "Player" data format is changed update this array!
_defaultData = [[], [], [], [], [], [], [], [], [], [], "", true];
// If data does not validate against default or is too short, assume player is new or already dead.
if !(_arr isEqualTypeParams _defaultData) then {
_dead = true; _dead = true;
} else { } else {
_medical = _arr select 1; _medical = _arr select 1;
@ -40,23 +47,21 @@ if (_playerObj isEqualType objNull) then {
if (_class == "Epoch_Female_F") then { if (_class == "Epoch_Female_F") then {
_isMale = false; _isMale = false;
}; };
_vars = _arr select 4; _vars = _arr select 4;
_hitpoints = _vars select 11; _medical params ["","","","_damage",["_hitpoints",[0,0,0,0,0,0,0,0,0,0,0]] ];
_deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT; _deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT;
// check if player is already dead or was critically hit HitHead = 2 or HitBody = 7 and if blood pressure too high.
if (_deadPlayer || (_medical select 3 == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 3 == 1) || (_vars select 12 >= 180)) then { if (_deadPlayer || (_damage == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 7 == 1) || (_vars select 12 >= 180)) then {
_dead = true; _dead = true;
}; };
}; };
// check status of community stats to prevent load / save issues // check status of community stats to prevent load / save issues
_communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE; _communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
if((_communityStatsArray select 1) isEqualTo []) then{ if((_communityStatsArray select 1) isEqualTo []) then{
_return = ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [EPOCH_defaultStatVars]] call EPOCH_fnc_server_hiveSETEX; _return = ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [EPOCH_defaultStatVars]] call EPOCH_fnc_server_hiveSETEX;
}; };
/* true => New Char /* true => New Char
false => load old Char */ false => load old Char */
['_checkPlayer_PVC', _dead] remoteExec ['EPOCH_playerLoginInit',_playerObj]; ['_checkPlayer_PVC', _dead] remoteExec ['EPOCH_playerLoginInit',_playerObj];

View File

@ -1,19 +1,19 @@
/* /*
Author: Aaron Clark - EpochMod.com Author: Aaron Clark - EpochMod.com
Contributors: He-Man Contributors: He-Man
Description: Description:
Player Login Player Login
Licence: Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github: Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_CheckLocation","_allGroupMembers","_alreadyDead","_attachments","_backpack","_canBeRevived","_class","_currWeap","_deadPlayer","_defaultData","_dir","_equipped","_found","_goggles","_group","_headgear","_hitpoints","_instanceID","_itemsInContainers","_jammer","_jammers","_linkedItems","_location","_newLocation","_newPlyr","_normalMagazines","_playerData","_playerGroup","_playerGroupArray","_playerNetID","_playerUID","_reject","_serverSettingsConfig","_type","_uniform","_vars","_vest","_wMags","_wMagsArray","_weapon","_weaponsAndItems","_weaponsInContainers","_communityStatsArray","_communityStats"]; private ["_CheckLocation","_allGroupMembers","_alreadyDead","_assignedItems","_attachments","_backpack","_backpackItems","_canBeRevived","_class","_communityStats","_communityStatsArray","_currWeap","_deadPlayer","_defaultData","_dir","_equipped","_found","_goggles","_group","_handgunWeapon","_headgear","_instanceID","_jammer","_jammers","_linkedItems","_loadout","_location","_newLocation","_newPlyr","_playerData","_playerGroup","_playerGroupArray","_playerNetID","_playerUID","_primaryWeapon","_reject","_secondaryWeapon","_serverSettingsConfig","_type","_uniform","_uniformItems","_vars","_vest","_vestItems","_wMags","_wMagsArray","_weapon"];
//[[[end]]] //[[[end]]]
_reject = true; _reject = true;
@ -21,24 +21,24 @@ params [["_player",objNull,[objNull]],["_isMale",true]];
if (!isNull _player) then { if (!isNull _player) then {
// load server settings // load server settings
_serverSettingsConfig = configFile >> "CfgEpochServer"; _serverSettingsConfig = configFile >> "CfgEpochServer";
_instanceID = call EPOCH_fn_InstanceID; _instanceID = call EPOCH_fn_InstanceID;
_playerNetID = owner _player; _playerNetID = owner _player;
_playerUID = getPlayerUID _player; _playerUID = getPlayerUID _player;
if (_playerUID != "") then { if (_playerUID != "") then {
// Make Hive call // Make Hive call
_playerData = []; _playerData = [];
(["Player", _playerUID] call EPOCH_fnc_server_hiveGETRANGE) params [ (["Player", _playerUID] call EPOCH_fnc_server_hiveGETRANGE) params [
["_status", 0 ], ["_status", 0 ],
["_playerDataTmp", [] ] ["_playerDataTmp", [] ]
]; ];
if (_status == 1 && _playerDataTmp isEqualType []) then { if (_status == 1 && _playerDataTmp isEqualType []) then {
_playerData = _playerDataTmp; _playerData = _playerDataTmp;
}; };
// Apperance defaults // Apperance defaults
_uniform = [_serverSettingsConfig, "defaultUniformFemale", "U_Test_uniform"] call EPOCH_fnc_returnConfigEntry; _uniform = [_serverSettingsConfig, "defaultUniformFemale", "U_Test_uniform"] call EPOCH_fnc_returnConfigEntry;
@ -54,87 +54,105 @@ if (!isNull _player) then {
_backpack = [_serverSettingsConfig, "defaultBackpack", ""] call EPOCH_fnc_returnConfigEntry; _backpack = [_serverSettingsConfig, "defaultBackpack", ""] call EPOCH_fnc_returnConfigEntry;
// Inventory defaults // Inventory defaults
_linkedItems = [_serverSettingsConfig, "linkedItems", ["ItemMap","EpochRadio0"]] call EPOCH_fnc_returnConfigEntry; _primaryWeapon = [_serverSettingsConfig, "defaultprimaryWeapon", []] call EPOCH_fnc_returnConfigEntry; // ["arifle_MX_pointer_F","","acc_pointer_IR","",["30Rnd_65x39_caseless_mag",29],[],""];
_itemsInContainers = [_serverSettingsConfig, "itemsInContainers", []] call EPOCH_fnc_returnConfigEntry; _secondaryWeapon = [_serverSettingsConfig, "defaultsecondaryWeapon", []] call EPOCH_fnc_returnConfigEntry; // ["launch_NLAW_F","","","",["NLAW_F",1],[],""];
_weaponsInContainers = [_serverSettingsConfig, "weaponsInContainers", []] call EPOCH_fnc_returnConfigEntry; _handgunWeapon = [_serverSettingsConfig, "defaulthandgunWeapon", []] call EPOCH_fnc_returnConfigEntry; // ["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""];
_normalMagazines = [_serverSettingsConfig, "normalMagazines", []] call EPOCH_fnc_returnConfigEntry; _uniformItems = [_serverSettingsConfig, "defaultuniformItems", []] call EPOCH_fnc_returnConfigEntry; // [["FirstAidKit",1],["30Rnd_65x39_caseless_mag",2,30],["Chemlight_green",1,1]];
_weaponsAndItems = [_serverSettingsConfig, "weaponsAndItems", ["", []] ] call EPOCH_fnc_returnConfigEntry; _vestItems = [_serverSettingsConfig, "defaultvestItems", []] call EPOCH_fnc_returnConfigEntry; // [["30Rnd_65x39_caseless_mag",3,30],["16Rnd_9x21_Mag",2,16],["SmokeShell",1,1],["SmokeShellGreen",1,1],["SmokeShellBlue",1,1],["SmokeShellOrange",1,1],["Chemlight_green",1,1]];
_backpackItems = [_serverSettingsConfig, "defaultbackpackItems", []] call EPOCH_fnc_returnConfigEntry; // [["Medikit",1],["FirstAidKit",10],[["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],1]];
_assignedItems = [_serverSettingsConfig, "defaultassignedItems", ["","","","",[],[],""]] call EPOCH_fnc_returnConfigEntry; // ["Rangefinder","","","",[],[],""]
_linkedItems = [_serverSettingsConfig, "defaultlinkedItems", ["ItemMap","","EpochRadio0","","",""]] call EPOCH_fnc_returnConfigEntry; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
// default data _loadout = [
_defaultData = [[0, [], _instanceID], [0, 0, 1, 0, []], [_goggles, _headgear, _vest, _backpack, _uniform, _class], [], call EPOCH_defaultVars_SEPXVar, _weaponsAndItems, _linkedItems, _normalMagazines, _itemsInContainers, _weaponsInContainers, "", true]; _primaryWeapon,
_secondaryWeapon,
_handgunWeapon,
[_uniform,_uniformItems],
[_vest,_vestItems],
[_backpack,_backpackItems],
_headgear,
_goggles,
_assignedItems,
_linkedItems
];
// todo make dynamic // default data, if "Player" data format is changed update this array!
if (count _playerData < 11) then { // invaild format attempt to override _defaultData = [[0, [], _instanceID, 1.0], [0, 0, 1, 0, [0,0,0,0,0,0,0,0,0,0,0]], ["", "", "", "", "", _class], [], call EPOCH_defaultVars_SEPXVar, _loadout, [], [], [], [], "", true];
// If data does not validate against default or is too short, override with default data.
if !(_playerData isEqualTypeParams _defaultData) then {
diag_log format["DEBUG: Invaild player data %1, defaults used instead.", _playerData];
_playerData = _defaultData; _playerData = _defaultData;
}; };
_playerData params ["_worldspace","_medical","","_server_vars","_vars","","","","","","_playerGroup","_canBeRevived"]; _playerData params ["_worldspace","_medical","","_server_vars","_vars","","","","","","_playerGroup","_canBeRevived"];
// Load world space and previous instance id // Load world space and previous instance id
_worldspace params ["_dir","_location","_prevInstance"]; _worldspace params ["_dir","_location","_prevInstance",["_schemaVersion",0.5]];
if (count _location == 2) then{ if (count _location == 2) then{
_location = (_location select 0) vectorAdd (_location select 1); _location = (_location select 0) vectorAdd (_location select 1);
}; };
// Get player group // Get player group
_playerGroupArray = []; _playerGroupArray = [];
// check players group // check players group
if (_playerGroup != "") then { if (_playerGroup != "") then {
_found = false; _found = false;
(["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE) params [ (["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE) params [
["_status", 0 ], ["_status", 0 ],
["_playerGroupArrayTmp", [] ] ["_playerGroupArrayTmp", [] ]
]; ];
if (_status == 1 && !(_playerGroupArrayTmp isEqualTo[])) then { if (_status == 1 && !(_playerGroupArrayTmp isEqualTo[])) then {
_playerGroupArrayTmp params ["","","","_modArray","_memberArray"]; _playerGroupArrayTmp params ["","","","_modArray","_memberArray"];
_found = _playerGroup == _playerUID; _found = _playerGroup == _playerUID;
if (!_found) then { if (!_found) then {
_allGroupMembers = (_modArray + _memberArray) apply {_x select 0}; _allGroupMembers = (_modArray + _memberArray) apply {_x select 0};
_found = _playerUID in _allGroupMembers; _found = _playerUID in _allGroupMembers;
}; };
if (_found) then { if (_found) then {
_playerGroupArray = _playerGroupArrayTmp; _playerGroupArray = _playerGroupArrayTmp;
}; };
}; };
if (!_found) then { if (!_found) then {
_playerGroup = ""; _playerGroup = "";
}; };
// diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup]; // diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup];
}; };
_hitpoints = _vars select 11; _medical params ["_bleedingRemaining","_fatigue","_oxygenRemaining","_damage",["_hitpoints",[0,0,0,0,0,0,0,0,0,0,0]] ];
_deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT; _deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT;
_alreadyDead = (_deadPlayer || (_medical select 3 == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 3 == 1) || (_vars select 12 >= 180));
// check if player is already dead or was critically hit HitHead = 2 or HitBody = 7 and if blood pressure too high.
_alreadyDead = (_deadPlayer || (_damage == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 7 == 1) || (_vars select 12 >= 180));
if (_alreadyDead || _prevInstance != _instanceID || (count _location) < 3 || !(_location isEqualType [])) then { if (_alreadyDead || _prevInstance != _instanceID || (count _location) < 3 || !(_location isEqualType [])) then {
_dir = random 360; _dir = random 360;
// try to find respawn point by position // try to find respawn point by position
_newLocation = _server_vars param [0,[]]; // 0 = RESPAWN POS _newLocation = _server_vars param [0,[]]; // 0 = RESPAWN POS
// normal respawn location // normal respawn location
_location = getMarkerPos "respawn_west"; _location = getMarkerPos "respawn_west";
_location set[2, 0]; _location set[2, 0];
if (_newLocation isEqualType [] && {(count _newLocation) == 3}) then { if (_newLocation isEqualType [] && {(count _newLocation) == 3}) then {
_CheckLocation = _newLocation; _CheckLocation = _newLocation;
if (surfaceiswater _newLocation) then { if (surfaceiswater _newLocation) then {
_CheckLocation = ATLToASL _newLocation; _CheckLocation = ATLToASL _newLocation;
}; };
_jammers = nearestObjects[_CheckLocation, ["PlotPole_EPOCH"], 6]; _jammers = nearestObjects[_CheckLocation, ["PlotPole_EPOCH"], 6];
if !(_jammers isEqualTo[]) then { if !(_jammers isEqualTo[]) then {
// get nearby object // get nearby object
_jammer = _jammers param [0,objNull]; _jammer = _jammers param [0,objNull];
// check if object is not null and is alive. // check if object is not null and is alive.
if (!isNull _jammer && {alive _jammer}) then { if (!isNull _jammer && {alive _jammer}) then {
// check if player is still a member of object group. // check if player is still a member of object group.
if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [_playerUID, _playerGroup]) then { if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [_playerUID, _playerGroup]) then {
// Override location with that of object // Override location with that of object
_location = _newLocation; _location = _newLocation;
}; };
}; };
}; };
}; };
if (_alreadyDead) then { if (_alreadyDead) then {
_vars = call EPOCH_defaultVars_SEPXVar; _vars = call EPOCH_defaultVars_SEPXVar;
_canBeRevived = true; _canBeRevived = true;
@ -160,6 +178,9 @@ if (!isNull _player) then {
_newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"]; _newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"];
if !(isNull _newPlyr) then { if !(isNull _newPlyr) then {
// disable damage server side
_newPlyr allowDamage false;
// add to cleanup
addToRemainsCollector[_newPlyr]; addToRemainsCollector[_newPlyr];
{ {
_newPlyr disableAI _x; _newPlyr disableAI _x;
@ -170,127 +191,137 @@ if (!isNull _player) then {
if (!_alreadyDead) then { if (!_alreadyDead) then {
// Medical // Medical
_medical params ["_bleedingRemaining","_fatigue","_oxygenRemaining","_damage"];
_newPlyr setBleedingRemaining _bleedingRemaining; _newPlyr setBleedingRemaining _bleedingRemaining;
// _newPlyr setFatigue _fatigue; // _newPlyr setFatigue _fatigue;
_newPlyr setOxygenRemaining _oxygenRemaining; _newPlyr setOxygenRemaining _oxygenRemaining;
_newPlyr setDamage _damage; _newPlyr setDamage _damage;
} else { } else {
// player dead use default Data for appearance and loadout data // player dead use default Data for appearance and loadout data
_playerData = _defaultData; _playerData = _defaultData;
}; };
// Apperance + Weapons // set player loadout
_playerData params ["","","_apperance","","","_weaponsAndItems","_linkedItems","_normalMagazines","_itemsInContainers","_weaponsInContainers"]; if (_schemaVersion >= 1.0) then {
// load Apperance _playerData params ["","","","","","_loadout"];
_apperance params ["_goggles","_headgear","_vest","_backpack","_uniform"]; _newPlyr setUnitLoadout [_loadout, false];
diag_log format["DEBUG: loaded player %1 with new schema Version %2", _newPlyr, _schemaVersion];
// Load Apperance START } else {
if (_uniform != "") then { // Legacy code start
_newPlyr addUniform _uniform; // Apperance + Weapons
}; _playerData params ["","","_apperance","","","_weaponsAndItems","_linkedItems","_normalMagazines","_itemsInContainers","_weaponsInContainers"];
if (_backpack != "") then { // load Apperance
_newPlyr addBackpack _backpack; _apperance params ["_goggles","_headgear","_vest","_backpack","_uniform"];
};
if (_goggles != "") then {
_newPlyr addGoggles _goggles;
};
if (_headgear != "") then {
_newPlyr addHeadgear _headgear;
};
if (_vest != "") then {
_newPlyr addVest _vest;
};
// Load Apperance END
_currWeap = ""; // old data format for 0.5 and prior.
// Load inventory + defaults START // Load Apperance START
if (count _weaponsAndItems >= 3) then { if (_uniform != "") then {
_weaponsAndItems params ["_currWeapTmp","_weaponsAndItemsArray","_equipped"]; _newPlyr addUniform _uniform;
_currWeap = _currWeapTmp; };
{ if (_backpack != "") then {
_weapon = _x deleteAt 0; _newPlyr addBackpack _backpack;
_type = getNumber(configfile >> "cfgweapons" >> _weapon >> "type"); };
_attachments = []; if (_goggles != "") then {
_wMags = false; _newPlyr addGoggles _goggles;
_wMagsArray = []; };
// suppressor, laser, optics, magazines(array), bipods if (_headgear != "") then {
{ _newPlyr addHeadgear _headgear;
// magazines };
if (_x isEqualType []) then{ if (_vest != "") then {
_wMags = true; _newPlyr addVest _vest;
_wMagsArray pushback _x; };
} else { // Load Apperance END
// attachments _currWeap = "";
if (_x != "") then{ // Load inventory + defaults START
_attachments pushBack _x; if (count _weaponsAndItems >= 3) then {
}; _weaponsAndItems params ["_currWeapTmp","_weaponsAndItemsArray","_equipped"];
}; _currWeap = _currWeapTmp;
} forEach _x; {
if (_wMags) then { _weapon = _x deleteAt 0;
{ _type = getNumber(configfile >> "cfgweapons" >> _weapon >> "type");
_newPlyr addMagazine _x; _attachments = [];
} foreach _wMagsArray; _wMags = false;
}; _wMagsArray = [];
// add weapon if equiped // suppressor, laser, optics, magazines(array), bipods
if (_weapon in _equipped) then { {
_equipped = _equipped - [_weapon]; // magazines
if (_weapon != "") then { if (_x isEqualType []) then{
_newPlyr addWeapon _weapon; _wMags = true;
}; _wMagsArray pushback _x;
switch (_type) do { } else {
case 1: { // primary // attachments
removeAllPrimaryWeaponItems _newPlyr; if (_x != "") then{
{ _newPlyr addPrimaryWeaponItem _x } forEach _attachments; _attachments pushBack _x;
}; };
case 2: { // handgun };
removeAllHandgunItems _newPlyr; } forEach _x;
{ _newPlyr addHandgunItem _x } forEach _attachments; if (_wMags) then {
}; {
case 4: { // secondary _newPlyr addMagazine _x;
// removeAllSecondaryWeaponItems player; does not exist ? } foreach _wMagsArray;
{ };
_newPlyr removeSecondaryWeaponItem _x; // add weapon if equiped
} forEach (secondaryWeaponItems _newPlyr); if (_weapon in _equipped) then {
{ _newPlyr addSecondaryWeaponItem _x } forEach _attachments; _equipped = _equipped - [_weapon];
}; if (_weapon != "") then {
}; _newPlyr addWeapon _weapon;
}else{ };
{ switch (_type) do {
_newPlyr addItem _x; case 1: { // primary
} forEach _attachments; removeAllPrimaryWeaponItems _newPlyr;
}; { _newPlyr addPrimaryWeaponItem _x } forEach _attachments;
} forEach _weaponsAndItemsArray; };
}; case 2: { // handgun
// Linked items removeAllHandgunItems _newPlyr;
{ { _newPlyr addHandgunItem _x } forEach _attachments;
if (_x in["Binocular", "Rangefinder","Laserdesignator","Laserdesignator_02","Laserdesignator_03","Laserdesignator_01_khk_F","Laserdesignator_02_ghex_F"]) then { };
_newPlyr addWeapon _x; case 4: { // secondary
} else { // removeAllSecondaryWeaponItems player; does not exist ?
_newPlyr linkItem _x; {
_newPlyr removeSecondaryWeaponItem _x;
} forEach (secondaryWeaponItems _newPlyr);
{ _newPlyr addSecondaryWeaponItem _x } forEach _attachments;
};
};
}else{
{
_newPlyr addItem _x;
} forEach _attachments;
};
} forEach _weaponsAndItemsArray;
}; };
} forEach _linkedItems;
// add items to containers // Linked items
[_newPlyr, _itemsInContainers] call EPOCH_fnc_addItemToX; {
if (_x in["Binocular", "Rangefinder","Laserdesignator","Laserdesignator_02","Laserdesignator_03","Laserdesignator_01_khk_F","Laserdesignator_02_ghex_F"]) then {
_newPlyr addWeapon _x;
} else {
_newPlyr linkItem _x;
};
} forEach _linkedItems;
// add weapons to containers // add items to containers
[_newPlyr, _weaponsInContainers] call EPOCH_fnc_addItemToX; [_newPlyr, _itemsInContainers] call EPOCH_fnc_addItemToX;
// Add magazines // add weapons to containers
{_newPlyr addMagazine _x} forEach _normalMagazines; [_newPlyr, _weaponsInContainers] call EPOCH_fnc_addItemToX;
// Load inventory + defaults END
// Add magazines
{_newPlyr addMagazine _x} forEach _normalMagazines;
// Load inventory + defaults END
// Legacy code stop
};
// Final Push // Final Push
if (isNull _player) then { if (isNull _player) then {
deleteVehicle _newPlyr; deleteVehicle _newPlyr;
diag_log "Epoch: DEBUG: _player object was null reject connection"; diag_log "Epoch: DEBUG: _player object was null reject connection";
} else { } else {
_reject = false; _reject = false;
if (_playerGroup != "") then { if (_playerGroup != "") then {
_newPlyr setVariable["GROUP", _playerGroup]; _newPlyr setVariable["GROUP", _playerGroup];
}; };
_newPlyr setVariable["PUID", _playerUID]; _newPlyr setVariable["PUID", _playerUID];
@ -309,21 +340,21 @@ if (!isNull _player) then {
// load community stats // load community stats
_communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE; _communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
_communityStats = ((_communityStatsArray select 1) select 0); _communityStats = ((_communityStatsArray select 1) select 0);
_newPlyr setVariable["COMMUNITY_STATS", _communityStats]; _newPlyr setVariable["COMMUNITY_STATS", _communityStats];
[_playerNetID, _playerUID, [_newPlyr, _vars, _currWeap, loadAbs _newPlyr, _playerGroup, _canBeRevived, _newPlyr call EPOCH_server_setPToken,_playerGroupArray, _communityStats]] call EPOCH_server_pushPlayer; // re enable damage server side
//diag_log format["DEBUG (Load Player) Sent Group: %1 %2", _playerGroup, _playerGroupArray]; _newPlyr allowDamage true;
// Flag new body as ready for use.
_newPlyr setVariable["SETUP", true, true]; _newPlyr setVariable["SETUP", true, true];
// revive // Send message to player so they can take over the new body.
_newPlyr setVariable ['#rev_enabled', true, true]; [_playerNetID, _playerUID, [_newPlyr, _vars, _currWeap, loadAbs _newPlyr, _playerGroup, _canBeRevived, _newPlyr call EPOCH_server_setPToken,_playerGroupArray, _communityStats, _hitpoints]] call EPOCH_server_pushPlayer;
// [] remoteExec ["bis_fnc_reviveInit",_player]; // revive test
_newPlyr setVariable ['#rev_enabled', true, true];
// [] remoteExec ["bis_fnc_reviveInit",_player];
// This is a test to see setUnitLoadout can force propagation of unit loadout.
_newPlyr setUnitLoadout (getUnitLoadout _newPlyr); // if this works, possibly replace all inventory code with with get|setUnitLoadout
// new Dynamicsimulation // new Dynamicsimulation
if(["CfgDynamicSimulation", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then if(["CfgDynamicSimulation", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then
{ {

View File

@ -12,8 +12,10 @@
Github: Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf
*/ */
private["_return", "_return2", "_pos", "_medical", "_playerUID", "_weapons", "_itemsplayer", "_weaponsplayer", "_appearance", "_dmg", "_allowSave", "_cIndex", "_Svars", "_current_crypto", "_group", "_revive", "_vehiclePlyr","_server_vars","_stats"]; //[[[cog import generate_private_arrays ]]]
params [["_player",objNull], ["_vars",[]]]; private ["_Svars","_allowSave","_appearance","_cIndex","_dmg","_group","_hitpoints","_itemsplayer","_loadout","_medical","_playerUID","_pos","_return","_return2","_revive","_schemaVersion","_server_vars","_stats","_vehiclePlyr","_weapons","_weaponsplayer"];
//[[[end]]]
params [["_player",objNull], ["_vars",[]] ];
if (isNull _player) exitWith { if (isNull _player) exitWith {
diag_log "DEBUG SAVE ABORT null player object"; diag_log "DEBUG SAVE ABORT null player object";
@ -79,19 +81,31 @@ if (_allowSave) then{
}; };
_dmg = damage _player; _dmg = damage _player;
_medical = [getBleedingRemaining _player, 0, getOxygenRemaining _player, _dmg]; _hitpoints = (getAllHitPointsDamage _player) param [2,[]];
_medical = [getBleedingRemaining _player, 0, getOxygenRemaining _player, _dmg, _hitpoints];
// appearance now handled with getUnitLoadout, typeof is still need to determine players class.
_appearance = ["", "", "", "", "", typeOf _player];
/* Old unused method
_appearance = [goggles _player, headgear _player, vest _player, backpack _player, uniform _player, typeOf _player]; _appearance = [goggles _player, headgear _player, vest _player, backpack _player, uniform _player, typeOf _player];
_itemsplayer = [getItemCargo(uniformContainer _player), getItemCargo(vestContainer _player), getItemCargo(backpackContainer _player)]; _itemsplayer = [getItemCargo(uniformContainer _player), getItemCargo(vestContainer _player), getItemCargo(backpackContainer _player)];
_weaponsplayer = [getWeaponCargo(uniformContainer _player), getWeaponCargo(vestContainer _player), getWeaponCargo(backpackContainer _player)]; _weaponsplayer = [getWeaponCargo(uniformContainer _player), getWeaponCargo(vestContainer _player), getWeaponCargo(backpackContainer _player)];
_weapons = [currentWeapon _player, weaponsItems _player, [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player]]; _weapons = [currentWeapon _player, weaponsItems _player, [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player]];
*/
// new save format
_loadout = getUnitLoadout _player;
// change this if needed
_schemaVersion = 1.0;
// save player // save player
_return = ["Player", _playerUID, EPOCH_expiresPlayer, [[getDir _player, _pos, (call EPOCH_fn_InstanceID)], _medical, _appearance, _server_vars, _vars, _weapons, assignedItems _player, magazinesAmmo _player, _itemsplayer, _weaponsplayer, _group, _revive]] call EPOCH_fnc_server_hiveSETEX; _return = ["Player", _playerUID, EPOCH_expiresPlayer, [[getDir _player, _pos, (call EPOCH_fn_InstanceID), _schemaVersion], _medical, _appearance, _server_vars, _vars, _loadout, [], [], [], [], _group, _revive]] call EPOCH_fnc_server_hiveSETEX;
// save community stats // save community stats
_stats = _player getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars]; _stats = _player getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars];
_return2 = ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [_stats]] call EPOCH_fnc_server_hiveSETEX; _return2 = ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [_stats]] call EPOCH_fnc_server_hiveSETEX;
// kill player if blood pressure >= 180 // kill player if blood pressure >= 180
if (_vars select 12 >= 180) then { if (_vars select 12 >= 180) then {
_player setDamage 1; _player setDamage 1;