Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config values "civClass" replaces #define GRAD_CIVS_CIVCLASS #48

Merged
merged 5 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,32 @@ Attribute | Default Value | Explanation
-------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------
autoInit | 0 | Toggles on automatic initialization of module on missions start (0/1). Keep this off if you want to use functions to set civs properties first.
automaticVehicleGroupSize| 1 | Allow vehicles to be filled according to capacity, ignoring *initialGroupSize* (0,1).
enableOnFoot | 1 | Enable civilians on foot (0/1).
enableInVehicles | 1 | Enable civilians in vehicles (0/1).
maxCivsOnFoot | 30 | Maximum number of civs on foot.
maxCivsInVehicles | 10 | Maximum number of civs in vehicles.
maxCivsResidents | 20 | Maximum number of civs that are residents, mostly doing their thing at home.
spawnDistancesOnFoot | [1000,4500] | Minimum and maximum distance to players that civilians on foot can spawn in.
spawnDistancesResidents | [500, 1000] | Minimum and maximum distance to players that civilians living in houses spawn in.
spawnDistancesInVehicles | [1500,6000] | Minimum and maximum distance to players that civilians in vehicles can spawn in.
backpackProbability | 50 | Probability that a civilian will wear a backpack, in percent
backpacks | [] | All classnames of backpacks that civilians may wear.
civClass | "C_Man_1" | Unit class to use for spawning civilians
clothes | [] | All classnames of clothes that civilians may wear.
debugCivState | 0 | Toggles civ behavior debugging mode (0/1).
debugFps | 0 | Toggles fps monitoring mode (0/1).
enableInVehicles | 1 | Enable civilians in vehicles (0/1).
enableOnFoot | 1 | Enable civilians on foot (0/1).
exitOn | "" | Condition upon which grad-civs loops will stop.
faces | [] | All classnames of faces that civilians may have.
goggles | [] | All classnames of goggles that civilians may wear.
headgear | [] | All classnames of headgear that civilians may wear.
initialGroupSize | 3 | Initial group size for civilians, between 1..N . Value may be any valid parameter to the `random` command.
maxCivsInVehicles | 10 | Maximum number of civs in vehicles.
maxCivsOnFoot | 30 | Maximum number of civs on foot.
maxCivsResidents | 20 | Maximum number of civs that are residents, mostly doing their thing at home.
minCivUpdateTime | 2 | Spawn new civilians only if their beheviour states get updated at least every N seconds. NOTE: each frame only one civ gets updated. Example: With 40fps and minCivUpdateTime=2, not more than 80 civs will be alive at any given time. This setting is meant to prevent civs from becoming too unresponsive.
minFps | 40 | Spawn new civilians only if fps are at or above N . NOTE: the fps are taken from the machine that spawns the civs, which may be a HC.
onSpawn | "" | Code to execute on civilian spawn. Passed parameters are: [civilian,vehicle (objNull if on foot)].
onHeldUp | "" | Code to execute when civilian stops because a weapon is pointed at him. Passed parameters are: [civilian].
onKilled | "" | Code to execute when civilian is killed. Passed parameters are: [civilian,killer].
exitOn | "" | Condition upon which grad-civs loops will stop.
clothes | [] | All classnames of clothes that civilians may wear.
faces | [] | All classnames of faces that civilians may have.
goggles | [] | All classnames of goggles that civilians may wear.
headgear | [] | All classnames of headgear that civilians may wear.
backpacks | [] | All classnames of backpacks that civilians may wear.
onSpawn | "" | Code to execute on civilian spawn. Passed parameters are: [civilian,vehicle (objNull if on foot)].
panicCooldown | [15,120,240] | Time it takes until a civilian relaxes after panicking (trivariate: [lowest, median, highest])
spawnDistancesInVehicles | [1500,6000] | Minimum and maximum distance to players that civilians in vehicles can spawn in.
spawnDistancesOnFoot | [1000,4500] | Minimum and maximum distance to players that civilians on foot can spawn in.
spawnDistancesResidents | [500, 1000] | Minimum and maximum distance to players that civilians living in houses spawn in.
vehicles | ["C_Van_01_fuel_F", "C_Hatchback_01_F", "C_Offroad_02_unarmed_F", "C_Truck_02_fuel_F", "C_Truck_02_covered_F", "C_Offroad_01_F", "C_SUV_01_F", "C_Van_01_transport_F", "C_Van_01_box_F"] | All classnames of vehicles that civilians may drive.
backpackProbability | 50 | Probability that a civilian will wear a backpack, in percent

