Skip to content

Commit

Permalink
Merge pull request #165 from ColinM9991/api-suggestions
Browse files Browse the repository at this point in the history
* add setter function to override civClasses
* add function to remove exclusion zone
  • Loading branch information
Fusselwurm authored Jul 29, 2022
2 parents ab49c37 + cc993ad commit 1dbbc6a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
48 changes: 43 additions & 5 deletions addons/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,51 @@ From existing Population Zones, subtract areas where civilian may *not* spawn.

## API

### `grad_civs_common_fnc_addExclusionZone` and `grad_civs_common_fnc_addPopulationZone`
## grad_civs_common_fnc_addPopulationZone

Whitelist areas or prevent civilians from spawning in areas (area = trigger area).
Whitelist areas to allow civilians to spawn in those areas (area = trigger area).

**Syntax**
```sqf
[_trigger, _civClasses, _vehicleClasses] call grad_civs_common_fnc_addPopulationZone
```

## grad_civs_common_fnc_addExclusionZone

Prevent civilians from being spawned in specific areas.

**Syntax**
```sqf
[_trigger] call grad_civs_common_fnc_addExclusionZone;
```

**Alternative syntax**
```sqf
[
[
[x, y, z], // Coordinates
150, // X Radius
150, // Y Radius
0, // Angle
false // True if area is Rectangle. False for Ellipse
]
] call grad_civs_common_fnc_addExclusionZone;
```

*known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.*

#### Syntax
## grad_civs_common_fnc_removeExclusionZone

Remove a zone from the exclusion list to allow civilians to spawn there again.

**Syntax**
```sqf
[_trigger] call grad_civs_common_fnc_removeExclusionZone
```

* `[_trigger, _civClasses, _vehicleClasses] call grad_civs_common_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_common_fnc_addExclusionZone`
* `[_trigger] call grad_civs_common_fnc_addExclusionZone;`
**Alternative syntax**
```sqf
[
[x, y, z] // Coordinates for an existing exclusion zone. X, Y and Z must be an exact match.
] call grad_civs_common_fnc_removeExclusionZone;
```
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ PREP(module_populationZone);
PREP(nowPlusSeconds);
PREP(parseCsv);
PREP(registerCivTaskType);
PREP(removeExclusionZone);
15 changes: 15 additions & 0 deletions addons/common/functions/fnc_removeExclusionZone.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "..\script_component.hpp"

params ["_area"];

ISNILS(GVAR(EXCLUSION_ZONES), []);

private _zoneIdx = GVAR(EXCLUSION_ZONES) findIf {
_area isEqualTo (if(_x isEqualType []) then [{_x#0}, {_x}]);
};

if(_zoneIdx isEqualTo -1) exitWith{};

GVAR(EXCLUSION_ZONES) deleteAt _zoneIdx;

INFO_1("removed exclusion zone %1", _area);
17 changes: 16 additions & 1 deletion addons/lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ Controls all spawning & despawning of civilians, as well as incapacitation & dea

## API

### Events
## grad_civs_lifecycle_fnc_setCivilians

Sets the classnames that civilians will spawn as. Overwrites value from CBA settings. Execute globally

#### Example

```sqf
private _civClasses = ["C_Man_01"];
[_civClasses] call grad_civs_lifecycle_fnc_setCivilians
```

Parameter | Explanation
------------|-------------------------------------------------------------
civClasses | Array - All classnames that civilians will spawn as.

## Events

**NOTE:** event names are prefixed with `grad_civs_lifecycle_`

Expand Down
1 change: 1 addition & 0 deletions addons/lifecycle/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PREP(globalSpawnPass);
PREP(initHCs);
PREP(isInDistanceFromOtherPlayers);
PREP(overclockStateMachines);
PREP(setCivilians);
PREP(sm_lifecycle);
PREP(sm_lifecycle_state_death_enter);
PREP(sm_lifecycle_state_despawn_enter);
Expand Down
9 changes: 9 additions & 0 deletions addons/lifecycle/functions/fnc_setCivilians.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "..\script_component.hpp"

params [
["_value",[], [[]]] // array of civilian unit class names
];

assert(_value isEqualTypeAll "");

[QGVAR(civClasses), str _value, 1, "mission"] call CBA_settings_fnc_set;

0 comments on commit 1dbbc6a

Please sign in to comment.