diff --git a/.gitignore b/.gitignore index c3d2ae7..a578295 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,7 @@ texHeaders.bin *.swo *.biprivatekey Thumbs.db +keys/* +.hemtt/local node_modules diff --git a/addons/api/functions/fnc_attachZenFunctions.sqf b/addons/api/functions/fnc_attachZenFunctions.sqf index ba2c5a3..c59981c 100644 --- a/addons/api/functions/fnc_attachZenFunctions.sqf +++ b/addons/api/functions/fnc_attachZenFunctions.sqf @@ -22,7 +22,13 @@ private _cat = "FP Zombies"; _args params ["_pos"]; ([_pos, "AREA:", [_radius, _radius, 0, true]] call CBA_fnc_createTrigger) params ["_trigger"]; - [_trigger, _density, -1, -1, _maxActive] remoteExecCall [QFUNC(registerZone), 2]; + private _hcs = EGVAR(zombies,headlessClients) select {!isNull _x}; + if (_hcs isNotEqualTo []) then { + [_trigger, _density, -1, -1, _maxActive] remoteExecCall [QFUNC(registerZone), selectRandom _hcs]; + } else { + [_trigger, _density, -1, -1, _maxActive] remoteExecCall [QFUNC(registerZone), 2]; + }; + }, {}, [_pos]] call zen_dialog_fnc_create; }] call zen_custom_modules_fnc_register; @@ -39,12 +45,15 @@ private _cat = "FP Zombies"; params ["_dialog", "_args"]; _dialog params ["_amount", "_radius"]; _args params ["_pos"]; + private _posList = []; for "_i" from 1 to _amount do { - private _z = [] call EFUNC(zombies,spawnZombie); - if (!isNull _z) then { - private _rpos = [_pos, _radius] call CBA_fnc_randPos; - [_z, _rpos] call EFUNC(zombies,zombieInit); - }; + _posList pushBack ([_pos, _radius] call CBA_fnc_randPos); + }; + private _hcs = EGVAR(zombies,headlessClients) select {!isNull _x}; + if (_hcs isNotEqualTo []) then { + [QEGVAR(zombies,spawnZombieBulk), [[], _posList], selectRandom _hcs] call CBA_fnc_targetEvent; + } else { + [QEGVAR(zombies,spawnZombieBulk), [[], _posList]] call CBA_fnc_serverEvent; }; }, {}, [_pos]] call zen_dialog_fnc_create; }] call zen_custom_modules_fnc_register; diff --git a/addons/api/functions/fnc_init.sqf b/addons/api/functions/fnc_init.sqf index a4a8f96..9608a68 100644 --- a/addons/api/functions/fnc_init.sqf +++ b/addons/api/functions/fnc_init.sqf @@ -26,18 +26,15 @@ if (hasInterface) then { ["ace_firedPlayerVehicleNonLocal", {_this call EFUNC(zombies,firedVehicle)}] call CBA_fnc_addEventHandler; ["ace_firedNonPlayerVehicle", {_this call EFUNC(zombies,firedVehicle)}] call CBA_fnc_addEventHandler; -// TODO: HC support -if (isServer) then { +if (isServer || {!hasInterface}) then { [{ - EGVAR(zones,players) = allPlayers select { + EGVAR(zones,players) = (call CBA_fnc_players) select { alive _x && {!(_x isKindOf "VirtualMan_F")} && {!(_x getVariable [QEGVAR(zombies,ignore), false])} && {simulationEnabled _x} }; }, 2] call CBA_fnc_addPerFrameHandler; - - [EFUNC(zones,zonePfh), 0.03] call CBA_fnc_addPerFrameHandler; }; true diff --git a/addons/api/functions/fnc_registerZone.sqf b/addons/api/functions/fnc_registerZone.sqf index 41d2ab0..66362cd 100644 --- a/addons/api/functions/fnc_registerZone.sqf +++ b/addons/api/functions/fnc_registerZone.sqf @@ -32,3 +32,7 @@ _zone setVariable [QEGVAR(zones,maxActiveInZone), _maxActiveInZone]; TRACE_4("Registering zone",_zone, abs round _amount, abs round _radius, abs round _activateDistance, _maxActiveInZone); EGVAR(zones,zones) pushBack _zone; + +if (EGVAR(zones,zonePFH) isEqualTo -1) then { + EGVAR(zones,zonePFH) = [EFUNC(zones,zonePfh), 0.03] call CBA_fnc_addPerFrameHandler; +}; diff --git a/addons/api/functions/fnc_spawnHorde.sqf b/addons/api/functions/fnc_spawnHorde.sqf index 5b9c4db..7d835ed 100644 --- a/addons/api/functions/fnc_spawnHorde.sqf +++ b/addons/api/functions/fnc_spawnHorde.sqf @@ -7,7 +7,7 @@ params [ ["_ignoreMaxZombies", false] ]; -private _zombies = []; +private _posList = []; for "_i" from 1 to _amount do { private _rnd = if (_pos isEqualType objNull && {_pos isKindOf "EmptyDetector"}) then { [_pos] call CBA_fnc_randPosArea; @@ -15,14 +15,18 @@ for "_i" from 1 to _amount do { (_pos call CBA_fnc_getPos) getPos [random 10, random 360]; }; - private _zombie = [selectRandom ["zombie_bolter", "zombie_runner"], _ignoreMaxZombies] call EFUNC(zombies,spawnZombie); - if (!isNull _zombie) then { - _zombies pushBack _zombie; - [_zombie, _rnd, true] call EFUNC(zombies,zombieInit); - if (_sound && {_i >= _amount} && {!isNull _zombie}) then { - [_zombie, ["fpz_yell", 1200, 1]] remoteExecCall ["say", 0]; - }; - }; + _posList pushBack _rnd; }; -_zombies +if (_posList isEqualTo []) exitWith {}; + +private _hcs = EGVAR(zombies,headlessClients) select {!isNull _x}; +if (_hcs isNotEqualTo []) then { + [QEGVAR(zombies,spawnZombieBulk), [["zombie_bolter", "zombie_runner"], _posList, true], selectRandom _hcs] call CBA_fnc_targetEvent; +} else { + [QEGVAR(zombies,spawnZombieBulk), [["zombie_bolter", "zombie_runner"], _posList, true]] call CBA_fnc_serverEvent; +}; + +if (_sound) then { + playSound3D ["rvg_zeds\sounds\zombie_yell.ogg", objNull, false, AGLToASL (_posList select 0), 5, 1, 1200]; +}; diff --git a/addons/zombies/XEH_postInit.sqf b/addons/zombies/XEH_postInit.sqf index 365b23f..8585783 100644 --- a/addons/zombies/XEH_postInit.sqf +++ b/addons/zombies/XEH_postInit.sqf @@ -1,5 +1,31 @@ #include "script_component.hpp" +if (!hasInterface && {!isServer}) then { + // headless client + [QGVAR(headlessClientJoined), [player]] call CBA_fnc_serverEvent; +}; + +[QGVAR(spawnZombie), { + params [ + ["_type", ""], + ["_pos", []], + ["_isHorde", false] + ]; + private _zombie = [_type] call FUNC(spawnZombie); + if (isNull _zombie) exitWith {}; + [_zombie, _pos, _isHorde] call FUNC(zombieInit); +}] call CBA_fnc_addEventHandler; + +[QGVAR(spawnZombieBulk), { + params [["_types", []], ["_posList", []], ["_isHorde", false]]; + if (_types isEqualTo []) then { + _types = [""]; + }; + { + [QGVAR(spawnZombie), [selectRandom _types, _x, _isHorde]] call CBA_fnc_localEvent; + } forEach _posList; +}] call CBA_fnc_addEventHandler; + // Runs for everyone when a zombie is spawned [QGVAR(onSpawn), { params ["_zombie", "_identity", "_pos"]; diff --git a/addons/zombies/XEH_preInit.sqf b/addons/zombies/XEH_preInit.sqf index 4e0e605..dfc0bc1 100644 --- a/addons/zombies/XEH_preInit.sqf +++ b/addons/zombies/XEH_preInit.sqf @@ -4,7 +4,19 @@ ADDON = false; #include "XEH_PREP.hpp" -ADDON = true; - GVAR(targets) = []; GVAR(zombies) = []; + +if (isServer) then { + GVAR(headlessClients) = []; + publicVariable QGVAR(headlessClients); + [QGVAR(headlessClientJoined), { + params ["_headlessClient"]; + GVAR(headlessClients) = GVAR(headlessClients) - [objNull]; + if (_headlessClient in GVAR(headlessClients)) exitWith {}; + GVAR(headlessClients) pushBack _headlessClient; + publicVariable QGVAR(headlessClients); + }] call CBA_fnc_addEventHandler; +}; + +ADDON = true; diff --git a/addons/zones/XEH_preInit.sqf b/addons/zones/XEH_preInit.sqf index 114ad22..58a82ce 100644 --- a/addons/zones/XEH_preInit.sqf +++ b/addons/zones/XEH_preInit.sqf @@ -8,6 +8,7 @@ ADDON = true; GVAR(zones) = []; GVAR(players) = []; +GVAR(zonePFH) = -1; [QGVAR(registerLocalZone), { params [["_zone", objNull]]; diff --git a/addons/zones/functions/fnc_activeZoneCheck.sqf b/addons/zones/functions/fnc_activeZoneCheck.sqf index cdcb4bf..851beed 100644 --- a/addons/zones/functions/fnc_activeZoneCheck.sqf +++ b/addons/zones/functions/fnc_activeZoneCheck.sqf @@ -18,7 +18,7 @@ for "_i" from (count _zombies) to 0 step -1 do { }; #endif } else { - if (!NEARBY_PLAYER(_zombie,fpz_despawnDistance)) then { + if (!NEARBY_PLAYER(getPosWorld _zombie,fpz_despawnDistance)) then { private _pos = _zombie getVariable [QGVAR(zonePos), []]; if !(_pos isEqualTo []) then { _positions pushBack _pos; @@ -39,7 +39,7 @@ private _empty = _zombies isEqualTo []; if (_empty && {_positions isEqualTo []}) exitWith {true}; private _deactivateDistance = (_zone getVariable [QGVAR(activateDistance), fpz_maxChaseDistance]) + DEACTIVATE_MODIFIER; -if (_empty && {!([_zone, _deactivateDistance] call FUNC(nearPlayer))}) exitWith { +if (_empty && {!([getPosWorld _zone, _deactivateDistance] call FUNC(nearPlayer))}) exitWith { _zone setVariable [QGVAR(active), false]; #ifdef DEBUG_MODE_FULL {format ["%1%2", QGVAR(debugMrkPos), _x] setMarkerAlphaLocal 0} forEach _positions; diff --git a/addons/zones/functions/fnc_nearPlayer.sqf b/addons/zones/functions/fnc_nearPlayer.sqf index 1ba98e2..1d5430d 100644 --- a/addons/zones/functions/fnc_nearPlayer.sqf +++ b/addons/zones/functions/fnc_nearPlayer.sqf @@ -1,10 +1,4 @@ #include "script_component.hpp" params ["_pos", "_range"]; -private _ret = false; - -{ - if (_x distance _pos < _range) exitWith {_ret = true}; -} forEach GVAR(players); - -_ret +(GVAR(players) inAreaArray [_pos, _range, _range, 0, false, -1]) isNotEqualTo [] diff --git a/addons/zones/functions/fnc_zonePfh.sqf b/addons/zones/functions/fnc_zonePfh.sqf index 2710c44..3b7ba28 100644 --- a/addons/zones/functions/fnc_zonePfh.sqf +++ b/addons/zones/functions/fnc_zonePfh.sqf @@ -2,7 +2,8 @@ params ["", ["_pfhId", -1]]; if (GVAR(zones) isEqualTo []) exitWith { - //[_pfhId] call CBA_fnc_removePerFrameHandler; + [_pfhId] call CBA_fnc_removePerFrameHandler; + GVAR(zonePFH) = -1; }; private _zone = GVAR(zones) deleteAt 0; @@ -24,7 +25,7 @@ if (_zone getVariable [QGVAR(active), false]) then { GVAR(zones) pushBack _zone; }; } else { - private _playerNear = [_zone, _zone getVariable [QGVAR(activateDistance), fpz_maxChaseDistance]] call FUNC(nearPlayer); + private _playerNear = [getPosWorld _zone, _zone getVariable [QGVAR(activateDistance), fpz_maxChaseDistance]] call FUNC(nearPlayer); if (_playerNear) then {_zone setVariable [QGVAR(active), true]}; GVAR(zones) pushBack _zone; }; diff --git a/hemtt.json b/hemtt.json deleted file mode 100644 index 7a2b444..0000000 --- a/hemtt.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "version": "2", - "name": "fpz", - "prefix": "fpz", - "author": "FP Mod Team", - "modname": "fpz", - "keyname": "fpz_v{{version}}", - "signame": "fpz_v{{version}}", - "files": [ - "mod.cpp", - "AUTHORS.txt", - "LICENSE", - "logo_ca.paa", - "README.md" - ], - "reuse_private_key": false, - "exclude": [ - "*.psd", - "*.png", - "*.tga" - ] -} diff --git a/hemtt.toml b/hemtt.toml index d04a83e..5685f98 100644 --- a/hemtt.toml +++ b/hemtt.toml @@ -3,8 +3,8 @@ name = "fpz" prefix = "fpz" author = "FP Mod Team" modname = "fpz" -keyname = "fpz_v{{version}}" -signame = "fpz_v{{version}}" +# keyname = "fpz_v{{version}}" +# signame = "fpz_v{{version}}" files = [ "mod.cpp", "AUTHORS.txt",