From e38f47375ca978b8b29943e882a688a288219446 Mon Sep 17 00:00:00 2001 From: ebayShopper Date: Mon, 20 Mar 2017 15:53:35 -0400 Subject: [PATCH] Fix some issues with traps Removed two unused files. Vanilla commits: https://github.com/DayZMod/DayZ/commit/42e72463a3f3722ad974d50a093b4f57edbf8c00 https://github.com/DayZMod/DayZ/commit/02726fb1923a7354121796a0e306a8ca92cdc42f https://github.com/DayZMod/DayZ/commit/6a7c53ebcf48f6e552bf4d5bb65be07792a0cd92 https://github.com/DayZMod/DayZ/commit/1fb6308995584472b0494a54d211dc5b216bfd98 https://github.com/DayZMod/DayZ/commit/9543ea057f97ba6f1105f6abecaa04e1fe5d4457 --- CHANGE LOG 1.0.6.2.txt | 4 ++ SQF/dayz_code/Configs/CfgVehicles/Traps.hpp | 18 ++++----- SQF/dayz_code/actions/object_pickup.sqf | 14 +++++-- SQF/dayz_code/actions/player_setTrap.sqf | 40 ------------------- SQF/dayz_code/init/compiles.sqf | 1 - SQF/dayz_code/init/variables.sqf | 3 +- SQF/dayz_code/traps/beartrap.sqf | 5 +-- SQF/dayz_code/traps/beartrapflare.sqf | 6 +-- SQF/dayz_code/traps/beartrapsmoke.sqf | 6 +-- SQF/dayz_code/traps/functions/arm.sqf | 12 +++++- SQF/dayz_code/traps/functions/disarm.sqf | 11 ++++- SQF/dayz_code/traps/functions/remove.sqf | 8 +++- SQF/dayz_code/traps/functions/setup.sqf | 4 +- SQF/dayz_code/traps/functions/trigger.sqf | 2 +- SQF/dayz_code/traps/tripcans.sqf | 2 +- SQF/dayz_code/traps/tripflare.sqf | 2 +- SQF/dayz_code/traps/tripgrenade.sqf | 26 +++++++++++- SQF/dayz_code/traps/tripsmoke.sqf | 29 ++++++++++++-- .../system/scheduler/sched_init.sqf | 2 - .../system/scheduler/sched_traps.sqf | 33 --------------- 20 files changed, 111 insertions(+), 117 deletions(-) delete mode 100644 SQF/dayz_code/actions/player_setTrap.sqf delete mode 100644 SQF/dayz_server/system/scheduler/sched_traps.sqf diff --git a/CHANGE LOG 1.0.6.2.txt b/CHANGE LOG 1.0.6.2.txt index 92ff31a2d..2b59a7201 100644 --- a/CHANGE LOG 1.0.6.2.txt +++ b/CHANGE LOG 1.0.6.2.txt @@ -3,6 +3,10 @@ [FIXED] Kamaz refuel trucks no longer allow automatic refueling. #1855 @coresync2k @dreamforceinc [FIXED] Trees at POIs can be chopped down now. Other trees spawned with createVehicle can be added to dayz_treeTypes in variables.sqf to allow chopping them down. [FIXED] POIs were moved back to global spawn again. This synchronizes the POI buildings and trees destroyed/chopped status for all clients. +[FIXED] All traps now need to be armed after placing. This fixes them not triggering right after building. +[FIXED] Smoke and grenade tripwires now require a grenade to rearm after triggering. +[FIXED] Player no longer does medic animation after triggering a single use trap. +[FIXED] Removing a trap with no room in your gear will no longer delete the trap. [NOTE] Fixes below are included in the mission file and server pbo as part of server package 1.0.6.1A (March 10th 2017) [FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions. diff --git a/SQF/dayz_code/Configs/CfgVehicles/Traps.hpp b/SQF/dayz_code/Configs/CfgVehicles/Traps.hpp index 9f9977164..3333e1d2e 100644 --- a/SQF/dayz_code/Configs/CfgVehicles/Traps.hpp +++ b/SQF/dayz_code/Configs/CfgVehicles/Traps.hpp @@ -8,7 +8,7 @@ class BearTrap_DZ : TrapItems { model = "\dayz_equip\models\bear_trap.p3d"; script = "beartrap"; // compiled script variable name (used by server side loop) - initState = 0; // initial armed state + initState = 0; // initial armed state (>0 is not currently working) singleUse = 0; nounderground = 0; requireplot = 0; @@ -128,7 +128,7 @@ class TrapBearTrapFlare : TrapItems { constructioncount = 1; script = "beartrapflare"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state + initState = 0; // initial armed state (>0 is not currently working) singleUse = 1; // gets replaced by BearTrap_DZ due to animation issues class Eventhandlers { @@ -180,7 +180,7 @@ class TrapBearTrapSmoke : TrapItems { constructioncount = 1; script = "beartrapsmoke"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state + initState = 0; // initial armed state (>0 is not currently working) singleUse = 1; // gets replaced by BearTrap_DZ due to animation issues class Eventhandlers { @@ -230,7 +230,7 @@ class Trap_Cans : TrapItems { nounderground = 0; script = "tripcans"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state + initState = 0; // initial armed state (>0 is not currently working) singleUse = 0; requireplot = 0; constructioncount = 1; @@ -282,7 +282,7 @@ class TrapTripwireFlare : TrapItems { nounderground = 0; script = "tripflare"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state + initState = 0; // initial armed state (>0 is not currently working) singleUse = 0; requireplot = 0; constructioncount = 1; @@ -334,8 +334,8 @@ class TrapTripwireGrenade : TrapItems { nounderground = 0; script = "tripgrenade"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state - singleUse = 1; + initState = 0; // initial armed state (>0 is not currently working) + singleUse = 0; //Trap can now be rearmed with another grenade requireplot = 0; constructioncount = 1; @@ -386,8 +386,8 @@ class TrapTripwireSmoke : TrapItems { nounderground = 0; script = "tripsmoke"; // compiled script variable name (used by server side loop) - initState = 1; // initial armed state - singleUse = 1; + initState = 0; // initial armed state (>0 is not currently working) + singleUse = 0; //Trap can now be rearmed with another smoke requireplot = 0; constructioncount = 1; diff --git a/SQF/dayz_code/actions/object_pickup.sqf b/SQF/dayz_code/actions/object_pickup.sqf index 52868aa3d..fcc418611 100644 --- a/SQF/dayz_code/actions/object_pickup.sqf +++ b/SQF/dayz_code/actions/object_pickup.sqf @@ -6,7 +6,6 @@ _type = _array select 0; _classname = _array select 1; _holder = _array select 2; - if (player distance _holder > 3) exitwith { localize "str_pickup_limit_1","PLAIN DOWN" }; _playerID = getPlayerUID player; @@ -29,8 +28,6 @@ if (isnil "claimed") then { canPickup = false; -if (_classname isKindOf "TrapBear") exitWith { deleteVehicle _holder; }; - player playActionNow "PutDown"; //Adding random chance of arrow is re-usable on pickup @@ -74,6 +71,17 @@ _isOk = [player,_config] call BIS_fnc_invAdd; true call dz_fn_meleeMagazines; if (_isOk) then { + if (_holder isKindOf "TrapItems") then { + if !(_holder getVariable ["fullRefund",true]) then { + //Trap was already triggered, refund all parts except grenade + player removeMagazine _classname; + ["equip_string",1,1] call fn_dropItem; + ["PartWoodPile",1,1] call fn_dropItem; + ["equip_duct_tape",1,1] call fn_dropItem; + }; + PVDZ_obj_Destroy = [(_holder getVariable["ObjectID","0"]),(_holder getVariable["ObjectUID","0"]),player]; + publicVariableServer "PVDZ_obj_Destroy"; + }; deleteVehicle _holder; } else { if (!_isOk) exitWith { diff --git a/SQF/dayz_code/actions/player_setTrap.sqf b/SQF/dayz_code/actions/player_setTrap.sqf deleted file mode 100644 index 371a9e1d1..000000000 --- a/SQF/dayz_code/actions/player_setTrap.sqf +++ /dev/null @@ -1,40 +0,0 @@ -private ["_item","_config","_onLadder","_classname","_text","_consume","_hastrapitem","_location","_object"]; - -_item = _this; -_config = configFile >> "CfgWeapons" >> _item; - -if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; -dayz_actionInProgress = true; - -_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -if (_onLadder) exitWith { dayz_actionInProgress = false; localize "str_player_21" call dayz_rollingMessages;}; - -call gear_ui_init; - -_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); -_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); -_consume = ([] + getArray (_config >> "magazines")) select 0; - -_hastrapitem = _item in magazines player; - -if (!_hastrapitem) exitWith { dayz_actionInProgress = false; format[localize "str_player_31",_text,localize "str_player_31_place"] call dayz_rollingMessages;}; - -player removeMagazine _item; -_location = getPosATL player; - -player playActionNow "PutDown"; -sleep 1; - -_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; -_object setDir (getDir player); - -_object setVariable ["armed", false, true]; - -PVDZ_obj_Publish = [dayz_characterID,_object,[getDir _object, getPosATL _object],[["armed", _object getVariable "armed"]]]; -publicVariableServer "PVDZ_obj_Publish"; -diag_log [diag_ticktime, __FILE__, "New Networked object, request to save to hive. PVDZ_obj_Publish:", PVDZ_obj_Publish]; - -player reveal _object; - -dayz_actionInProgress = false; -format[localize "str_build_01",_text] call dayz_rollingMessages; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index f989d454d..a80fda9de 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -103,7 +103,6 @@ if (!isDedicated) then { object_upgradeFireplace = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\object_upgradeFireplace.sqf"; player_wearClothes = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_wearClothes.sqf"; player_dropWeapon = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_dropWeapon.sqf"; - //player_setTrap = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_setTrap.sqf"; object_pickup = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\object_pickup.sqf"; //player_sleep = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_sleep.sqf"; player_combineMag = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_combineMags.sqf"; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index aadb1baf0..8d1694da0 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -53,7 +53,6 @@ Dayz_attachment_array = ["Attachment_ACG","Attachment_AIM"]; DayZ_Backpacks = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Pouch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_CivilBackpack_EP1","DZ_Backpack_EP1","DZ_TerminalPack_EP1","DZ_CompactPack_EP1","DZ_GunBag_EP1","DZ_LargeGunBag_EP1"]; Dayz_Gutting = ["ItemKnife","ItemKnife5","ItemKnife4","ItemKnife3","ItemKnife2","ItemKnife1","ItemKnifeBlunt"]; DayZ_Ignitors = ["ItemMatchbox","Item5Matchbox","Item4Matchbox","Item3Matchbox","Item2Matchbox","Item1Matchbox"]; -DayZ_traps = ["Trap_Cans","TrapTripwireFlare","TrapBearTrapSmoke","TrapTripwireGrenade","TrapTripwireSmoke","TrapBearTrapFlare"]; DayZ_ViralZeds = ["z_new_villager2","z_new_villager3","z_new_villager4","z_new_worker2","z_new_worker3","z_new_worker4"]; DayZ_SafeObjects = ["Base_Fire_DZ","WoodenGate_1","WoodenGate_2","WoodenGate_3","WoodenGate_4","Land_Fire_DZ","TentStorage","TentStorage0","TentStorage1","TentStorage2","TentStorage3","TentStorage4","StashSmall","StashSmall1","StashSmall2","StashSmall3","StashSmall4","StashMedium","StashMedium1","StashMedium2","StashMedium3","StashMedium4","Wire_cat1","Sandbag1_DZ","Fence_DZ","Generator_DZ","Hedgehog_DZ","BearTrap_DZ","DomeTentStorage","DomeTentStorage0","DomeTentStorage1","DomeTentStorage2","DomeTentStorage3","DomeTentStorage4","CamoNet_DZ","Trap_Cans","TrapTripwireFlare","TrapBearTrapSmoke","TrapTripwireGrenade","TrapTripwireSmoke","TrapBearTrapFlare","TentStorageDomed","VaultStorageLocked","BagFenceRound_DZ","TrapBear","Fort_RazorWire","WoodGate_DZ","Land_HBarrier1_DZ","Land_HBarrier3_DZ","Land_HBarrier5_DZ","Fence_corrugated_DZ","M240Nest_DZ","CanvasHut_DZ","ParkBench_DZ","MetalGate_DZ","OutHouse_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ","Plastic_Pole_EP1_DZ","StickFence_DZ","LightPole_DZ","FuelPump_DZ","DesertCamoNet_DZ","ForestCamoNet_DZ","DesertLargeCamoNet_DZ","ForestLargeCamoNet_DZ","SandNest_DZ","DeerStand_DZ","MetalPanel_DZ","WorkBench_DZ","WoodFloor_DZ","WoodLargeWall_DZ","WoodLargeWallDoor_DZ","WoodLargeWallWin_DZ","WoodSmallWall_DZ","WoodSmallWallWin_DZ","WoodSmallWallDoor_DZ","LockboxStorageLocked","WoodFloorHalf_DZ","WoodFloorQuarter_DZ","WoodStairs_DZ","WoodStairsSans_DZ","WoodStairsRails_DZ","WoodSmallWallThird_DZ","WoodLadder_DZ","Land_DZE_GarageWoodDoor","Land_DZE_LargeWoodDoor","Land_DZE_WoodDoor","Land_DZE_GarageWoodDoorLocked","Land_DZE_LargeWoodDoorLocked","Land_DZE_WoodDoorLocked","CinderWallHalf_DZ","CinderWall_DZ","CinderWallDoorway_DZ","CinderWallDoor_DZ","CinderWallDoorLocked_DZ","CinderWallSmallDoorway_DZ","CinderWallDoorSmall_DZ","CinderWallDoorSmallLocked_DZ","MetalFloor_DZ","WoodRamp_DZ","GunRack_DZ","FireBarrel_DZ","WoodCrate_DZ","Scaffolding_DZ","DesertTentStorage","DesertTentStorage0","DesertTentStorage1","DesertTentStorage2","DesertTentStorage3","DesertTentStorage4"]; DayZ_DropDrageeObjects = ["WoodenGate_1","WoodenGate_2","WoodenGate_3","WoodenGate_4","TentStorage","TentStorage0","TentStorage1","TentStorage2","TentStorage3","TentStorage4","Wire_cat1","Sandbag1_DZ","Fence_DZ","Generator_DZ","Hedgehog_DZ","DomeTentStorage","DomeTentStorage0","DomeTentStorage1","DomeTentStorage2","DomeTentStorage3","DomeTentStorage4","TentStorageDomed","VaultStorageLocked","BagFenceRound_DZ","Fort_RazorWire","WoodGate_DZ","Land_HBarrier1_DZ","Land_HBarrier3_DZ","Land_HBarrier5_DZ","Fence_corrugated_DZ","M240Nest_DZ","ParkBench_DZ","MetalGate_DZ","OutHouse_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ","StickFence_DZ","SandNest_DZ","MetalPanel_DZ","WorkBench_DZ","WoodLargeWall_DZ","WoodLargeWallDoor_DZ","WoodLargeWallWin_DZ","WoodSmallWall_DZ","WoodSmallWallWin_DZ","WoodSmallWallDoor_DZ","LockboxStorageLocked","WoodSmallWallThird_DZ","WoodLadder_DZ","Land_DZE_GarageWoodDoor","Land_DZE_LargeWoodDoor","Land_DZE_WoodDoor","Land_DZE_GarageWoodDoorLocked","Land_DZE_LargeWoodDoorLocked","Land_DZE_WoodDoorLocked","CinderWallHalf_DZ","CinderWall_DZ","CinderWallDoorway_DZ","CinderWallDoor_DZ","CinderWallDoorLocked_DZ","CinderWallSmallDoorway_DZ","CinderWallDoorSmall_DZ","CinderWallDoorSmallLocked_DZ","DesertTentStorage","DesertTentStorage0","DesertTentStorage1","DesertTentStorage2","DesertTentStorage3","DesertTentStorage4","WoodFloorHalf_DZ","WoodFloor_DZ","WoodFloorQuarter_DZ","WoodStairs_DZ","WoodStairsSans_DZ","WoodStairsRails_DZ","MetalFloor_DZ","WoodRamp_DZ"]; @@ -378,7 +377,6 @@ dayz_maxMaxModels = 80; // max quantity of Man models (player or Z, dead or aliv dayz_cantseeDist = 150; // distance from which we can spawn a Z in front of any player without ray-tracing and angle checks dayz_cantseefov = 70; // half player field-of-view. Visible Z won't be spawned in front of any near players dayz_canDelete = 350; // Z, further than this distance from its "owner", will be deleted -dayz_traps = []; dayz_traps_active = []; dayz_traps_trigger = []; @@ -544,6 +542,7 @@ if (isNil "DZE_slowZombies") then {DZE_slowZombies = false;}; TimeOutDisplayed = false; if (isServer) then { + dayz_traps = []; dead_bodyCleanup = []; needUpdate_objects = []; needUpdate_FenceObjects = []; diff --git a/SQF/dayz_code/traps/beartrap.sqf b/SQF/dayz_code/traps/beartrap.sqf index b8730a720..8bda41c9e 100644 --- a/SQF/dayz_code/traps/beartrap.sqf +++ b/SQF/dayz_code/traps/beartrap.sqf @@ -12,9 +12,6 @@ _init = { _arm = { //if (isServer) then { - _trap animate ["LeftShutter", 0]; - _trap animate ["RightShutter", 0]; - _trigger = createTrigger ["EmptyDetector", getPosATL _trap]; _trigger setpos getPosATL _trap; _trigger setTriggerArea [0.5, 0.5, 0, false]; @@ -27,7 +24,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; diff --git a/SQF/dayz_code/traps/beartrapflare.sqf b/SQF/dayz_code/traps/beartrapflare.sqf index 41ec460c7..b588fa50e 100644 --- a/SQF/dayz_code/traps/beartrapflare.sqf +++ b/SQF/dayz_code/traps/beartrapflare.sqf @@ -12,10 +12,6 @@ _init = { _arm = { //if (isServer) then { - // don't work (due to proxies n stuff) - //_trap animate ["LeftShutter", 0]; - //_trap animate ["RightShutter", 0]; - _trigger = createTrigger ["EmptyDetector", getPosATL _trap]; _trigger setpos getPosATL _trap; _trigger setTriggerArea [0.5, 0.5, 0, false]; @@ -28,7 +24,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; diff --git a/SQF/dayz_code/traps/beartrapsmoke.sqf b/SQF/dayz_code/traps/beartrapsmoke.sqf index 6c456b538..3db8c94cb 100644 --- a/SQF/dayz_code/traps/beartrapsmoke.sqf +++ b/SQF/dayz_code/traps/beartrapsmoke.sqf @@ -12,10 +12,6 @@ _init = { _arm = { //if (isServer) then { - // don't work (due to proxies n stuff) - //_trap animate ["LeftShutter", 0]; - //_trap animate ["RightShutter", 0]; - _trigger = createTrigger ["EmptyDetector", getPosATL _trap]; _trigger setpos getPosATL _trap; _trigger setTriggerArea [0.5, 0.5, 0, false]; @@ -28,7 +24,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; diff --git a/SQF/dayz_code/traps/functions/arm.sqf b/SQF/dayz_code/traps/functions/arm.sqf index dfaedd94f..e0c102de8 100644 --- a/SQF/dayz_code/traps/functions/arm.sqf +++ b/SQF/dayz_code/traps/functions/arm.sqf @@ -1,12 +1,20 @@ _trap = _this select 0; _trigger = _this select 1; +//Doesn't work on flare and smoke beartraps "due to proxies n stuff" _trap animate ['LeftShutter', 0]; _trap animate ['RightShutter', 0]; -_trap setVariable ["armed", true, true]; +if !(_trap getVariable ["armed", false]) then { + _trap setVariable ["armed", true, true]; +}; + PVDZ_veh_Save = [_trap, "gear"]; -publicVariableServer "PVDZ_veh_Save"; +if (isServer) then { + PVDZ_veh_Save call server_updateObject; +} else { + publicVariableServer "PVDZ_veh_Save"; +}; dayz_traps_active set [count dayz_traps_active, _trap]; dayz_traps_trigger set [count dayz_traps_trigger, _trigger]; diff --git a/SQF/dayz_code/traps/functions/disarm.sqf b/SQF/dayz_code/traps/functions/disarm.sqf index c426a6b25..3de9f6b16 100644 --- a/SQF/dayz_code/traps/functions/disarm.sqf +++ b/SQF/dayz_code/traps/functions/disarm.sqf @@ -3,9 +3,16 @@ _trap = _this select 0; _trap animate ['LeftShutter', 1]; _trap animate ['RightShutter', 1]; -_trap setVariable ["armed", false, true]; +if (_trap getVariable ["armed", false]) then { + _trap setVariable ["armed", false, true]; +}; + PVDZ_veh_Save = [_trap, "gear"]; -publicVariableServer "PVDZ_veh_Save"; +if (isServer) then { + PVDZ_veh_Save call server_updateObject; +} else { + publicVariableServer "PVDZ_veh_Save"; +}; if (_trap in dayz_traps_active) then { deleteVehicle (dayz_traps_trigger select (dayz_traps_active find _trap)); diff --git a/SQF/dayz_code/traps/functions/remove.sqf b/SQF/dayz_code/traps/functions/remove.sqf index f34117879..516dc9629 100644 --- a/SQF/dayz_code/traps/functions/remove.sqf +++ b/SQF/dayz_code/traps/functions/remove.sqf @@ -7,5 +7,11 @@ _objectUID = _obj getVariable ["ObjectUID","0"]; if (isServer) then { [_objectID,_objectUID,"__SERVER__"] call server_deleteObj; } else { - [nil,nil,nil,_obj] execVM "\z\addons\dayz_code\actions\remove.sqf"; + if (count _this == 2) then { + //single use trap triggered, remove with no animation + //For normal remove let object_pickup.sqf perform deletion to ensure player has room in gear first, no others remove at same time and animation runs + PVDZ_obj_Destroy = [_objectID,_objectUID,player]; + publicVariableServer "PVDZ_obj_Destroy"; + deleteVehicle _obj; + }; }; \ No newline at end of file diff --git a/SQF/dayz_code/traps/functions/setup.sqf b/SQF/dayz_code/traps/functions/setup.sqf index 14ad1d57f..ae7ba0d35 100644 --- a/SQF/dayz_code/traps/functions/setup.sqf +++ b/SQF/dayz_code/traps/functions/setup.sqf @@ -10,7 +10,9 @@ if (!isNull _trap) then { if (isNull _trap) exitWith { /* break from loop */ }; if (((parseNumber _id > 0) || (parseNumber _uid > 0)) && !isNil "_armed") exitWith { - dayz_traps set [count dayz_traps, _trap]; + if (isServer) then { + dayz_traps set [count dayz_traps, _trap]; + }; }; uiSleep 0.5; diff --git a/SQF/dayz_code/traps/functions/trigger.sqf b/SQF/dayz_code/traps/functions/trigger.sqf index 44b3cd072..d7c71dce9 100644 --- a/SQF/dayz_code/traps/functions/trigger.sqf +++ b/SQF/dayz_code/traps/functions/trigger.sqf @@ -1,7 +1,7 @@ _trap = _this select 0; if (getNumber (configFile >> "CfgVehicles" >> typeOf _trap >> "singleUse") > 0) then { - [_trap] call remove_trap; + [_trap,true] call remove_trap; } else { [_trap] call disarm_trap; }; diff --git a/SQF/dayz_code/traps/tripcans.sqf b/SQF/dayz_code/traps/tripcans.sqf index af6e2b0ba..75e9fda93 100644 --- a/SQF/dayz_code/traps/tripcans.sqf +++ b/SQF/dayz_code/traps/tripcans.sqf @@ -28,7 +28,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; diff --git a/SQF/dayz_code/traps/tripflare.sqf b/SQF/dayz_code/traps/tripflare.sqf index 95f9bccf1..14569bc79 100644 --- a/SQF/dayz_code/traps/tripflare.sqf +++ b/SQF/dayz_code/traps/tripflare.sqf @@ -28,7 +28,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; diff --git a/SQF/dayz_code/traps/tripgrenade.sqf b/SQF/dayz_code/traps/tripgrenade.sqf index b996a691f..1574c6c94 100644 --- a/SQF/dayz_code/traps/tripgrenade.sqf +++ b/SQF/dayz_code/traps/tripgrenade.sqf @@ -11,6 +11,24 @@ _init = { }; _arm = { + _exit = false; + + if (!isDedicated && !(_trap getVariable["fullRefund",true])) then { + _exit = true; + { + if (_x in magazines player) exitWith { + player removeMagazine _x; + _exit = false; + _trap setVariable ["fullRefund",true,true]; + }; + } count ["HandGrenade_West","HandGrenade_East"]; + }; + + if (_exit) exitWith { + //Trap was already triggered, require grenade to rearm + format[localize "str_player_03",localize "str_dn_grenade"] call dayz_rollingMessages; + }; + //if (isServer) then { _pos = getPosATL _trap; _pos1 = _trap modelToWorld (_trap selectionPosition "TripA"); @@ -28,7 +46,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; @@ -45,6 +63,8 @@ _remove = { [_trap] call remove_trap; } else { [_trap] call remove_trap; + + //Refund is determined in object_pickup.sqf [0,0,0,["cfgMagazines","ItemTrapTripwireGrenade",_trap]] spawn object_pickup; }; }; @@ -62,6 +82,10 @@ _trigger = { _flare = createVehicle ["GrenadeHandTimedWest_DZ", _position, [], 0, "CAN_COLLIDE"]; [_trap] call trigger_trap; + //Trap is left nearby to allow null source in damage handler. + + //TO-DO: save this variable to DB, currently allows one free rearm after server restart + _trap setVariable ["fullRefund",false,true]; }; }; diff --git a/SQF/dayz_code/traps/tripsmoke.sqf b/SQF/dayz_code/traps/tripsmoke.sqf index 41b76c08f..db39f090c 100644 --- a/SQF/dayz_code/traps/tripsmoke.sqf +++ b/SQF/dayz_code/traps/tripsmoke.sqf @@ -11,6 +11,24 @@ _init = { }; _arm = { + _exit = false; + + if (!isDedicated && !(_trap getVariable["fullRefund",true])) then { + _exit = true; + { + if (_x in magazines player) exitWith { + player removeMagazine _x; + _exit = false; + _trap setVariable ["fullRefund",true,true]; + }; + } count ["SmokeShell","SmokeShellRed","SmokeShellGreen"]; + }; + + if (_exit) exitWith { + //Trap was already triggered, require smoke to rearm + format[localize "str_player_03",localize "str_dn_smoke"] call dayz_rollingMessages; + }; + //if (isServer) then { _pos = getPosATL _trap; _pos1 = _trap modelToWorld (_trap selectionPosition "TripA"); @@ -28,7 +46,7 @@ _arm = { [_trap, _trigger] call arm_trap; //} else { - _trap setVariable ["armed", true, true]; + //_trap setVariable ["armed", true, true]; //}; }; @@ -45,12 +63,14 @@ _remove = { [_trap] call remove_trap; } else { [_trap] call remove_trap; + + //Refund is determined in object_pickup.sqf [0,0,0,["cfgMagazines","ItemTrapTripwireSmoke",_trap]] spawn object_pickup; }; }; _trigger = { - //if (isServer) then { + if (isServer) then { private "_entity"; _entity = _this select 0; @@ -62,7 +82,10 @@ _trigger = { _flare = createVehicle ["SmokeShell", _position, [], 0, "CAN_COLLIDE"]; [_trap] call trigger_trap; - //}; + + //TO-DO: save this variable to DB, currently allows one free rearm after server restart + _trap setVariable ["fullRefund",false,true]; + }; }; private ["_event", "_trap", "_args"]; diff --git a/SQF/dayz_server/system/scheduler/sched_init.sqf b/SQF/dayz_server/system/scheduler/sched_init.sqf index b217c5980..1273f0f40 100644 --- a/SQF/dayz_server/system/scheduler/sched_init.sqf +++ b/SQF/dayz_server/system/scheduler/sched_init.sqf @@ -6,7 +6,6 @@ call compile preprocessFileLineNumbers (_base+"sched_lootpiles.sqf"); //call compile preprocessFileLineNumbers (_base+"sched_playersHivesync.sqf"); //call compile preprocessFileLineNumbers (_base+"sched_vehiclesHivesync.sqf"); call compile preprocessFileLineNumbers (_base+"sched_sync.sqf"); -//call compile preprocessFileLineNumbers (_base+"sched_traps.sqf"); call compile preprocessFileLineNumbers (_base+"sched_safetyVehicle.sqf"); [ @@ -18,7 +17,6 @@ call compile preprocessFileLineNumbers (_base+"sched_safetyVehicle.sqf"); [ 6, 340, sched_lootpiles ], [ 900, 0, sched_sync ], [ 120, 48, sched_safetyVehicle ] - //[ 0.1, 1, sched_traps ] ] execFSM ("z\addons\dayz_code\system\scheduler\scheduler.fsm"); //diag_log [ __FILE__, "Scheduler started"]; diff --git a/SQF/dayz_server/system/scheduler/sched_traps.sqf b/SQF/dayz_server/system/scheduler/sched_traps.sqf deleted file mode 100644 index 47b9ede4c..000000000 --- a/SQF/dayz_server/system/scheduler/sched_traps.sqf +++ /dev/null @@ -1,33 +0,0 @@ -sched_traps = { - private ["_n","_x"]; - // EVERY 5 SECONDS - // CHECK TRAPS STATE - if (!isNil "dayz_traps") then { - _n = 0; - { - if ((isNil "_x") OR {(isNull _x)}) then { - dayz_traps = dayz_traps - [_x]; - } - else { - if (_x getVariable ["armed", false]) then { - if !(_x in dayz_traps_active) then { - ["arm", _x] call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script"); - if !(_x in dayz_traps_active) then { dayz_traps_active set [ count dayz_traps_active, _x ]; }; - _n = _n + 1; - }; - } else { - if (_x in dayz_traps_active) then { - ["disarm", _x] call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script"); - if (_x in dayz_traps_active) then { dayz_traps_active = dayz_traps_active - [_x]; }; - _n = _n + 1; - }; - }; - }; - } forEach dayz_traps; - if (_n > 0) then { - diag_log format ["%1: traps polling, changed %2 states", __FILE__, _n]; - }; - }; - - objNull -}; \ No newline at end of file