### Example

Expand Down
2 changes: 0 additions & 2 deletions component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//#define DEBUG_MODE_FULL
#include "\x\cba\addons\main\script_macros_mission.hpp"

#define GRAD_CIVS_CIVCLASS "C_man_1"

#ifdef DEBUG_MODE_FULL

#define LOGTIME_START(var1) missionNamespace setVariable [var1,diag_tickTime]
Expand Down
2 changes: 1 addition & 1 deletion functions/common/fn_getGlobalCivs.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ params [

if (isNil "GRAD_CIVS_fnc_getGlobalCivs_arr") then {
// on first run, init array with existing civs
private _potentialCivs = entities [[GRAD_CIVS_CIVCLASS], [], true, true];
private _potentialCivs = entities [[GVAR(CIVCLASS)], [], true, true];
GRAD_CIVS_fnc_getGlobalCivs_arr = _potentialCivs select { (_x getVariable ["grad_civs_primaryTask", ""]) != ""};

// then, register event handler to update the array appropriately to always include all living civs
Expand Down
1 change: 1 addition & 0 deletions functions/init/fn_initConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if !(([missionConfigFile, "corpseManagerMode", -1] call BIS_fnc_returnConfigEntr

INFO("Civs initConfig running...");

if (isNil QGVAR(CIVCLASS)) then {missionNamespace setVariable [QGVAR(CIVCLASS),[missionConfigFile >> "cfgGradCivs","civClass","C_man_1"] call BIS_fnc_returnConfigEntry]};
if (isNil "GRAD_CIVS_CLOTHES") then {missionNamespace setVariable ["GRAD_CIVS_CLOTHES",[missionConfigFile >> "cfgGradCivs","clothes",[]] call BIS_fnc_returnConfigEntry]};
if (isNil "GRAD_CIVS_HEADGEAR") then {missionNamespace setVariable ["GRAD_CIVS_HEADGEAR",[missionConfigFile >> "cfgGradCivs","headgear",[]] call BIS_fnc_returnConfigEntry]};
if (isNil "GRAD_CIVS_FACES") then {missionNamespace setVariable ["GRAD_CIVS_FACES",[missionConfigFile >> "cfgGradCivs","faces",[]] call BIS_fnc_returnConfigEntry]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (random 10 < 9) exitWith {false};

private _neighborToMeet = {
private _maxDist = _x;
private _nearCivs = (_this nearEntities [[GRAD_CIVS_CIVCLASS], _maxDist]);
private _nearCivs = (_this nearEntities [[GVAR(CIVCLASS)], _maxDist]);
private _socialNeighbors = _nearCivs select {
(_x != _this) &&
(_x getVariable ["grad_civs_primaryTask", ""] == "reside") &&
Expand Down
2 changes: 1 addition & 1 deletion functions/spawn/fn_serverLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ grad_civs_debugLoop = [{
if (!hasInterface && !isDedicated) then {
[
{
private _allCivs = entities GRAD_CIVS_CIVCLASS;
private _allCivs = entities GVAR(CIVCLASS);
private _myCivs = _allCivs select { local _x && (_x getVariable ["grad_civs_primaryTask", ""] != "")};
private _orphanedCivs = _myCivs - GRAD_CIVS_LOCAL_CIVS;
INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs);
Expand Down
2 changes: 1 addition & 1 deletion functions/spawn/fn_spawnCivilian.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ params [
["_primaryTask", ""]
];

private _civ = _group createUnit [GRAD_CIVS_CIVCLASS, _pos, [], 0, "NONE"];
private _civ = _group createUnit [GVAR(CIVCLASS), _pos, [], 0, "NONE"];

GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS + [_civ];
[QGVAR(civ_added), [_civ]] call CBA_fnc_globalEvent;
Expand Down