Skip to content

Commit

Permalink
config values "civClass" replaces #define GRAD_CIVS_CIVCLASS (#48)
Browse files Browse the repository at this point in the history
* configurable civ class replaces `#define`
* sort config values in README
  • Loading branch information
Fusselwurm authored Mar 14, 2020
1 parent 5a28bad commit e2c51ce
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
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

0 comments on commit e2c51ce

Please sign in to comment.