Fix combat logging

In the initialize section of the fsm r_player_unconscious and
r_player_timeout return their default values (false and 0). Also, the
Vanilla server-side combat check doesn't appear to work, or it doesn't
work with the antihack disabled (I haven't tested with it enabled).

New variable inCombat is set more quickly than the combatTimeout
variable
This commit is contained in:
icomrade
2016-07-26 20:51:10 -04:00
parent a72498671d
commit e446603ea2
9 changed files with 45 additions and 26 deletions

View File

@@ -225,6 +225,7 @@ if (_hit in USEC_MinorWounds) then {
if (_unit == player) then { if (_unit == player) then {
//Set player in combat //Set player in combat
_unit setVariable["startcombattimer", 1]; _unit setVariable["startcombattimer", 1];
_unit setVariable["inCombat", 1, true];
}; };
//Shake the cam, frighten them! //Shake the cam, frighten them!

View File

@@ -65,6 +65,7 @@ player setVariable ["USEC_isCardiac",false,true];
player setVariable ["medForceUpdate",true,true]; player setVariable ["medForceUpdate",true,true];
player setVariable ["bloodTaken", false, true]; player setVariable ["bloodTaken", false, true];
player setVariable ["startcombattimer", 0]; //remove combat timer on death player setVariable ["startcombattimer", 0]; //remove combat timer on death
player setVariable ["inCombat", 0, true];
r_player_unconscious = false; r_player_unconscious = false;
r_player_cardiac = false; r_player_cardiac = false;
_model = typeOf player; _model = typeOf player;

View File

@@ -1,4 +1,4 @@
private ["_charID","_newmodel","_old","_updates","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_combattimeout","_banditKills","_fractures","_wpnType","_ismelee"]; private ["_charID","_newmodel","_old","_updates","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_combattimeout","_inCombat","_banditKills","_fractures","_wpnType","_ismelee"];
//_playerUID = _this select 0; //_playerUID = _this select 0;
_charID = _this select 1; _charID = _this select 1;
_model = _this select 2; _model = _this select 2;
@@ -24,7 +24,7 @@ _humanKills = player getVariable ["humanKills",0];
_banditKills = player getVariable ["banditKills",0]; _banditKills = player getVariable ["banditKills",0];
_achievements = player getVariable ["Achievements",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]; _achievements = player getVariable ["Achievements",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
_combattimeout = player getVariable["combattimeout",0]; _combattimeout = player getVariable["combattimeout",0];
_inCombat = player getVariable["inCombat",0];
_ConfirmedHumanKills = player getVariable ["ConfirmedHumanKills",0]; _ConfirmedHumanKills = player getVariable ["ConfirmedHumanKills",0];
_ConfirmedBanditKills = player getVariable ["ConfirmedBanditKills",0]; _ConfirmedBanditKills = player getVariable ["ConfirmedBanditKills",0];
_friendlies = player getVariable ["friendlies",[]]; _friendlies = player getVariable ["friendlies",[]];
@@ -83,6 +83,7 @@ player setVariable ["characterID",_charID,true];
player setVariable ["worldspace",_worldspace]; player setVariable ["worldspace",_worldspace];
player setVariable ["Achievements",_achievements]; player setVariable ["Achievements",_achievements];
player setVariable ["combattimeout",_combattimeout,false]; player setVariable ["combattimeout",_combattimeout,false];
player setVariable ["inCombat", _inCombat, true];
player setVariable ["ConfirmedHumanKills",_ConfirmedHumanKills,true]; player setVariable ["ConfirmedHumanKills",_ConfirmedHumanKills,true];
player setVariable ["ConfirmedBanditKills",_ConfirmedBanditKills,true]; player setVariable ["ConfirmedBanditKills",_ConfirmedBanditKills,true];

View File

@@ -34,6 +34,7 @@ while {(alive _projectile) && !(isNull _projectile) && (_callCount < 85)} do {
_isInCombat = _nearVehicle getVariable["startcombattimer",0]; _isInCombat = _nearVehicle getVariable["startcombattimer",0];
if ((alive _nearVehicle) and _isInCombat == 0) then { if ((alive _nearVehicle) and _isInCombat == 0) then {
_nearVehicle setVariable["startcombattimer", 1]; _nearVehicle setVariable["startcombattimer", 1];
_nearVehicle setVariable["inCombat", 1, true];
diag_log("Now in Combat (Player): " + name _unit); diag_log("Now in Combat (Player): " + name _unit);
}; };
}; };
@@ -43,6 +44,7 @@ while {(alive _projectile) && !(isNull _projectile) && (_callCount < 85)} do {
_isInCombat = _x getVariable["startcombattimer",0]; _isInCombat = _x getVariable["startcombattimer",0];
if (isPlayer _x and _isInCombat == 0 and alive _x) then { if (isPlayer _x and _isInCombat == 0 and alive _x) then {
_x setVariable["startcombattimer", 1]; _x setVariable["startcombattimer", 1];
_x setVariable["inCombat", 1, true];
diag_log("Now in Combat (Crew): " + name _x); diag_log("Now in Combat (Crew): " + name _x);
}; };
} forEach (crew _nearVehicle); } forEach (crew _nearVehicle);

View File

@@ -22,8 +22,10 @@ private ["_handled"];
// Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4 // Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4
//diag_log ("DEBUG: AMMO TYPE: " +str(_ammo)); //diag_log ("DEBUG: AMMO TYPE: " +str(_ammo));
_firer setVariable["startcombattimer", 1]; _firer setVariable["startcombattimer", 1];
_firer setVariable["inCombat", 1, true];
if (_distance <= 8) then { if (_distance <= 8) then {
_unit setVariable["startcombattimer", 1]; _unit setVariable["startcombattimer", 1];
_unit setVariable["inCombat", 1, true];
}; };
if (_inVehicle) exitWith {}; if (_inVehicle) exitWith {};

View File

@@ -32,7 +32,7 @@ item27[] = {"ERROR__Bad_Versi",2,250,325.000000,850.000000,425.000000,900.000000
item28[] = {"Display_Ready",4,218,-175.000000,1200.000000,-75.000000,1250.000000,0.000000,"Display" \n "Ready"}; item28[] = {"Display_Ready",4,218,-175.000000,1200.000000,-75.000000,1250.000000,0.000000,"Display" \n "Ready"};
item29[] = {"Preload_Display",2,250,-75.000000,1250.000000,25.000000,1300.000000,0.000000,"Preload" \n "Display"}; item29[] = {"Preload_Display",2,250,-75.000000,1250.000000,25.000000,1300.000000,0.000000,"Preload" \n "Display"};
item30[] = {"Preload_Done",4,218,-175.000000,1300.000000,-75.000000,1350.000000,0.000000,"Preload" \n "Done"}; item30[] = {"Preload_Done",4,218,-175.000000,1300.000000,-75.000000,1350.000000,0.000000,"Preload" \n "Done"};
item31[] = {"Initialize",2,250,-75.000000,1350.000000,25.000000,1400.000000,0.000000,"Initialize"}; item31[] = {"Initialize",2,4346,-75.000000,1350.000000,25.000000,1400.000000,0.000000,"Initialize"};
item32[] = {"Finish",1,250,-75.000000,1625.000000,25.000000,1675.000000,0.000000,"Finish"}; item32[] = {"Finish",1,250,-75.000000,1625.000000,25.000000,1675.000000,0.000000,"Finish"};
item33[] = {"no_Time_Date",4,218,125.000000,950.000000,225.000000,1000.000000,0.000000,"no Time/Date"}; item33[] = {"no_Time_Date",4,218,125.000000,950.000000,225.000000,1000.000000,0.000000,"no Time/Date"};
item34[] = {"sleep",4,218,525.000000,150.000000,625.000000,200.000000,0.000000,"sleep"}; item34[] = {"sleep",4,218,525.000000,150.000000,625.000000,200.000000,0.000000,"sleep"};
@@ -108,7 +108,7 @@ item103[] = {"",7,210,-279.000000,371.000000,-271.000000,379.000000,0.000000,""}
item104[] = {"retry_Login",4,218,-250.000000,350.000000,-150.000000,400.000000,0.000000,"retry Login"}; item104[] = {"retry_Login",4,218,-250.000000,350.000000,-150.000000,400.000000,0.000000,"retry Login"};
item105[] = {"",7,210,-379.000031,471.000000,-371.000000,479.000000,0.000000,""}; item105[] = {"",7,210,-379.000031,471.000000,-371.000000,479.000000,0.000000,""};
item106[] = {"Finish_1",2,250,-75.000000,1500.000000,25.000000,1550.000000,0.000000,"Finish"}; item106[] = {"Finish_1",2,250,-75.000000,1500.000000,25.000000,1550.000000,0.000000,"Finish"};
item107[] = {"dayz_preloadFini",4,4314,50.000000,1550.000000,150.000000,1600.000000,0.000000,"dayz_preloadFinished"}; item107[] = {"dayz_preloadFini",4,218,50.000000,1550.000000,150.000000,1600.000000,0.000000,"dayz_preloadFinished"};
item108[] = {"New_INFECTED_Character",4,218,-271.606934,571.673645,-171.606934,621.673645,5.000000,"New" \n "INFECTED Character" \n "258"}; item108[] = {"New_INFECTED_Character",4,218,-271.606934,571.673645,-171.606934,621.673645,5.000000,"New" \n "INFECTED Character" \n "258"};
item109[] = {"Player_Zombie__S",2,250,-611.348511,641.870300,-521.348145,691.870300,0.000000,"Player Zombie" \n " Selection"}; item109[] = {"Player_Zombie__S",2,250,-611.348511,641.870300,-521.348145,691.870300,0.000000,"Player Zombie" \n " Selection"};
item110[] = {"",7,210,-955.744385,664.969482,-947.744385,672.969482,0.000000,""}; item110[] = {"",7,210,-955.744385,664.969482,-947.744385,672.969482,0.000000,""};
@@ -243,8 +243,8 @@ link127[] = {107,32};
link128[] = {108,109}; link128[] = {108,109};
link129[] = {109,110}; link129[] = {109,110};
link130[] = {110,64}; link130[] = {110,64};
globals[] = {0.000000,0,0,0,0,640,480,3,262,6316128,1,-633.732300,669.877075,2180.669678,358.546051,890,1244,1}; globals[] = {0.000000,0,0,0,0,640,480,3,262,6316128,1,-420.384094,456.528290,1882.460693,656.753967,890,1244,1};
window[] = {2,-1,-1,-1,-1,786,260,1280,260,3,908}; window[] = {2,-1,-1,-32000,-32000,1270,1052,2072,744,3,908};
*//*%FSM</HEAD>*/ *//*%FSM</HEAD>*/
class FSM class FSM
{ {
@@ -732,7 +732,7 @@ class FSM
"_worldspace = PVCDZ_plr_Login2 select 0;" \n "_worldspace = PVCDZ_plr_Login2 select 0;" \n
"_state = PVCDZ_plr_Login2 select 1;" \n "_state = PVCDZ_plr_Login2 select 1;" \n
"" \n "" \n
"player setVariable [""Achievements"",[],false];" \n "player setVariable [""Achievements"",[],false];" \n
"" \n "" \n
"_setDir = _worldspace select 0;" \n "_setDir = _worldspace select 0;" \n
"_setPos = _worldspace select 1;" \n "_setPos = _worldspace select 1;" \n
@@ -864,6 +864,7 @@ class FSM
"r_player_cardiac = player getVariable[""USEC_isCardiac"",false];" \n "r_player_cardiac = player getVariable[""USEC_isCardiac"",false];" \n
"r_player_lowblood = player getVariable[""USEC_lowBlood"",false];" \n "r_player_lowblood = player getVariable[""USEC_lowBlood"",false];" \n
"r_player_blood = player getVariable[""USEC_BloodQty"",r_player_bloodTotal];" \n "r_player_blood = player getVariable[""USEC_BloodQty"",r_player_bloodTotal];" \n
"r_player_timeout = player getVariable[""unconsciousTime"",0];" \n
"" \n "" \n
"//Hunger/Thirst" \n "//Hunger/Thirst" \n
"_messing = player getVariable[""messing"",[0,0,0]];" \n "_messing = player getVariable[""messing"",[0,0,0]];" \n
@@ -1136,13 +1137,12 @@ class FSM
"//Medical" \n "//Medical" \n
"dayz_medicalH = [] execVM ""\z\addons\dayz_code\medical\init_medical.sqf""; //Medical Monitor Script (client only)" \n "dayz_medicalH = [] execVM ""\z\addons\dayz_code\medical\init_medical.sqf""; //Medical Monitor Script (client only)" \n
"[player] call fnc_usec_damageHandle;" \n "[player] call fnc_usec_damageHandle;" \n
"" \n
"if (r_player_unconscious) then {" \n "if (r_player_unconscious) then {" \n
" r_player_timeout = player getVariable[""unconsciousTime"",0];" \n
" player playActionNow ""Die"";" \n " player playActionNow ""Die"";" \n
" [player,r_player_timeout] call fnc_usec_damageUnconscious;" \n
"};" \n "};" \n
"" \n "" \n
"" \n
"" \n
"//Add core tools" \n "//Add core tools" \n
"player addWeapon ""Loot"";" \n "player addWeapon ""Loot"";" \n
"if ((currentWeapon player == """")) then { player action [""SWITCHWEAPON"", player,player,1]; };" \n "if ((currentWeapon player == """")) then { player action [""SWITCHWEAPON"", player,player,1]; };" \n
@@ -1170,8 +1170,7 @@ class FSM
"" \n "" \n
"{ _x call fnc_veh_ResetEH; } forEach vehicles;" \n "{ _x call fnc_veh_ResetEH; } forEach vehicles;" \n
"player allowDamage true;" \n "player allowDamage true;" \n
"player enableSimulation true;" \n "player enableSimulation true;"/*%FSM</STATEINIT""">*/;
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/; precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links class Links
{ {
@@ -1195,9 +1194,9 @@ class FSM
name = "Finish"; name = "Finish";
itemno = 32; itemno = 32;
init = /*%FSM<STATEINIT""">*/"diag_log 'player_forceSave called from fsm';" \n init = /*%FSM<STATEINIT""">*/"diag_log 'player_forceSave called from fsm';" \n
"//call player_forceSave;" \n "//call player_forceSave;" \n
"" \n "" \n
"publicVariableServer ""PVDZ_plr_LoginRecord"";"/*%FSM</STATEINIT""">*/; "publicVariableServer ""PVDZ_plr_LoginRecord"";"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/; precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links class Links
{ {
@@ -1934,22 +1933,28 @@ class FSM
name = "Finish_1"; name = "Finish_1";
itemno = 106; itemno = 106;
init = /*%FSM<STATEINIT""">*/"if (_debug == 1) then {diag_log [diag_tickTime,'Finish'];};" \n init = /*%FSM<STATEINIT""">*/"if (_debug == 1) then {diag_log [diag_tickTime,'Finish'];};" \n
"" \n "" \n
"PVDZ_plr_LoginRecord = [_playerUID,_charID,0,toArray (name vehicle player)];" \n "PVDZ_plr_LoginRecord = [_playerUID,_charID,0,toArray (name vehicle player)];" \n
"" \n "" \n
"if (r_player_unconscious) then {" \n
" r_player_timeout = player getVariable[""unconsciousTime"",0];" \n
" player playActionNow ""Die"";" \n
" [player,r_player_timeout] call fnc_usec_damageUnconscious;" \n
"};" \n
"" \n
"progressLoadingScreen 1;" \n "progressLoadingScreen 1;" \n
"" \n "" \n
"diag_log ['Sent to server: PVDZ_plr_LoginRecord', PVDZ_plr_LoginRecord]; " \n "diag_log ['Sent to server: PVDZ_plr_LoginRecord', PVDZ_plr_LoginRecord]; " \n
"" \n "" \n
"_world = toUpper(worldName); //toUpper(getText (configFile >> ""CfgWorlds"" >> (worldName) >> ""description""));" \n "_world = toUpper(worldName); //toUpper(getText (configFile >> ""CfgWorlds"" >> (worldName) >> ""description""));" \n
"_nearestCity = nearestLocations [getPos player, [""NameCityCapital"",""NameCity"",""NameVillage"",""NameLocal""],1000];" \n "_nearestCity = nearestLocations [getPos player, [""NameCityCapital"",""NameCity"",""NameVillage"",""NameLocal""],1000];" \n
"" \n "" \n
"Dayz_logonTown = ""Wilderness"";" \n "Dayz_logonTown = ""Wilderness"";" \n
"if (count _nearestCity > 0) then {Dayz_logonTown = text (_nearestCity select 0)};" \n "if (count _nearestCity > 0) then {Dayz_logonTown = text (_nearestCity select 0)};" \n
"" \n "" \n
"[_world,Dayz_logonTown,format[localize ""str_player_06"",dayz_Survived]] spawn {uiSleep 5; _this spawn BIS_fnc_infoText;};" \n "[_world,Dayz_logonTown,format[localize ""str_player_06"",dayz_Survived]] spawn {uiSleep 5; _this spawn BIS_fnc_infoText;};" \n
"" \n "" \n
"dayz_myPosition = getPosATL player;" \n "dayz_myPosition = getPosATL player;" \n
"Dayz_loginCompleted = true;" \n "Dayz_loginCompleted = true;" \n
"" \n "" \n
"//Other Counters" \n "//Other Counters" \n

View File

@@ -361,6 +361,7 @@ while {1 == 1} do {
_startcombattimer = player getVariable["startcombattimer", 0]; _startcombattimer = player getVariable["startcombattimer", 0];
if (_startcombattimer == 1) then { //if (_startcombattimer == 1 || _PlayerNearby) then { // do not use _PlayerNearby it makes building impossible, tthis is handled in player_onPause.sqf just fine if (_startcombattimer == 1) then { //if (_startcombattimer == 1 || _PlayerNearby) then { // do not use _PlayerNearby it makes building impossible, tthis is handled in player_onPause.sqf just fine
player setVariable["combattimeout", diag_tickTime + 30, false]; player setVariable["combattimeout", diag_tickTime + 30, false];
player setVariable["inCombat", 1, true];
player setVariable["startcombattimer", 0, false]; player setVariable["startcombattimer", 0, false];
}; /* else { }; /* else {
if (_ZedsNearby && !_isPZombie) then { //this makes building a nightmare, this is handled in player_onPause.sqf just fine if (_ZedsNearby && !_isPZombie) then { //this makes building a nightmare, this is handled in player_onPause.sqf just fine

View File

@@ -5,6 +5,11 @@ sched_playerActions = {
call fnc_usec_selfActions; call fnc_usec_selfActions;
call fnc_usec_damageActions; call fnc_usec_damageActions;
call fnc_usec_upgradeActions; call fnc_usec_upgradeActions;
//combat check
if ((player getVariable ["combattimeout",0] < diag_tickTime) && {player getVariable ["inCombat", 0] > 0}) then {
player setVariable ["inCombat", 0, true];
};
objNull objNull
}; };

View File

@@ -25,6 +25,7 @@ _characterID = _playerObj getVariable["characterID", "?"];
_lastDamage = _playerObj getVariable["noatlf4",0]; _lastDamage = _playerObj getVariable["noatlf4",0];
_Sepsis = _playerObj getVariable["USEC_Sepsis",false]; _Sepsis = _playerObj getVariable["USEC_Sepsis",false];
_lastDamage = round(diag_ticktime - _lastDamage); _lastDamage = round(diag_ticktime - _lastDamage);
_inCombat = _playerObj getVariable ["inCombat", 0];
//Readded Logout debug info. //Readded Logout debug info.
diag_log format["INFO - Player: %3(UID:%1/CID:%2) as (%4), logged off at %5%6", diag_log format["INFO - Player: %3(UID:%1/CID:%2) as (%4), logged off at %5%6",
@@ -64,12 +65,12 @@ if (_characterID != "?") exitwith {
}; };
//Punish combat log //Punish combat log
if ((_lastDamage > 5 && {_lastDamage < 30}) && {alive _playerObj && (_playerObj distance (getMarkerpos "respawn_west") >= 2000)}) then { if ((_inCombat > 0) && {alive _playerObj && (_playerObj distance (getMarkerpos "respawn_west") >= 2000)}) then {
_playerObj setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious _playerObj setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
_playerObj setVariable ["unconsciousTime",150,true]; // Set knock out timer to 150 seconds _playerObj setVariable ["unconsciousTime",150,true]; // Set knock out timer to 150 seconds
//_playerObj setVariable ["USEC_injured",true]; // Set status to bleeding //_playerObj setVariable ["USEC_injured",true]; // Set status to bleeding
//_playerObj setVariable ["USEC_BloodQty",3000]; // Set blood to 3000 //_playerObj setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
diag_log format["PLAYER COMBAT LOGGED: %1(%4) (with %2s combat time remaining) at location %3",_playerName,_lastDamage,_playerPos,_playerUID]; diag_log format["PLAYER COMBAT LOGGED: %1(%3) at location %2",_playerName,_playerPos,_playerUID];
_message = format["PLAYER COMBAT LOGGED: %1",_playerName]; _message = format["PLAYER COMBAT LOGGED: %1",_playerName];
[nil, nil, rTitleText, _message, "PLAIN"] call RE; // Message whole server [nil, nil, rTitleText, _message, "PLAIN"] call RE; // Message whole server
}; };