From 097a02b19a59d729de1cfbd4e52a8bfc04c1dfa0 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Wed, 1 Feb 2017 20:36:00 -0500 Subject: [PATCH] Make zombie_agent.fsm customizable for admins #1877 Also fixed HandleDamage EH was added twice. We moved it to the configs and forgot to take it out of the FSM in 6853263. --- SQF/dayz_code/Configs/CfgVehicles/Zeds/SwarmZeds.hpp | 5 ++--- SQF/dayz_code/Configs/CfgVehicles/Zeds/Zeds.hpp | 4 ++-- SQF/dayz_code/compile/zombie_initialize.sqf | 10 ++++++++++ SQF/dayz_code/configVariables.sqf | 4 ++-- SQF/dayz_code/init/compiles.sqf | 1 + SQF/dayz_code/system/fn_swarmagent.fsm | 3 --- SQF/dayz_code/system/zombie_agent.fsm | 7 ++----- SQF/dayz_code/system/zombie_wildagent.fsm | 3 --- 8 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 SQF/dayz_code/compile/zombie_initialize.sqf diff --git a/SQF/dayz_code/Configs/CfgVehicles/Zeds/SwarmZeds.hpp b/SQF/dayz_code/Configs/CfgVehicles/Zeds/SwarmZeds.hpp index 24d065055..8bb53b70f 100644 --- a/SQF/dayz_code/Configs/CfgVehicles/Zeds/SwarmZeds.hpp +++ b/SQF/dayz_code/Configs/CfgVehicles/Zeds/SwarmZeds.hpp @@ -22,9 +22,8 @@ class Swarm_Base : Citizen1 { forcedSpeed = 6; class Eventhandlers { - init = "_this execFSM ""\z\AddOns\dayz_code\system\zombie_agent.fsm"""; - //local = "if(_this select 1) then {[(position (_this select 0)),(_this select 0),true] execFSM '\z\AddOns\dayz_code\system\fn_swarmagent.fsm'};"; - local = "_z = _this select 0; if (!(_this select 1)) exitWith {}; if (isServer) exitWith { _z call sched_co_deleteVehicle; }; [_z,true] execFSM '\z\AddOns\dayz_code\system\zombie_agent.fsm';"; + init = "_this call zombie_initialize;"; + local = "_z = _this select 0; if (!(_this select 1)) exitWith {}; if (isServer) exitWith { _z call sched_co_deleteVehicle; }; [_z,true] call zombie_initialize;"; HandleDamage = "_this call local_zombieDamage;"; Killed = "[_this,'zombieKills'] call local_eventKill;"; }; diff --git a/SQF/dayz_code/Configs/CfgVehicles/Zeds/Zeds.hpp b/SQF/dayz_code/Configs/CfgVehicles/Zeds/Zeds.hpp index 0bc9c8e2d..653a6f8f2 100644 --- a/SQF/dayz_code/Configs/CfgVehicles/Zeds/Zeds.hpp +++ b/SQF/dayz_code/Configs/CfgVehicles/Zeds/Zeds.hpp @@ -52,8 +52,8 @@ class zZombie_Base : Zed_Base { class Eventhandlers { - init = "_this execFSM ""\z\AddOns\dayz_code\system\zombie_agent.fsm"""; - local = "_z = _this select 0; if (!(_this select 1)) exitWith {}; if (isServer) exitWith { _z call sched_co_deleteVehicle; }; [_z,true] execFSM '\z\AddOns\dayz_code\system\zombie_agent.fsm';"; + init = "_this call zombie_initialize;"; + local = "_z = _this select 0; if (!(_this select 1)) exitWith {}; if (isServer) exitWith { _z call sched_co_deleteVehicle; }; [_z,true] call zombie_initialize;"; HandleDamage = "_this call local_zombieDamage;"; Killed = "[_this,'zombieKills'] call local_eventKill;"; }; diff --git a/SQF/dayz_code/compile/zombie_initialize.sqf b/SQF/dayz_code/compile/zombie_initialize.sqf new file mode 100644 index 000000000..88b762813 --- /dev/null +++ b/SQF/dayz_code/compile/zombie_initialize.sqf @@ -0,0 +1,10 @@ +// Moved from config to allow admins to modify +// Put agent second for compatibility with old configs like Namalsk custom zombies. + +if (count _this == 1) then { + //Called from init EH + ["", (_this select 0)] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; +} else { + //Called from local EH + ["", (_this select 0), true] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; +}; \ No newline at end of file diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index 82d8b9c14..92e9ef554 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -1,7 +1,7 @@ // EPOCH CONFIG VARIABLES // -// To change a variable copy it to your mission init.sqf in the Epoch Config Variables section -// Standard DayZ variables are found in dayz_code\init\variables.sqf +// To change a variable copy paste it in the mission init.sqf below the #include line. +// Standard DayZ variables are found in dayz_code\init\variables.sqf. dayz_knifeDulling = false; // Enable knife dulling. Knives need to be sharpened after so many uses. dayz_matchboxCount = false; // Enable match stick count. After five uses matches run out and must be replaced. diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index d233dd413..ff0a62157 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -663,6 +663,7 @@ fnc_Obj_FenceHandleDam = compile preprocessFileLineNumbers "\z\addons\dayz_code\ object_roadFlare = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_roadFlare.sqf"; DZ_KeyDown_EH = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\keyboard.sqf"; fn_shuffleArray = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_shuffleArray.sqf"; +zombie_initialize = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_initialize.sqf"; call compile preprocessFileLineNumbers "\z\addons\dayz_code\traps\init.sqf"; if (dayz_townGenerator) then { diff --git a/SQF/dayz_code/system/fn_swarmagent.fsm b/SQF/dayz_code/system/fn_swarmagent.fsm index 27fdef638..1ad6e5a58 100644 --- a/SQF/dayz_code/system/fn_swarmagent.fsm +++ b/SQF/dayz_code/system/fn_swarmagent.fsm @@ -140,9 +140,6 @@ class FSM "_bodyStay = 60;" \n "" \n "_timeN = time;" \n - "" \n - " _id = _agent addeventhandler [""HandleDamage"",{_this call local_zombieDamage}];" \n - "" \n "//hint ""run local zombie"";" \n "_isSomeone = true;" \n "" \n diff --git a/SQF/dayz_code/system/zombie_agent.fsm b/SQF/dayz_code/system/zombie_agent.fsm index 9ecda39d6..a211dde4d 100644 --- a/SQF/dayz_code/system/zombie_agent.fsm +++ b/SQF/dayz_code/system/zombie_agent.fsm @@ -211,11 +211,11 @@ class FSM class init { name = "init"; - init = /*%FSM*/"_agent = _this select 0;" \n + init = /*%FSM*/"_agent = _this select 1; //Compatible with old configs like Namalsk's custom zombies" \n "_position = _agent modelToWorld [0,0,0];" \n "_secondHand = false;" \n "" \n - "if (count _this > 1) then {" \n + "if (count _this > 2) then {" \n " _secondHand = true;" \n " diag_log (""Second Hand Zombie Initialized: "" + str(_this));" \n "};"/*%FSM*/; @@ -475,9 +475,6 @@ class FSM "_timeN = diag_tickTime;" \n "" \n "_agent setBehaviour ""CARELESS"";" \n - "" \n - " _id = _agent addeventhandler [""HandleDamage"",{_this call local_zombieDamage}];" \n - "" \n "//hint ""run local zombie"";" \n "_isSomeone = true;" \n "" \n diff --git a/SQF/dayz_code/system/zombie_wildagent.fsm b/SQF/dayz_code/system/zombie_wildagent.fsm index f45ca4e39..2cdab3d83 100644 --- a/SQF/dayz_code/system/zombie_wildagent.fsm +++ b/SQF/dayz_code/system/zombie_wildagent.fsm @@ -282,9 +282,6 @@ class FSM "_agent disableAI ""FSM"";" \n "_newDest = getPosATL _agent;" \n "_timeN = time;" \n - "" \n - " _id = _agent addeventhandler [""HandleDamage"",{_this call local_zombieDamage}];" \n - "" \n "_target = objNull;" \n "_targetPos = [];" \n "_countr = 0;" \n