Skip to content

Commit

Permalink
backpacks configurability
Browse files Browse the repository at this point in the history
  • Loading branch information
McDiod committed Apr 26, 2017
1 parent 99c2b6a commit 14ee7b1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
2 changes: 2 additions & 0 deletions functions/init/fn_initModule.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 6 additions & 0 deletions functions/init/fn_setBackpacks.sqf
Original file line number Diff line number Diff line change
@@ -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];
17 changes: 8 additions & 9 deletions functions/spawn/fn_dressAndBehave.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,26 @@ _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];

};

_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;
};
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grad-civs",
"description": "ambient civilians",
"version": "0.0.2",
"version": "0.0.3",
"contributors": [
{
"name": "nomisum"
Expand Down

0 comments on commit 14ee7b1

Please sign in to comment.