diff --git a/README.md b/README.md index c8205405..da5fc57d 100644 --- a/README.md +++ b/README.md @@ -35,19 +35,21 @@ Add the class `cfgGradCivs` to your `description.ext`. Use the following attribu ## Attributes -Attribute | Default Value | Explanation ----------------|---------------|--------------------------------------------------------------------- -autoInit | 1 | Toggles on automatic initialization of module on missions start (0/1). Turn this off if you want to use functions to set civs properties first. -maxCivs | 60 | Maximum number of civs that can exist at any time. -spawnDistances | [1000,4500] | Minimum and maximum distance to players that civilians can spawn in. -debugMode | 0 | Toggles debug mode (0/1). -onSpawn | "" | Code to execute on civilian spawn. Passed parameters are: [civilian]. -onHeldUp | "" | Code to execute when civilian stops because a weapon is pointed at him. Passed parameters are: [civilian]. -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. +Attribute | Default Value | Explanation +--------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------ +autoInit | 1 | Toggles on automatic initialization of module on missions start (0/1). Turn this off if you want to use functions to set civs properties first. +maxCivs | 60 | Maximum number of civs that can exist at any time. +spawnDistances | [1000,4500] | Minimum and maximum distance to players that civilians can spawn in. +debugMode | 0 | Toggles debug mode (0/1). +onSpawn | "" | Code to execute on civilian spawn. Passed parameters are: [civilian]. +onHeldUp | "" | Code to execute when civilian stops because a weapon is pointed at him. Passed parameters are: [civilian]. +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. +backpackProbability | 0.5 | Probability that a civilian will wear a backpack. ## Example @@ -128,6 +130,17 @@ Parameter | Explanation ----------|----------------------------------------------------------- headgear | Array - All classnames of clothes that civilians may wear. +## grad_civs_fnc_Backpacks +Sets all backpacks that civilians may wear and sets probability. Overwrites `cfgGradCivs` value. Effect is global. + +### Syntax +`[backpacks,probability] call grad_civs_fnc_setHeadgear` + +Parameter | Explanation +------------|----------------------------------------------------------------------- +backpacks | Array - All classnames of clothes that civilians may wear. +probability | Number - Probability that civilian will wear a backpack. Default: 0.5. + ## grad_civs_fnc_initModule Used to manually initialize module. Has to be executed on clients and server. Effect is local. diff --git a/cfgFunctions.hpp b/cfgFunctions.hpp index d4115f6d..729ddd5a 100644 --- a/cfgFunctions.hpp +++ b/cfgFunctions.hpp @@ -31,6 +31,7 @@ class GRAD_civs { file = MODULES_DIRECTORY\grad-civs\functions\init; class initModule {preInit = 1;}; + class setBackpacks {}; class setClothes {}; class setFaces {}; class setGoggles {}; diff --git a/functions/init/fn_initModule.sqf b/functions/init/fn_initModule.sqf index 95eea740..9ca736d6 100644 --- a/functions/init/fn_initModule.sqf +++ b/functions/init/fn_initModule.sqf @@ -9,6 +9,8 @@ if (isServer) then { if (isNil "GRAD_CIVS_HEADGEAR") then {missionNamespace setVariable ["GRAD_CIVS_HEADGEAR",[missionConfigFile >> "cfgGradCivs","headgear",[]] call BIS_fnc_returnConfigEntry,true]}; if (isNil "GRAD_CIVS_FACES") then {missionNamespace setVariable ["GRAD_CIVS_FACES",[missionConfigFile >> "cfgGradCivs","faces",[]] call BIS_fnc_returnConfigEntry,true]}; if (isNil "GRAD_CIVS_GOGGLES") then {missionNamespace setVariable ["GRAD_CIVS_GOGGLES",[missionConfigFile >> "cfgGradCivs","goggles",[]] call BIS_fnc_returnConfigEntry,true]}; + if (isNil "GRAD_CIVS_BACKPACKS") then {missionNamespace setVariable ["GRAD_CIVS_BACKPACKS",[missionConfigFile >> "cfgGradCivs","backpacks",[]] call BIS_fnc_returnConfigEntry,true]}; + if (isNil "GRAD_CIVS_BACKPACKPROBABILITY") then {missionNamespace setVariable ["GRAD_CIVS_BACKPACKPROBABILITY",[missionConfigFile >> "cfgGradCivs","backpackProbability",0.5] call BIS_fnc_returnConfigEntry,true]}; missionNamespace setVariable ["GRAD_CIVS_EXITON",compile ([missionConfigFile >> "cfgGradCivs","exitOn",""] call BIS_fnc_returnConfigEntry),true]; missionNamespace setVariable ["GRAD_CIVS_MAXCOUNT",[missionConfigFile >> "cfgGradCivs","maxCivs",""] call BIS_fnc_returnConfigEntry,true]; diff --git a/functions/init/fn_setBackpacks.sqf b/functions/init/fn_setBackpacks.sqf new file mode 100644 index 00000000..56cf27db --- /dev/null +++ b/functions/init/fn_setBackpacks.sqf @@ -0,0 +1,6 @@ +#include "..\..\component.hpp" + +params [["_value",[]],["_probability",0.5]]; + +missionNamespace setVariable ["GRAD_CIVS_BACKPACKS",_value,true]; +missionNamespace setVariable ["GRAD_CIVS_BACKPACKPROBABILITY",_value,true]; diff --git a/functions/spawn/fn_dressAndBehave.sqf b/functions/spawn/fn_dressAndBehave.sqf index db3a5016..c8cdf4c1 100644 --- a/functions/spawn/fn_dressAndBehave.sqf +++ b/functions/spawn/fn_dressAndBehave.sqf @@ -34,7 +34,9 @@ _reclotheHim = { _guy setUnitLoadout _loadout; - [[_guy, selectRandom GRAD_CIVS_FACES], "setCustomFace"] call BIS_fnc_MP; + if (count GRAD_CIVS_FACES > 0) then { + [[_guy, selectRandom GRAD_CIVS_FACES], "setCustomFace"] call BIS_fnc_MP; + }; _guy setVariable ["BIS_noCoreConversations", true]; }; @@ -42,19 +44,16 @@ _reclotheHim = { _addBeard = { params ["_guy"]; - _firstBeard = GRAD_CIVS_GOGGLES select 0; - // INFO_1("_trying to select beard %1", _firstBeard); - // add beards if possible - if (!(isClass (configfile >> "CfgGlasses" >> "TRYK_Beard"))) exitWith {}; - - _guy addGoggles selectRandom GRAD_CIVS_GOGGLES; + if (count GRAD_CIVS_GOGGLES > 0) then { + _guy addGoggles selectRandom GRAD_CIVS_GOGGLES; + }; }; _addBackpack = { params ["_unit"]; - if (random 2 > 1) then { - _unit addBackpackGlobal "rhs_sidor"; + if (random 100 <= GRAD_CIVS_BACKPACKPROBABILITY && {count GRAD_CIVS_BACKPACKS > 0}) then { + _unit addBackpackGlobal selectRandom GRAD_CIVS_BACKPACKS; }; }; diff --git a/package.json b/package.json index 7cd2bcc5..7a99b00f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grad-civs", "description": "ambient civilians", - "version": "0.0.2", + "version": "0.0.3", "contributors": [ { "name": "nomisum"