Skip to content

Commit

Permalink
Merge pull request #6 from fparma/random_updates
Browse files Browse the repository at this point in the history
Random updates
  • Loading branch information
diwako authored Sep 14, 2022
2 parents 65ceb77 + a54a4dc commit 7d18cbd
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ texHeaders.bin
*.swo
*.biprivatekey
Thumbs.db
keys/*
.hemtt/local

node_modules
21 changes: 15 additions & 6 deletions addons/api/functions/fnc_attachZenFunctions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions addons/api/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions addons/api/functions/fnc_registerZone.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
24 changes: 14 additions & 10 deletions addons/api/functions/fnc_spawnHorde.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ 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;
} else {
(_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];
};
26 changes: 26 additions & 0 deletions addons/zombies/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -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"];
Expand Down
16 changes: 14 additions & 2 deletions addons/zombies/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions addons/zones/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ADDON = true;

GVAR(zones) = [];
GVAR(players) = [];
GVAR(zonePFH) = -1;

[QGVAR(registerLocalZone), {
params [["_zone", objNull]];
Expand Down
4 changes: 2 additions & 2 deletions addons/zones/functions/fnc_activeZoneCheck.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions addons/zones/functions/fnc_nearPlayer.sqf
Original file line number Diff line number Diff line change
@@ -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 []
5 changes: 3 additions & 2 deletions addons/zones/functions/fnc_zonePfh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
22 changes: 0 additions & 22 deletions hemtt.json

This file was deleted.

4 changes: 2 additions & 2 deletions hemtt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7d18cbd

Please sign in to comment.