diff --git a/.github/workflows/ace_sqf_validator.yml b/.github/workflows/ace_sqf_validator.yml new file mode 100644 index 00000000..76be5d2b --- /dev/null +++ b/.github/workflows/ace_sqf_validator.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: ACE SQF validator + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + wget https://raw.githubusercontent.com/acemod/ACE3/b181fa6013d30a06b310b367caa5039435b085d0/tools/sqf_validator.py + sed -i '117d' sqf_validator.py + sed -i '116d' sqf_validator.py + sed -i '115d' sqf_validator.py + - name: Lint + run: | + python3 sqf_validator.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b4f44e4f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI + +on: [push, pull_request] + +jobs: + hemtt: + name: HEMTT + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Build with HEMTT + uses: gruppe-adler/action-release-with-hemtt@1.1.3 + id: build + + - name: Upload artifact + uses: actions/upload-artifact@1.0.0 + with: + name: 'grad_civs' + path: ${{ steps.build.outputs.zip_path }} diff --git a/.github/workflows/sqflint.yml b/.github/workflows/sqflint.yml new file mode 100644 index 00000000..ac2379f7 --- /dev/null +++ b/.github/workflows/sqflint.yml @@ -0,0 +1,27 @@ +name: SQF linting (LordGolias/sqf) + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install sqflint + run: | + python -m pip install --upgrade pip + python -m pip install https://github.com/gruppe-adler/sqf/archive/0f6edf0d7b928afc8783ccad3c3c7cb7120feb1a.tar.gz + - name: Lint with + run: | + sqflint -d . -e e + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..33e26434 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.pbo +releases/* +*.biprivatekey +keys/* +.hemtt/local + diff --git a/.npmignore b/.npmignore deleted file mode 100644 index d8e616b1..00000000 --- a/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -docs/ -.idea -.git diff --git a/README.md b/README.md index 4b6fc534..02359fcd 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,20 @@ Spawn ambient civilians on the map. ## Features -* civilians patrol and drive around the country, alone and in small groups -* stop and raise their hands when threatened with weapons -* vehicles will stop when you gesture at them (ACE 'hold' gesture) -* ACE interactions: "back up vehicle", "carry on" +* automatically populate the map with civilians +* dedicated to + * doing foot patrols + * driving around the country + * living in houses (that they leave only to visit their neighbors) +* everything is automatically offloaded to Headless Clients (if available) +* interactions with players: + * stop and raise their hands when threatened with weapons + * vehicles will stop when you gesture at them (ACE 'hold' gesture) + * ACE interactions: "back up vehicle", "carry on" + * will move out of player's way when getting honked at * will panic and flee in firefights -* will move out of player's way when getting honked at -* civilian players will get hints as to what a "grad-civ" civilian would notice (like, being pointed at with a gun, told to go away by ACE interact, ...) -* civilians get assigned homes +* civilian *players* get visual aids when trying to pose as AI civilians (like, if they're being pointed at with a gun, told to go away by ACE interact, ...) + ## Dependencies @@ -21,42 +27,24 @@ Spawn ambient civilians on the map. * [ACE3](https://github.com/acemod/ACE3) ## Installation -### Manually -1. Create a folder in your mission root folder and name it `modules`. Then create one inside there and call it `grad-civs`. -2. Download the contents of this repository ( there's a download link at the side ) and put it into the directory you just created. -3. Append the following lines of code to the `description.ext`: - -```sqf -class CfgFunctions { - #include "modules\grad-civs\cfgFunctions.hpp" -}; -``` +*It's a mod now, baby!* -### Via `npm` -_for details about what npm is and how to use it, look it up on [npmjs.com](https://www.npmjs.com/)_ - -1. Install package `grad-civs` : `npm install --save grad-civs` -2. Prepend your mission's `description.ext` with `#define MODULES_DIRECTORY node_modules` -3. Append the following lines of code to the `description.ext`: - -```sqf -class CfgFunctions { - #include "node_modules\grad-civs\cfgFunctions.hpp" -}; -``` +Do grab a zip file from the releases page, or look it up on the Steam Workshop where it may or may not appear sometime. ## Usage Notes -To avoid micro lags / fps dips on the server, it is recommended to add a headless client (no configuration needed for that). +To avoid micro lags / fps dips on the server, it is recommended to add a headless client to your scenarios. -If that is not possible, civilian group size (looking at you, [Ikraus 260](https://de.wikipedia.org/wiki/Ikarus_260)!) as well as total population count should be kept small. +If that is not possible, civilian group size (looking at you, [Ikarus 260](https://de.wikipedia.org/wiki/Ikarus_260)!) as well as total population count should be kept small. Civilians on separate islands can run into pathing problems. Avoid by creating exclusion zones. - ## Config -Add the class `cfgGradCivs` to your `description.ext`. Use the following attributes to configure the module: + +Settings can be found as CBA Addon settings. + +![settings](docs/grad_civs-cba_settings.png) ### Attributes @@ -92,80 +80,31 @@ spawnDistancesOnFoot | [1000,4500] | Minimum and maximum distance to playe 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. -### Example - -```sqf -class CfgGradCivs { - autoInit = 1; - maxCivsOnFoot = 20; - maxCivsResidents = 30; - maxCivsInVehicles = 10; - spawnDistancesOnFoot[] = {1000,4500}; - spawnDistancesInVehicles[] = {1000,4500}; - debugCivState = 0; - debugFps = 0; - minCivUpdateTime = 3; - minFps = 35; - automaticVehicleGroupSize = 1; - exitOn = ""; - onSpawn = "systemChat format ['%1 spawned', typeOf (_this select 0)];"; - onHeldUp = ""; - backpackProbability = 0.5; - - clothes[] = { - "rds_uniform_Worker1", - "rds_uniform_Worker2" - }; - - headgear[] = { - "rds_Villager_cap1", - "rds_Villager_cap2" - }; - - faces[] = { - "PersianHead_A3_01", - "PersianHead_A3_02", - "PersianHead_A3_03" - }; - - goggles[] = { - "TRYK_Beard_BK", - "TRYK_Beard_BK2", - "TRYK_Beard_BK3" - }; - - backpacks[] = { - "rhs_sidor" - }; -}; -``` - -## Functions +## API -All functions meant for use from outside sit in the `/functions/api` directory. +### grad_civs_legacy_fnc_doCustomActivity -### grad_civs_fnc_doCustomActivity +To let civilians break from their usual activity and do something else for a limited time. -To let civilians break from their usual activity and do something else: +Example: ``` [ - _civ, // _civilian - { _this#0 setBehaviour "STEALTH" }, // _doStart - { _this#0 setBehaviour "CARELESS" },// _doEnd - 600, // _timeout or _endCondition - [], // _moreParameters - "hiding", // _id - "pooped my pants, hiding for ten minutes" // self-description -] call grad_civs_fnc_doCustomActivity; + _civ, + { _this#0 setBehaviour "STEALTH" }, + { _this#0 setBehaviour "CARELESS" }, + 600, + [], + "hiding", + "pooped my pants, hiding for ten minutes" +] call grad_civs_legacy_fnc_doCustomActivity; ``` **NOTE**: this whole thing will *NOT* work while they are panicking. **NOTE**: do clean up after yourself in the `_doEnd` parameter. reset disableAI stuff etc! -#### Syntax -`[civ, doStart, doEnd, timeoutOrCondition, moreParameters, name, description] call grad_civs_fnc_setFaces` +#### Parameters Parameter | Explanation --------------------|----------------------------------------------------------- @@ -177,123 +116,96 @@ moreParameters | array (optional) - more parameters to be passed to doStart name | string (optional) - behavior name description | string (optional) - behavior description -### grad_civs_fnc_setClothes -Sets all clothes that civilians may wear. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_loadout_fnc_setClothes + +Sets all clothes that civilians may wear. Overwrites value from CBA settings. Execute globally #### Syntax -`[clothes] call grad_civs_fnc_setClothes` +`[clothes] call grad_civs_loadout_fnc_setClothes` Parameter | Explanation ----------|----------------------------------------------------------- clothes | Array - All classnames of clothes that civilians may wear. -### grad_civs_fnc_setFaces -Sets all faces that civilians may have. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_loadout_fnc_setFaces +Sets all faces that civilians may have. Overwrites value from CBA settings. Execute globally #### Syntax -`[faces] call grad_civs_fnc_setFaces` +`[faces] call grad_civs_loadout_fnc_setFaces` Parameter | Explanation ----------|--------------------------------------------------------- faces | Array - All classnames of faces that civilians may have. -### grad_civs_fnc_setGoggles -Sets all goggles that civilians may wear. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_loadout_fnc_setGoggles +Sets all goggles that civilians may wear. Overwrites value from CBA settings. Execute globally #### Syntax -`[goggles] call grad_civs_fnc_setGoggles` +`[goggles] call grad_civs_loadout_fnc_setGoggles` Parameter | Explanation ----------|----------------------------------------------------------- goggles | Array - All classnames of goggles that civilians may wear. -### grad_civs_fnc_setHeadgear -Sets all headgear that civilians may wear. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_loadout_fnc_setHeadgear +Sets all headgear that civilians may wear. Overwrites value from CBA settings. Execute globally #### Syntax -`[headgear] call grad_civs_fnc_setHeadgear` +`[headgear] call grad_civs_loadout_fnc_setHeadgear` Parameter | Explanation ----------|----------------------------------------------------------- headgear | Array - All classnames of clothes that civilians may wear. -### grad_civs_fnc_setBackpacks -Sets all backpacks that civilians may wear and sets probability. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_loadout_fnc_setBackpacks +Sets all backpacks that civilians may wear and sets probability. Overwrites value from CBA settings. Execute globally #### Syntax -`[backpacks,probability] call grad_civs_fnc_setHeadgear` +`[backpacks,probability] call grad_civs_legacy_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_setVehicles -Sets all vehicles that civilians may drive. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_voyage_fnc_setVehicles +Sets all vehicles that civilians may drive. Overwrites value from CBA settings. Execute globally #### Syntax -`[vehicles] call grad_civs_fnc_setVehicles` +`[vehicles] call grad_civs_voyage_fnc_setVehicles` Parameter | Explanation ----------|------------------------------------------------------------- vehicles | Array - All classnames of vehicles that civilians may drive. -### grad_civs_fnc_setDebugMode -Sets debug mode. Overwrites `cfgGradCivs` value. Effect is global. +### grad_civs_legacy_fnc_setDebugMode +Sets debug mode. Overwrites value from CBA settings. Execute local. #### Syntax -`[debugCivState] call grad_civs_fnc_setDebugMode` +`[debugCivState] call grad_civs_legacy_fnc_setDebugMode` Parameter | Explanation --------------|-------------------------- debugCivState | Bool - Debug mode on/off. -### grad_civs_fnc_initModule -Used to manually initialize module. Has to be executed on all machines. Effect is local. - -#### Syntax -`[] call grad_civs_fnc_initModule` -`[] remoteExec ["grad_civs_fnc_initModule",0,true]` - -Parameter | Explanation -----------|----------------------------------------------------------- -headgear | Array - All classnames of clothes that civilians may wear. - -### grad_civs_fnc_populateArea -Manually populates an area with civilians. These civilians count towards the maximum amount. - -*probably horribly broken right now, dont rely on* - -#### Syntax -`[area,amount,excludeFromCleanup,staticVehicles,staticVehiclesMax] call grad_civs_fnc_populateArea` - -Parameter | Explanation -------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------- -area | Array / Object - Area array in format `[a, b, angle, isRectangle]` or array of area arrays or gamelogic synchronzed to one or multiple triggers. -amount | Number - Amount of civilians to spawn. -excludeFromCleanup (optional) | Bool - Sets if these civilians will be excluded from cleanup when no players are near. (default: true) -staticVehicles (optional) | Bool - Sets if static vehicles will be created in the area. (default: false) -staticVehiclesMax (optional) | Number - Maximum amount of static vehicles to create. Actual amount is based on number of roads and houses in area. - - -![](http://i.imgur.com/Cimaz4c.jpg) -### grad_civs_fnc_addExclusionZone and grad_civs_fnc_addPopulationZone +### grad_civs_legacy_fnc_addExclusionZone and grad_civs_legacy_fnc_addPopulationZone Prevent civilians from entering areas. -Optionally whitelist areas using `[_area] call grad_civs_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_fnc_addExclusionZone` . +Optionally whitelist areas using `[_area] call grad_civs_legacy_fnc_addPopulationZone` , then forbid parts of them using `[_area] call grad_civs_legacy_fnc_addExclusionZone` . *known issues: pathing through area is not checked. To minimize that problem, define exclusionZones with large diameter.* #### Syntax -`[_trigger] call grad_civs_fnc_addExclusionZone;` +`[_trigger] call grad_civs_legacy_fnc_addExclusionZone;` ## Development -* we're using the CBA state machine implementation, see `/functions/sm_*/` +* we're using the CBA state machine implementation, see `addons/*/functions/sm_*/` +* there's also some extensions being done to the CBA state machnie implementation to allow for nested states and other shenanigans, see addons/cba_statemachine * if you add states or transitions, please update the DOT files in `/docs` * which is where you'll find the compiled SVG files, too. * install [Graphviz](https://graphviz.gitlab.io/) and generate them using `dot -Tsvg states.gv > states.svg` or use an online editor @@ -315,9 +227,9 @@ Let's have a very simple example: ```sqf MY_CIV_LIST = ["C_Offroad_01_F" createVehicle position player]; _machine = [{MY_CIV_LIST}] call CBA_statemachine_fnc_create; -_state_init = [_machine, { diag_log "init"; }, { diag_log "onEnter_init" }, { diag_log "onExit_init" }] call grad_civs_fnc_addState; -_state_stuff = [_machine, {diag_log "wörk" }, {diag_log "onEnter_wörk"}, {}] call grad_civs_fnc_addState; -_transition = [_machine, _state_init, _state_stuff, {CBA_missionTime > 30}, {diag_log "changing state" }] call grad_civs_fnc_addTransition; +_state_init = [_machine, { diag_log "init"; }, { diag_log "onEnter_init" }, { diag_log "onExit_init" }] call grad_civs_legacy_fnc_addState; +_state_stuff = [_machine, {diag_log "wörk" }, {diag_log "onEnter_wörk"}, {}] call grad_civs_legacy_fnc_addState; +_transition = [_machine, _state_init, _state_stuff, {CBA_missionTime > 30}, {diag_log "changing state" }] call grad_civs_legacy_fnc_addTransition; ``` this will print something like this to RPT: @@ -340,12 +252,12 @@ wörk In our case, and with CBA state machines, that means: * we have a bunch of state machines, chief of which is the *activities* state machine. It is implemented in `/functions/sm_activities/fn_activities.sqf` -* states are added to it using [grad_civs_fnc_addState](https://cbateam.github.io/CBA_A3/docs/files/statemachine/fnc_addState-sqf.html) . +* states are added to it using [grad_civs_legacy_fnc_addState](https://cbateam.github.io/CBA_A3/docs/files/statemachine/fnc_addState-sqf.html) . * every state has a bunch of callbacks that are called with a civilian as parameter * one is called periodically as long as the civ is in the state * one is called when the civ enters the state * one is called when the civ leaves the state -* transitions are being added by using [grad_civs_fnc_addTransition](https://cbateam.github.io/CBA_A3/docs/files/statemachine/fnc_addTransition-sqf.html) (or fnc_addEventTransition for transitions triggered by CBA events) +* transitions are being added by using [grad_civs_legacy_fnc_addTransition](https://cbateam.github.io/CBA_A3/docs/files/statemachine/fnc_addTransition-sqf.html) (or fnc_addEventTransition for transitions triggered by CBA events) * every transition is defined as a one-way connection between two states * every transition gets two callbacks * one is called periodically to check whether a civ can move along the transition diff --git a/addons/cba_statemachine/$PBOPREFIX$ b/addons/cba_statemachine/$PBOPREFIX$ new file mode 100644 index 00000000..9a0f49b3 --- /dev/null +++ b/addons/cba_statemachine/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\cba_statemachine diff --git a/addons/cba_statemachine/CfgEventHandlers.hpp b/addons/cba_statemachine/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/cba_statemachine/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/cba_statemachine/XEH_PREP.hpp b/addons/cba_statemachine/XEH_PREP.hpp new file mode 100644 index 00000000..a33928e3 --- /dev/null +++ b/addons/cba_statemachine/XEH_PREP.hpp @@ -0,0 +1,6 @@ +PREP(addCompoundState); +PREP(addState); +PREP(addToStateMachine); +PREP(addTransition); +PREP(getCurrentState); +PREP(removeFromStateMachine); diff --git a/addons/cba_statemachine/XEH_postInit.sqf b/addons/cba_statemachine/XEH_postInit.sqf new file mode 100644 index 00000000..6eccf9d1 --- /dev/null +++ b/addons/cba_statemachine/XEH_postInit.sqf @@ -0,0 +1,2 @@ +#include "script_component.hpp" + diff --git a/addons/cba_statemachine/XEH_preInit.sqf b/addons/cba_statemachine/XEH_preInit.sqf new file mode 100644 index 00000000..b47cf662 --- /dev/null +++ b/addons/cba_statemachine/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/addons/cba_statemachine/config.cpp b/addons/cba_statemachine/config.cpp new file mode 100644 index 00000000..39bf3f1a --- /dev/null +++ b/addons/cba_statemachine/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/functions/statemachine/fn_addCompoundState.sqf b/addons/cba_statemachine/functions/fnc_addCompoundState.sqf similarity index 90% rename from functions/statemachine/fn_addCompoundState.sqf rename to addons/cba_statemachine/functions/fnc_addCompoundState.sqf index 20209f70..bfa60284 100644 --- a/functions/statemachine/fn_addCompoundState.sqf +++ b/addons/cba_statemachine/functions/fnc_addCompoundState.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" #define NESTED(var) (var + "_nested") #define COMPOUNDONSTATEENTERED(var) (var + "_onCompoundStateEntered") @@ -27,7 +27,7 @@ private _wrappedOnStateEntered = { _this call _origOnStateEntered; { - [_this, _x] call grad_civs_fnc_addToStateMachine; + [_this, _x] call FUNC(addToStateMachine); } forEach _nestedStateMachines; }; @@ -37,13 +37,13 @@ private _wrappedOnStateLeaving = { private _nestedStateMachines = _stateMachine getVariable [NESTED(_thisState), []]; { - [_this, _x] call grad_civs_fnc_removeFromStateMachine; + [_this, _x] call FUNC(removeFromStateMachine); } forEach _nestedStateMachines; _this call _origOnStateLeaving; }; -private _state = [_outerStateMachine, _onState, _wrappedOnStateEntered, _wrappedOnStateLeaving, _name] call grad_civs_fnc_addState; +private _state = [_outerStateMachine, _onState, _wrappedOnStateEntered, _wrappedOnStateLeaving, _name] call FUNC(addState); if (_state == "") exitWith {ERROR_1("could not add state", _name); ""}; diff --git a/functions/statemachine/fn_addState.sqf b/addons/cba_statemachine/functions/fnc_addState.sqf similarity index 98% rename from functions/statemachine/fn_addState.sqf rename to addons/cba_statemachine/functions/fnc_addState.sqf index 83b631c8..d2f5d601 100644 --- a/functions/statemachine/fn_addState.sqf +++ b/addons/cba_statemachine/functions/fnc_addState.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" #define TIMEDONSTATEENTERED(var) (var + "_onTimedStateEntered") #define TIMEDONSTATELEAVING(var) (var + "_onTimedStateLeaving") diff --git a/functions/statemachine/fn_addToStateMachine.sqf b/addons/cba_statemachine/functions/fnc_addToStateMachine.sqf similarity index 88% rename from functions/statemachine/fn_addToStateMachine.sqf rename to addons/cba_statemachine/functions/fnc_addToStateMachine.sqf index fb635a64..fb2c9b47 100644 --- a/functions/statemachine/fn_addToStateMachine.sqf +++ b/addons/cba_statemachine/functions/fnc_addToStateMachine.sqf @@ -1,3 +1,4 @@ +#include "..\script_component.hpp" params [ ["_listItem", objNull, [missionNamespace, objNull, grpNull, teamMemberNull, taskNull, locationNull]], diff --git a/functions/statemachine/fn_addTransition.sqf b/addons/cba_statemachine/functions/fnc_addTransition.sqf similarity index 97% rename from functions/statemachine/fn_addTransition.sqf rename to addons/cba_statemachine/functions/fnc_addTransition.sqf index c67f91ba..4e4d5c07 100644 --- a/functions/statemachine/fn_addTransition.sqf +++ b/addons/cba_statemachine/functions/fnc_addTransition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" #define TIMEDTRANSITIONCONDITION(var) (var + "_onTimedTransitionCondition") #define TIMEDTRANSITIONHANDLER(var) (var + "_onTimedTransitionHandler") diff --git a/functions/common/fn_getCurrentState.sqf b/addons/cba_statemachine/functions/fnc_getCurrentState.sqf similarity index 96% rename from functions/common/fn_getCurrentState.sqf rename to addons/cba_statemachine/functions/fnc_getCurrentState.sqf index eb310a73..b80ca124 100644 --- a/functions/common/fn_getCurrentState.sqf +++ b/addons/cba_statemachine/functions/fnc_getCurrentState.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" /* ---------------------------------------------------------------------------- Function: CBA_statemachine_fnc_getCurrentState diff --git a/functions/common/fn_removeFromStateMachine.sqf b/addons/cba_statemachine/functions/fnc_removeFromStateMachine.sqf similarity index 91% rename from functions/common/fn_removeFromStateMachine.sqf rename to addons/cba_statemachine/functions/fnc_removeFromStateMachine.sqf index 609064b4..6b950799 100644 --- a/functions/common/fn_removeFromStateMachine.sqf +++ b/addons/cba_statemachine/functions/fnc_removeFromStateMachine.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_listItem", objNull, [missionNamespace, objNull, grpNull, teamMemberNull, taskNull, locationNull]], ["_stateMachine", locationNull] diff --git a/addons/cba_statemachine/script_component.hpp b/addons/cba_statemachine/script_component.hpp new file mode 100644 index 00000000..9b5b83f6 --- /dev/null +++ b/addons/cba_statemachine/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT cba_statemachine +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/common/$PBOPREFIX$ b/addons/common/$PBOPREFIX$ new file mode 100644 index 00000000..9e3ab875 --- /dev/null +++ b/addons/common/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\common diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/common/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp new file mode 100644 index 00000000..811e9948 --- /dev/null +++ b/addons/common/XEH_PREP.hpp @@ -0,0 +1,2 @@ +PREP(registerCivTaskType); +PREP(civGetState); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf new file mode 100644 index 00000000..5961e0a4 --- /dev/null +++ b/addons/common/XEH_postInit.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf new file mode 100644 index 00000000..b47cf662 --- /dev/null +++ b/addons/common/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/addons/common/config.cpp b/addons/common/config.cpp new file mode 100644 index 00000000..6a47f0e8 --- /dev/null +++ b/addons/common/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"A3_Modules_F", "CBA_Extended_EventHandlers", "grad_civs_main"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/common/functions/fnc_civGetState.sqf b/addons/common/functions/fnc_civGetState.sqf new file mode 100644 index 00000000..2099ffc2 --- /dev/null +++ b/addons/common/functions/fnc_civGetState.sqf @@ -0,0 +1,12 @@ +#include "..\script_component.hpp" + +params [ + ["_civ", objNull, [objNull]], + ["_smName", "", [""]] +]; + +private _sm = EGVAR(common,stateMachines) getVariable [_smName, locationNull]; + +assert(!isNull _sm); + +[_civ, _sm, ""] call EFUNC(cba_statemachine,getCurrentState); diff --git a/addons/common/functions/fnc_registerCivTaskType.sqf b/addons/common/functions/fnc_registerCivTaskType.sqf new file mode 100644 index 00000000..6e667baa --- /dev/null +++ b/addons/common/functions/fnc_registerCivTaskType.sqf @@ -0,0 +1,15 @@ +#include "..\script_component.hpp" + +params [ + ["_type", "", [""]], + ["_cleanupDistance", 99999, [0]], + ["_despawnCondition", {false}, [{}]] +]; + +ISNILS(GVAR(civTaskTypes), call CBA_fnc_createNamespace); + +if (_type in (allVariables GVAR(civTaskTypes))) exitWith { + ERROR_1("civTaskType %1 has already been registered", _type); +}; + +GVAR(civTaskTypes) setVariable [_type, [_cleanupDistance, _despawnCondition]]; diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp new file mode 100644 index 00000000..65790baf --- /dev/null +++ b/addons/common/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT common +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/legacy/$PBOPREFIX$ b/addons/legacy/$PBOPREFIX$ new file mode 100644 index 00000000..bc2645ed --- /dev/null +++ b/addons/legacy/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\legacy diff --git a/addons/legacy/CfgEventHandlers.hpp b/addons/legacy/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/legacy/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/legacy/CfgVehicles.hpp b/addons/legacy/CfgVehicles.hpp new file mode 100644 index 00000000..f8875b10 --- /dev/null +++ b/addons/legacy/CfgVehicles.hpp @@ -0,0 +1,57 @@ +class CfgVehicles +{ + class Logic; + class Module_F: Logic { + class AttributesBase { + class Default; + class ModuleDescription; + class Units; + }; + // Description base classes, for more information see below + class ModuleDescription { + + }; + }; + class GVAR(addPopulationZone): Module_F + { + scope = 2; // visible in editor + displayName = "add population zone"; + icon = ""; // Map icon. Delete this entry to use the default icon + category = QEGVAR(main,modules); + + // Name of function triggered once conditions are met + function = QFUNC(module_addPopulationZone); + functionPriority = 0; // first to execute + isGlobal = 1; + isTriggerActivated = 0; + isDisposable = 1; // doesnt get activated repeatably + is3DEN = 1; + + // Module description. Must inherit from base class, otherwise pre-defined entities won't be available + class ModuleDescription: ModuleDescription + { + description = "GRAD civs : add population zone where civilians may spawn and live."; // Short description, will be formatted as structured text + }; + }; + class GVAR(addExclusionZone): Module_F + { + scope = 2; // visible in editor + displayName = "add exclusion zone"; + icon = ""; // Map icon. Delete this entry to use the default icon + category = QEGVAR(main,modules); + + // Name of function triggered once conditions are met + function = QFUNC(module_addExclusionZone); + functionPriority = 0; // first to execute + isGlobal = 1; + isTriggerActivated = 0; + isDisposable = 1; // doesnt get activated repeatably + is3DEN = 1; + + // Module description. Must inherit from base class, otherwise pre-defined entities won't be available + class ModuleDescription: ModuleDescription + { + description = "GRAD civs : add exclusion zone that civilians are prevented from entering"; // Short description, will be formatted as structured text + }; + }; +}; diff --git a/addons/legacy/XEH_PREP.hpp b/addons/legacy/XEH_PREP.hpp new file mode 100644 index 00000000..1ba52fd1 --- /dev/null +++ b/addons/legacy/XEH_PREP.hpp @@ -0,0 +1,98 @@ +PREP(addCivInteractions); +PREP(addExclusionZone); +PREP(addPopulationZone); +PREP(arrayContains); +PREP(checkHonkingOnCivilian); +PREP(checkWeaponOnCivilianPerception); +PREP(checkWeaponOnCivilianPointer); +PREP(clearCurrentlyThinking); +PREP(clearExclusionZones); +PREP(clearPopulationZones); +PREP(compare); +PREP(customActivity_reverse); +PREP(deleteIfDamaged); +PREP(doCustomActivity); +PREP(drawCivs); +// PREP(feelsAddressedByGesture.spec); +PREP(feelsAddressedByGesture); +PREP(findBuildings); +PREP(findPositionOfInterest); +PREP(findRandomPosArea); +PREP(findRandomPos); +// PREP(findSpawnPosition.spec); +PREP(findSpawnPosition); +PREP(findUnclaimedHouse); +PREP(forceEmotionSpeed); +PREP(forcePanicSpeed); +PREP(formatNowPlusSeconds); +PREP(getCurrentlyThinking); +PREP(getExclusionZones); +PREP(getGlobalCivs); +PREP(getPopulationZones); +PREP(handleAnimation); +PREP(handleGestureGo); +PREP(handleGestureStop); +PREP(initCommonEventhandlers); +PREP(initConfig); +PREP(initHCs); +PREP(initPlayer); +PREP(interact_backUpAction); +PREP(interact_backUpCondition); +PREP(interact_carryOnAction); +PREP(interact_carryOnCondition); +PREP(isInDistanceFromOtherPlayers); +PREP(isInHouse); +PREP(isInPopulatedZone); +PREP(isPlayerHonking); +PREP(mapMarkers); +PREP(nowPlusSeconds); +PREP(playerLoop); +PREP(reverse_abort); +PREP(reverse_internal_end); +PREP(reverse_internal_pfh); +PREP(reverse_internal_stopCondition); +// PREP(reverse.spec); +PREP(reverse); +PREP(serverLoop); +PREP(setCurrentlyThinking); +PREP(setDebugMode); +PREP(setupZeusModules); +PREP(showWhatTheyThink); +PREP(sm_activities_helper_freeCondition); +PREP(sm_activities_helper_surrenderCondition); +PREP(sm_activities); +PREP(sm_activities_state_asOrdered_enter); +PREP(sm_activities_state_asOrdered_exit); +PREP(sm_activities_state_panic_enter); +PREP(sm_activities_state_panic_exit); +PREP(sm_activities_state_surrendered_enter); +PREP(sm_activities_state_surrendered_exit); +PREP(sm_activities_trans_business_panic_condition); +PREP(sm_activities_trans_business_surrendered_condition); +PREP(sm_activities_trans_dismount_surrendered_condition); +PREP(sm_activities_trans_surrendered_business_condition); +PREP(sm_activities_trans_surrendered_panic_condition); +PREP(sm_business); +PREP(sm_business_state_rally_enter); +PREP(sm_business_state_rally_loop); +PREP(sm_emotions); +PREP(sm_lifecycle); +PREP(sm_lifecycle_state_death_enter); +PREP(sm_lifecycle_state_despawn_enter); +PREP(sm_lifecycle_state_life_enter); +PREP(sm_lifecycle_state_life_exit); +PREP(sm_lifecycle_state_spawn_enter); +PREP(sm_lifecycle_trans_life_despawn_condition); +PREP(sm_panic); +PREP(sm_panic_state_flight_enter); +PREP(sm_panic_state_flight_loop); +PREP(sm_panic_state_hidden_enter); +PREP(sm_panic_state_hide_enter); +PREP(sm_panic_state_hide_exit); +PREP(sm_panic_trans_hide_hidden_condition); +PREP(sm_panic_trans_hide_hidden_handler); +PREP(spawnCivilianGroup); +PREP(spawnCivilian); +PREP(spawnPass); +PREP(uid); +PREP(updateInfoLine); diff --git a/addons/legacy/XEH_postInit.sqf b/addons/legacy/XEH_postInit.sqf new file mode 100644 index 00000000..717e8100 --- /dev/null +++ b/addons/legacy/XEH_postInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("grad_civs is disabled. good bye."); +}; + +[] call FUNC(initCommonEventhandlers); +[] call FUNC(initHCs); +[] call FUNC(initPlayer); diff --git a/addons/legacy/XEH_preInit.sqf b/addons/legacy/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/legacy/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/legacy/config.cpp b/addons/legacy/config.cpp new file mode 100644 index 00000000..c52feb44 --- /dev/null +++ b/addons/legacy/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers", "grad_civs_main", "grad_civs_common", "grad_civs_cba_statemachine"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/functions/player/fn_addCivInteractions.sqf b/addons/legacy/functions/fnc_addCivInteractions.sqf similarity index 83% rename from functions/player/fn_addCivInteractions.sqf rename to addons/legacy/functions/fnc_addCivInteractions.sqf index 46df44e2..c35e78d3 100644 --- a/functions/player/fn_addCivInteractions.sqf +++ b/addons/legacy/functions/fnc_addCivInteractions.sqf @@ -1,4 +1,6 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" + +private _civClass = [QGVAR(civClass)] call CBA_settings_fnc_get; private _carryOnAction = [ QGVAR(carryOnAction), @@ -8,7 +10,7 @@ private _carryOnAction = [ FUNC(interact_carryOnCondition) ] call ace_interact_menu_fnc_createAction; [ - GVAR(CIVCLASS), + _civClass, 0, ["ACE_MainActions"], _carryOnAction, @@ -23,7 +25,7 @@ private _backUpAction = [ FUNC(interact_backUpCondition) ] call ace_interact_menu_fnc_createAction; [ - GVAR(CIVCLASS), + _civClass, 0, ["ACE_MainActions"], _backUpAction, diff --git a/functions/api/fn_addExclusionZone.sqf b/addons/legacy/functions/fnc_addExclusionZone.sqf similarity index 60% rename from functions/api/fn_addExclusionZone.sqf rename to addons/legacy/functions/fnc_addExclusionZone.sqf index e458a9ee..33f83012 100644 --- a/functions/api/fn_addExclusionZone.sqf +++ b/addons/legacy/functions/fnc_addExclusionZone.sqf @@ -1,7 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_area"]; +ISNILS(GVAR(EXCLUSION_ZONES), []); GVAR(EXCLUSION_ZONES) pushBackUnique _area; INFO_1("added exclusion zone %1", _area); diff --git a/functions/api/fn_addPopulationZone.sqf b/addons/legacy/functions/fnc_addPopulationZone.sqf similarity index 59% rename from functions/api/fn_addPopulationZone.sqf rename to addons/legacy/functions/fnc_addPopulationZone.sqf index 1930a370..5c089bc4 100644 --- a/functions/api/fn_addPopulationZone.sqf +++ b/addons/legacy/functions/fnc_addPopulationZone.sqf @@ -1,7 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_area"]; +ISNILS(GVAR(POPULATION_ZONES), []); GVAR(POPULATION_ZONES) pushBack _area; INFO_1("added population zone %1", _area); diff --git a/functions/common/fn_arrayContains.sqf b/addons/legacy/functions/fnc_arrayContains.sqf similarity index 85% rename from functions/common/fn_arrayContains.sqf rename to addons/legacy/functions/fnc_arrayContains.sqf index 3874e75f..820f1a2d 100644 --- a/functions/common/fn_arrayContains.sqf +++ b/addons/legacy/functions/fnc_arrayContains.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_arr", []], ["_discriminator", {}] diff --git a/functions/player/fn_checkHonkingOnCivilian.sqf b/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf similarity index 91% rename from functions/player/fn_checkHonkingOnCivilian.sqf rename to addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf index 286ec50c..04de4ba0 100644 --- a/functions/player/fn_checkHonkingOnCivilian.sqf +++ b/addons/legacy/functions/fnc_checkHonkingOnCivilian.sqf @@ -1,9 +1,9 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _playerPos = getPosATL player; -private _nearCivs = (_playerPos nearEntities [["Man"], 200]) arrayIntersect ([] call GRAD_CIVS_fnc_getGlobalCivs); +private _nearCivs = (_playerPos nearEntities [["Man"], 200]) arrayIntersect ([] call FUNC(getGlobalCivs)); -if (!GVAR(DEBUG_CIVSTATE) && (count _nearCivs) == 0) exitWith {}; +if (!([QGVAR(debugCivState)] call CBA_settings_fnc_get) && (count _nearCivs) == 0) exitWith {}; private _playerVelocity = velocity player; private _speed = vectorMagnitude _playerVelocity; @@ -42,7 +42,7 @@ private _dangerPolyInPlayerHeight = _dangerPoly apply { [_x select 0, _x select 1, _playerPos select 2] }; -if (GVAR(DEBUG_CIVSTATE)) then { +if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { player setVariable ["grad_civs_dangerPolyInPlayerHeight", _dangerPolyInPlayerHeight]; }; diff --git a/functions/player/fn_checkWeaponOnCivilianPerception.sqf b/addons/legacy/functions/fnc_checkWeaponOnCivilianPerception.sqf similarity index 98% rename from functions/player/fn_checkWeaponOnCivilianPerception.sqf rename to addons/legacy/functions/fnc_checkWeaponOnCivilianPerception.sqf index 7f4ed95f..1ba95020 100644 --- a/functions/player/fn_checkWeaponOnCivilianPerception.sqf +++ b/addons/legacy/functions/fnc_checkWeaponOnCivilianPerception.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_pointer", objNull], ["_pointee", objNull] diff --git a/functions/player/fn_checkWeaponOnCivilianPointer.sqf b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf similarity index 57% rename from functions/player/fn_checkWeaponOnCivilianPointer.sqf rename to addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf index dac43b6e..28b47ca6 100644 --- a/functions/player/fn_checkWeaponOnCivilianPointer.sqf +++ b/addons/legacy/functions/fnc_checkWeaponOnCivilianPointer.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" scopeName "checkPointer_main"; @@ -15,11 +15,11 @@ if ( _possibleCiv = driver cursorTarget; /* remove my marker on civ, if i dont target him anymore */ - if !((_currentCiv isEqualTo _possibleCiv) || (cursorTarget isEqualTo (_currentCiv call grad_civs_fnc_getGroupVehicle))) then { + if !((_currentCiv isEqualTo _possibleCiv) || (cursorTarget isEqualTo (_currentCiv call EFUNC(voyage,getGroupVehicle)))) then { // TODO resolve circular dependency // maybe use `vehicle _currentCiv` instead? if (!isNull _currentCiv) then { player setVariable ["GRAD_isPointingAtObj", objNull]; - if (GVAR(DEBUG_CIVSTATE)) then { hint format ["depointing %1", _currentCiv]; }; - ["pointed_at_dec", [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; + if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { hint format ["depointing %1", _currentCiv]; }; + [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; }; } else { breakTo "checkPointer_main"; @@ -29,10 +29,10 @@ if ( /* if civ is civ, alive and they perceive you as a threat, make them a target */ if ((side _possibleCiv) == civilian && (alive _possibleCiv)) then { - if ([player, _possibleCiv] call grad_civs_fnc_checkWeaponOnCivilianPerception) then { + if ([player, _possibleCiv] call FUNC(checkWeaponOnCivilianPerception)) then { player setVariable ["GRAD_isPointingAtObj", _possibleCiv]; - if (GVAR(DEBUG_CIVSTATE)) then { hint format ["pointing at %1", _possibleCiv]; }; - ["pointed_at_inc", [_possibleCiv], [_possibleCiv]] call CBA_fnc_targetEvent; + if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { hint format ["pointing at %1", _possibleCiv]; }; + [QEGVAR(common,pointed_at_inc), [_possibleCiv], [_possibleCiv]] call CBA_fnc_targetEvent; }; }; @@ -42,7 +42,7 @@ if ( if (!isNull _currentCiv) then { player setVariable ["GRAD_isPointingAtObj", objNull]; - if (GVAR(DEBUG_CIVSTATE)) then { hint format ["depointing %1", _currentCiv]; }; - ["pointed_at_dec", [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; + if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { hint format ["depointing %1", _currentCiv]; }; + [QEGVAR(common,pointed_at_dec), [_currentCiv], [_currentCiv]] call CBA_fnc_targetEvent; }; }; diff --git a/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf b/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf new file mode 100644 index 00000000..bb5062a2 --- /dev/null +++ b/addons/legacy/functions/fnc_clearCurrentlyThinking.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { + _this setVariable ["grad_civs_currentlyThinking", nil, true]; +}; diff --git a/functions/api/fn_clearExclusionZones.sqf b/addons/legacy/functions/fnc_clearExclusionZones.sqf similarity index 65% rename from functions/api/fn_clearExclusionZones.sqf rename to addons/legacy/functions/fnc_clearExclusionZones.sqf index 9a51863f..5e286e29 100644 --- a/functions/api/fn_clearExclusionZones.sqf +++ b/addons/legacy/functions/fnc_clearExclusionZones.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" GVAR(EXCLUSION_ZONES) = []; diff --git a/functions/api/fn_clearPopulationZones.sqf b/addons/legacy/functions/fnc_clearPopulationZones.sqf similarity index 66% rename from functions/api/fn_clearPopulationZones.sqf rename to addons/legacy/functions/fnc_clearPopulationZones.sqf index 106ba38d..0186785d 100644 --- a/functions/api/fn_clearPopulationZones.sqf +++ b/addons/legacy/functions/fnc_clearPopulationZones.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" GVAR(POPULATION_ZONES) = []; diff --git a/functions/common/fn_compare.sqf b/addons/legacy/functions/fnc_compare.sqf similarity index 100% rename from functions/common/fn_compare.sqf rename to addons/legacy/functions/fnc_compare.sqf diff --git a/functions/behaviour/fn_customActivity_reverse.sqf b/addons/legacy/functions/fnc_customActivity_reverse.sqf similarity index 97% rename from functions/behaviour/fn_customActivity_reverse.sqf rename to addons/legacy/functions/fnc_customActivity_reverse.sqf index df81c73a..aeb8ca4f 100644 --- a/functions/behaviour/fn_customActivity_reverse.sqf +++ b/addons/legacy/functions/fnc_customActivity_reverse.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_civ", objNull], diff --git a/functions/spawn/fn_deleteIfDamaged.sqf b/addons/legacy/functions/fnc_deleteIfDamaged.sqf similarity index 87% rename from functions/spawn/fn_deleteIfDamaged.sqf rename to addons/legacy/functions/fnc_deleteIfDamaged.sqf index 4cdc74c2..f0b02d50 100644 --- a/functions/spawn/fn_deleteIfDamaged.sqf +++ b/addons/legacy/functions/fnc_deleteIfDamaged.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" [{!isNull (_this select 0)}, { [{ diff --git a/functions/api/fn_doCustomActivity.sqf b/addons/legacy/functions/fnc_doCustomActivity.sqf similarity index 97% rename from functions/api/fn_doCustomActivity.sqf rename to addons/legacy/functions/fnc_doCustomActivity.sqf index 50451451..4af4830f 100644 --- a/functions/api/fn_doCustomActivity.sqf +++ b/addons/legacy/functions/fnc_doCustomActivity.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" /* compel civilians to do your bidding. @@ -20,7 +20,7 @@ params [ assert(local _civ); -private _id = [_name, call FUNC(uid)] select { _x != ""} joinString "_"; +private _id = ([_name, call FUNC(uid)] select { _x != ""}) joinString "_"; INFO_2("civ %1: generated uid %2 for custom activity", _civ, _id); private _timeout = 86400*366; // if you run a scenario for over one year, take this bug with love <3. diff --git a/functions/debug/fn_drawCivs.sqf b/addons/legacy/functions/fnc_drawCivs.sqf similarity index 84% rename from functions/debug/fn_drawCivs.sqf rename to addons/legacy/functions/fnc_drawCivs.sqf index 09d0c04b..2e5276b2 100644 --- a/functions/debug/fn_drawCivs.sqf +++ b/addons/legacy/functions/fnc_drawCivs.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ "_map", diff --git a/functions/common/fn_feelsAddressedByGesture.spec.sqf b/addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf similarity index 95% rename from functions/common/fn_feelsAddressedByGesture.spec.sqf rename to addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf index 8a4609ff..b59092a4 100644 --- a/functions/common/fn_feelsAddressedByGesture.spec.sqf +++ b/addons/legacy/functions/fnc_feelsAddressedByGesture.spec.sqf @@ -2,7 +2,7 @@ private _bAwareOfAGesturing = [ "then B will feel addressed by A", { params ["_a", "_b"]; - [[_a, vectorDirVisual _a, driver _b] call grad_civs_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertTrue; + [[_a, vectorDirVisual _a, driver _b] call grad_civs_legacy_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertTrue; } ]; @@ -10,7 +10,7 @@ private _bUnawareOfAGesturing = [ "then B will not feel addressed by A", { params ["_a", "_b"]; - [[_a, vectorDirVisual _a, driver _b] call grad_civs_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertFalse; + [[_a, vectorDirVisual _a, driver _b] call grad_civs_legacy_fnc_feelsAddressedByGesture] call grad_testing_fnc_assertFalse; } ]; diff --git a/functions/common/fn_feelsAddressedByGesture.sqf b/addons/legacy/functions/fnc_feelsAddressedByGesture.sqf similarity index 97% rename from functions/common/fn_feelsAddressedByGesture.sqf rename to addons/legacy/functions/fnc_feelsAddressedByGesture.sqf index cb55fdc5..a527647e 100644 --- a/functions/common/fn_feelsAddressedByGesture.sqf +++ b/addons/legacy/functions/fnc_feelsAddressedByGesture.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_gesturer", objNull], ["_gesturingVector", []], diff --git a/functions/common/fn_findBuildings.sqf b/addons/legacy/functions/fnc_findBuildings.sqf similarity index 93% rename from functions/common/fn_findBuildings.sqf rename to addons/legacy/functions/fnc_findBuildings.sqf index 2c6a7748..4dd2ee4d 100644 --- a/functions/common/fn_findBuildings.sqf +++ b/addons/legacy/functions/fnc_findBuildings.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_searchPos", [0, 0, 0]], diff --git a/functions/common/fn_findPositionOfInterest.sqf b/addons/legacy/functions/fnc_findPositionOfInterest.sqf similarity index 96% rename from functions/common/fn_findPositionOfInterest.sqf rename to addons/legacy/functions/fnc_findPositionOfInterest.sqf index 728e278f..19f3ea60 100644 --- a/functions/common/fn_findPositionOfInterest.sqf +++ b/addons/legacy/functions/fnc_findPositionOfInterest.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_searchPosition", [0, 0, 0]], diff --git a/functions/common/fn_findRandomPos.sqf b/addons/legacy/functions/fnc_findRandomPos.sqf similarity index 96% rename from functions/common/fn_findRandomPos.sqf rename to addons/legacy/functions/fnc_findRandomPos.sqf index 33e0cbbc..8eb0c4b5 100644 --- a/functions/common/fn_findRandomPos.sqf +++ b/addons/legacy/functions/fnc_findRandomPos.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_center", [0, 0, 0]], diff --git a/functions/common/fn_findRandomPosArea.sqf b/addons/legacy/functions/fnc_findRandomPosArea.sqf similarity index 94% rename from functions/common/fn_findRandomPosArea.sqf rename to addons/legacy/functions/fnc_findRandomPosArea.sqf index bcfc3c22..990eb377 100644 --- a/functions/common/fn_findRandomPosArea.sqf +++ b/addons/legacy/functions/fnc_findRandomPosArea.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_area",["_vehicleType","B_Soldier_F"],["_findWaterPos",false],["_findRoadPos",false]]; diff --git a/functions/spawn/fn_findSpawnPosition.spec.sqf b/addons/legacy/functions/fnc_findSpawnPosition.spec.sqf similarity index 96% rename from functions/spawn/fn_findSpawnPosition.spec.sqf rename to addons/legacy/functions/fnc_findSpawnPosition.spec.sqf index b40ae996..98a4becd 100644 --- a/functions/spawn/fn_findSpawnPosition.spec.sqf +++ b/addons/legacy/functions/fnc_findSpawnPosition.spec.sqf @@ -28,7 +28,7 @@ }; diag_log (_houses#0 buildingPos -1); - GRAD_CIVS_EXCLUSION_ZONES = []; + GVAR(EXCLUSION_ZONES) = []; sleep 1; [_allPlayers, _houses] }, @@ -41,7 +41,7 @@ private _house = objNull; for "_i" from 0 to 10 do { - _house = [_allPlayers, 50, 100, "house"] call grad_civs_fnc_findSpawnPosition; + _house = [_allPlayers, 50, 100, "house"] call grad_civs_legacy_fnc_findSpawnPosition; if (!(isNull _house)) exitWith {}; }; diff --git a/functions/spawn/fn_findSpawnPosition.sqf b/addons/legacy/functions/fnc_findSpawnPosition.sqf similarity index 94% rename from functions/spawn/fn_findSpawnPosition.sqf rename to addons/legacy/functions/fnc_findSpawnPosition.sqf index d218811d..d023b6c6 100644 --- a/functions/spawn/fn_findSpawnPosition.sqf +++ b/addons/legacy/functions/fnc_findSpawnPosition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" // returns houses or roads or positions _this params [ @@ -24,7 +24,7 @@ private _searchDistancePoints = _searchDirs apply { 0 ] }; - +// TODO: handle playercount == 0 private _shuffledPlayers = _allPlayers call BIS_fnc_arrayShuffle; private _result = { // try to find houses - and abort when we found one thats good @@ -44,7 +44,7 @@ private _result = { } }; case "house": { - ([_refPos, _halfSectorWidth] call grad_civs_fnc_findUnclaimedHouse) + ([_refPos, _halfSectorWidth] call FUNC(findUnclaimedHouse)) }; default { _refPos diff --git a/functions/spawn/fn_findUnclaimedHouse.sqf b/addons/legacy/functions/fnc_findUnclaimedHouse.sqf similarity index 93% rename from functions/spawn/fn_findUnclaimedHouse.sqf rename to addons/legacy/functions/fnc_findUnclaimedHouse.sqf index 02b0c819..5ad94a6b 100644 --- a/functions/spawn/fn_findUnclaimedHouse.sqf +++ b/addons/legacy/functions/fnc_findUnclaimedHouse.sqf @@ -1,6 +1,6 @@ -/* return house or objNull */ +#include "..\script_component.hpp" -#include "..\..\component.hpp" +/* return house or objNull */ params [ ["_position", [0, 0, 0]], @@ -13,7 +13,9 @@ private _houses = [ _position, _radius, true -] call grad_civs_fnc_findBuildings; +] call FUNC(findBuildings); + +// TODO exclude watchtowers //exclusion list for houses private _exclusionList = [ diff --git a/functions/accessors/fn_forceEmotionSpeed.sqf b/addons/legacy/functions/fnc_forceEmotionSpeed.sqf similarity index 70% rename from functions/accessors/fn_forceEmotionSpeed.sqf rename to addons/legacy/functions/fnc_forceEmotionSpeed.sqf index c5eec46d..dcd1d501 100644 --- a/functions/accessors/fn_forceEmotionSpeed.sqf +++ b/addons/legacy/functions/fnc_forceEmotionSpeed.sqf @@ -1,6 +1,6 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" -private _emo = [_this, GRAD_CIVS_STATE_EMOTIONS] call cba_statemachine_fnc_getCurrentState; +private _emo = [_this, "emotions"] call EFUNC(common,civGetState); private _speed = switch (_emo) do { case "emo_panic": {_this getVariable ["grad_civs_runspeed", 6]}; case "emo_wary": {(_this getVariable ["grad_civs_runspeed", 6]) * 0.66}; diff --git a/functions/accessors/fn_forcePanicSpeed.sqf b/addons/legacy/functions/fnc_forcePanicSpeed.sqf similarity index 64% rename from functions/accessors/fn_forcePanicSpeed.sqf rename to addons/legacy/functions/fnc_forcePanicSpeed.sqf index 8f8b44d7..9bd6077d 100644 --- a/functions/accessors/fn_forcePanicSpeed.sqf +++ b/addons/legacy/functions/fnc_forcePanicSpeed.sqf @@ -1 +1,3 @@ +#include "..\script_component.hpp" + _this forceSpeed (_this getVariable ["grad_civs_runspeed", 6]); diff --git a/functions/common/fn_formatNowPlusSeconds.sqf b/addons/legacy/functions/fnc_formatNowPlusSeconds.sqf similarity index 76% rename from functions/common/fn_formatNowPlusSeconds.sqf rename to addons/legacy/functions/fnc_formatNowPlusSeconds.sqf index 433f1881..1c90de96 100644 --- a/functions/common/fn_formatNowPlusSeconds.sqf +++ b/addons/legacy/functions/fnc_formatNowPlusSeconds.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _seconds = _this; private _date = _seconds call FUNC(nowPlusSeconds); diff --git a/addons/legacy/functions/fnc_getCurrentlyThinking.sqf b/addons/legacy/functions/fnc_getCurrentlyThinking.sqf new file mode 100644 index 00000000..b35b2a47 --- /dev/null +++ b/addons/legacy/functions/fnc_getCurrentlyThinking.sqf @@ -0,0 +1,7 @@ +#include "..\script_component.hpp" + +if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { + _this getVariable ["grad_civs_currentlyThinking", "dumdidum"]; +} else { + "" +}; diff --git a/addons/legacy/functions/fnc_getExclusionZones.sqf b/addons/legacy/functions/fnc_getExclusionZones.sqf new file mode 100644 index 00000000..51531163 --- /dev/null +++ b/addons/legacy/functions/fnc_getExclusionZones.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(EXCLUSION_ZONES), []); +GVAR(EXCLUSION_ZONES) diff --git a/addons/legacy/functions/fnc_getGlobalCivs.sqf b/addons/legacy/functions/fnc_getGlobalCivs.sqf new file mode 100644 index 00000000..a3ba76c5 --- /dev/null +++ b/addons/legacy/functions/fnc_getGlobalCivs.sqf @@ -0,0 +1,35 @@ +#include "..\script_component.hpp" + +/* get ALL grad managed civs, regardless of location*/ +params [ + ["_primaryTask", "", [""]] /* filter civs by primary task */ +]; + +if (isNil QFUNC(getGlobalCivs_arr)) then { + // on first run, init array with existing civs + private _civClass = [QGVAR(civClass)] call CBA_settings_fnc_get; + private _potentialCivs = entities [[_civClass], [], true, true]; + FUNC(getGlobalCivs_arr) = _potentialCivs select { (_x getVariable ["grad_civs_primaryTask", ""]) != ""}; + + // then, register event handler to update the array appropriately to always include all living civs + [ + QGVAR(civ_added), + { + SCRIPT("getGlobalCivs_civ_added"); + FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) + _this; + } + ] call CBA_fnc_addEventHandler; + [ + QGVAR(civ_removed), + { + SCRIPT("getGlobalCivs_civ_removed"); + FUNC(getGlobalCivs_arr) = FUNC(getGlobalCivs_arr) - _this; + } + ] call CBA_fnc_addEventHandler; +}; + +if (_primaryTask == "") then { + FUNC(getGlobalCivs_arr) +} else { + (FUNC(getGlobalCivs_arr) select { _x getVariable ["grad_civs_primaryTask", ""] == _primaryTask}) +}; diff --git a/addons/legacy/functions/fnc_getPopulationZones.sqf b/addons/legacy/functions/fnc_getPopulationZones.sqf new file mode 100644 index 00000000..a90d987c --- /dev/null +++ b/addons/legacy/functions/fnc_getPopulationZones.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +ISNILS(GVAR(POPULATION_ZONES), []); +GVAR(POPULATION_ZONES) diff --git a/functions/common/fn_handleAnimation.sqf b/addons/legacy/functions/fnc_handleAnimation.sqf similarity index 90% rename from functions/common/fn_handleAnimation.sqf rename to addons/legacy/functions/fnc_handleAnimation.sqf index 1fc36c4f..99ec43d1 100644 --- a/functions/common/fn_handleAnimation.sqf +++ b/addons/legacy/functions/fnc_handleAnimation.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_unit", "_animation"]; diff --git a/functions/common/fn_handleGestureGo.sqf b/addons/legacy/functions/fnc_handleGestureGo.sqf similarity index 96% rename from functions/common/fn_handleGestureGo.sqf rename to addons/legacy/functions/fnc_handleGestureGo.sqf index 27258e0a..d9f2df60 100644 --- a/functions/common/fn_handleGestureGo.sqf +++ b/addons/legacy/functions/fnc_handleGestureGo.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" #define SEND_RADIUS 10 params [ diff --git a/functions/common/fn_handleGestureStop.sqf b/addons/legacy/functions/fnc_handleGestureStop.sqf similarity index 95% rename from functions/common/fn_handleGestureStop.sqf rename to addons/legacy/functions/fnc_handleGestureStop.sqf index 3a698484..47892b8f 100644 --- a/functions/common/fn_handleGestureStop.sqf +++ b/addons/legacy/functions/fnc_handleGestureStop.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_gesturer", objNull] diff --git a/functions/init/fn_initCommonEventhandlers.sqf b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf similarity index 60% rename from functions/init/fn_initCommonEventhandlers.sqf rename to addons/legacy/functions/fnc_initCommonEventhandlers.sqf index 725c4570..0da539a8 100644 --- a/functions/init/fn_initCommonEventhandlers.sqf +++ b/addons/legacy/functions/fnc_initCommonEventhandlers.sqf @@ -1,9 +1,4 @@ -#include "..\..\component.hpp" - -params [ - ["_mode", "runtime"] -]; -if (_mode == "postInit" && {([missionConfigFile >> "cfgGradCivs", "autoInit", 0] call BIS_fnc_returnConfigEntry) != 1}) exitWith {INFO("autoInit disabled, not running initCommonEventhandlers right now...")}; +#include "..\script_component.hpp" [QGVAR(switchMove), { params ["_unit", "_animation"]; diff --git a/addons/legacy/functions/fnc_initConfig.sqf b/addons/legacy/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..28fc75eb --- /dev/null +++ b/addons/legacy/functions/fnc_initConfig.sqf @@ -0,0 +1,93 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "2) basics"]; + +[ + QGVAR(civClass), + "EDITBOX", + "Unit class to use for spawning civilians", + _settingsGroup, + "C_Man_1", + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(debugCivState), + "CHECKBOX", + "Toggle civ behavior debugging mode.", + _settingsGroup, + false, + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(debugFps), + "CHECKBOX", + "Toggles fps debugging mode", + _settingsGroup, + false, + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(minCivUpdateTime), + "SLIDER", + "Keep civ reaction times under [s]", + _settingsGroup, + [0.1, 10, 3, 1], + false, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(minFps), + "SLIDER", + "Keep civ owner fps over [1/s]", + _settingsGroup, + [10, 50, 35, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(panicCooldown), + "EDITBOX", + "Time for panic to wear off [lowest, median, highest]", + _settingsGroup, + QUOTE([ARR_3(15,120,240)]), + false, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(cleanupCorpses), + "CHECKBOX", + "Clean up corpses (requires corpseManagerMode set!)", + _settingsGroup, + true, + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(spawnOnlyWithPlayers), + "CHECKBOX", + "Spawn civilians only when players on server", + _settingsGroup, + true, + true, + {}, + false +] call CBA_fnc_addSetting; diff --git a/addons/legacy/functions/fnc_initHCs.sqf b/addons/legacy/functions/fnc_initHCs.sqf new file mode 100644 index 00000000..e74aeaa9 --- /dev/null +++ b/addons/legacy/functions/fnc_initHCs.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +if (isServer || !hasInterface) then { + INFO("Server/HC init running..."); + + if ( + ([QGVAR(cleanupCorpses)] call CBA_settings_fnc_get) && + !(([missionConfigFile, "corpseManagerMode", -1] call BIS_fnc_returnConfigEntry) in [1, 3]) + ) then { + WARNING("'cleanupCorpses' flag is set, but 'corpseManagerMode' in description.ext is switched off!"); + }; + + GVAR(localCivs) = []; + EGVAR(common,stateMachines) = [] call CBA_fnc_createNamespace; + + [] call FUNC(sm_lifecycle); + [] call FUNC(serverLoop); +}; diff --git a/addons/legacy/functions/fnc_initPlayer.sqf b/addons/legacy/functions/fnc_initPlayer.sqf new file mode 100644 index 00000000..f296042f --- /dev/null +++ b/addons/legacy/functions/fnc_initPlayer.sqf @@ -0,0 +1,13 @@ +#include "..\script_component.hpp" + +if (hasInterface) then { + + [] call FUNC(playerLoop); + [] call FUNC(addCivInteractions); + [] call FUNC(setupZeusModules); + if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { + [] call FUNC(showWhatTheyThink); + + [{!isNull (findDisplay 12)}, {[] call FUNC(mapMarkers)}, []] call CBA_fnc_waitUntilAndExecute; + }; +}; diff --git a/functions/player/fn_interact_backUpAction.sqf b/addons/legacy/functions/fnc_interact_backUpAction.sqf similarity index 84% rename from functions/player/fn_interact_backUpAction.sqf rename to addons/legacy/functions/fnc_interact_backUpAction.sqf index 457778ae..3ced2f67 100644 --- a/functions/player/fn_interact_backUpAction.sqf +++ b/addons/legacy/functions/fnc_interact_backUpAction.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _veh = vehicle _target; private _reverseTargetPos = (getPos _veh) vectorAdd ((vectorDir _veh) vectorMultiply -50); diff --git a/functions/player/fn_interact_backUpCondition.sqf b/addons/legacy/functions/fnc_interact_backUpCondition.sqf similarity index 75% rename from functions/player/fn_interact_backUpCondition.sqf rename to addons/legacy/functions/fnc_interact_backUpCondition.sqf index 89a44596..25a41190 100644 --- a/functions/player/fn_interact_backUpCondition.sqf +++ b/addons/legacy/functions/fnc_interact_backUpCondition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _veh = vehicle _target; diff --git a/functions/player/fn_interact_carryOnAction.sqf b/addons/legacy/functions/fnc_interact_carryOnAction.sqf similarity index 82% rename from functions/player/fn_interact_carryOnAction.sqf rename to addons/legacy/functions/fnc_interact_carryOnAction.sqf index 44d63a6e..387176e6 100644 --- a/functions/player/fn_interact_carryOnAction.sqf +++ b/addons/legacy/functions/fnc_interact_carryOnAction.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" [ _target, diff --git a/functions/player/fn_interact_carryOnCondition.sqf b/addons/legacy/functions/fnc_interact_carryOnCondition.sqf similarity index 80% rename from functions/player/fn_interact_carryOnCondition.sqf rename to addons/legacy/functions/fnc_interact_carryOnCondition.sqf index c6376bdb..da5ccc7f 100644 --- a/functions/player/fn_interact_carryOnCondition.sqf +++ b/addons/legacy/functions/fnc_interact_carryOnCondition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" alive _target && (_target getVariable ["grad_civs_primaryTask", ""] != "") && diff --git a/addons/legacy/functions/fnc_isInDistanceFromOtherPlayers.sqf b/addons/legacy/functions/fnc_isInDistanceFromOtherPlayers.sqf new file mode 100644 index 00000000..f080a756 --- /dev/null +++ b/addons/legacy/functions/fnc_isInDistanceFromOtherPlayers.sqf @@ -0,0 +1,12 @@ +#include "..\script_component.hpp" + +params [ + ["_allPlayers", [], [[]]], + ["_posOrObject", [0, 0], [[], objNull]], + ["_minDistance", 0, [0]] +]; + +{ + if (((getPos _x) distance _posOrObject) < _minDistance) exitWith {false}; + true +} forEach _allPlayers; diff --git a/functions/common/fn_isInHouse.sqf b/addons/legacy/functions/fnc_isInHouse.sqf similarity index 100% rename from functions/common/fn_isInHouse.sqf rename to addons/legacy/functions/fnc_isInHouse.sqf diff --git a/addons/legacy/functions/fnc_isInPopulatedZone.sqf b/addons/legacy/functions/fnc_isInPopulatedZone.sqf new file mode 100644 index 00000000..92a147ae --- /dev/null +++ b/addons/legacy/functions/fnc_isInPopulatedZone.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" + +params [ + ["_position", [0, 0, 0]] +]; + +assert(_position isEqualType []); + +private _populationZones = [] call FUNC(getPopulationZones); +private _exclusionZones = [] call FUNC(getExclusionZones); + +private _inAnyPopulationZone = if (count _populationZones == 0) then { + true +} else { + // TODO uhm… how about [] findIf {} != -1 ? + [_populationZones, {_position inArea (_this#0)}] call FUNC(arrayContains) +}; +if (!_inAnyPopulationZone) exitWith {false}; + +private _inAnyExclusionZone = [_exclusionZones, {_position inArea (_this#0)}] call FUNC(arrayContains); + +!_inAnyExclusionZone diff --git a/functions/player/fn_isPlayerHonking.sqf b/addons/legacy/functions/fnc_isPlayerHonking.sqf similarity index 78% rename from functions/player/fn_isPlayerHonking.sqf rename to addons/legacy/functions/fnc_isPlayerHonking.sqf index fdc40ca2..f0bed216 100644 --- a/functions/player/fn_isPlayerHonking.sqf +++ b/addons/legacy/functions/fnc_isPlayerHonking.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if (vehicle player == player) exitWith {false}; if (driver player != player) exitWith {false}; (inputAction "defaultAction") > 0 diff --git a/functions/debug/fn_mapMarkers.sqf b/addons/legacy/functions/fnc_mapMarkers.sqf similarity index 62% rename from functions/debug/fn_mapMarkers.sqf rename to addons/legacy/functions/fnc_mapMarkers.sqf index a45cfde1..580d6460 100644 --- a/functions/debug/fn_mapMarkers.sqf +++ b/addons/legacy/functions/fnc_mapMarkers.sqf @@ -1,15 +1,17 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" -params [["_onOff",GVAR(DEBUG_CIVSTATE)]]; +params [ + ["_onOff", GVAR(debugCivState)] +]; ASSERT_PLAYER(""); -GVAR(DEBUG_CIVSTATE) = _onOff; +GVAR(debugCivState) = _onOff; if (_onOff) then { GVAR(DRAWUNITSEH) = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", { - private _civs = [] call grad_civs_fnc_getGlobalCivs; + private _civs = [] call FUNC(getGlobalCivs); private _civsInCarDrivers = _civs select { private _vec = vehicle _x; _vec != _x && driver _vec == _x @@ -18,8 +20,8 @@ if (_onOff) then { vehicle _x == _x }; - [_this select 0, _civsOnFoot, "iconMan"] call grad_civs_fnc_drawCivs; - [_this select 0, _civsInCarDrivers, "iconCar"] call grad_civs_fnc_drawCivs; + [_this select 0, _civsOnFoot, "iconMan"] call FUNC(drawCivs); + [_this select 0, _civsInCarDrivers, "iconCar"] call FUNC(drawCivs); //one day: iconHelicopter }]; } else { diff --git a/addons/legacy/functions/fnc_module_misc.sqf b/addons/legacy/functions/fnc_module_misc.sqf new file mode 100644 index 00000000..f91f7488 --- /dev/null +++ b/addons/legacy/functions/fnc_module_misc.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +diag_log _this; +INFO("legacy"); diff --git a/functions/common/fn_nowPlusSeconds.sqf b/addons/legacy/functions/fnc_nowPlusSeconds.sqf similarity index 60% rename from functions/common/fn_nowPlusSeconds.sqf rename to addons/legacy/functions/fnc_nowPlusSeconds.sqf index 89c160e2..74375d30 100644 --- a/functions/common/fn_nowPlusSeconds.sqf +++ b/addons/legacy/functions/fnc_nowPlusSeconds.sqf @@ -1,2 +1,4 @@ +#include "..\script_component.hpp" + private _seconds = _this; (daytime + (_seconds / 3600)) diff --git a/addons/legacy/functions/fnc_playerLoop.sqf b/addons/legacy/functions/fnc_playerLoop.sqf new file mode 100644 index 00000000..c58b991b --- /dev/null +++ b/addons/legacy/functions/fnc_playerLoop.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" + +[{ + if (!isGameFocused || isGamePaused) exitWith {}; + [] call FUNC(checkWeaponOnCivilianPointer); +}, 0.5, []] call CBA_fnc_addPerFrameHandler; + +[{ + if (!isGameFocused || isGamePaused) exitWith {}; + if ([] call FUNC(isPlayerHonking)) then { + [] call FUNC(checkHonkingOnCivilian); + }; +}, 0.1, []] call CBA_fnc_addPerFrameHandler; + +[ + "server_fps", + { + if ([QGVAR(debugFps)] call CBA_settings_fnc_get) then { + systemChat format ["%1 fps on %2", _this select 1, _this select 0]; + }; + } +] call CBA_fnc_addEventHandler; diff --git a/functions/common/fn_reverse.spec.sqf b/addons/legacy/functions/fnc_reverse.spec.sqf similarity index 89% rename from functions/common/fn_reverse.spec.sqf rename to addons/legacy/functions/fnc_reverse.spec.sqf index f58fad0b..247102a4 100644 --- a/functions/common/fn_reverse.spec.sqf +++ b/addons/legacy/functions/fnc_reverse.spec.sqf @@ -21,7 +21,7 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { [ ["WHEN I let it reverse", { - [_this, [0, -50, 0]] call grad_civs_fnc_reverse; + [_this, [0, -50, 0]] call grad_civs_legacy_fnc_reverse; _this }, [ @@ -54,14 +54,14 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { [ ["WHEN I let it reverse", { - [_this, [0, -50, 0]] call grad_civs_fnc_reverse; + [_this, [0, -50, 0]] call grad_civs_legacy_fnc_reverse; _this }, [ ["THEN it has indeed reversed after 2s", { sleep 4; - [(getPos _this)#1, -20, -1] call grad_testing_fnc_assertBetween; + [(getPos _this) select 1, -20, -1] call grad_testing_fnc_assertBetween; } ], ["THEN it is still moving after 2s", @@ -82,7 +82,7 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { private _d = _group createUnit ["C_Man_1", _pos, [], 0, "NONE"]; _d moveInDriver _this; { - if (isNull (_x#0)) then { + if (isNull (_x select 0)) then { private _p = _group createUnit ["C_Man_1", [0, 10, 0], [], 0, "NONE"]; _p moveInAny _this; }; @@ -92,14 +92,14 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { [ ["WHEN I let it reverse", { - [_this, [0, -20, 0]] call grad_civs_fnc_reverse; + [_this, [0, -20, 0]] call grad_civs_legacy_fnc_reverse; _this }, [ ["THEN it has indeed reversed after 2s", { sleep 4; - [(getPos _this)#1, -25, -1] call grad_testing_fnc_assertBetween; + [(getPos _this) select 1, -25, -1] call grad_testing_fnc_assertBetween; } ], ["THEN it is still moving after 2s", @@ -111,8 +111,8 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { ["THEN it is close to the target and stopped after 15s", { sleep 12; - [(getPos _this)#1, -22, -18] call grad_testing_fnc_assertBetween; - [(getPos _this)#0, -5, 5] call grad_testing_fnc_assertBetween; + [(getPos _this) select 1, -22, -18] call grad_testing_fnc_assertBetween; + [(getPos _this) select 0, -5, 5] call grad_testing_fnc_assertBetween; [speed _this, 0] call grad_testing_fnc_assertEquals; } ], @@ -126,9 +126,9 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { ], ["WHEN I let it reverse 100m AND abort after 2 seconds", { - [_this, [0, -100, 0]] call grad_civs_fnc_reverse; + [_this, [0, -100, 0]] call grad_civs_legacy_fnc_reverse; sleep 2; - [_this] call grad_civs_fnc_reverse_abort; + [_this] call grad_civs_legacy_fnc_reverse_abort; _this }, [ @@ -141,7 +141,7 @@ if (isClass (configFile >> "CfgVehicles" >> "LOP_AFR_Civ_Ural_open")) then { ["THEN it is not even close to the target", { - [(getPos _this)#1, -20, -1] call grad_testing_fnc_assertBetween; + [(getPos _this) select 1, -20, -1] call grad_testing_fnc_assertBetween; } ], ["THEN its effective commander is the driver again (NOTE: works only for civilian vehicles)", diff --git a/functions/common/fn_reverse.sqf b/addons/legacy/functions/fnc_reverse.sqf similarity index 92% rename from functions/common/fn_reverse.sqf rename to addons/legacy/functions/fnc_reverse.sqf index db38329a..6c488f08 100644 --- a/functions/common/fn_reverse.sqf +++ b/addons/legacy/functions/fnc_reverse.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_vehicle", objNull], @@ -26,14 +26,14 @@ if (effectiveCommander _vehicle == _driver) then { breakOut "main"; }; _ec = (group _driver) createUnit ["C_Soldier_VR_F", [0, 0, 0], [], 0, "NONE"]; - if (!GVAR(DEBUG_CIVSTATE)) then { + if (!([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { ["ace_common_hideObjectGlobal", [_ec, true]] call CBA_fnc_serverEvent; }; _ec assignAsCargo _vehicle; _ec moveInCargo _vehicle; _ec setVariable ["grad_civs_virtual_ec", true]; } else { - _ec = (crew _vehicle)#1; + _ec = (crew _vehicle) select 1; }; INFO_1("setting EC to %1", typeOf _ec); diff --git a/functions/common/fn_reverse_abort.sqf b/addons/legacy/functions/fnc_reverse_abort.sqf similarity index 73% rename from functions/common/fn_reverse_abort.sqf rename to addons/legacy/functions/fnc_reverse_abort.sqf index 584484be..3ab9bca3 100644 --- a/functions/common/fn_reverse_abort.sqf +++ b/addons/legacy/functions/fnc_reverse_abort.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_vehicle", objNull] diff --git a/functions/common/fn_reverse_internal_end.sqf b/addons/legacy/functions/fnc_reverse_internal_end.sqf similarity index 92% rename from functions/common/fn_reverse_internal_end.sqf rename to addons/legacy/functions/fnc_reverse_internal_end.sqf index 6a488ba2..38aae6b1 100644 --- a/functions/common/fn_reverse_internal_end.sqf +++ b/addons/legacy/functions/fnc_reverse_internal_end.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_handle", "_vehicle", "", "", "_onDone"]; INFO_2("ending reverse drive! removing 'BACK' PFH %1 from %2 ...", _handle, _vehicle); diff --git a/functions/common/fn_reverse_internal_pfh.sqf b/addons/legacy/functions/fnc_reverse_internal_pfh.sqf similarity index 70% rename from functions/common/fn_reverse_internal_pfh.sqf rename to addons/legacy/functions/fnc_reverse_internal_pfh.sqf index 6c2de344..e7640aa7 100644 --- a/functions/common/fn_reverse_internal_pfh.sqf +++ b/addons/legacy/functions/fnc_reverse_internal_pfh.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_args", "_handle"]; _args params ["_car"]; diff --git a/functions/common/fn_reverse_internal_stopCondition.sqf b/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf similarity index 93% rename from functions/common/fn_reverse_internal_stopCondition.sqf rename to addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf index a0f42a06..64d94a84 100644 --- a/functions/common/fn_reverse_internal_stopCondition.sqf +++ b/addons/legacy/functions/fnc_reverse_internal_stopCondition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_handle", "_vehicle", "_targetPos", "_tryAtLeastUntil", "", "_abortCondition"]; private _nowDst = (_targetPos distance _vehicle); diff --git a/functions/spawn/fn_serverLoop.sqf b/addons/legacy/functions/fnc_serverLoop.sqf similarity index 70% rename from functions/spawn/fn_serverLoop.sqf rename to addons/legacy/functions/fnc_serverLoop.sqf index bcc1a0d6..1fc39a1f 100644 --- a/functions/spawn/fn_serverLoop.sqf +++ b/addons/legacy/functions/fnc_serverLoop.sqf @@ -1,8 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" ASSERT_SERVER(""); -if (!GRAD_CIVS_ENABLEDINVEHICLES && !GRAD_CIVS_ENABLEDONFOOT) exitWith {-1}; +ISNILS(GVAR(EXITON), {}); private _mainLoop = { params ["_args", "_handle"]; @@ -12,7 +12,7 @@ private _mainLoop = { [_handle] call CBA_fnc_removePerFrameHandler }; if (isDedicated && (count ((entities "HeadlessClient_F") arrayIntersect allPlayers) > 0)) exitWith { - INFO("HCs are taking over, will not spawn any more civs"); + INFO("HCs are available, will not spawn any more civs"); [_handle] call CBA_fnc_removePerFrameHandler }; @@ -23,25 +23,25 @@ private _mainLoop = { [ { private _mainLoop = _this#0; - grad_civs_mainLoop = [_mainLoop, 2, []] call CBA_fnc_addPerFrameHandler; + GVAR(mainLoopHandle) = [_mainLoop, 2, []] call CBA_fnc_addPerFrameHandler; }, [_mainLoop], 10 ] call CBA_fnc_waitAndExecute; -grad_civs_debugLoop = [{ +GVAR(debugLoopHandle) = [{ params ["_args", "_handle"]; - if (call GRAD_CIVS_EXITON) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; - if (GVAR(DEBUG_CIVSTATE)) then { - { _x call FUNC(updateInfoLine); } forEach GVAR(LOCAL_CIVS); + if (call GVAR(EXITON)) exitWith {[_handle] call CBA_fnc_removePerFrameHandler}; + if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { + { _x call FUNC(updateInfoLine); } forEach GVAR(localCivs); }; }, 0.1, []] call CBA_fnc_addPerFrameHandler; [ { - if (GRAD_CIVS_DEBUG_FPS) then { + if ([QGVAR(debugFps)] call CBA_settings_fnc_get) then { ["server_fps", [clientOwner, diag_fps]] call CBA_fnc_globalEvent; }; }, @@ -52,7 +52,7 @@ grad_civs_debugLoop = [{ // clean up objNull references in civs array - that happens for example when a zeus person deletes them [ { - GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS select { + GVAR(localCivs) = GVAR(localCivs) select { if (isNull _x) then { INFO_1("abandoning civilian they have become NULL (deleted?)", _x); false @@ -76,11 +76,12 @@ grad_civs_debugLoop = [{ if (!hasInterface && !isDedicated) then { [ { - private _allCivs = entities GVAR(CIVCLASS); + private _civClass = [QGVAR(civClass)] call CBA_settings_fnc_get; + private _allCivs = entities _civClass; private _myCivs = _allCivs select { local _x && (_x getVariable ["grad_civs_primaryTask", ""] != "")}; - private _orphanedCivs = _myCivs - GRAD_CIVS_LOCAL_CIVS; + private _orphanedCivs = _myCivs - GVAR(localCivs); INFO_1("%1 orphaned civs - putting them into my own array", count _orphanedCivs); - GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS + _orphanedCivs; + GVAR(localCivs) = GVAR(localCivs) + _orphanedCivs; }, 30, [] diff --git a/functions/accessors/fn_setCurrentlyThinking.sqf b/addons/legacy/functions/fnc_setCurrentlyThinking.sqf similarity index 56% rename from functions/accessors/fn_setCurrentlyThinking.sqf rename to addons/legacy/functions/fnc_setCurrentlyThinking.sqf index 1032672f..5810c85a 100644 --- a/functions/accessors/fn_setCurrentlyThinking.sqf +++ b/addons/legacy/functions/fnc_setCurrentlyThinking.sqf @@ -1,10 +1,10 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_unit", objNull], ["_thoughts", ""] ]; -if (GVAR(DEBUG_CIVSTATE)) then { +if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { _unit setVariable ["grad_civs_currentlyThinking", _thoughts]; }; diff --git a/addons/legacy/functions/fnc_setDebugMode.sqf b/addons/legacy/functions/fnc_setDebugMode.sqf new file mode 100644 index 00000000..7ec2cda1 --- /dev/null +++ b/addons/legacy/functions/fnc_setDebugMode.sqf @@ -0,0 +1,10 @@ +#include "..\script_component.hpp" + +params [["_value",false]]; + +if (GVAR(debugCivState) isEqualTo _value) exitWith {}; + +GVAR(debugCivState) = _value; + +[_value] remoteExec [QFUNC(showWhatTheyThink),0,false]; +[_value] remoteExec [QFUNC(mapMarkers),0,false]; diff --git a/functions/player/fn_setupZeusModules.sqf b/addons/legacy/functions/fnc_setupZeusModules.sqf similarity index 88% rename from functions/player/fn_setupZeusModules.sqf rename to addons/legacy/functions/fnc_setupZeusModules.sqf index 5a8c35d2..fafd4209 100644 --- a/functions/player/fn_setupZeusModules.sqf +++ b/addons/legacy/functions/fnc_setupZeusModules.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" ["GRAD-CIVS","ADD EXCLUSION ZONE (click within existing area marker!)", { @@ -49,13 +49,3 @@ _marker setMarkerColorLocal "ColorCIV"; } ] call zen_custom_modules_fnc_register; - -["GRAD-CIVS","ADD CAR", - { - params [ - ["_clickPos", [0, 0, 0]] - ]; - - [[], ASLToAGL _clickPos] call FUNC(addCarCrew); - } -] call zen_custom_modules_fnc_register; diff --git a/functions/debug/fn_showWhatTheyThink.sqf b/addons/legacy/functions/fnc_showWhatTheyThink.sqf similarity index 67% rename from functions/debug/fn_showWhatTheyThink.sqf rename to addons/legacy/functions/fnc_showWhatTheyThink.sqf index 38a67225..e479ed15 100644 --- a/functions/debug/fn_showWhatTheyThink.sqf +++ b/addons/legacy/functions/fnc_showWhatTheyThink.sqf @@ -1,25 +1,20 @@ -#include "..\..\component.hpp" - -params [["_onOff",GVAR(DEBUG_CIVSTATE)]]; +#include "..\script_component.hpp" ASSERT_PLAYER(""); -GVAR(DEBUG_CIVSTATE) = _onOff; -publicVariable QGVAR(DEBUG_CIVSTATE); - -GRAD_CIVS_CIVSTATE_FORMAT = 0; +GVAR(civStateFormat) = 0; [{ - if (!GVAR(DEBUG_CIVSTATE)) exitWith {[_this select 1] call CBA_fnc_removePerFrameHandler}; + if (!([QGVAR(debugCivState)] call CBA_settings_fnc_get)) exitWith {[_this select 1] call CBA_fnc_removePerFrameHandler}; if (!isGameFocused || isGamePaused) exitWith {}; _filterTimeVars = { - (allVariables _this) select { + ((allVariables _this) select { (_x find "grad_civs_state_time_") > -1 } apply { [_x, floor CBA_missionTime - (_this getVariable _x)] joinString ": " - } joinString ", "; + }) joinString ", "; }; private _camPos = AGLToASL positionCameraToWorld [0, 0, 0]; @@ -37,7 +32,7 @@ GRAD_CIVS_CIVSTATE_FORMAT = 0; if (_civAngle < _fov) then { _text = ""; - switch (GRAD_CIVS_CIVSTATE_FORMAT) do { + switch (GVAR(civStateFormat)) do { case 0: { _text =_x getVariable ["grad_civs_infoLine",""]; }; case 1: { _text = format["%1 | speedmode: %2 %3", _x, speedMode _x, if (leader _x == _x) then {"(is leader)"} else {""}]; }; case 2: { _text = format["%1 | %2 guns point at him", _x, _x getVariable ["grad_civs_isPointedAtCount", 0]]}; @@ -69,37 +64,38 @@ GRAD_CIVS_CIVSTATE_FORMAT = 0; } , 0, []] call CBA_fnc_addPerFrameHandler; -private _addCivAction = { - params [ - ["_title", ""], - ["_id", 0] - ]; - - player addAction [ - _title, - { GVAR(CIVSTATE_FORMAT) = _this#3; }, - _id, - 10, - false, - false, - "", - QGVAR(DEBUG_CIVSTATE) - ]; +if ([QGVAR(debugCivState)] call CBA_settings_fnc_get) then { + private _addCivAction = { + params [ + ["_title", ""], + ["_id", 0] + ]; + + player addAction [ + _title, + { GVAR(civStateFormat) = _this#3; }, + _id, + 10, + false, + false, + "", + QUOTE([QQGVAR(debugCivState)] call CBA_settings_fnc_get) + ]; + }; + + ["civstate format: infoLine", 0] call _addCivAction; + ["civstate format: speedmode", 1] call _addCivAction; + ["civstate format: guns", 2] call _addCivAction; + ["civstate format: locality", 3] call _addCivAction; + ["civstate format: behaviour", 4] call _addCivAction; + ["civstate format: state times", 5] call _addCivAction; + ["civstate format: waypoints", 6] call _addCivAction; + ["civstate format: empty", 7] call _addCivAction; }; -["civstate format: infoLine", 0] call _addCivAction; -["civstate format: speedmode", 1] call _addCivAction; -["civstate format: guns", 2] call _addCivAction; -["civstate format: locality", 3] call _addCivAction; -["civstate format: behaviour", 4] call _addCivAction; -["civstate format: state times", 5] call _addCivAction; -["civstate format: waypoints", 6] call _addCivAction; -["civstate format: empty", 7] call _addCivAction; - - ISNILS(GVAR(showWhatTheyThink_civ_added), 0); ISNILS(GVAR(showWhatTheyThinkciv_removed), 0); -if (GVAR(DEBUG_CIVSTATE)) then { +if (([QGVAR(debugCivState)] call CBA_settings_fnc_get)) then { GVAR(showWhatTheyThink_civ_added) = [ QGVAR(civ_added), { diff --git a/functions/sm_activities/fn_sm_activities.sqf b/addons/legacy/functions/fnc_sm_activities.sqf similarity index 83% rename from functions/sm_activities/fn_sm_activities.sqf rename to addons/legacy/functions/fnc_sm_activities.sqf index 1b93882b..b2824c4b 100644 --- a/functions/sm_activities/fn_sm_activities.sqf +++ b/addons/legacy/functions/fnc_sm_activities.sqf @@ -1,19 +1,17 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _activities = [[], true] call CBA_statemachine_fnc_create; -private _business = [] call grad_civs_fnc_sm_business; -private _panic = [] call grad_civs_fnc_sm_panic; +private _business = [] call FUNC(sm_business); +private _panic = [] call FUNC(sm_panic); -// CBA EVENTS - -["pointed_at_inc", { +[QEGVAR(common,pointed_at_inc), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; _civ setVariable ["grad_civs_isPointedAtCount", _currentCount + 1]; }] call CBA_fnc_addEventHandler; -["pointed_at_dec", { +[QEGVAR(common,pointed_at_dec), { params ["_civ"]; if (_civ == ACE_player) exitWith {}; private _currentCount = _civ getVariable ["grad_civs_isPointedAtCount", 0]; @@ -168,35 +166,35 @@ private _act_business = [ {}, {}, "act_business" -] call grad_civs_fnc_addCompoundState; +] call EFUNC(cba_statemachine,addCompoundState); assert(_act_business != ""); private _act_asOrdered = [ _activities, {}, - { _this call grad_civs_fnc_sm_activities_state_asOrdered_enter }, - { _this call grad_civs_fnc_sm_activities_state_asOrdered_exit }, + { _this call FUNC(sm_activities_state_asOrdered_enter) }, + { _this call FUNC(sm_activities_state_asOrdered_exit) }, "act_asOrdered" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState); assert(_act_asOrdered != ""); private _act_surrendered = [ _activities, {}, - { _this call grad_civs_fnc_sm_activities_state_surrendered_enter }, - { _this call grad_civs_fnc_sm_activities_state_surrendered_exit }, + { _this call FUNC(sm_activities_state_surrendered_enter) }, + { _this call FUNC(sm_activities_state_surrendered_exit) }, "act_surrendered" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState); assert(_act_surrendered != ""); private _act_panic = [ _activities, [_panic], { }, - { _this call grad_civs_fnc_sm_activities_state_panic_enter }, - { _this call grad_civs_fnc_sm_activities_state_panic_exit }, + { _this call FUNC(sm_activities_state_panic_enter) }, + { _this call FUNC(sm_activities_state_panic_exit) }, "act_panic" -] call grad_civs_fnc_addCompoundState; +] call EFUNC(cba_statemachine,addCompoundState); assert(_act_panic != ""); // TRANSITIONS @@ -204,34 +202,34 @@ assert(_act_panic != ""); assert ([ _activities, _act_business, _act_surrendered, - { _this call grad_civs_fnc_sm_activities_trans_business_surrendered_condition }, + { _this call FUNC(sm_activities_trans_business_surrendered_condition) }, {}, _act_business + _act_surrendered -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _activities, _act_business, _act_panic, - { _this call grad_civs_fnc_sm_activities_trans_business_panic_condition }, + { _this call FUNC(sm_activities_trans_business_panic_condition) }, {}, _act_business + _act_panic -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _activities, _act_surrendered, _act_business, - { _this call grad_civs_fnc_sm_activities_trans_surrendered_business_condition }, + { _this call FUNC(sm_activities_trans_surrendered_business_condition) }, {}, _act_surrendered + _act_business -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _activities, _act_surrendered, _act_panic, - { _this call grad_civs_fnc_sm_activities_trans_surrendered_panic_condition }, + { _this call FUNC(sm_activities_trans_surrendered_panic_condition) }, {}, _act_surrendered + _act_panic -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _activities, @@ -260,7 +258,8 @@ assert ([ _act_asOrdered + _act_business + "_event" ] call CBA_statemachine_fnc_addEventTransition); -GRAD_CIVS_STATE_ACTIVITIES = _activities; -GRAD_CIVS_STATEMACHINES setVariable ["activities", _activities]; +EGVAR(common,stateMachines) setVariable ["activities", _activities]; + + _activities diff --git a/functions/sm_activities/fn_sm_activities_helper_freeCondition.sqf b/addons/legacy/functions/fnc_sm_activities_helper_freeCondition.sqf similarity index 79% rename from functions/sm_activities/fn_sm_activities_helper_freeCondition.sqf rename to addons/legacy/functions/fnc_sm_activities_helper_freeCondition.sqf index 60ec309b..04ef9231 100644 --- a/functions/sm_activities/fn_sm_activities_helper_freeCondition.sqf +++ b/addons/legacy/functions/fnc_sm_activities_helper_freeCondition.sqf @@ -1,2 +1,4 @@ +#include "..\script_component.hpp" + (_this getVariable ["grad_civs_isPointedAtCount", 0] <= 0) && ((CBA_missionTime - (_this getVariable ["grad_civs_surrenderTime", 0])) > 3) diff --git a/functions/sm_activities/fn_sm_activities_helper_surrenderCondition.sqf b/addons/legacy/functions/fnc_sm_activities_helper_surrenderCondition.sqf similarity index 92% rename from functions/sm_activities/fn_sm_activities_helper_surrenderCondition.sqf rename to addons/legacy/functions/fnc_sm_activities_helper_surrenderCondition.sqf index 2791fa6f..a85e8968 100644 --- a/functions/sm_activities/fn_sm_activities_helper_surrenderCondition.sqf +++ b/addons/legacy/functions/fnc_sm_activities_helper_surrenderCondition.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + private _pointingCount = _this getVariable ["grad_civs_isPointedAtCount", 0]; private _recklessness = _this getVariable ["grad_civs_recklessness", 5]; // goes from 0…10 as gaussian distribution diff --git a/functions/sm_activities/fn_sm_activities_state_asOrdered_enter.sqf b/addons/legacy/functions/fnc_sm_activities_state_asOrdered_enter.sqf similarity index 54% rename from functions/sm_activities/fn_sm_activities_state_asOrdered_enter.sqf rename to addons/legacy/functions/fnc_sm_activities_state_asOrdered_enter.sqf index 61d2efc3..7c47679c 100644 --- a/functions/sm_activities/fn_sm_activities_state_asOrdered_enter.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_asOrdered_enter.sqf @@ -1,3 +1,3 @@ -#include "..\..\component.hpp"; +#include "..\script_component.hpp"; LOG_1("%1 entering ordered state", _this) diff --git a/functions/sm_activities/fn_sm_activities_state_asOrdered_exit.sqf b/addons/legacy/functions/fnc_sm_activities_state_asOrdered_exit.sqf similarity index 60% rename from functions/sm_activities/fn_sm_activities_state_asOrdered_exit.sqf rename to addons/legacy/functions/fnc_sm_activities_state_asOrdered_exit.sqf index 8cead54b..f89ad3f0 100644 --- a/functions/sm_activities/fn_sm_activities_state_asOrdered_exit.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_asOrdered_exit.sqf @@ -1,2 +1,4 @@ +#include "..\script_component.hpp" + _this setUnitPos "AUTO"; _this doFollow (leader _this); diff --git a/functions/sm_activities/fn_sm_activities_state_panic_enter.sqf b/addons/legacy/functions/fnc_sm_activities_state_panic_enter.sqf similarity index 83% rename from functions/sm_activities/fn_sm_activities_state_panic_enter.sqf rename to addons/legacy/functions/fnc_sm_activities_state_panic_enter.sqf index c6e0358c..517a5e38 100644 --- a/functions/sm_activities/fn_sm_activities_state_panic_enter.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_panic_enter.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" _this enableDynamicSimulation false; // prevent from freezing mid-flight (?) [QGVAR(switchMove), [_this, ""]] call CBA_fnc_globalEvent; // leave everything diff --git a/functions/sm_activities/fn_sm_activities_state_panic_exit.sqf b/addons/legacy/functions/fnc_sm_activities_state_panic_exit.sqf similarity index 51% rename from functions/sm_activities/fn_sm_activities_state_panic_exit.sqf rename to addons/legacy/functions/fnc_sm_activities_state_panic_exit.sqf index 46e22925..0d6ec5a6 100644 --- a/functions/sm_activities/fn_sm_activities_state_panic_exit.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_panic_exit.sqf @@ -1,2 +1,3 @@ -_this enableDynamicSimulation true; +#include "..\script_component.hpp" +_this enableDynamicSimulation true; diff --git a/functions/sm_activities/fn_sm_activities_state_surrendered_enter.sqf b/addons/legacy/functions/fnc_sm_activities_state_surrendered_enter.sqf similarity index 84% rename from functions/sm_activities/fn_sm_activities_state_surrendered_enter.sqf rename to addons/legacy/functions/fnc_sm_activities_state_surrendered_enter.sqf index aa3ce0e8..f162c83d 100644 --- a/functions/sm_activities/fn_sm_activities_state_surrendered_enter.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_surrendered_enter.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [_this] call GRAD_CIVS_ONHELDUP; _this setVariable ["grad_civs_surrenderTime", CBA_missionTime]; [_this, true] call ACE_captives_fnc_setSurrendered; diff --git a/functions/sm_activities/fn_sm_activities_state_surrendered_exit.sqf b/addons/legacy/functions/fnc_sm_activities_state_surrendered_exit.sqf similarity index 80% rename from functions/sm_activities/fn_sm_activities_state_surrendered_exit.sqf rename to addons/legacy/functions/fnc_sm_activities_state_surrendered_exit.sqf index ae4e6431..84272e23 100644 --- a/functions/sm_activities/fn_sm_activities_state_surrendered_exit.sqf +++ b/addons/legacy/functions/fnc_sm_activities_state_surrendered_exit.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + _this enableAI "ANIM"; _this enableAI "MOVE"; [_this, false] call ACE_captives_fnc_setSurrendered; diff --git a/addons/legacy/functions/fnc_sm_activities_trans_business_panic_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_business_panic_condition.sqf new file mode 100644 index 00000000..f97a226a --- /dev/null +++ b/addons/legacy/functions/fnc_sm_activities_trans_business_panic_condition.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +(vehicle _this == _this) && + ([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic" diff --git a/addons/legacy/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf new file mode 100644 index 00000000..336b9c20 --- /dev/null +++ b/addons/legacy/functions/fnc_sm_activities_trans_business_surrendered_condition.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +_this call FUNC(sm_activities_helper_surrenderCondition) && (vehicle _this == _this) diff --git a/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf new file mode 100644 index 00000000..16d6dde9 --- /dev/null +++ b/addons/legacy/functions/fnc_sm_activities_trans_dismount_surrendered_condition.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +// transition if surrendering and has dismounted +(_this call FUNC(sm_activities_helper_surrenderCondition)) && (vehicle _this == _this) diff --git a/addons/legacy/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf new file mode 100644 index 00000000..c51c2c9b --- /dev/null +++ b/addons/legacy/functions/fnc_sm_activities_trans_surrendered_business_condition.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +(_this call FUNC(sm_activities_helper_freeCondition)) && (([_this, "emotions"] call EFUNC(common,civGetState)) != "emo_panic") diff --git a/addons/legacy/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf b/addons/legacy/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf new file mode 100644 index 00000000..a2b225cc --- /dev/null +++ b/addons/legacy/functions/fnc_sm_activities_trans_surrendered_panic_condition.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +(_this call FUNC(sm_activities_helper_freeCondition)) && (([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") diff --git a/addons/legacy/functions/fnc_sm_business.sqf b/addons/legacy/functions/fnc_sm_business.sqf new file mode 100644 index 00000000..82813f9f --- /dev/null +++ b/addons/legacy/functions/fnc_sm_business.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +private _business = [[], true] call CBA_statemachine_fnc_create; + +// entry point +private _bus_rally = [ + _business, + { _this call FUNC(sm_business_state_rally_loop) }, + { _this call FUNC(sm_business_state_rally_enter) }, + { }, + "bus_rally" +] call EFUNC(cba_statemachine,addState);; + +EGVAR(common,stateMachines) setVariable ["business", _business]; + + + +_business diff --git a/functions/sm_business/fn_sm_business_state_rally_enter.sqf b/addons/legacy/functions/fnc_sm_business_state_rally_enter.sqf similarity index 68% rename from functions/sm_business/fn_sm_business_state_rally_enter.sqf rename to addons/legacy/functions/fnc_sm_business_state_rally_enter.sqf index c80dcbdd..e5a95915 100644 --- a/functions/sm_business/fn_sm_business_state_rally_enter.sqf +++ b/addons/legacy/functions/fnc_sm_business_state_rally_enter.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + _this stop false; _this setSpeedMode "NORMAL"; [_this] doFollow (leader _this); diff --git a/functions/sm_business/fn_sm_business_state_rally_loop.sqf b/addons/legacy/functions/fnc_sm_business_state_rally_loop.sqf similarity index 63% rename from functions/sm_business/fn_sm_business_state_rally_loop.sqf rename to addons/legacy/functions/fnc_sm_business_state_rally_loop.sqf index 8afd69e2..15ea43c4 100644 --- a/functions/sm_business/fn_sm_business_state_rally_loop.sqf +++ b/addons/legacy/functions/fnc_sm_business_state_rally_loop.sqf @@ -1,10 +1,10 @@ -private _leader = leader _this; +#include "..\script_component.hpp" -assert(_stateMachine == GRAD_CIVS_STATE_BUSINESS); +private _leader = leader _this; /*if leader is calling for mounting up: get in*/ -if (([_leader, _stateMachine] call CBA_statemachine_fnc_getCurrentState) == "bus_mountUp") then { - private _veh = _this call grad_civs_fnc_getGroupVehicle; +if (([_this, "business"] call EFUNC(common,civGetState)) == "bus_mountUp") then { + private _veh = _this call EFUNC(voyage,getGroupVehicle); // TODO resolve circular dependency if (_veh != vehicle _this) then { _this assignAsCargo _veh; [_this] orderGetIn true; diff --git a/functions/sm_emotions/fn_sm_emotions.sqf b/addons/legacy/functions/fnc_sm_emotions.sqf similarity index 81% rename from functions/sm_emotions/fn_sm_emotions.sqf rename to addons/legacy/functions/fnc_sm_emotions.sqf index 2ac1f0f7..baf3e41d 100644 --- a/functions/sm_emotions/fn_sm_emotions.sqf +++ b/addons/legacy/functions/fnc_sm_emotions.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _emotions = [] call CBA_statemachine_fnc_create; @@ -13,7 +13,7 @@ private _emo_relaxed = [ { }, "emo_relaxed" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; private _emo_wary = [ _emotions, @@ -24,7 +24,7 @@ private _emo_wary = [ { }, "emo_wary" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; private _emo_panic = [ _emotions, @@ -36,7 +36,7 @@ private _emo_panic = [ ["grad_civs_panicking_end", [_this], [_this]] call CBA_fnc_targetEvent; }, "emo_panic" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; // TRANSITIONS @@ -49,14 +49,14 @@ assert ([ private _cooldown = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]; private _timeUntilCooldown = _thisStateTime + _cooldown - CBA_missionTime; - [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call grad_civs_fnc_setCurrentlyThinking; + [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call FUNC(setCurrentlyThinking); _timeUntilCooldown <= 0 }, { _this call FUNC(forceEmotionSpeed); }, _emo_panic + _emo_wary -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ @@ -66,14 +66,14 @@ assert ([ private _cooldown = _this getVariable["GRAD_CIVS_PANICCOOLDOWN", 60]; private _timeUntilCooldown = _thisStateTime + _cooldown - CBA_missionTime; - [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call grad_civs_fnc_setCurrentlyThinking; + [_this, format["%1 seconds until cooldown", round _timeUntilCooldown]] call FUNC(setCurrentlyThinking); _timeUntilCooldown <= 0 }, { _this call FUNC(forceEmotionSpeed); }, _emo_wary + _emo_relaxed -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _emotions, @@ -102,7 +102,8 @@ assert ([ _emo_relaxed + _emo_wary ] call CBA_statemachine_fnc_addEventTransition); -GRAD_CIVS_STATE_EMOTIONS = _emotions; -GRAD_CIVS_STATEMACHINES setVariable ["emotions", _emotions]; +EGVAR(common,stateMachines) setVariable ["emotions", _emotions]; + + _emotions diff --git a/functions/sm_lifecycle/fn_sm_lifecycle.sqf b/addons/legacy/functions/fnc_sm_lifecycle.sqf similarity index 52% rename from functions/sm_lifecycle/fn_sm_lifecycle.sqf rename to addons/legacy/functions/fnc_sm_lifecycle.sqf index 012f172a..d472224f 100644 --- a/functions/sm_lifecycle/fn_sm_lifecycle.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle.sqf @@ -1,6 +1,6 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" -private _lifecycle = [{GVAR(LOCAL_CIVS)}, true] call CBA_statemachine_fnc_create; +private _lifecycle = [{GVAR(localCivs)}, true] call CBA_statemachine_fnc_create; private _activities = [] call FUNC(sm_activities); private _emotions = [] call FUNC(sm_emotions); @@ -8,35 +8,35 @@ private _emotions = [] call FUNC(sm_emotions); private _lifecycle_spawn = [ _lifecycle, {}, - { _this call grad_civs_fnc_sm_lifecycle_state_spawn_enter }, + { _this call FUNC(sm_lifecycle_state_spawn_enter) }, {}, "lfc_spawn" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; private _lifecycle_life = [ _lifecycle, [_activities, _emotions], {}, - { _this call grad_civs_fnc_sm_lifecycle_state_life_enter }, - { _this call grad_civs_fnc_sm_lifecycle_state_life_exit }, + { _this call FUNC(sm_lifecycle_state_life_enter) }, + { _this call FUNC(sm_lifecycle_state_life_exit) }, "lfc_life" -] call grad_civs_fnc_addCompoundState; +] call EFUNC(cba_statemachine,addCompoundState);; private _lifecycle_death = [ _lifecycle, {}, - { _this call grad_civs_fnc_sm_lifecycle_state_death_enter }, + { _this call FUNC(sm_lifecycle_state_death_enter) }, {}, "lfc_death" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; private _lifecycle_despawn = [ _lifecycle, {}, - { _this call grad_civs_fnc_sm_lifecycle_state_despawn_enter }, + { _this call FUNC(sm_lifecycle_state_despawn_enter) }, {}, "lfc_despawn" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; assert ([ _lifecycle, @@ -44,15 +44,15 @@ assert ([ { true }, { }, _lifecycle_spawn + _lifecycle_life -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _lifecycle, _lifecycle_life, _lifecycle_despawn, - { _this call grad_civs_fnc_sm_lifecycle_trans_life_despawn_condition }, + { _this call FUNC(sm_lifecycle_trans_life_despawn_condition) }, {}, _lifecycle_life + _lifecycle_despawn -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _lifecycle, @@ -63,7 +63,8 @@ assert ([ _lifecycle_life + _lifecycle_death ] call CBA_statemachine_fnc_addEventTransition); -GRAD_CIVS_STATE_LIFECYCLE = _lifecycle; -GRAD_CIVS_STATEMACHINES setVariable ["lifecycle", _lifecycle]; +EGVAR(common,stateMachines) setVariable ["lifecycle", _lifecycle]; + + _lifecycle diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_state_death_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf similarity index 74% rename from functions/sm_lifecycle/fn_sm_lifecycle_state_death_enter.sqf rename to addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf index ef0af8d8..93d8cdf1 100644 --- a/functions/sm_lifecycle/fn_sm_lifecycle_state_death_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_death_enter.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _deathPos = getPos _this; private _killer = _this getVariable ["ace_medical_lastDamageSource", objNull]; @@ -15,6 +15,9 @@ publicVariableServer "CIV_KILLED"; // even newer CBA event magic ["grad_civs_civKilled", CIV_KILLED] call CBA_fnc_globalEvent; -GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS - [_this]; +GVAR(localCivs) = GVAR(localCivs) - [_this]; ["grad_civs_civ_removed", [_this]] call CBA_fnc_globalEvent; -addToRemainsCollector [_this]; + +if ([QGVAR(cleanupCorpses)] call CBA_settings_fnc_get) then { + addToRemainsCollector [_this]; +}; diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_state_despawn_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf similarity index 73% rename from functions/sm_lifecycle/fn_sm_lifecycle_state_despawn_enter.sqf rename to addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf index bcff3442..40add3c2 100644 --- a/functions/sm_lifecycle/fn_sm_lifecycle_state_despawn_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_despawn_enter.sqf @@ -1,8 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _vec = vehicle _this; if (_vec != _this) then { - GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS - (crew _vec); + GVAR(localCivs) = GVAR(localCivs) - (crew _vec); [QGVAR(civ_removed), (crew _vec)] call CBA_fnc_globalEvent; private _count = { _vec deleteVehicleCrew _x; @@ -11,7 +11,7 @@ if (_vec != _this) then { deleteVehicle _vec; INFO_1("vehicle with %1 civs was despawned", _count); } else { - GRAD_CIVS_LOCAL_CIVS = GRAD_CIVS_LOCAL_CIVS - [_this]; + GVAR(localCivs) = GVAR(localCivs) - [_this]; [QGVAR(civ_removed), [_this]] call CBA_fnc_globalEvent; deleteVehicle _this; INFO("1 civ was despawned"); diff --git a/functions/sm_business/fn_sm_business_state_mountUp_exit.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_life_enter.sqf similarity index 100% rename from functions/sm_business/fn_sm_business_state_mountUp_exit.sqf rename to addons/legacy/functions/fnc_sm_lifecycle_state_life_enter.sqf diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_state_life_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_life_exit.sqf similarity index 100% rename from functions/sm_lifecycle/fn_sm_lifecycle_state_life_enter.sqf rename to addons/legacy/functions/fnc_sm_lifecycle_state_life_exit.sqf diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_state_spawn_enter.sqf b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf similarity index 57% rename from functions/sm_lifecycle/fn_sm_lifecycle_state_spawn_enter.sqf rename to addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf index 2654a174..1700c93f 100644 --- a/functions/sm_lifecycle/fn_sm_lifecycle_state_spawn_enter.sqf +++ b/addons/legacy/functions/fnc_sm_lifecycle_state_spawn_enter.sqf @@ -1,37 +1,7 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _unit = _this; - - -private _reclotheHim = { - params ["_unit", "_loadout"]; - - _unit setUnitLoadout _loadout; - - if (count GRAD_CIVS_FACES > 0) then { - [_unit, selectRandom GRAD_CIVS_FACES] remoteExec ["setFace",0,_unit]; - }; - - _unit setVariable ["BIS_noCoreConversations",true]; -}; - -private _addBeard = { - params ["_unit"]; - - if (count GRAD_CIVS_GOGGLES > 0) then { - _unit addGoggles selectRandom GRAD_CIVS_GOGGLES; - }; -}; - -private _addBackpack = { - params ["_unit"]; - - if ((GRAD_CIVS_BACKPACKPROBABILITY > random 100) && {count GRAD_CIVS_BACKPACKS > 0}) then { - _unit addBackpackGlobal selectRandom GRAD_CIVS_BACKPACKS; - }; -}; - private _addBehaviour = { params ["_unit"]; @@ -48,6 +18,8 @@ private _addBehaviour = { _unit disableAI "AUTOCOMBAT"; }; +_unit setVariable ["BIS_noCoreConversations",true]; + private _addKilledNews = { (_this select 0) addEventHandler ["Killed", { @@ -78,20 +50,16 @@ private _addVars = { ["_civ", objNull] ]; private _fastSpeed = _civ getSpeed "FAST"; - _civ setVariable["GRAD_CIVS_PANICCOOLDOWN" , random GRAD_CIVS_PANICCOOLDOWN, true]; + private _panicCooldown = parseSimpleArray ([QGVAR(panicCooldown)] call cba_settings_fnc_get); // TODO safe parsing + _civ setVariable["GRAD_CIVS_PANICCOOLDOWN" , random _panicCooldown, true]; _civ setVariable["grad_civs_runspeed", random [_fastSpeed * 0.5, _fastSpeed, _fastSpeed * 1.3], true]; _civ setVariable["grad_civs_recklessness", random [0, 5, 10], true]; }; _unit enableDynamicSimulation true; -[_unit, _vehicle] call GRAD_CIVS_ONSPAWN; - -if ((count GRAD_CIVS_CLOTHES > 0) && (count GRAD_CIVS_HEADGEAR > 0)) then { - private _unitLoadout = [[],[],[],[selectRandom GRAD_CIVS_CLOTHES,[]],[],[],selectRandom GRAD_CIVS_HEADGEAR,"""",[],["""","""","""","""","""",""""]]; - [_unit, _unitLoadout] call _reclotheHim; -}; - +ISNILS(GRAD_CIVS_ONSPAWN, {}); // TODO trigger event instead +[_unit] call GRAD_CIVS_ONSPAWN; _unit setVariable ["asr_ai_exclude", true]; @@ -99,6 +67,4 @@ _unit setVariable ["asr_ai_exclude", true]; [_unit] call _addKilledNews; [_unit] call _addGunfightNewsAndFlee; [_unit] call _addBehaviour; -[_unit] call _addBeard; -[_unit] call _addBackpack; [_unit] call _addVars; diff --git a/addons/legacy/functions/fnc_sm_lifecycle_trans_life_despawn_condition.sqf b/addons/legacy/functions/fnc_sm_lifecycle_trans_life_despawn_condition.sqf new file mode 100644 index 00000000..a93ba53d --- /dev/null +++ b/addons/legacy/functions/fnc_sm_lifecycle_trans_life_despawn_condition.sqf @@ -0,0 +1,29 @@ +#include "..\script_component.hpp" + +private _idx = GVAR(localCivs) find _this; + +if (_idx == -1) exitWith {false}; // should not happen, really + +if (((floor CBA_missionTime) mod 10) != (_idx mod 10)) exitWith {false}; // check only every 10s for a given unit + +if (_this getVariable ["grad_civs_excludeFromCleanup",false]) exitWith {false}; + +scopeName "main"; + +private _type = _this getVariable ["grad_civs_primaryTask", ""]; +private _civTaskTypeInfo = EGVAR(common,civTaskTypes) getVariable [_type, []]; +_civTaskTypeInfo params [ + ["_cleanupDistance", 99999, [0]], + ["_despawnCondition", {false}, [{}]] +]; + +if ((count ALL_HUMAN_PLAYERS > 0) || ([QGVAR(spawnOnlyWithPlayers)] call CBA_settings_fnc_get)) then { + if ([ALL_HUMAN_PLAYERS, getPos _this, _cleanupDistance] call FUNC(isInDistanceFromOtherPlayers)) then { + INFO("despawning civ based on distance"); + breakOut "main"; + }; +} else { + INFO("no human players connected, but civs allowed - will abstain from despawning civilians based on player distance"); +}; + +_this call _despawnCondition diff --git a/functions/sm_panic/fn_sm_panic.sqf b/addons/legacy/functions/fnc_sm_panic.sqf similarity index 53% rename from functions/sm_panic/fn_sm_panic.sqf rename to addons/legacy/functions/fnc_sm_panic.sqf index 08e7d69f..5cf203f3 100644 --- a/functions/sm_panic/fn_sm_panic.sqf +++ b/addons/legacy/functions/fnc_sm_panic.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + /** * they're coming to get me! * @@ -8,19 +10,19 @@ private _panic = [] call CBA_statemachine_fnc_create; private _pan_flight = [ _panic, - { _this call grad_civs_fnc_sm_panic_state_flight_loop }, - { _this call grad_civs_fnc_sm_panic_state_flight_enter }, - { _this call grad_civs_fnc_sm_panic_state_flight_exit }, + { _this call FUNC(sm_panic_state_flight_loop) }, + { _this call FUNC(sm_panic_state_flight_enter) }, + { _this call FUNC(sm_panic_state_flight_exit) }, "pan_flight" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; private _pan_hide = [ _panic, {}, - { _this call grad_civs_fnc_sm_panic_state_hide_enter }, - { _this call grad_civs_fnc_sm_panic_state_hide_exit }, + { _this call FUNC(sm_panic_state_hide_enter) }, + { _this call FUNC(sm_panic_state_hide_exit) }, "pan_hide" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; // NOTE concerning act_hidden and act_surrendered @@ -29,10 +31,10 @@ private _pan_hide = [ private _pan_hidden = [ _panic, {}, - { _this call grad_civs_fnc_sm_panic_state_hidden_enter }, + { _this call FUNC(sm_panic_state_hidden_enter) }, {}, "pan_hidden" -] call grad_civs_fnc_addState; +] call EFUNC(cba_statemachine,addState);; // TRANSITIONS @@ -45,18 +47,19 @@ assert ([ }, {}, _pan_flight + _pan_hide -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); assert ([ _panic, _pan_hide, _pan_hidden, - { _this call grad_civs_fnc_sm_panic_trans_hide_hidden_condition }, - { _this call grad_civs_fnc_sm_panic_trans_hide_hidden_handler }, + { _this call FUNC(sm_panic_trans_hide_hidden_condition) }, + { _this call FUNC(sm_panic_trans_hide_hidden_handler) }, _pan_hide + _pan_hidden -] call grad_civs_fnc_addTransition); +] call EFUNC(cba_statemachine,addTransition)); + +EGVAR(common,stateMachines) setVariable ["panic", _panic]; + -GRAD_CIVS_STATE_PANIC = _panic; -GRAD_CIVS_STATEMACHINES setVariable ["panic", _panic]; _panic diff --git a/functions/sm_panic/fn_sm_panic_state_flight_enter.sqf b/addons/legacy/functions/fnc_sm_panic_state_flight_enter.sqf similarity index 76% rename from functions/sm_panic/fn_sm_panic_state_flight_enter.sqf rename to addons/legacy/functions/fnc_sm_panic_state_flight_enter.sqf index 313c9856..a3b325ee 100644 --- a/functions/sm_panic/fn_sm_panic_state_flight_enter.sqf +++ b/addons/legacy/functions/fnc_sm_panic_state_flight_enter.sqf @@ -1 +1,3 @@ +#include "..\script_component.hpp" + _this setVariable ["grad_civ_hidetime", CBA_missionTime + (random 20)]; //start hiding only after up to N seconds diff --git a/functions/sm_panic/fn_sm_panic_state_flight_loop.sqf b/addons/legacy/functions/fnc_sm_panic_state_flight_loop.sqf similarity index 71% rename from functions/sm_panic/fn_sm_panic_state_flight_loop.sqf rename to addons/legacy/functions/fnc_sm_panic_state_flight_loop.sqf index e7778220..83897a7d 100644 --- a/functions/sm_panic/fn_sm_panic_state_flight_loop.sqf +++ b/addons/legacy/functions/fnc_sm_panic_state_flight_loop.sqf @@ -1,8 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" _flightpoint = _this getVariable ["grad_civs_flightpoint", [0, 0, 0]]; if (((_this distance _flightpoint) < 2) || (_flightpoint isEqualTo [0, 0, 0])) then { - _pos = [leader _this, [150,300], [0,360]] call grad_civs_fnc_findRandomPos; + _pos = [leader _this, [150,300], [0,360]] call FUNC(findRandomPos); _this setVariable ["grad_civs_flightpoint", _pos]; _this doMove _pos; _this call FUNC(forceEmotionSpeed); diff --git a/functions/sm_panic/fn_sm_panic_state_hidden_enter.sqf b/addons/legacy/functions/fnc_sm_panic_state_hidden_enter.sqf similarity index 82% rename from functions/sm_panic/fn_sm_panic_state_hidden_enter.sqf rename to addons/legacy/functions/fnc_sm_panic_state_hidden_enter.sqf index 0f52bfe9..dd665bb3 100644 --- a/functions/sm_panic/fn_sm_panic_state_hidden_enter.sqf +++ b/addons/legacy/functions/fnc_sm_panic_state_hidden_enter.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + private _animationHiding = ["Acts_CivilHiding_1", "Acts_CivilHiding_2"]; _this playMoveNow (selectRandom _animationHiding); _this setVariable ["grad_civs_flightpoint", nil]; diff --git a/functions/sm_panic/fn_sm_panic_state_hide_enter.sqf b/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf similarity index 59% rename from functions/sm_panic/fn_sm_panic_state_hide_enter.sqf rename to addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf index a10a0ebc..2a39d329 100644 --- a/functions/sm_panic/fn_sm_panic_state_hide_enter.sqf +++ b/addons/legacy/functions/fnc_sm_panic_state_hide_enter.sqf @@ -1,5 +1,7 @@ -private _pos = [_this, true] call grad_civs_fnc_findPositionOfInterest; -[_this, format ["going to pos %1 (still %2m) to hide", _pos, _this distance _pos]] call grad_civs_fnc_setCurrentlyThinking; +#include "..\script_component.hpp" + +private _pos = [_this, true] call FUNC(findPositionOfInterest); +[_this, format ["going to pos %1 (still %2m) to hide", _pos, _this distance _pos]] call FUNC(setCurrentlyThinking); _this setVariable ["grad_civs_hidepoint", _pos]; _this doMove _pos; _this setSpeedMode "FULL"; diff --git a/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf b/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf new file mode 100644 index 00000000..6b566552 --- /dev/null +++ b/addons/legacy/functions/fnc_sm_panic_state_hide_exit.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +_this call FUNC(clearCurrentlyThinking) diff --git a/functions/sm_panic/fn_sm_panic_trans_hide_hidden_condition.sqf b/addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_condition.sqf similarity index 79% rename from functions/sm_panic/fn_sm_panic_trans_hide_hidden_condition.sqf rename to addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_condition.sqf index 9ae6c9cc..799d220f 100644 --- a/functions/sm_panic/fn_sm_panic_trans_hide_hidden_condition.sqf +++ b/addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_condition.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + // within 2m of hidepoint (if one exists) _hidepoint = _this getVariable ["grad_civs_hidepoint", [0, 0, 0]]; (_this distance _hidepoint) < 2 diff --git a/addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_handler.sqf b/addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_handler.sqf new file mode 100644 index 00000000..4aee07e5 --- /dev/null +++ b/addons/legacy/functions/fnc_sm_panic_trans_hide_hidden_handler.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +_this stop true diff --git a/addons/legacy/functions/fnc_spawnCivilian.sqf b/addons/legacy/functions/fnc_spawnCivilian.sqf new file mode 100644 index 00000000..6998e59d --- /dev/null +++ b/addons/legacy/functions/fnc_spawnCivilian.sqf @@ -0,0 +1,19 @@ +#include "..\script_component.hpp" + +params [ + ["_pos", [0, 0, 0]], + ["_group", grpNull], + ["_primaryTask", ""] +]; + +private _civClass = [QGVAR(civClass)] call CBA_settings_fnc_get; +private _civ = _group createUnit [_civClass, _pos, [], 0, "NONE"]; // TODO: ensure unit is not spawning within editor-placed rocks/houses + +GVAR(localCivs) = GVAR(localCivs) + [_civ]; +[QGVAR(civ_added), [_civ]] call CBA_fnc_globalEvent; + + +_civ setVariable ["grad_civs_primaryTask", _primaryTask, true]; +_civ setVariable ["acex_headless_blacklist", true, true]; + +_civ diff --git a/addons/legacy/functions/fnc_spawnCivilianGroup.sqf b/addons/legacy/functions/fnc_spawnCivilianGroup.sqf new file mode 100644 index 00000000..995b9da3 --- /dev/null +++ b/addons/legacy/functions/fnc_spawnCivilianGroup.sqf @@ -0,0 +1,32 @@ +#include "..\script_component.hpp" + +params [ + ["_pos", [0, 0, 0]], + ["_groupSize", 1], + ["_house", objNull], + ["_primaryTask", ""] +]; + +if (_pos isEqualTo [0, 0, 0]) exitWith { + ERROR_1("tried to spawn civs at %1", _pos); + grpNull +}; + +private _group = createGroup [civilian, true]; +_group setCombatMode "GREEN"; + +for "_i" from 1 to _groupSize do { + private _civ = [_pos, _group, _primaryTask] call FUNC(spawnCivilian); +}; + +if (isNull _house) then { + WARNING_2("no house for group %1 (primaryTask=%2)",_group, _primaryTask); +} else { + _group setVariable ["grad_civs_home", _house, true]; + _house setVariable ["grad_civs_residents", units _group, true]; + { + _x setVariable ["grad_civs_home", _house, true]; + } forEach units _group; +}; + +_group diff --git a/addons/legacy/functions/fnc_spawnPass.sqf b/addons/legacy/functions/fnc_spawnPass.sqf new file mode 100644 index 00000000..73a0b3f8 --- /dev/null +++ b/addons/legacy/functions/fnc_spawnPass.sqf @@ -0,0 +1,14 @@ +#include "..\script_component.hpp" + +if ((ALL_HUMAN_PLAYERS isEqualTo []) && ([QGVAR(spawnOnlyWithPlayers)] call CBA_settings_fnc_get)) exitWith { + INFO("no human players connected, will abstain from spawning civilians") +}; + +private _minCivUpdateTime = [QGVAR(minCivUpdateTime)] call cba_settings_fnc_get; +private _minFps = [QGVAR(minFps)] call cba_settings_fnc_get; + +private _fps = diag_fps; +if (_fps < _minFps) exitWith {INFO_2("not spawning additional civs: less FPS than required (%1/%2)", _fps, _minFps)}; +if ((_fps * _minCivUpdateTime) < (count GVAR(localCivs))) exitWith {INFO_3("not spawning additional civs: cannot guarantee update times less than %1 for %2 civs with %3 fps", _minCivUpdateTime, count GVAR(localCivs), _fps)}; + +[QGVAR(spawnAllowed), []] call CBA_fnc_localEvent; diff --git a/functions/common/fn_uid.sqf b/addons/legacy/functions/fnc_uid.sqf similarity index 87% rename from functions/common/fn_uid.sqf rename to addons/legacy/functions/fnc_uid.sqf index 5568e7e7..64529af2 100644 --- a/functions/common/fn_uid.sqf +++ b/addons/legacy/functions/fnc_uid.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + // generate some kind of weak UID toString(("1234567890" splitString "") apply { diff --git a/functions/debug/fn_updateInfoLine.sqf b/addons/legacy/functions/fnc_updateInfoLine.sqf similarity index 51% rename from functions/debug/fn_updateInfoLine.sqf rename to addons/legacy/functions/fnc_updateInfoLine.sqf index 5096ffb2..20dcec55 100644 --- a/functions/debug/fn_updateInfoLine.sqf +++ b/addons/legacy/functions/fnc_updateInfoLine.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" ASSERT_SERVER(""); @@ -6,15 +6,15 @@ ASSERT_SERVER(""); set a civ's info line for debugging. this is done server-side, because players cannot access the civ state machine */ -private _statemachineNames = allVariables GRAD_CIVS_STATEMACHINES; +private _statemachineNames = allVariables EGVAR(common,stateMachines); private _states = (_statemachineNames apply { - private _sm = GRAD_CIVS_STATEMACHINES getVariable _x; - private _state = [_this, _sm, "NONE"] call grad_civs_fnc_getCurrentState; + private _sm = EGVAR(common,stateMachines) getVariable _x; + private _state = [_this, _sm, "NONE"] call EFUNC(cba_statemachine,getCurrentState); format ["%1: %2", _x, _state]; }) joinString ", "; -_text = format ["%1 | %2 | %3", _this, _states, _x call grad_civs_fnc_getCurrentlyThinking]; +_text = format ["%1 | %2 | %3", _this, _states, _x call FUNC(getCurrentlyThinking)]; _this setVariable ["grad_civs_infoLine", _text, true]; _this setVariable ["grad_civs_owner", clientOwner, true]; diff --git a/addons/legacy/script_component.hpp b/addons/legacy/script_component.hpp new file mode 100644 index 00000000..a17fca81 --- /dev/null +++ b/addons/legacy/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT legacy +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/loadout/$PBOPREFIX$ b/addons/loadout/$PBOPREFIX$ new file mode 100644 index 00000000..8606d546 --- /dev/null +++ b/addons/loadout/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\loadout diff --git a/addons/loadout/CfgEventHandlers.hpp b/addons/loadout/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/loadout/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/loadout/XEH_PREP.hpp b/addons/loadout/XEH_PREP.hpp new file mode 100644 index 00000000..e264c25c --- /dev/null +++ b/addons/loadout/XEH_PREP.hpp @@ -0,0 +1,7 @@ +PREP(civAddLoadout); +PREP(initConfig); +PREP(setBackpacks); +PREP(setClothes); +PREP(setFaces); +PREP(setGoggles); +PREP(setHeadgear); diff --git a/addons/loadout/XEH_postInit.sqf b/addons/loadout/XEH_postInit.sqf new file mode 100644 index 00000000..8812ef0d --- /dev/null +++ b/addons/loadout/XEH_postInit.sqf @@ -0,0 +1,14 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + + +[QEGVAR(legacy,civ_added), { + params [["_civ", objNull, [objNull]]]; + assert(!isNull _civ); + if (local _civ) then { + [_civ] call FUNC(civAddLoadout); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/loadout/XEH_preInit.sqf b/addons/loadout/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/loadout/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/loadout/config.cpp b/addons/loadout/config.cpp new file mode 100644 index 00000000..f5c89298 --- /dev/null +++ b/addons/loadout/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers", "grad_civs_common"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/loadout/functions/fnc_civAddLoadout.sqf b/addons/loadout/functions/fnc_civAddLoadout.sqf new file mode 100644 index 00000000..3e371cb5 --- /dev/null +++ b/addons/loadout/functions/fnc_civAddLoadout.sqf @@ -0,0 +1,47 @@ +#include "..\script_component.hpp" + +params [ + ["_unit", objNull, [objNull]] +]; + +assert(!isNull _unit); + + +private _reclotheHim = { + params ["_unit", "_loadout"]; + + _unit setUnitLoadout _loadout; + private _faces = parseSimpleArray ([QGVAR(faces)] call cba_settings_fnc_get); + if (count _faces > 0) then { + [_unit, selectRandom _faces] remoteExec ["setFace", 0, _unit]; + }; +}; + +private _addBeard = { + params ["_unit"]; + private _goggles = parseSimpleArray ([QGVAR(goggles)] call cba_settings_fnc_get); + if (count _goggles > 0) then { + _unit addGoggles selectRandom _goggles; + }; +}; + +private _addBackpack = { + params ["_unit"]; + + private _backpacks = parseSimpleArray ([QGVAR(backpacks)] call cba_settings_fnc_get); + private _backpackProbability = [QGVAR(backpackProbability)] call cba_settings_fnc_get; + if ((_backpackProbability > (random 1)) && {count _backpacks > 0}) then { + _unit addBackpackGlobal selectRandom _backpacks; + }; +}; + +private _clothes = parseSimpleArray ([QGVAR(clothes)] call cba_settings_fnc_get); +private _headgear = parseSimpleArray ([QGVAR(headgear)] call cba_settings_fnc_get); +if ((count _clothes > 0) && (count _headgear > 0)) then { + private _unitLoadout = [[],[],[],[selectRandom _clothes,[]],[],[],selectRandom _headgear,"""",[],["""","""","""","""","""",""""]]; + [_unit, _unitLoadout] call _reclotheHim; +}; + + +[_unit] call _addBeard; +[_unit] call _addBackpack; diff --git a/addons/loadout/functions/fnc_initConfig.sqf b/addons/loadout/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..4c75be19 --- /dev/null +++ b/addons/loadout/functions/fnc_initConfig.sqf @@ -0,0 +1,71 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "6) loadout"]; + +[ + QGVAR(backpacks), + "EDITBOX", + "Backpacks that civilians may wear", + _settingsGroup, + "[]", + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(backpackProbability), + "SLIDER", + "Ratio of civs who will wear backpacks", + _settingsGroup, + [0, 100, 50, 0, true], // TODO when reading this setting, take care - its a percentage now + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(clothes), + "EDITBOX", + "Clothes that civilians must wear", + _settingsGroup, + "[]", + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(headgear), + "EDITBOX", + "Headgear that civilians must wear", + _settingsGroup, + "[]", + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(faces), + "EDITBOX", + "Faces that civilians must have.", + _settingsGroup, + "[]", + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(goggles), + "EDITBOX", + "Goggles that civilians must wear", + _settingsGroup, + "[]", + true, + {}, + false +] call CBA_fnc_addSetting; diff --git a/addons/loadout/functions/fnc_setBackpacks.sqf b/addons/loadout/functions/fnc_setBackpacks.sqf new file mode 100644 index 00000000..df394bef --- /dev/null +++ b/addons/loadout/functions/fnc_setBackpacks.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" + +params [["_value",[]],["_probability",0.5]]; + +[QGVAR(backpacks), _value, 0, "mission"] call CBA_settings_fnc_set; +[QGVAR(backpackProbability), _probability, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/loadout/functions/fnc_setClothes.sqf b/addons/loadout/functions/fnc_setClothes.sqf new file mode 100644 index 00000000..1c82ec4a --- /dev/null +++ b/addons/loadout/functions/fnc_setClothes.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params [["_value",[]]]; + +[QGVAR(clothes), _value, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/loadout/functions/fnc_setFaces.sqf b/addons/loadout/functions/fnc_setFaces.sqf new file mode 100644 index 00000000..6760e5b3 --- /dev/null +++ b/addons/loadout/functions/fnc_setFaces.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params [["_value",[]]]; + +[QGVAR(faces), _value, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/loadout/functions/fnc_setGoggles.sqf b/addons/loadout/functions/fnc_setGoggles.sqf new file mode 100644 index 00000000..c98a74c8 --- /dev/null +++ b/addons/loadout/functions/fnc_setGoggles.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params [["_value",[]]]; + +[QGVAR(goggles), _value, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/loadout/functions/fnc_setHeadgear.sqf b/addons/loadout/functions/fnc_setHeadgear.sqf new file mode 100644 index 00000000..337c40e8 --- /dev/null +++ b/addons/loadout/functions/fnc_setHeadgear.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params [["_value",[]]]; + +[QGVAR(headgear), _value, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/loadout/script_component.hpp b/addons/loadout/script_component.hpp new file mode 100644 index 00000000..7233a5e0 --- /dev/null +++ b/addons/loadout/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT loadout +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/main/$PBOPREFIX$ b/addons/main/$PBOPREFIX$ new file mode 100644 index 00000000..2ad73d79 --- /dev/null +++ b/addons/main/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\main diff --git a/addons/main/CfgEventHandlers.hpp b/addons/main/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/main/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/main/CfgFactionClasses.hpp b/addons/main/CfgFactionClasses.hpp new file mode 100644 index 00000000..c41b8795 --- /dev/null +++ b/addons/main/CfgFactionClasses.hpp @@ -0,0 +1,8 @@ +class CfgFactionClasses +{ + class NO_CATEGORY; + class GVAR(modules): NO_CATEGORY + { + displayName = "GRAD civs"; + }; +}; diff --git a/addons/main/XEH_PREP.hpp b/addons/main/XEH_PREP.hpp new file mode 100644 index 00000000..6baf2dfb --- /dev/null +++ b/addons/main/XEH_PREP.hpp @@ -0,0 +1 @@ +PREP(initConfig); diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf new file mode 100644 index 00000000..421c54b4 --- /dev/null +++ b/addons/main/XEH_postInit.sqf @@ -0,0 +1 @@ +#include "script_component.hpp" diff --git a/addons/main/XEH_preInit.sqf b/addons/main/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/main/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/main/config.cpp b/addons/main/config.cpp new file mode 100644 index 00000000..fda4a1af --- /dev/null +++ b/addons/main/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers", "A3_Modules_F"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFactionClasses.hpp" diff --git a/addons/main/functions/fnc_initConfig.sqf b/addons/main/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..b9edaec1 --- /dev/null +++ b/addons/main/functions/fnc_initConfig.sqf @@ -0,0 +1,14 @@ +#include "..\script_component.hpp" + +private _settingsGroup = ["GRAD Civs", "1) main"]; + +[ + QGVAR(enabled), + "CHECKBOX", + "Enable grad_civs", + _settingsGroup, + false, + true, + {}, + true +] call CBA_fnc_addSetting; diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp new file mode 100644 index 00000000..054bfd92 --- /dev/null +++ b/addons/main/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT main +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/component.hpp b/addons/main/script_macros.hpp similarity index 52% rename from component.hpp rename to addons/main/script_macros.hpp index 845b38fd..a86ee27d 100644 --- a/component.hpp +++ b/addons/main/script_macros.hpp @@ -1,21 +1,22 @@ -#define PREFIX GRAD -#define COMPONENT civs +#include "\x\cba\addons\main\script_macros_common.hpp" -// #define DEBUG_MODE_FULL -#include "\x\cba\addons\main\script_macros_mission.hpp" +#define DFUNC(var1) TRIPLES(ADDON,fnc,var1) + +#ifdef DISABLE_COMPILE_CACHE + #undef PREP + #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\DOUBLES(fnc,fncName).sqf) +#else + #undef PREP + #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction +#endif #ifdef DEBUG_MODE_FULL -#define LOGTIME_START(var1) missionNamespace setVariable [var1,diag_tickTime] -#define LOGTIME_DELTAT(var1) diag_tickTime - (missionNamespace getVariable [var1,diag_tickTime]) -#define LOGTIME_END(var1) LOG_SYS('PERFORMANCE',format [ARR_3('%1 took %2s',var1,LOGTIME_DELTAT(var1))]); missionNamespace setVariable [var1,nil] #define ASSERT_SERVER(var1) if (!assert(!hasInterface || isServer)) exitWith { diag_log(var1); } #define ASSERT_PLAYER(var1) if (!assert(hasInterface)) exitWith { diag_log(var1); } #else -#define LOGTIME_START(var1) -#define LOGTIME_END(var1) #define ASSERT_SERVER(var1) if (!(!hasInterface || isServer)) exitWith { diag_log(var1); } #define ASSERT_PLAYER(var1) if (!hasInterface) exitWith { diag_log(var1); } diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp new file mode 100644 index 00000000..8d0f8f1b --- /dev/null +++ b/addons/main/script_mod.hpp @@ -0,0 +1,9 @@ +#define MAINPREFIX z +#define PREFIX grad_civs + +#include "script_version.hpp" + +#define VERSION MAJOR.MINOR.PATCH.BUILD +#define VERSION_AR MAJOR,MINOR,PATCH,BUILD + +#define REQUIRED_VERSION 1.96 diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp new file mode 100644 index 00000000..4c749707 --- /dev/null +++ b/addons/main/script_version.hpp @@ -0,0 +1,4 @@ +#define MAJOR 0 +#define MINOR 1 +#define PATCH 0 +#define BUILD 0 diff --git a/addons/main/ui/civ.paa b/addons/main/ui/civ.paa new file mode 100644 index 00000000..f1d48bc5 Binary files /dev/null and b/addons/main/ui/civ.paa differ diff --git a/addons/mimikry/$PBOPREFIX$ b/addons/mimikry/$PBOPREFIX$ new file mode 100644 index 00000000..d2c17ef5 --- /dev/null +++ b/addons/mimikry/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\mimikry diff --git a/addons/mimikry/CfgEventHandlers.hpp b/addons/mimikry/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/mimikry/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/mimikry/README.md b/addons/mimikry/README.md new file mode 100644 index 00000000..2e4b61e5 --- /dev/null +++ b/addons/mimikry/README.md @@ -0,0 +1,6 @@ +# grad\_civs\_mimikry + +if mimikry is enabled, grad\_civs will inform civilian *players* of certain actions done to them by other players that AI civilians would react to. + +Example: AI civilians will raise their hands when pointed at with a weapon. To give a civilian *player* the chance to pass for an AI civ, they will get a hint about s/o pointing their weapon at them in a way that would cause an AI civilian to raise their hands. + diff --git a/addons/mimikry/XEH_PREP.hpp b/addons/mimikry/XEH_PREP.hpp new file mode 100644 index 00000000..ce1f9e83 --- /dev/null +++ b/addons/mimikry/XEH_PREP.hpp @@ -0,0 +1,4 @@ +PREP(addEventHandlers); +PREP(createInfoChannel); +PREP(initConfig); +PREP(showCivHint); diff --git a/addons/mimikry/XEH_postInit.sqf b/addons/mimikry/XEH_postInit.sqf new file mode 100644 index 00000000..5ca70ae7 --- /dev/null +++ b/addons/mimikry/XEH_postInit.sqf @@ -0,0 +1,41 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +if (!([QGVAR(enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("module disabled. good bye."); +}; + +if (isServer) then { + INFO("server init running..."); + GVAR(INFOCHANNEL) = [] call FUNC(createInfoChannel); + publicVariable QGVAR(INFOCHANNEL); +}; + +if (hasInterface) then { + ISNILS(GVAR(INFOCHANNEL), 0); + [] call FUNC(addEventHandlers); +}; + +GVAR(PLAYERSIDE) = sideUnknown; +[ + { + if (!isGameFocused || isGamePaused) exitWith {}; + if !(alive player) exitWith {}; + if (GVAR(PLAYERSIDE) == side player) exitWith {}; + if ((["HEALTHY", "INJURED"] find (lifeState player)) == -1) exitWith {}; + + if (side player == civilian) then { + GVAR(INFOCHANNEL) radioChannelAdd [player]; + ["you are CIVILIAN now"] call FUNC(showCivHint); + } else { if (GVAR(PLAYERSIDE) == civilian) then { + ["you are NO LONGER CIVILIAN"] call FUNC(showCivHint); + GVAR(INFOCHANNEL) radioChannelRemove [player]; + }}; + GVAR(PLAYERSIDE) = side player; + }, + 5, + [] +] call CBA_fnc_addPerFrameHandler; diff --git a/addons/mimikry/XEH_preInit.sqf b/addons/mimikry/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/mimikry/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/mimikry/config.cpp b/addons/mimikry/config.cpp new file mode 100644 index 00000000..218a1efa --- /dev/null +++ b/addons/mimikry/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers", "ace_common", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/functions/player/fn_registerAceInteractionHandler.sqf b/addons/mimikry/functions/fnc_addEventHandlers.sqf similarity index 79% rename from functions/player/fn_registerAceInteractionHandler.sqf rename to addons/mimikry/functions/fnc_addEventHandlers.sqf index fd8d4f61..df97327c 100644 --- a/functions/player/fn_registerAceInteractionHandler.sqf +++ b/addons/mimikry/functions/fnc_addEventHandlers.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" ["ace_interaction_sendAway", { params ["_civ"]; @@ -7,7 +7,7 @@ addCamShake [4, 0.5, 5]; private _message = "you are being told to GO AWAY"; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; ["ace_interaction_getDown", { @@ -17,11 +17,11 @@ addCamShake [4, 0.5, 5]; private _message = "you are being told to GET DOWN"; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -["pointed_at_inc", { +[QEGVAR(common,pointed_at_inc), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; @@ -29,10 +29,10 @@ _civ setVariable ["grad_civs_isPointedAtCount", _newCount]; private _message = format["you're being pointed at with %1 guns", _newCount]; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -["pointed_at_dec", { +[QEGVAR(common,pointed_at_dec), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; @@ -45,22 +45,22 @@ if (_newCount == 0) then { _message = "you're NOT pointed at with guns anymore"; }; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -["honked_at", { +[QEGVAR(common,honked_at), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; private _message = "a car honks at you"; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; -[QGVAR(gestured_at_stop), { +[QEGVAR(common,gestured_at_stop), { params ["_civ"]; if (_civ != ACE_player) exitWith {}; private _message = "someone gestures at you to stop"; - [_message] call grad_civs_fnc_showCivHint; + [_message] call FUNC(showCivHint); }] call CBA_fnc_addEventHandler; diff --git a/functions/spawn/fn_createInfoChannel.sqf b/addons/mimikry/functions/fnc_createInfoChannel.sqf similarity index 81% rename from functions/spawn/fn_createInfoChannel.sqf rename to addons/mimikry/functions/fnc_createInfoChannel.sqf index 754f66a6..4189c1f7 100644 --- a/functions/spawn/fn_createInfoChannel.sqf +++ b/addons/mimikry/functions/fnc_createInfoChannel.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" ASSERT_SERVER("radio channel must be created on server"); diff --git a/addons/mimikry/functions/fnc_initConfig.sqf b/addons/mimikry/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..6a4e7bfb --- /dev/null +++ b/addons/mimikry/functions/fnc_initConfig.sqf @@ -0,0 +1,16 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "7) player mimikry"]; + +[ + QGVAR(enabled), + "CHECKBOX", + "Enable player mimikry", + _settingsGroup, + true, + true, + {}, + true +] call CBA_fnc_addSetting; diff --git a/functions/player/fn_showCivHint.sqf b/addons/mimikry/functions/fnc_showCivHint.sqf similarity index 63% rename from functions/player/fn_showCivHint.sqf rename to addons/mimikry/functions/fnc_showCivHint.sqf index 9543bead..01a9e927 100644 --- a/functions/player/fn_showCivHint.sqf +++ b/addons/mimikry/functions/fnc_showCivHint.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_plain", ""], ["_structured", ""] @@ -8,8 +10,8 @@ if (_structured == "") then { }; [_structured] call ace_common_fnc_displayTextStructured; -if (GRAD_CIVS_INFOCHANNEL == 0) then { +if (GVAR(INFOCHANNEL) == 0) then { systemChat _plain; } else { - player customChat [GRAD_CIVS_INFOCHANNEL, _plain]; + player customChat [GVAR(INFOCHANNEL), _plain]; }; diff --git a/addons/mimikry/script_component.hpp b/addons/mimikry/script_component.hpp new file mode 100644 index 00000000..f79ad140 --- /dev/null +++ b/addons/mimikry/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT mimikry +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/patrol/$PBOPREFIX$ b/addons/patrol/$PBOPREFIX$ new file mode 100644 index 00000000..e77e7ad1 --- /dev/null +++ b/addons/patrol/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\patrol diff --git a/addons/patrol/CfgEventHandlers.hpp b/addons/patrol/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/patrol/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/patrol/XEH_PREP.hpp b/addons/patrol/XEH_PREP.hpp new file mode 100644 index 00000000..45176eaf --- /dev/null +++ b/addons/patrol/XEH_PREP.hpp @@ -0,0 +1,13 @@ +PREP(addCycleWaypoint); +PREP(addFootsy); +PREP(initConfig); +PREP(sm_business); +PREP(sm_business_state_patrol_enter); +PREP(sm_business_state_patrol_exit); +PREP(sm_business_trans_rally_patrol_condition); +PREP(taskPatrolAddWaypoint); +PREP(taskPatrolFindWaypoint); +// PREP(taskPatrolFindWaypoints.spec); +PREP(taskPatrolFindWaypoints); +// PREP(taskPatrol.spec); +PREP(taskPatrol); diff --git a/addons/patrol/XEH_postInit.sqf b/addons/patrol/XEH_postInit.sqf new file mode 100644 index 00000000..b223c527 --- /dev/null +++ b/addons/patrol/XEH_postInit.sqf @@ -0,0 +1,33 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +[ + QEGVAR(legacy,spawnAllowed), + { + ISNILS(GVAR(maxCivsOnFoot), [QGVAR(maxCivsOnFoot)] call CBA_settings_fnc_get); + if ((count (["patrol"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsOnFoot)) then { + [ALL_HUMAN_PLAYERS] call FUNC(addFootsy); + }; + } +] call CBA_fnc_addEventHandler; + +private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesOnFoot)] call CBA_settings_fnc_get); +[ + "patrol", + _spawnDistances#1 * 1.5 +] call EFUNC(common,registerCivTaskType); + +[ + {"business" in (allVariables EGVAR(common,stateMachines))}, + { + [EGVAR(common,stateMachines) getVariable "business"] call FUNC(sm_business); + }, + [], + 300, + { + ERROR("'business' state machine did not get initialized - cannot add to it"); + } +] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/patrol/XEH_preInit.sqf b/addons/patrol/XEH_preInit.sqf new file mode 100644 index 00000000..a6fbf9d8 --- /dev/null +++ b/addons/patrol/XEH_preInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + +[] call FUNC(initConfig); diff --git a/addons/patrol/config.cpp b/addons/patrol/config.cpp new file mode 100644 index 00000000..f1cc2370 --- /dev/null +++ b/addons/patrol/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"CBA_Extended_EventHandlers", "grad_civs_main", "grad_civs_common", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/functions/behaviour/fn_addCycleWaypoint.sqf b/addons/patrol/functions/fnc_addCycleWaypoint.sqf similarity index 85% rename from functions/behaviour/fn_addCycleWaypoint.sqf rename to addons/patrol/functions/fnc_addCycleWaypoint.sqf index 97a9df44..a1c01264 100644 --- a/functions/behaviour/fn_addCycleWaypoint.sqf +++ b/addons/patrol/functions/fnc_addCycleWaypoint.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_group", grpNull], ["_position", [0, 0, 0]] diff --git a/addons/patrol/functions/fnc_addFootsy.sqf b/addons/patrol/functions/fnc_addFootsy.sqf new file mode 100644 index 00000000..5f445b3b --- /dev/null +++ b/addons/patrol/functions/fnc_addFootsy.sqf @@ -0,0 +1,25 @@ +#include "..\script_component.hpp" + +params [ + ["_allPlayers", []] +]; + +private _footSpawnDistances = parseSimpleArray ([QGVAR(spawnDistancesOnFoot)] call CBA_settings_fnc_get); +private _footSpawnDistanceMin = _footSpawnDistances#0; +private _footSpawnDistanceMax = _footSpawnDistances#1; + +private _house = [ + _allPlayers, + _footSpawnDistanceMin, + _footSpawnDistanceMax, + "house" +] call EFUNC(legacy,findSpawnPosition); + +if (isNull _house) exitWith { + LOG("could not find house for patrol"); +}; + +private _maxInitialGroupSize = [QGVAR(initialGroupSize)] call CBA_settings_fnc_get; +private _groupSize = (floor random _maxInitialGroupSize) + 1; + +_group = [getPos _house, _groupSize, _house, "patrol"] call EFUNC(legacy,spawnCivilianGroup); diff --git a/addons/patrol/functions/fnc_initConfig.sqf b/addons/patrol/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..7fc2afd2 --- /dev/null +++ b/addons/patrol/functions/fnc_initConfig.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "4) patrols"]; + +[ + QGVAR(initialGroupSize), + "SLIDER", + "Max group size for civilians", + _settingsGroup, + [0, 50, 3, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(maxCivsOnFoot), + "SLIDER", + "Maximum total number of civilians patroling on foot", + _settingsGroup, + [0, 300, 30, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(spawnDistancesOnFoot), + "EDITBOX", + "Spawn distance ([min,max])", + _settingsGroup, + QUOTE(ARR_2([1000,4500])), + false, + {}, + false +] call CBA_fnc_addSetting; diff --git a/addons/patrol/functions/fnc_sm_business.sqf b/addons/patrol/functions/fnc_sm_business.sqf new file mode 100644 index 00000000..c158dbd1 --- /dev/null +++ b/addons/patrol/functions/fnc_sm_business.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" + +params [ + ["_business", locationNull, [locationNull]] +]; + +private _bus_rally = "bus_rally"; +/** + * most simple thing to do: go on patrol. yay! + */ +private _bus_patrol = [ + _business, + {}, + { _this call FUNC(sm_business_state_patrol_enter) }, + { _this call FUNC(sm_business_state_patrol_exit) }, + QUOTE(bus_patrol) +] call EFUNC(cba_statemachine,addState);; + + + // TRANSITIONS patrol: + +assert ([ + _business, + _bus_rally, _bus_patrol, + { _this call FUNC(sm_business_trans_rally_patrol_condition) }, + {}, + _bus_rally + _bus_patrol +] call EFUNC(cba_statemachine,addTransition)); + +_business diff --git a/functions/sm_business/fn_sm_business_state_patrol_enter.sqf b/addons/patrol/functions/fnc_sm_business_state_patrol_enter.sqf similarity index 86% rename from functions/sm_business/fn_sm_business_state_patrol_enter.sqf rename to addons/patrol/functions/fnc_sm_business_state_patrol_enter.sqf index ea0ff82d..f386182e 100644 --- a/functions/sm_business/fn_sm_business_state_patrol_enter.sqf +++ b/addons/patrol/functions/fnc_sm_business_state_patrol_enter.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" if (_this == leader _this) then { _grp = group _this; @@ -13,5 +13,5 @@ if (_this == leader _this) then { _x enableDynamicSimulation true; false } count (units _grp); - _this call FUNC(forceEmotionSpeed); + _this call EFUNC(legacy,forceEmotionSpeed); }; diff --git a/functions/sm_business/fn_sm_business_state_patrol_exit.sqf b/addons/patrol/functions/fnc_sm_business_state_patrol_exit.sqf similarity index 100% rename from functions/sm_business/fn_sm_business_state_patrol_exit.sqf rename to addons/patrol/functions/fnc_sm_business_state_patrol_exit.sqf diff --git a/addons/patrol/functions/fnc_sm_business_trans_rally_patrol_condition.sqf b/addons/patrol/functions/fnc_sm_business_trans_rally_patrol_condition.sqf new file mode 100644 index 00000000..0eb7a6ba --- /dev/null +++ b/addons/patrol/functions/fnc_sm_business_trans_rally_patrol_condition.sqf @@ -0,0 +1,9 @@ +#include "..\script_component.hpp" + +private _grpUnits = units _this; +private _nonRallyCount = { + ([_this, "business"] call EFUNC(common,civGetState)) != "bus_rally" +} count _grpUnits; +private _allRallying = _nonRallyCount == 0; + +_allRallying && ((_this getVariable ["grad_civs_primaryTask", ""]) == "patrol") diff --git a/functions/behaviour/fn_taskPatrol.spec.sqf b/addons/patrol/functions/fnc_taskPatrol.spec.sqf similarity index 92% rename from functions/behaviour/fn_taskPatrol.spec.sqf rename to addons/patrol/functions/fnc_taskPatrol.spec.sqf index 36bb8c8f..6f4614ac 100644 --- a/functions/behaviour/fn_taskPatrol.spec.sqf +++ b/addons/patrol/functions/fnc_taskPatrol.spec.sqf @@ -1,6 +1,6 @@ ["a civilian", { - call grad_civs_fnc_clearExclusionZones; + call grad_civs_legacy_fnc_clearExclusionZones; private _group = createGroup [civilian, true]; _group setCombatMode "GREEN"; private _pos = [0, 0, 0]; @@ -27,7 +27,7 @@ ["who is tasked to patrol on foot", { params [["_civ", objNull]]; - [_civ, getPos _civ, 250, 3] call grad_civs_fnc_taskPatrol; + [_civ, getPos _civ, 250, 3] call grad_civs_legacy_fnc_taskPatrol; [_civ] }, [ @@ -98,15 +98,15 @@ private _trgW = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [-250, 150, 0]]; _trgW setTriggerArea [150, 250, 0, true]; - [_trgW] call grad_civs_fnc_addExclusionZone; + [_trgW] call grad_civs_legacy_fnc_addExclusionZone; private _trgS = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [0, -250, 0]]; _trgS setTriggerArea [200, 150, 0, true]; - [_trgS] call grad_civs_fnc_addExclusionZone; + [_trgS] call grad_civs_legacy_fnc_addExclusionZone; private _trgE = createTrigger ["EmptyDetector", (getPos _civ) vectorAdd [250, 150, 0]]; _trgE setTriggerArea [150, 250, 0, true]; - [_trgE] call grad_civs_fnc_addExclusionZone; + [_trgE] call grad_civs_legacy_fnc_addExclusionZone; [_civ] }, @@ -114,7 +114,7 @@ ["and tasked to patrol", { params [["_civ", objNull]]; - [_civ, getPos _civ, 250, 3] call GRAD_CIVS_fnc_taskPatrol; + [_civ, getPos _civ, 250, 3] call grad_civs_legacy_fnc_taskPatrol; [_civ] }, [ @@ -134,7 +134,7 @@ format ["waypoint %1 at %2 is not in exclusion zone at %3 (%4)", _forEachIndex, _x, getPos _exclusionZone, triggerArea _exclusionZone] ] call grad_testing_fnc_assertFalse; } forEach _waypointPositions; - } forEach (call grad_civs_fnc_getExclusionZones); + } forEach (call grad_civs_legacy_fnc_getExclusionZones); } ], ["will avoid crossing exclusion zones", @@ -145,7 +145,7 @@ ] ] ], - grad_civs_fnc_clearExclusionZones + grad_civs_legacy_fnc_clearExclusionZones ] ], { diff --git a/functions/behaviour/fn_taskPatrol.sqf b/addons/patrol/functions/fnc_taskPatrol.sqf similarity index 95% rename from functions/behaviour/fn_taskPatrol.sqf rename to addons/patrol/functions/fnc_taskPatrol.sqf index 3dfd45d9..37a17d2d 100644 --- a/functions/behaviour/fn_taskPatrol.sqf +++ b/addons/patrol/functions/fnc_taskPatrol.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + /* Creates random patrol for group * * [group,position,radius,count] call grad_civs_taskPatrol; @@ -10,8 +12,6 @@ * 4: timeout array - waypoint timeout [min, mid, max] */ -#include "..\..\component.hpp" - params [ ["_groupOrUnit", grpNull], ["_centerPositionOrObject", [0, 0, 0]], @@ -60,6 +60,6 @@ if (!isNull _home) then { }; LOG("adding cycle wp close by group position"); // NOTE : a cycle waypoint points to the *closest waypoint other than the previous one*! which means in our case: close to the initial waypoint -[_group, _position vectorAdd [10, 0, 0]] call grad_civs_fnc_addCycleWaypoint; +[_group, _position vectorAdd [10, 0, 0]] call FUNC(addCycleWaypoint); LOG_2("taskPatrol end. waypoints for group %1 : %2", _group, count waypoints _group); diff --git a/functions/behaviour/fn_taskPatrolAddWaypoint.sqf b/addons/patrol/functions/fnc_taskPatrolAddWaypoint.sqf similarity index 94% rename from functions/behaviour/fn_taskPatrolAddWaypoint.sqf rename to addons/patrol/functions/fnc_taskPatrolAddWaypoint.sqf index 99dc0f97..2fe1c220 100644 --- a/functions/behaviour/fn_taskPatrolAddWaypoint.sqf +++ b/addons/patrol/functions/fnc_taskPatrolAddWaypoint.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_group", grpNull], ["_position", [0, 0, 0]], diff --git a/functions/behaviour/fn_taskPatrolFindWaypoint.sqf b/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf similarity index 84% rename from functions/behaviour/fn_taskPatrolFindWaypoint.sqf rename to addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf index 2838c1db..0f8ecc90 100644 --- a/functions/behaviour/fn_taskPatrolFindWaypoint.sqf +++ b/addons/patrol/functions/fnc_taskPatrolFindWaypoint.sqf @@ -1,9 +1,9 @@ +#include "..\script_component.hpp" + // 1: position position or object - if object, position of object is used // 2: radius number or array - if array, random radius between first and second element is used // 3: count number > 1, or array - amount of waypoints to generate, if array, random amount between first and second element is used -#include "..\..\component.hpp" - params [ ["_position", [0, 0, 0]], ["_radius", 0], @@ -27,18 +27,18 @@ for "_i" from 1 to _maxTries do { nil, _findWaterPos, _findRoadPos - ] call FUNC(findRandomPos); + ] call EFUNC(legacy,findRandomPos); if (_searchPosition isEqualTo []) then { _searchPosition = _position; }; _searchPosition = if (_findPosOfInterest && {80 > random 100}) then { - [_searchPosition, false] call FUNC(findPositionOfInterest); + [_searchPosition, false] call EFUNC(legacy,findPositionOfInterest); } else { _searchPosition }; - private _inPopulatedZone = [_searchPosition] call FUNC(isInPopulatedZone); + private _inPopulatedZone = [_searchPosition] call EFUNC(legacy,isInPopulatedZone); if (_inPopulatedZone) exitWith { LOG_1("position %1 is not in exclusionzone, return it", _searchPosition); _waypointPosition = _searchPosition; diff --git a/functions/behaviour/fn_taskPatrolFindWaypoints.spec.sqf b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf similarity index 81% rename from functions/behaviour/fn_taskPatrolFindWaypoints.spec.sqf rename to addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf index 518bfbb7..b0524a00 100644 --- a/functions/behaviour/fn_taskPatrolFindWaypoints.spec.sqf +++ b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.spec.sqf @@ -2,20 +2,20 @@ { private _trgW = createTrigger ["EmptyDetector", [-250, 150, 0]]; _trgW setTriggerArea [150, 250, 0, true]; - [_trgW] call grad_civs_fnc_addExclusionZone; + [_trgW] call grad_civs_legacy_fnc_addExclusionZone; private _trgS = createTrigger ["EmptyDetector", [0, -250, 0]]; _trgS setTriggerArea [200, 150, 0, true]; - [_trgS] call grad_civs_fnc_addExclusionZone; + [_trgS] call grad_civs_legacy_fnc_addExclusionZone; private _trgE = createTrigger ["EmptyDetector", [250, 150, 0]]; _trgE setTriggerArea [150, 250, 0, true]; - [_trgE] call grad_civs_fnc_addExclusionZone; + [_trgE] call grad_civs_legacy_fnc_addExclusionZone; }, [ ["when a patrol path is created", { - [([[0, 0, 0], 250, 3] call grad_civs_fnc_taskPatrolFindWaypoints)] + [([[0, 0, 0], 250, 3] call grad_civs_legacy_fnc_taskPatrolFindWaypoints)] }, [ ["three positions are returned as requested", @@ -37,7 +37,7 @@ format ["waypoint %1 at %2 is not in exclusion zone at %3 (%4)", _forEachIndex, _x, getPos _exclusionZone, triggerArea _exclusionZone] ] call grad_testing_fnc_assertFalse; } forEach _positions; - } forEach (call grad_civs_fnc_getExclusionZones); + } forEach (call grad_civs_legacy_fnc_getExclusionZones); } ], ["will avoid crossing exclusion zones", @@ -48,12 +48,12 @@ ] ] ], - grad_civs_fnc_clearExclusionZones + grad_civs_legacy_fnc_clearExclusionZones ] call grad_testing_fnc_executeTest; ["GIVEN a point and no exclusion zones WHEN a patrol path is created", { - [([[0, 0, 0], 250, 3] call grad_civs_fnc_taskPatrolFindWaypoints)] + [([[0, 0, 0], 250, 3] call grad_civs_legacy_fnc_taskPatrolFindWaypoints)] }, [ ["three positions are returned as requested", diff --git a/functions/behaviour/fn_taskPatrolFindWaypoints.sqf b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.sqf similarity index 96% rename from functions/behaviour/fn_taskPatrolFindWaypoints.sqf rename to addons/patrol/functions/fnc_taskPatrolFindWaypoints.sqf index f9885a75..ce71f9a4 100644 --- a/functions/behaviour/fn_taskPatrolFindWaypoints.sqf +++ b/addons/patrol/functions/fnc_taskPatrolFindWaypoints.sqf @@ -1,9 +1,9 @@ +#include "..\script_component.hpp" + // 1: position position or object - if object, position of object is used // 2: radius number or array - if array, random radius between first and second element is used // 3: count number > 1, or array - amount of waypoints to generate, if array, random amount between first and second element is used -#include "..\..\component.hpp" - params [ ["_position", [0, 0, 0]], ["_radius", 0], diff --git a/addons/patrol/script_component.hpp b/addons/patrol/script_component.hpp new file mode 100644 index 00000000..90459a2e --- /dev/null +++ b/addons/patrol/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT patrol +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/residents/$PBOPREFIX$ b/addons/residents/$PBOPREFIX$ new file mode 100644 index 00000000..1bb11936 --- /dev/null +++ b/addons/residents/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\residents diff --git a/addons/residents/CfgEventHandlers.hpp b/addons/residents/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/residents/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/residents/XEH_PREP.hpp b/addons/residents/XEH_PREP.hpp new file mode 100644 index 00000000..91febf06 --- /dev/null +++ b/addons/residents/XEH_PREP.hpp @@ -0,0 +1,16 @@ +PREP(addResident); +PREP(initConfig); +PREP(sm_business); +PREP(sm_business_state_chat_enter); +PREP(sm_business_state_chat_exit); +PREP(sm_business_state_chat_loop); +PREP(sm_business_state_housework_enter); +PREP(sm_business_state_housework_exit); +PREP(sm_business_trans_chat_housework_condition); +PREP(sm_business_state_meetNeighbor_enter); +PREP(sm_business_state_meetNeighbor_exit); +PREP(sm_business_state_meetNeighbor_loop); +PREP(sm_business_trans_housework_housework_condition); +PREP(sm_business_trans_housework_meetNeighbor_condition); +PREP(sm_business_trans_meetNeighbor_chat_condition); +PREP(sm_business_trans_rally_housework_condition); diff --git a/addons/residents/XEH_postInit.sqf b/addons/residents/XEH_postInit.sqf new file mode 100644 index 00000000..c7705244 --- /dev/null +++ b/addons/residents/XEH_postInit.sqf @@ -0,0 +1,33 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +[ + QEGVAR(legacy,spawnAllowed), + { + ISNILS(GVAR(maxCivsResidents), [QGVAR(maxCivsResidents)] call CBA_settings_fnc_get); + if ((count (["reside"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsResidents)) then { + [ALL_HUMAN_PLAYERS] call FUNC(addResident); + }; + } +] call CBA_fnc_addEventHandler; + +private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesResidents)] call CBA_settings_fnc_get); +[ + "reside", + _spawnDistances#1 * 1.2 +] call EFUNC(common,registerCivTaskType); + +[ + {"business" in (allVariables EGVAR(common,stateMachines))}, + { + [EGVAR(common,stateMachines) getVariable "business"] call FUNC(sm_business); + }, + [], + 300, + { + ERROR("'business' state machine did not get initialized - cannot add to it"); + } +] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/residents/XEH_preInit.sqf b/addons/residents/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/residents/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/residents/config.cpp b/addons/residents/config.cpp new file mode 100644 index 00000000..74aa1f6c --- /dev/null +++ b/addons/residents/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"grad_civs_common", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/residents/functions/fnc_addResident.sqf b/addons/residents/functions/fnc_addResident.sqf new file mode 100644 index 00000000..c216b2cc --- /dev/null +++ b/addons/residents/functions/fnc_addResident.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" + +params [ + ["_allPlayers", []] +]; + +private _residentSpawnDistances = parseSimpleArray ([QGVAR(spawnDistancesResidents)] call CBA_settings_fnc_get); +private _residentSpawnDistanceMin = _residentSpawnDistances#0; +private _residentSpawnDistanceMax = _residentSpawnDistances#1; + +private _house = [ + _allPlayers, + _residentSpawnDistanceMin, + _residentSpawnDistanceMax, + "house" +] call EFUNC(legacy,findSpawnPosition); + +if (isNil "_house") exitWith {LOG("could not find spawn position for resident this time (nil)")}; +if (isNull _house) exitWith {LOG("could not find spawn position for resident this time (null)")}; + +private _group = [getPos _house, 1, _house, "reside"] call EFUNC(legacy,spawnCivilianGroup); +if (isNull _group) exitWith {}; + +_group diff --git a/addons/residents/functions/fnc_initConfig.sqf b/addons/residents/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..735e9eb6 --- /dev/null +++ b/addons/residents/functions/fnc_initConfig.sqf @@ -0,0 +1,50 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "3) residents"]; + + +[ + QGVAR(maxCivsResidents), + "SLIDER", + "Maximum total number of civilian residents", + _settingsGroup, + [0, 300, 20, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(spawnDistancesResidents), + "EDITBOX", + "Spawn distance ([min,max])", + _settingsGroup, + QUOTE(ARR_2([500, 1000])), + false, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(chatTime), + "SLIDER", + "How long civilian chats can last", + _settingsGroup, + [5, 900, 20, 0], + false, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(meetNeighborCooldown), + "SLIDER", + "Time between visiting neighbors", + _settingsGroup, + [5, 3600, 150, 0], + false, + {}, + false +] call CBA_fnc_addSetting; diff --git a/addons/residents/functions/fnc_sm_business.sqf b/addons/residents/functions/fnc_sm_business.sqf new file mode 100644 index 00000000..4ab12cd4 --- /dev/null +++ b/addons/residents/functions/fnc_sm_business.sqf @@ -0,0 +1,80 @@ +#include "..\script_component.hpp" + +params [ + ["_business", locationNull, [locationNull]] +]; + +private _bus_rally = "bus_rally"; + +/* + * residence-cycle: housework, meetNeighbor, chat + * + * + */ +private _bus_housework = [ + _business, + {}, + { _this call FUNC(sm_business_state_housework_enter) }, + { _this call FUNC(sm_business_state_housework_exit) }, + "bus_housework" +] call EFUNC(cba_statemachine,addState); + +private _bus_meetNeighbor = [ + _business, + { _this call FUNC(sm_business_state_meetNeighbor_loop) }, + { _this call FUNC(sm_business_state_meetNeighbor_enter) }, + { _this call FUNC(sm_business_state_meetNeighbor_exit) }, + "bus_meetNeighbor" +] call EFUNC(cba_statemachine,addState); + +private _bus_chat = [ + _business, + { _this call FUNC(sm_business_state_chat_loop) }, + { _this call FUNC(sm_business_state_chat_enter) }, + { _this call FUNC(sm_business_state_chat_exit) }, + "bus_chat" +] call EFUNC(cba_statemachine,addState); + + // TRANSITIONS housework: + +assert ([ + _business, + _bus_rally, _bus_housework, + { _this call FUNC(sm_business_trans_rally_housework_condition) }, + {}, + _bus_rally + _bus_housework +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_housework, _bus_meetNeighbor, + { _this call FUNC(sm_business_trans_housework_meetNeighbor_condition) }, + {}, + _bus_housework + _bus_meetNeighbor +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_meetNeighbor, _bus_chat, + { _this call FUNC(sm_business_trans_meetNeighbor_chat_condition) }, + {}, + _bus_meetNeighbor + _bus_chat +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_chat, _bus_housework, + { _this call FUNC(sm_business_trans_chat_housework_condition) }, + {}, + _bus_chat + _bus_housework +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_housework, _bus_housework, + { _this call FUNC(sm_business_trans_housework_housework_condition) }, + {}, + _bus_housework + _bus_housework +] call EFUNC(cba_statemachine,addTransition)); + +_business diff --git a/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf b/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf new file mode 100644 index 00000000..32858a65 --- /dev/null +++ b/addons/residents/functions/fnc_sm_business_state_chat_enter.sqf @@ -0,0 +1,13 @@ +#include "..\script_component.hpp" + +private _baseChatTime = [QGVAR(chatTime)] call CBA_settings_fnc_get; + +private _chatTime = _baseChatTime * random [0.2, 1, 5]; +_this setVariable ["grad_civs_chat_time", _chatTime]; + +private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; +if (isNull _neighbor) exitWith {}; + +[_this, format ["chatting with %1", _neighbor]] call EFUNC(legacy,setCurrentlyThinking); + +_this lookAt _neighbor; diff --git a/functions/sm_business/fn_sm_business_state_chat_exit.sqf b/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf similarity index 69% rename from functions/sm_business/fn_sm_business_state_chat_exit.sqf rename to addons/residents/functions/fnc_sm_business_state_chat_exit.sqf index f042b496..7c6acbc8 100644 --- a/functions/sm_business/fn_sm_business_state_chat_exit.sqf +++ b/addons/residents/functions/fnc_sm_business_state_chat_exit.sqf @@ -1,7 +1,7 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" _this setVariable["grad_civs_lastSocialContact", CBA_missionTime]; _this setVariable ["grad_civs_chat_time", nil]; _this setVariable ["grad_civs_neighborToMeet", nil]; _this setRandomLip false; -_this call grad_civs_fnc_clearCurrentlyThinking; +_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/functions/sm_business/fn_sm_business_state_chat_loop.sqf b/addons/residents/functions/fnc_sm_business_state_chat_loop.sqf similarity index 80% rename from functions/sm_business/fn_sm_business_state_chat_loop.sqf rename to addons/residents/functions/fnc_sm_business_state_chat_loop.sqf index ac5f0687..a4e817d8 100644 --- a/functions/sm_business/fn_sm_business_state_chat_loop.sqf +++ b/addons/residents/functions/fnc_sm_business_state_chat_loop.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + doStop _this; _this lookAt (_this getVariable ["grad_civs_neighborToMeet", objNull]); _this setRandomLip (selectRandom [false, false, false, true]); diff --git a/functions/sm_business/fn_sm_business_state_housework_enter.sqf b/addons/residents/functions/fnc_sm_business_state_housework_enter.sqf similarity index 92% rename from functions/sm_business/fn_sm_business_state_housework_enter.sqf rename to addons/residents/functions/fnc_sm_business_state_housework_enter.sqf index 240d50be..397ddf85 100644 --- a/functions/sm_business/fn_sm_business_state_housework_enter.sqf +++ b/addons/residents/functions/fnc_sm_business_state_housework_enter.sqf @@ -1,8 +1,8 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _house = _this getVariable ["grad_civs_home", objNull]; _this setVariable ["grad_civs_housework_time", random [5, 15, 120]]; -_this call grad_civs_fnc_forceEmotionSpeed; +_this call EFUNC(legacy,forceEmotionSpeed); if (isNull _house) exitWith {}; diff --git a/functions/sm_business/fn_sm_business_state_housework_exit.sqf b/addons/residents/functions/fnc_sm_business_state_housework_exit.sqf similarity index 63% rename from functions/sm_business/fn_sm_business_state_housework_exit.sqf rename to addons/residents/functions/fnc_sm_business_state_housework_exit.sqf index b65f3feb..a7c9b9ed 100644 --- a/functions/sm_business/fn_sm_business_state_housework_exit.sqf +++ b/addons/residents/functions/fnc_sm_business_state_housework_exit.sqf @@ -1,3 +1,3 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" [QGVAR(switchMove), [_this, ""]] call CBA_fnc_globalEvent; diff --git a/functions/sm_business/fn_sm_business_state_meetNeighbor_enter.sqf b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf similarity index 80% rename from functions/sm_business/fn_sm_business_state_meetNeighbor_enter.sqf rename to addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf index c4849886..3981924c 100644 --- a/functions/sm_business/fn_sm_business_state_meetNeighbor_enter.sqf +++ b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_enter.sqf @@ -1,7 +1,7 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" [QGVAR(switchMove), [_this, ""]] call CBA_fnc_globalEvent; doStop _this; _this setVariable ["grad_civs_stopDistance", random [3, 7, 20]]; private _neighborToMeet = _this getVariable ["grad_civs_neighborToMeet", objNull]; -[_this, format ["going to chat with %1", _neighborToMeet]] call grad_civs_fnc_setCurrentlyThinking; +[_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); diff --git a/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf new file mode 100644 index 00000000..659e5654 --- /dev/null +++ b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_exit.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/functions/sm_business/fn_sm_business_state_meetNeighbor_loop.sqf b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_loop.sqf similarity index 81% rename from functions/sm_business/fn_sm_business_state_meetNeighbor_loop.sqf rename to addons/residents/functions/fnc_sm_business_state_meetNeighbor_loop.sqf index e51de56b..df8a3d15 100644 --- a/functions/sm_business/fn_sm_business_state_meetNeighbor_loop.sqf +++ b/addons/residents/functions/fnc_sm_business_state_meetNeighbor_loop.sqf @@ -1,9 +1,9 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (isNull _neighbor) exitWith {WARNING("wanted to meet neighbor, but now he's null!")}; -private _isSenior = ([_this, _neighbor] call FUNC(compare)) > 0; +private _isSenior = ([_this, _neighbor] call EFUNC(legacy,compare)) > 0; private _stopDistance = _this getVariable ["grad_civs_stopDistance", 5]; if (!(isOnRoad _this) && _isSenior && (_this distance _neighbor) < _stopDistance && (random 10 > 1)) exitWith {doStop _this}; // one of both may wait the last meters @@ -12,5 +12,5 @@ private _neighborPos = getPos _neighbor; if ((_knownNeighborPos distance _neighborPos) > 1) then { _this setVariable ["grad_civs_neighborPos", _neighborPos]; _this doMove _neighborPos; - _this call FUNC(forceEmotionSpeed); + _this call EFUNC(legacy,forceEmotionSpeed); }; diff --git a/functions/sm_business/fn_sm_business_trans_chat_housework_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_chat_housework_condition.sqf similarity index 89% rename from functions/sm_business/fn_sm_business_trans_chat_housework_condition.sqf rename to addons/residents/functions/fnc_sm_business_trans_chat_housework_condition.sqf index d7f953e0..e54e95f8 100644 --- a/functions/sm_business/fn_sm_business_trans_chat_housework_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_chat_housework_condition.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (isNull _neighbor) exitWith {true}; diff --git a/functions/sm_business/fn_sm_business_trans_housework_housework_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_housework_housework_condition.sqf similarity index 76% rename from functions/sm_business/fn_sm_business_trans_housework_housework_condition.sqf rename to addons/residents/functions/fnc_sm_business_trans_housework_housework_condition.sqf index 41fdd5eb..c50d9668 100644 --- a/functions/sm_business/fn_sm_business_trans_housework_housework_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_housework_housework_condition.sqf @@ -1,3 +1,4 @@ +#include "..\script_component.hpp" private _result = (_this getVariable ["grad_civs_housework_time", 0]) + _thisStateTime < CBA_missionTime; diff --git a/functions/sm_business/fn_sm_business_trans_housework_meetNeighbor_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf similarity index 64% rename from functions/sm_business/fn_sm_business_trans_housework_meetNeighbor_condition.sqf rename to addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf index b3dbb8b9..7112a7ee 100644 --- a/functions/sm_business/fn_sm_business_trans_housework_meetNeighbor_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_housework_meetNeighbor_condition.sqf @@ -1,10 +1,12 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" -if ((_this getVariable ["grad_civs_lastSocialContact", 0]) + GRAD_CIVS_BUS_MEETNEIGHBOR_COOLDOWN > CBA_missionTime) exitWith {false}; +private _neighborCooldown = [QGVAR(meetNeighborCooldown)] call CBA_settings_fnc_get; + +if ((_this getVariable ["grad_civs_lastSocialContact", 0]) + _neighborCooldown > CBA_missionTime) exitWith {false}; private _neighborToMeet = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (!(isNull _neighborToMeet)) exitWith { - [_this, format ["going to chat with %1", _neighborToMeet]] call grad_civs_fnc_setCurrentlyThinking; + [_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); true }; @@ -13,13 +15,14 @@ if (random 10 < 9) exitWith {false}; private _neighborToMeet = { private _maxDist = _x; - private _nearCivs = (_this nearEntities [[GVAR(CIVCLASS)], _maxDist]); + private _civClass = [QEGVAR(legacy,civClass)] call CBA_settings_fnc_get; // TODO: civclass is typeOf _this ! + private _nearCivs = (_this nearEntities [[_civClass], _maxDist]); private _socialNeighbors = _nearCivs select { (_x != _this) && (_x getVariable ["grad_civs_primaryTask", ""] == "reside") && ( (_x getVariable ["grad_civs_neighborToMeet", objNull] == _this) || - ((_x getVariable ["grad_civs_lastSocialContact", 0]) + GRAD_CIVS_BUS_MEETNEIGHBOR_COOLDOWN < CBA_missionTime) + ((_x getVariable ["grad_civs_lastSocialContact", 0]) + _neighborCooldown < CBA_missionTime) ) }; if (count _socialNeighbors > 0) exitWith {_socialNeighbors select 0}; @@ -29,5 +32,5 @@ if (isNil "_neighborToMeet") exitWith {false}; if (isNull _neighborToMeet) exitWith {false}; _this setVariable ["grad_civs_neighborToMeet", _neighborToMeet, true]; -[_this, format ["going to chat with %1", _neighborToMeet]] call grad_civs_fnc_setCurrentlyThinking; +[_this, format ["going to chat with %1", _neighborToMeet]] call EFUNC(legacy,setCurrentlyThinking); true diff --git a/functions/sm_business/fn_sm_business_trans_meetNeighbor_chat_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_meetNeighbor_chat_condition.sqf similarity index 90% rename from functions/sm_business/fn_sm_business_trans_meetNeighbor_chat_condition.sqf rename to addons/residents/functions/fnc_sm_business_trans_meetNeighbor_chat_condition.sqf index f31a7f93..eb69f4ec 100644 --- a/functions/sm_business/fn_sm_business_trans_meetNeighbor_chat_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_meetNeighbor_chat_condition.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; if (isNull _neighbor) exitWith {true}; // go to chat only so that chat can lead to housework in the next tick if (!(alive _neighbor)) exitWith {true}; diff --git a/functions/sm_business/fn_sm_business_trans_rally_housework_condition.sqf b/addons/residents/functions/fnc_sm_business_trans_rally_housework_condition.sqf similarity index 63% rename from functions/sm_business/fn_sm_business_trans_rally_housework_condition.sqf rename to addons/residents/functions/fnc_sm_business_trans_rally_housework_condition.sqf index d0e60b75..e7e7cf6e 100644 --- a/functions/sm_business/fn_sm_business_trans_rally_housework_condition.sqf +++ b/addons/residents/functions/fnc_sm_business_trans_rally_housework_condition.sqf @@ -1 +1,3 @@ +#include "..\script_component.hpp" + (_this getVariable ["grad_civs_primaryTask", ""]) == "reside" diff --git a/addons/residents/script_component.hpp b/addons/residents/script_component.hpp new file mode 100644 index 00000000..89069639 --- /dev/null +++ b/addons/residents/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT residents +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/addons/voyage/$PBOPREFIX$ b/addons/voyage/$PBOPREFIX$ new file mode 100644 index 00000000..a3fb12ab --- /dev/null +++ b/addons/voyage/$PBOPREFIX$ @@ -0,0 +1 @@ +z\grad_civs\addons\voyage diff --git a/addons/voyage/CfgEventHandlers.hpp b/addons/voyage/CfgEventHandlers.hpp new file mode 100644 index 00000000..770e715f --- /dev/null +++ b/addons/voyage/CfgEventHandlers.hpp @@ -0,0 +1,14 @@ +class Extended_PostInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; +class Extended_PreInit_EventHandlers +{ + class ADDON + { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/voyage/XEH_PREP.hpp b/addons/voyage/XEH_PREP.hpp new file mode 100644 index 00000000..57092eda --- /dev/null +++ b/addons/voyage/XEH_PREP.hpp @@ -0,0 +1,21 @@ +PREP(addCarCrew); +PREP(findSpawnRoadSegment); +PREP(getGroupVehicle); +PREP(initConfig); +PREP(loadAnimals); +PREP(setGroupVehicle); +PREP(setupZeusModules); +PREP(setVehicles); +PREP(sm_business); +PREP(sm_business_state_dismount_enter); +PREP(sm_business_state_mountUp_enter); +PREP(sm_business_state_mountUp_exit); +PREP(sm_business_state_voyage_enter); +PREP(sm_business_state_voyage_exit); +PREP(sm_business_state_voyage_loop); +PREP(sm_business_trans_dismount_rally_condition); +PREP(sm_business_trans_mountUp_dismount_condition); +PREP(sm_business_trans_mountUp_voyage_condition); +PREP(sm_business_trans_rally_mountUp_condition); +PREP(sm_business_trans_voyage_dismount_condition); +PREP(spawnVehicle); diff --git a/addons/voyage/XEH_postInit.sqf b/addons/voyage/XEH_postInit.sqf new file mode 100644 index 00000000..2488daae --- /dev/null +++ b/addons/voyage/XEH_postInit.sqf @@ -0,0 +1,35 @@ +#include "script_component.hpp" + +if (!([QEGVAR(main,enabled)] call CBA_settings_fnc_get)) exitWith { + INFO("GRAD civs is disabled. Good bye!"); +}; + +[ + QEGVAR(legacy,spawnAllowed), + { + ISNILS(GVAR(maxCivsInVehicles), [QGVAR(maxCivsInVehicles)] call CBA_settings_fnc_get); + if ((count (["voyage"] call EFUNC(legacy,getGlobalCivs))) < GVAR(maxCivsInVehicles)) then { + [ALL_HUMAN_PLAYERS] call FUNC(addCarCrew); + }; + } +] call CBA_fnc_addEventHandler; + +private _spawnDistances = parseSimpleArray ([QGVAR(spawnDistancesInVehicles)] call CBA_settings_fnc_get); +[ + "voyage", + _spawnDistances#1 * 1.5 +] call EFUNC(common,registerCivTaskType); + +[ + {"business" in (allVariables EGVAR(common,stateMachines))}, + { + [EGVAR(common,stateMachines) getVariable "business"] call FUNC(sm_business); + }, + [], + 300, + { + ERROR("'business' state machine did not get initialized - cannot add to it"); + } +] call CBA_fnc_waitUntilAndExecute; + +[] call FUNC(setupZeusModules); diff --git a/addons/voyage/XEH_preInit.sqf b/addons/voyage/XEH_preInit.sqf new file mode 100644 index 00000000..f7edd58d --- /dev/null +++ b/addons/voyage/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; + + +[] call FUNC(initConfig); diff --git a/addons/voyage/config.cpp b/addons/voyage/config.cpp new file mode 100644 index 00000000..74aa1f6c --- /dev/null +++ b/addons/voyage/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"grad_civs_common", "grad_civs_legacy"}; + author = "AUTHOR"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/voyage/functions/fnc_addCarCrew.sqf b/addons/voyage/functions/fnc_addCarCrew.sqf new file mode 100644 index 00000000..0a294c32 --- /dev/null +++ b/addons/voyage/functions/fnc_addCarCrew.sqf @@ -0,0 +1,70 @@ +#include "..\script_component.hpp" + +params [ + ["_allPlayers", []], + ["_forcePosition", []] +]; + +private _vehicleSpawnDistances = parseSimpleArray ([QGVAR(spawnDistancesInVehicles)] call CBA_settings_fnc_get); +private _vehicleSpawnDistanceMin = _vehicleSpawnDistances#0; +private _vehicleSpawnDistanceMax = _vehicleSpawnDistances#1; + +private _pos = if (_forcePosition isEqualTo []) then { + private _segment = [ + _allPlayers, + _vehicleSpawnDistanceMin, + _vehicleSpawnDistanceMax, + ["voyage"] call EFUNC(legacy,getGlobalCivs) + ] call FUNC(findSpawnRoadSegment); + + if (isNull _segment) exitWith { + LOG("could not find spawn position for car at this time"); + }; + getPos _segment +} else { + _forcePosition +}; + + +private _house = [ + _allPlayers, + 0, + _vehicleSpawnDistanceMax * 1.5, + "house" +] call FUNC(findSpawnPosition); + +private _vehicleClasses = parseSimpleArray ([QGVAR(vehicles)] call CBA_settings_fnc_get); +if (_vehicleClasses isEqualTo []) exitWith { + WARNING("will not spawn vehicles as zero vehicle classes are defined"); +}; +private _vehicleClass = selectRandom _vehicleClasses; + +_veh = [_pos, _vehicleClass] call FUNC(spawnVehicle); + +private _maxInitialGroupSize = [QEGVAR(patrol,initialGroupSize)] call CBA_settings_fnc_get; +private _automaticVehicleGroupSize = [QGVAR(automaticVehicleGroupSize)] call CBA_settings_fnc_get; + +private _groupSize = (floor random _maxInitialGroupSize) + 1; +if (_automtaicVehicleGroupSize) then { + private _maxCount = count ((fullCrew [_veh, "", true]) select { + !(_veh lockedCargo _x#2); + }); + _groupSize = (floor random [0, 1, _maxCount]) + 1 +}; + +_group = [_pos, _groupSize, _house, "voyage"] call EFUNC(legacy,spawnCivilianGroup); + +{ + // for convenience & speed: shortcut so units dont have to lengthily embark on their own + // also, prevents issues with civs spawning inside their vehicle, + // which for some reason happens to lone drivers regardless of "NONE" collision flag on spawn + if (_x == leader _group) then { + _x moveInDriver _veh; + _x assignAsDriver _veh; + } else { + _x moveInCargo _veh; + _x assignAsCargo _veh; + }; +} forEach (units _group); + +[_group, _veh] call FUNC(setGroupVehicle); diff --git a/functions/spawn/fn_findSpawnRoadSegment.sqf b/addons/voyage/functions/fnc_findSpawnRoadSegment.sqf similarity index 81% rename from functions/spawn/fn_findSpawnRoadSegment.sqf rename to addons/voyage/functions/fnc_findSpawnRoadSegment.sqf index e850811f..6f22eb28 100644 --- a/functions/spawn/fn_findSpawnRoadSegment.sqf +++ b/addons/voyage/functions/fnc_findSpawnRoadSegment.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" /*return road segment where one can spawn, or objNull */ @@ -8,4 +8,4 @@ if (_allPlayers isEqualTo []) exitWith {LOG("_allPlayers is empty"); objNull}; private _refPlayerPos = getPos (selectRandom _allPlayers); -([ALL_HUMAN_PLAYERS, _minSpawnDistance, _maxSpawnDistance, "road"] call grad_civs_fnc_findSpawnPosition); +([ALL_HUMAN_PLAYERS, _minSpawnDistance, _maxSpawnDistance, "road"] call EFUNC(legacy,findSpawnPosition)); diff --git a/functions/accessors/fn_getGroupVehicle.sqf b/addons/voyage/functions/fnc_getGroupVehicle.sqf similarity index 79% rename from functions/accessors/fn_getGroupVehicle.sqf rename to addons/voyage/functions/fnc_getGroupVehicle.sqf index 3bf0577e..11fab493 100644 --- a/functions/accessors/fn_getGroupVehicle.sqf +++ b/addons/voyage/functions/fnc_getGroupVehicle.sqf @@ -1,3 +1,4 @@ +#include "..\script_component.hpp" private _group = if (typeName _this == "OBJECT") then {group _this} else {_this}; diff --git a/addons/voyage/functions/fnc_initConfig.sqf b/addons/voyage/functions/fnc_initConfig.sqf new file mode 100644 index 00000000..67952c84 --- /dev/null +++ b/addons/voyage/functions/fnc_initConfig.sqf @@ -0,0 +1,60 @@ +#include "..\script_component.hpp" + +INFO("initConfig running..."); + +private _settingsGroup = ["GRAD Civs", "5) voyagers"]; + +[ + QGVAR(animalTransportChance), + "SLIDER", + "Suitable vehicles that will have animals as cargo", + _settingsGroup, + [0, 1, 0.4, 0, true], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(automaticVehicleGroupSize), + "CHECKBOX", + "Allow vehicles to be filled according to capacity", + _settingsGroup, + true, + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(maxCivsInVehicles), + "SLIDER", + "Maximum total number of civilian voyagers", + _settingsGroup, + [0, 300, 10, 0], + true, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(spawnDistancesInVehicles), + "EDITBOX", + "Spawn distance ([min,max])", + _settingsGroup, + QUOTE(ARR_2([1500,6000])), + false, + {}, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(vehicles), + "EDITBOX", + "Classnames of vehicles that civilians may drive.", + _settingsGroup, + "[""C_Van_01_fuel_F"",""C_Hatchback_01_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""]", + true, + {}, + false +] call CBA_fnc_addSetting; diff --git a/functions/spawn/fn_loadAnimals.sqf b/addons/voyage/functions/fnc_loadAnimals.sqf similarity index 95% rename from functions/spawn/fn_loadAnimals.sqf rename to addons/voyage/functions/fnc_loadAnimals.sqf index 69ab21ac..146584d1 100644 --- a/functions/spawn/fn_loadAnimals.sqf +++ b/addons/voyage/functions/fnc_loadAnimals.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params [ ["_vehicle", objNull, [objNull]], diff --git a/functions/accessors/fn_setGroupVehicle.sqf b/addons/voyage/functions/fnc_setGroupVehicle.sqf similarity index 87% rename from functions/accessors/fn_setGroupVehicle.sqf rename to addons/voyage/functions/fnc_setGroupVehicle.sqf index 948e422c..81ac76cd 100644 --- a/functions/accessors/fn_setGroupVehicle.sqf +++ b/addons/voyage/functions/fnc_setGroupVehicle.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params ["_groupOrUnit", "_vehicle"]; private _group = if (typeName _groupOrUnit == "OBJECT") then {group _groupOrUnit} else {_groupOrUnit}; diff --git a/addons/voyage/functions/fnc_setVehicles.sqf b/addons/voyage/functions/fnc_setVehicles.sqf new file mode 100644 index 00000000..961afc58 --- /dev/null +++ b/addons/voyage/functions/fnc_setVehicles.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params [["_value",[]]]; + +[QGVAR(vehicles), _value, 0, "mission"] call CBA_settings_fnc_set; diff --git a/addons/voyage/functions/fnc_setupZeusModules.sqf b/addons/voyage/functions/fnc_setupZeusModules.sqf new file mode 100644 index 00000000..fc0ee16f --- /dev/null +++ b/addons/voyage/functions/fnc_setupZeusModules.sqf @@ -0,0 +1,11 @@ +#include "..\script_component.hpp" + +["GRAD-CIVS","ADD CAR", + { + params [ + ["_clickPos", [0, 0, 0]] + ]; + + [[], ASLToAGL _clickPos] call FUNC(addCarCrew); + } +] call zen_custom_modules_fnc_register; diff --git a/addons/voyage/functions/fnc_sm_business.sqf b/addons/voyage/functions/fnc_sm_business.sqf new file mode 100644 index 00000000..4322cc17 --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business.sqf @@ -0,0 +1,91 @@ +#include "..\script_component.hpp" + +params [ + ["_business", locationNull, [locationNull]] +]; + +private _bus_rally = "bus_rally"; +/** + * part of the voyage cycle: mount up, voyage, dismount + */ +private _bus_mountUp = [ + _business, + {}, + { _this call FUNC(sm_business_state_mountUp_enter) }, + { _this call FUNC(sm_business_state_mountUp_exit) }, + "bus_mountUp" +] call EFUNC(cba_statemachine,addState); + +private _bus_voyage = [ + _business, + { _this call FUNC(sm_business_state_voyage_loop) }, + { _this call FUNC(sm_business_state_voyage_enter) }, + { _this call FUNC(sm_business_state_voyage_exit) }, + "bus_voyage" +] call EFUNC(cba_statemachine,addState); + +private _bus_dismount = [ + _business, + {}, + { _this call FUNC(sm_business_state_dismount_enter) }, + {}, + "bus_dismount" +] call EFUNC(cba_statemachine,addState); + + // TRANSITIONS voyage: + +assert ([ + _business, + _bus_rally, _bus_mountUp, + { _this call FUNC(sm_business_trans_rally_mountUp_condition) }, + {}, + _bus_rally + _bus_mountUp +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_mountUp, _bus_voyage, + { _this call FUNC(sm_business_trans_mountUp_voyage_condition) }, + {}, + _bus_mountUp + _bus_voyage +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_voyage, _bus_dismount, + { _this call FUNC(sm_business_trans_voyage_dismount_condition) }, + { + if (!(canMove vehicle _this)) then { + [_this, nil] call FUNC(setGroupVehicle); + } + }, + _bus_voyage + _bus_dismount +] call EFUNC(cba_statemachine,addTransition)); + +assert ([ + _business, + _bus_voyage, _bus_dismount, + ["grad_civs_panicking"], + { _this setSpeedMode "FULL"; speed vehicle _this < 30 }, + {}, + _bus_voyage + _bus_dismount +] call CBA_statemachine_fnc_addEventTransition); + +assert ([ + _business, + _bus_mountUp, _bus_dismount, + { _this call FUNC(sm_business_trans_mountUp_dismount_condition) }, + {}, + _bus_mountUp + _bus_dismount +] call EFUNC(cba_statemachine,addTransition)); + + +assert ([ + _business, + _bus_dismount, _bus_rally, + { _this call FUNC(sm_business_trans_dismount_rally_condition) }, + {}, + _bus_dismount + _bus_rally +] call EFUNC(cba_statemachine,addTransition)); + +_business diff --git a/functions/sm_business/fn_sm_business_state_dismount_enter.sqf b/addons/voyage/functions/fnc_sm_business_state_dismount_enter.sqf similarity index 100% rename from functions/sm_business/fn_sm_business_state_dismount_enter.sqf rename to addons/voyage/functions/fnc_sm_business_state_dismount_enter.sqf diff --git a/addons/voyage/functions/fnc_sm_business_state_mountUp_enter.sqf b/addons/voyage/functions/fnc_sm_business_state_mountUp_enter.sqf new file mode 100644 index 00000000..7dfe6194 --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_state_mountUp_enter.sqf @@ -0,0 +1,9 @@ +#include "..\script_component.hpp" + +_veh = _this call FUNC(getGroupVehicle); +if (canMove _veh) then { + _this assignAsDriver _veh; + [_this] orderGetIn true; +} else { + [_this, nil] call FUNC(setGroupVehicle); +}; diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_state_life_exit.sqf b/addons/voyage/functions/fnc_sm_business_state_mountUp_exit.sqf similarity index 100% rename from functions/sm_lifecycle/fn_sm_lifecycle_state_life_exit.sqf rename to addons/voyage/functions/fnc_sm_business_state_mountUp_exit.sqf diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf new file mode 100644 index 00000000..5eabe3ea --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_enter.sqf @@ -0,0 +1,7 @@ +#include "..\script_component.hpp" + +[_this, _this, 2500, 3, [0,0,0], false, true] call EFUNC(patrol,taskPatrol); // vehicle patrol: wide range +_this setSpeedMode "LIMITED"; +_this forceSpeed -1; +_this enableDynamicSimulation true; +_this doFollow _this; diff --git a/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf new file mode 100644 index 00000000..5b7b6e26 --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_exit.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +[group _this] call CBA_fnc_clearWaypoints; +_this call EFUNC(legacy,clearCurrentlyThinking); diff --git a/functions/sm_business/fn_sm_business_state_voyage_loop.sqf b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf similarity index 66% rename from functions/sm_business/fn_sm_business_state_voyage_loop.sqf rename to addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf index 45d68c6f..aab409b9 100644 --- a/functions/sm_business/fn_sm_business_state_voyage_loop.sqf +++ b/addons/voyage/functions/fnc_sm_business_state_voyage_loop.sqf @@ -1,6 +1,8 @@ +#include "..\script_component.hpp" + private _group = group _this; private _wpidx = currentWaypoint _group; private _wps = waypoints _group; private _wppos = waypointPosition (_wps select _wpidx); -[_this, format ["traveling to waypoint %1, %2 (%3m left)", _wpidx, _wppos, _this distance _wppos]] call grad_civs_fnc_setCurrentlyThinking; +[_this, format ["traveling to waypoint %1, %2 (%3m left)", _wpidx, _wppos, _this distance _wppos]] call EFUNC(legacy,setCurrentlyThinking); diff --git a/addons/voyage/functions/fnc_sm_business_trans_dismount_rally_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_dismount_rally_condition.sqf new file mode 100644 index 00000000..beaa836b --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_trans_dismount_rally_condition.sqf @@ -0,0 +1,4 @@ +#include "..\script_component.hpp" + +(vehicle _this == _this) && + ([_this, "emotions"] call EFUNC(common,civGetState)) != "emo_panic" diff --git a/addons/voyage/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf new file mode 100644 index 00000000..106689bb --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_trans_mountUp_dismount_condition.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +(([_this, "emotions"] call EFUNC(common,civGetState)) == "emo_panic") || (_this call EFUNC(legacy,sm_activities_helper_surrenderCondition)) diff --git a/functions/sm_business/fn_sm_business_trans_mountUp_voyage_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_mountUp_voyage_condition.sqf similarity index 100% rename from functions/sm_business/fn_sm_business_trans_mountUp_voyage_condition.sqf rename to addons/voyage/functions/fnc_sm_business_trans_mountUp_voyage_condition.sqf diff --git a/addons/voyage/functions/fnc_sm_business_trans_rally_mountUp_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_rally_mountUp_condition.sqf new file mode 100644 index 00000000..eed2c583 --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_trans_rally_mountUp_condition.sqf @@ -0,0 +1,16 @@ +#include "..\script_component.hpp" + +private _haveVehicle = (canMove (_this call FUNC(getGroupVehicle))); + +if (!_haveVehicle && _this getVariable ["grad_civs_primaryTask", ""] == "voyage") exitWith { + _this setVariable ["grad_civs_primaryTask", "patrol", true]; + INFO_1("%1 was tasked with voyage but vehicle %2 is immovable or absent - will go on patrol hencewith", _this, _this call FUNC(getGroupVehicle)); +}; + +private _grpUnits = units _this; +private _nonRallyCount = { + ([_this, "business"] call EFUNC(common,civGetState)) != "bus_rally" +} count _grpUnits; +private _allRallying = _nonRallyCount == 0; + +_allRallying && _haveVehicle && (leader _this == _this) diff --git a/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf b/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf new file mode 100644 index 00000000..013a07fd --- /dev/null +++ b/addons/voyage/functions/fnc_sm_business_trans_voyage_dismount_condition.sqf @@ -0,0 +1,3 @@ +#include "..\script_component.hpp" + +(_this call EFUNC(legacy,sm_activities_helper_surrenderCondition)) || !(canMove vehicle _this) diff --git a/functions/spawn/fn_spawnVehicle.sqf b/addons/voyage/functions/fnc_spawnVehicle.sqf similarity index 77% rename from functions/spawn/fn_spawnVehicle.sqf rename to addons/voyage/functions/fnc_spawnVehicle.sqf index d60c9597..a508a35f 100644 --- a/functions/spawn/fn_spawnVehicle.sqf +++ b/addons/voyage/functions/fnc_spawnVehicle.sqf @@ -1,4 +1,4 @@ -#include "..\..\component.hpp" +#include "..\script_component.hpp" params ["_pos","_type"]; @@ -22,6 +22,7 @@ _veh addEventHandler ["FiredNear", ["fired_near", _units, _units] call CBA_fnc_targetEvent; }]; -[_veh, GVAR(ANIMALTRANSPORT_CHANCE)] call FUNC(loadAnimals); +private _animalChance = [QGVAR(animalTransportChance)] call CBA_settings_fnc_get; +[_veh, _animalChance] call FUNC(loadAnimals); _veh diff --git a/addons/voyage/script_component.hpp b/addons/voyage/script_component.hpp new file mode 100644 index 00000000..7a21e4f3 --- /dev/null +++ b/addons/voyage/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT voyage +#include "\z\grad_civs\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\grad_civs\addons\main\script_macros.hpp" diff --git a/cfgFunctions.hpp b/cfgFunctions.hpp deleted file mode 100644 index 36b5610d..00000000 --- a/cfgFunctions.hpp +++ /dev/null @@ -1,231 +0,0 @@ -#ifndef MODULES_DIRECTORY - #define MODULES_DIRECTORY modules -#endif - -class grad_civs { - - class accessors { - file = MODULES_DIRECTORY\grad-civs\functions\accessors; - - class clearCurrentlyThinking {}; - class forceEmotionSpeed {}; - class forcePanicSpeed {}; - class getCurrentlyThinking {}; - class getGroupVehicle {}; - class setCurrentlyThinking {}; - class setGroupVehicle {}; - }; - - class api { - file = MODULES_DIRECTORY\grad-civs\functions\api; - - class addExclusionZone {}; - class clearExclusionZones {}; - class doCustomActivity {}; - class getExclusionZones {}; - class addPopulationZone {}; - class clearPopulationZones {}; - class getPopulationZones {}; - class populateArea {}; - class setBackpacks {}; - class setClothes {}; - class setDebugMode {}; - class setFaces {}; - class setGoggles {}; - class setHeadgear {}; - class setVehicles {}; - }; - - class behaviour { - file = MODULES_DIRECTORY\grad-civs\functions\behaviour; - - class addCycleWaypoint {}; - class customActivity_reverse {}; - class taskPatrol {}; - class taskPatrolAddWaypoint {}; - class taskPatrolFindWaypoints {}; - class taskPatrolFindWaypoint {}; - }; - - class common { - file = MODULES_DIRECTORY\grad-civs\functions\common; - class arrayContains {}; - class compare {}; - class feelsAddressedByGesture {}; - class findBuildings {}; - class findPositionOfInterest {}; - class findRandomPos {}; - class findRandomPosArea {}; - class formatNowPlusSeconds {}; - class getCurrentState {}; - class getGlobalCivs {}; - class handleAnimation {}; - class handleGestureStop {}; - class handleGestureGo {}; - class isInHouse {}; - class nowPlusSeconds {}; - class isInPopulatedZone {}; - class removeFromStateMachine {}; - class reverse {}; - class reverse_abort {}; - class reverse_internal_end {}; - class reverse_internal_stopCondition {}; - class reverse_internal_pfh {}; - class uid {}; - }; - - class debug { - file = MODULES_DIRECTORY\grad-civs\functions\debug; - - class drawCivs {}; - class mapMarkers {}; - class showWhatTheyThink {}; - class updateInfoLine {}; - }; - - class init { - file = MODULES_DIRECTORY\grad-civs\functions\init; - - class initCommonEventhandlers {postInit = 1;}; - class initConfig {preInit = 1;}; - class initHCs {postInit = 1;}; - class initModule {}; - class initPlayer {postInit = 1;}; - class initServer {postInit = 1;}; - }; - - class player { - file = MODULES_DIRECTORY\grad-civs\functions\player; - - class addCivInteractions {}; - class checkHonkingOnCivilian {}; - class checkWeaponOnCivilianPerception {}; - class checkWeaponOnCivilianPointer {}; - class interact_backUpAction {}; - class interact_backUpCondition {}; - class interact_carryOnAction {}; - class interact_carryOnCondition {}; - class isPlayerHonking {}; - class playerLoop {}; - class registerAceInteractionHandler {}; - class setupZeusModules {}; - class showCivHint {}; - }; - - class sm_activities { - file = MODULES_DIRECTORY\grad-civs\functions\sm_activities; - - class sm_activities {}; - class sm_activities_helper_freeCondition {}; - class sm_activities_helper_surrenderCondition {}; - class sm_activities_state_asOrdered_enter {}; - class sm_activities_state_asOrdered_exit {}; - class sm_activities_state_panic_enter {}; - class sm_activities_state_panic_exit {}; - class sm_activities_state_surrendered_enter {}; - class sm_activities_state_surrendered_exit {}; - class sm_activities_trans_business_panic_condition {}; - class sm_activities_trans_business_surrendered_condition {}; - // class sm_activities_trans_panic_business_condition {}; // event transition - class sm_activities_trans_surrendered_business_condition {}; - class sm_activities_trans_surrendered_panic_condition {}; - }; - - class sm_business { - file = MODULES_DIRECTORY\grad-civs\functions\sm_business; - - class sm_business {}; - class sm_business_state_dismount_enter {}; - class sm_business_state_mountUp_enter {}; - - class sm_business_state_chat_enter {}; - class sm_business_state_chat_exit {}; - class sm_business_state_chat_loop {}; - class sm_business_state_housework_enter {}; - class sm_business_state_housework_exit {}; - class sm_business_state_meetNeighbor_enter {}; - class sm_business_state_meetNeighbor_exit {}; - class sm_business_state_meetNeighbor_loop {}; - - class sm_business_state_mountUp_exit {}; - class sm_business_state_patrol_enter {}; - class sm_business_state_patrol_exit {}; - class sm_business_state_rally_enter {}; - class sm_business_state_rally_loop {}; - class sm_business_state_voyage_enter {}; - class sm_business_state_voyage_exit {}; - class sm_business_state_voyage_loop {}; - class sm_business_trans_chat_housework_condition {}; - class sm_business_trans_dismount_rally_condition {}; - class sm_business_trans_housework_housework_condition {}; - class sm_business_trans_housework_meetNeighbor_condition {}; - class sm_business_trans_meetNeighbor_chat_condition {}; - class sm_business_trans_mountUp_voyage_condition {}; - class sm_business_trans_mountUp_dismount_condition {}; - class sm_business_trans_rally_housework_condition {}; - class sm_business_trans_rally_mountUp_condition {}; - class sm_business_trans_rally_patrol_condition {}; - class sm_business_trans_voyage_dismount_condition {}; - }; - - class sm_lifecycle { - file = MODULES_DIRECTORY\grad-civs\functions\sm_lifecycle; - - class sm_lifecycle {}; - class sm_lifecycle_state_death_enter {}; - class sm_lifecycle_state_despawn_enter {}; - class sm_lifecycle_state_life_enter {}; - class sm_lifecycle_state_life_exit {}; - class sm_lifecycle_trans_life_despawn_condition {}; - class sm_lifecycle_state_spawn_enter {}; - }; - - class sm_emotions { - file = MODULES_DIRECTORY\grad-civs\functions\sm_emotions; - - class sm_emotions {}; - }; - - class sm_panic { - file = MODULES_DIRECTORY\grad-civs\functions\sm_panic; - - class sm_panic {}; - class sm_panic_state_flight_loop {}; - class sm_panic_state_flight_enter {}; - class sm_panic_state_hidden_enter {}; - class sm_panic_state_hide_enter {}; - class sm_panic_state_hide_exit {}; - class sm_panic_trans_hide_hidden_condition {}; - class sm_panic_trans_hide_hidden_handler {}; - }; - - class spawn { - file = MODULES_DIRECTORY\grad-civs\functions\spawn; - - class addCarCrew {}; - class addFootsy {}; - class addResident {}; - class createInfoChannel {}; - class createSideRoadVehicles {}; - class deleteIfDamaged {}; - class findUnclaimedHouse {}; - class findSpawnPosition {}; - class findSpawnRoadSegment {}; - class isInDistanceFromOtherPlayers {}; - class loadAnimals {}; - class serverLoop {}; - class spawnCivilian {}; - class spawnCivilianGroup {}; - class spawnPass {}; - class spawnVehicle {}; - }; - - class statemachine { - file = MODULES_DIRECTORY\grad-civs\functions\statemachine; - - class addCompoundState {}; - class addState {}; - class addToStateMachine {}; - class addTransition {}; - }; -}; diff --git a/docs/grad_civs-cba_settings.png b/docs/grad_civs-cba_settings.png new file mode 100644 index 00000000..2040fb2f Binary files /dev/null and b/docs/grad_civs-cba_settings.png differ diff --git a/functions/accessors/fn_clearCurrentlyThinking.sqf b/functions/accessors/fn_clearCurrentlyThinking.sqf deleted file mode 100644 index 889d11aa..00000000 --- a/functions/accessors/fn_clearCurrentlyThinking.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -if (GVAR(DEBUG_CIVSTATE)) then { - _this setVariable ["grad_civs_currentlyThinking", nil, true]; -}; diff --git a/functions/accessors/fn_getCurrentlyThinking.sqf b/functions/accessors/fn_getCurrentlyThinking.sqf deleted file mode 100644 index 4010ee56..00000000 --- a/functions/accessors/fn_getCurrentlyThinking.sqf +++ /dev/null @@ -1,7 +0,0 @@ -#include "..\..\component.hpp" - -if (GVAR(DEBUG_CIVSTATE)) then { - _this getVariable ["grad_civs_currentlyThinking", "dumdidum"]; -} else { - "" -}; diff --git a/functions/api/fn_getExclusionZones.sqf b/functions/api/fn_getExclusionZones.sqf deleted file mode 100644 index a1876554..00000000 --- a/functions/api/fn_getExclusionZones.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "..\..\component.hpp" - -GVAR(EXCLUSION_ZONES) diff --git a/functions/api/fn_getPopulationZones.sqf b/functions/api/fn_getPopulationZones.sqf deleted file mode 100644 index 51b76de7..00000000 --- a/functions/api/fn_getPopulationZones.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "..\..\component.hpp" - -GVAR(POPULATION_ZONES) diff --git a/functions/api/fn_populateArea.sqf b/functions/api/fn_populateArea.sqf deleted file mode 100644 index f73975e7..00000000 --- a/functions/api/fn_populateArea.sqf +++ /dev/null @@ -1,44 +0,0 @@ -#include "..\..\component.hpp" - -ASSERT_SERVER("populate area must be run on server or hc"); -if (!canSuspend) exitWith {_this spawn grad_civs_fnc_populateArea}; - -params ["_area",["_amount",20],["_excludeFromCleanup",true],["_staticCars",false],["_staticCarsMax",20]]; - -private _areas = if (_area isEqualType objNull) then {synchronizedObjects _area} else {[_area]}; -private _maxLoops = _amount * 5; -{ - _amountSpawned = 0; - for [{_i=0},{_i<1000},{_i=_i+1}] do { - - _spawnPos = [_x] call grad_civs_fnc_findRandomPosArea; - if (count _spawnPos > 0) then { - _group = [_spawnPos, GRAD_CIVS_INITIALGROUPSIZE, objNull, "reside"] call grad_civs_fnc_spawnCivilianGroup; - if (_excludeFromCleanup) then { - { - _x setVariable ["grad_civs_excludeFromCleanup",true]; - } forEach units _group; - }; - _amountSpawned = _amountSpawned + (count units _group); - }; - - if (_amountSpawned >= _amount) exitWith {}; - if (_i > _maxLoops) exitWith {}; - }; - - private _vehAmount = 0; - if (_staticCars) then { - _vehAmount = if (_x isEqualType objNull) then { - (triggerArea _x) params [["_a",0],["_b",0]]; - [getPos _x,_a max _b,5,5,15,_staticCarsMax] call grad_civs_fnc_createSideRoadVehicles - } else { - _x params ["_center",["_a",0],["_b",0]]; - [_center,_a max _b,5,5,15,_staticCarsMax] call grad_civs_fnc_createSideRoadVehicles - }; - }; - - - INFO_2("Populated area with %1 civilians and %2 static cars.",_amountSpawned,_vehAmount); - - false -} count _areas; diff --git a/functions/api/fn_setBackpacks.sqf b/functions/api/fn_setBackpacks.sqf deleted file mode 100644 index 0b2ced17..00000000 --- a/functions/api/fn_setBackpacks.sqf +++ /dev/null @@ -1,6 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]],["_probability",0.5]]; - -missionNamespace setVariable ["GRAD_CIVS_BACKPACKS",_value,true]; -missionNamespace setVariable ["GRAD_CIVS_BACKPACKPROBABILITY",_probability,true]; diff --git a/functions/api/fn_setClothes.sqf b/functions/api/fn_setClothes.sqf deleted file mode 100644 index f187a5c9..00000000 --- a/functions/api/fn_setClothes.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]]]; - -missionNamespace setVariable ["GRAD_CIVS_CLOTHES",_value,true]; diff --git a/functions/api/fn_setDebugMode.sqf b/functions/api/fn_setDebugMode.sqf deleted file mode 100644 index e399a72d..00000000 --- a/functions/api/fn_setDebugMode.sqf +++ /dev/null @@ -1,10 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",false]]; - -if ((missionNamespace getVariable [QGVAR(DEBUG_CIVSTATE),false]) isEqualTo _value) exitWith {}; - -missionNamespace setVariable [QGVAR(DEBUG_CIVSTATE),_value,true]; - -[_value] remoteExec ["grad_civs_fnc_showWhatTheyThink",0,false]; -[_value] remoteExec ["grad_civs_fnc_mapMarkers",0,false]; diff --git a/functions/api/fn_setFaces.sqf b/functions/api/fn_setFaces.sqf deleted file mode 100644 index c7b67899..00000000 --- a/functions/api/fn_setFaces.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]]]; - -missionNamespace setVariable ["GRAD_CIVS_FACES",_value,true]; diff --git a/functions/api/fn_setGoggles.sqf b/functions/api/fn_setGoggles.sqf deleted file mode 100644 index 7bb9530f..00000000 --- a/functions/api/fn_setGoggles.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]]]; - -missionNamespace setVariable ["GRAD_CIVS_GOGGLES",_value,true]; diff --git a/functions/api/fn_setHeadgear.sqf b/functions/api/fn_setHeadgear.sqf deleted file mode 100644 index 5a76843a..00000000 --- a/functions/api/fn_setHeadgear.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]]]; - -missionNamespace setVariable ["GRAD_CIVS_HEADGEAR",_value,true]; diff --git a/functions/api/fn_setVehicles.sqf b/functions/api/fn_setVehicles.sqf deleted file mode 100644 index 69b18c15..00000000 --- a/functions/api/fn_setVehicles.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\..\component.hpp" - -params [["_value",[]]]; - -missionNamespace setVariable ["GRAD_CIVS_VEHICLES",_value,true]; diff --git a/functions/common/fn_getGlobalCivs.sqf b/functions/common/fn_getGlobalCivs.sqf deleted file mode 100644 index 8c28e717..00000000 --- a/functions/common/fn_getGlobalCivs.sqf +++ /dev/null @@ -1,34 +0,0 @@ -#include "..\..\component.hpp" - -/* get ALL grad managed civs, regardless of location*/ -params [ - ["_primaryTask", "", ["patrol", "voyage"]] /* filter civs by primary task */ -]; - -if (isNil "GRAD_CIVS_fnc_getGlobalCivs_arr") then { - // on first run, init array with existing civs - 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 - [ - QGVAR(civ_added), - { - SCRIPT("getGlobalCivs_civ_added"); - GRAD_CIVS_fnc_getGlobalCivs_arr = GRAD_CIVS_fnc_getGlobalCivs_arr + _this; - } - ] call CBA_fnc_addEventHandler; - [ - QGVAR(civ_removed), - { - SCRIPT("getGlobalCivs_civ_removed"); - GRAD_CIVS_fnc_getGlobalCivs_arr = GRAD_CIVS_fnc_getGlobalCivs_arr - _this; - } - ] call CBA_fnc_addEventHandler; -}; - -if (_primaryTask == "") then { - GRAD_CIVS_fnc_getGlobalCivs_arr -} else { - (GRAD_CIVS_fnc_getGlobalCivs_arr select { _x getVariable ["grad_civs_primaryTask", ""] == _primaryTask}) -}; diff --git a/functions/common/fn_isInPopulatedZone.sqf b/functions/common/fn_isInPopulatedZone.sqf deleted file mode 100644 index eade3582..00000000 --- a/functions/common/fn_isInPopulatedZone.sqf +++ /dev/null @@ -1,19 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_position", [0, 0, 0]] -]; - -assert(_position isEqualType []); - -private _inAnyPopulationZone = if (count GVAR(POPULATION_ZONES) == 0) then { - true -} else { - // TODO uhm… how about [] findIf {} != -1 ? - [GVAR(POPULATION_ZONES), {_position inArea (_this#0)}] call FUNC(arrayContains) -}; -if (!_inAnyPopulationZone) exitWith {false}; - -private _inAnyExclusionZone = [GVAR(EXCLUSION_ZONES), {_position inArea (_this#0)}] call FUNC(arrayContains); - -!_inAnyExclusionZone diff --git a/functions/init/fn_initConfig.sqf b/functions/init/fn_initConfig.sqf deleted file mode 100644 index 43f935db..00000000 --- a/functions/init/fn_initConfig.sqf +++ /dev/null @@ -1,73 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_mode", "runtime"] -]; -if (_mode == "preInit" && {([missionConfigFile >> "cfgGradCivs", "autoInit", 0] call BIS_fnc_returnConfigEntry) != 1}) exitWith {INFO("autoInit disabled, not running initConfig right now...")}; - -assert(isClass (configFile >> "CfgWeapons" >> "ACE_Banana")); // we depend on ACE - -if !(([missionConfigFile, "corpseManagerMode", -1] call BIS_fnc_returnConfigEntry) in [1, 3]) then { - INFO("'corpseManagerMode' is switched off for all units, but grad-civs will add its corpses anyway"); -}; - -INFO("Civs initConfig running..."); - -if (isNil QGVAR(ANIMALTRANSPORT_CHANCE)) then {missionNamespace setVariable [QGVAR(ANIMALTRANSPORT_CHANCE),[missionConfigFile >> "cfgGradCivs","animalTransportChance", 0.4] call BIS_fnc_returnConfigEntry]}; -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]}; -if (isNil "GRAD_CIVS_GOGGLES") then {missionNamespace setVariable ["GRAD_CIVS_GOGGLES",[missionConfigFile >> "cfgGradCivs","goggles",[]] call BIS_fnc_returnConfigEntry]}; -if (isNil "GRAD_CIVS_BACKPACKS") then {missionNamespace setVariable ["GRAD_CIVS_BACKPACKS",[missionConfigFile >> "cfgGradCivs","backpacks",[]] call BIS_fnc_returnConfigEntry]}; -if (isNil "GRAD_CIVS_VEHICLES") then {missionNamespace setVariable [ - "GRAD_CIVS_VEHICLES", - [ - missionConfigFile >> "cfgGradCivs", - "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"] - ] call BIS_fnc_returnConfigEntry -]}; - -if (isNil "GRAD_CIVS_BACKPACKPROBABILITY") then {missionNamespace setVariable ["GRAD_CIVS_BACKPACKPROBABILITY",[missionConfigFile >> "cfgGradCivs","backpackProbability",0.5] call BIS_fnc_returnConfigEntry]}; - -if (isNil "GRAD_CIVS_DEBUG_CIVSTATE") then {missionNamespace setVariable ["GRAD_CIVS_DEBUG_CIVSTATE",([missionConfigFile >> "cfgGradCivs","debugCivState",0] call BIS_fnc_returnConfigEntry) == 1]}; -if (isNil "GRAD_CIVS_DEBUG_FPS") then {missionNamespace setVariable ["GRAD_CIVS_DEBUG_FPS",([missionConfigFile >> "cfgGradCivs","debugFps",0] call BIS_fnc_returnConfigEntry) == 1]}; - -if (isNil "GRAD_CIVS_MINFPS") then {missionNamespace setVariable ["GRAD_CIVS_MINFPS", [missionConfigFile >> "cfgGradCivs","minFps", 35] call BIS_fnc_returnConfigEntry]}; -if (isNil "GRAD_CIVS_MINCIVUPDATETIME") then {missionNamespace setVariable ["GRAD_CIVS_MINCIVUPDATETIME", [missionConfigFile >> "cfgGradCivs","minCivUpdateTime", 3] call BIS_fnc_returnConfigEntry]}; - -missionNamespace setVariable ["GRAD_CIVS_ENABLEDONFOOT",([missionConfigFile >> "cfgGradCivs","enableOnFoot",1] call BIS_fnc_returnConfigEntry) == 1]; -missionNamespace setVariable ["GRAD_CIVS_ENABLEDINVEHICLES",([missionConfigFile >> "cfgGradCivs","enableInVehicles",1] call BIS_fnc_returnConfigEntry) == 1]; - -missionNamespace setVariable ["GRAD_CIVS_MAXCIVSONFOOT",[missionConfigFile >> "cfgGradCivs","maxCivsOnFoot",30] call BIS_fnc_returnConfigEntry]; -missionNamespace setVariable ["GRAD_CIVS_MAXCIVSINVEHICLES",[missionConfigFile >> "cfgGradCivs","maxCivsInVehicles",10] call BIS_fnc_returnConfigEntry]; -missionNamespace setVariable ["GRAD_CIVS_MAXCIVSRESIDENTS", [missionConfigFile >> "cfgGradCivs","maxCivsResidents", 20] call BIS_fnc_returnConfigEntry]; - -missionNamespace setVariable ["GRAD_CIVS_EXITON",compile ([missionConfigFile >> "cfgGradCivs","exitOn",""] call BIS_fnc_returnConfigEntry)]; -missionNamespace setVariable ["GRAD_CIVS_ONSPAWN",compile ([missionConfigFile >> "cfgGradCivs","onSpawn",""] call BIS_fnc_returnConfigEntry)]; -missionNamespace setVariable ["GRAD_CIVS_ONHELDUP",compile ([missionConfigFile >> "cfgGradCivs","onHeldUp",""] call BIS_fnc_returnConfigEntry)]; -missionNamespace setVariable ["GRAD_CIVS_ONKILLED",compile ([missionConfigFile >> "cfgGradCivs","onKilled",""] call BIS_fnc_returnConfigEntry)]; - -_initialGroupSize = [missionConfigFile >> "cfgGradCivs","initialGroupSize", 3] call BIS_fnc_returnConfigEntry; -if (typeName _initialGroupSize == "SCALAR") then { _initialGroupSize = _initialGroupSize + 1 }; -missionNamespace setVariable ["GRAD_CIVS_INITIALGROUPSIZE", _initialGroupSize]; -missionNamespace setVariable ["GRAD_CIVS_AUTOMATICVEHICLEGROUPSIZE", ([missionConfigFile >> "cfgGradCivs","automaticVehicleGroupSize", 1] call BIS_fnc_returnConfigEntry) == 1]; -missionNamespace setVariable ["GRAD_CIVS_PANICCOOLDOWN", ([missionConfigFile >> "cfgGradCivs", "panicCooldown", [15, 120, 240]] call BIS_fnc_returnConfigEntry)]; - -_distances = [missionConfigFile >> "cfgGradCivs","spawnDistancesResidents",[50, 750]] call BIS_fnc_returnConfigEntry; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCERESIDENTMIN",_distances select 0]; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCERESIDENTMAX",_distances select 1]; - -_distances = [missionConfigFile >> "cfgGradCivs","spawnDistancesOnFoot",[1000,4500]] call BIS_fnc_returnConfigEntry; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCEONFOOTMIN",_distances select 0]; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCEONFOOTMAX",_distances select 1]; - -_distances = [missionConfigFile >> "cfgGradCivs","spawnDistancesInVehicles",[1500,6000]] call BIS_fnc_returnConfigEntry; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCEINVEHICLESMIN",_distances select 0]; -missionNamespace setVariable ["GRAD_CIVS_SPAWNDISTANCEINVEHICLESMAX",_distances select 1]; - -GRAD_CIVS_BUS_MEETNEIGHBOR_COOLDOWN = 150; -GRAD_CIVS_CHAT_TIME = 20; -GVAR(EXCLUSION_ZONES) = []; -GVAR(POPULATION_ZONES) = []; diff --git a/functions/init/fn_initHCs.sqf b/functions/init/fn_initHCs.sqf deleted file mode 100644 index 9e5559c0..00000000 --- a/functions/init/fn_initHCs.sqf +++ /dev/null @@ -1,19 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_mode", "runtime"] -]; -if (_mode == "postInit" && {([missionConfigFile >> "cfgGradCivs", "autoInit", 0] call BIS_fnc_returnConfigEntry) != 1}) exitWith {INFO("autoInit disabled, not running initHCs right now...")}; - -if (isServer || !hasInterface) then { - if (!assert(isNil "GRAD_CIVS_STATEMACHINES")) exitWith { - ERROR("Already initialized, not doing it a second time!"); - }; - INFO("Civs init running..."); - - GRAD_CIVS_LOCAL_CIVS = []; - GRAD_CIVS_STATEMACHINES = [] call CBA_fnc_createNamespace; - - [] call grad_civs_fnc_sm_lifecycle; - [] call grad_civs_fnc_serverLoop; -}; diff --git a/functions/init/fn_initModule.sqf b/functions/init/fn_initModule.sqf deleted file mode 100644 index 482e0d28..00000000 --- a/functions/init/fn_initModule.sqf +++ /dev/null @@ -1,14 +0,0 @@ -#include "..\..\component.hpp" - -if (!(isNil "GRAD_CIVS_INITIALIZED")) exitWith { - WARNING("grad-civs already initialized (autoInit=1 maybe?), will NOT run again. If you're sure about this, unset GRAD_CIVS_INITIALIZED and try again!"); -}; -GRAD_CIVS_INITIALIZED = true; - -INFO("running full grad-civs initialization now..."); - -[] call grad_civs_fnc_initConfig; -[] call grad_civs_fnc_initCommonEventhandlers; -[] call grad_civs_fnc_initServer; -[] call grad_civs_fnc_initHCs; -[] call grad_civs_fnc_initPlayer; diff --git a/functions/init/fn_initPlayer.sqf b/functions/init/fn_initPlayer.sqf deleted file mode 100644 index 0aa0fdea..00000000 --- a/functions/init/fn_initPlayer.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_mode", "runtime"] -]; -if (_mode == "postInit" && {([missionConfigFile >> "cfgGradCivs", "autoInit", 0] call BIS_fnc_returnConfigEntry) != 1}) exitWith {INFO("autoInit disabled, not running initPlayer right now...")}; - -if (hasInterface) then { - if (isNil QGVAR(DEBUG_CIVSTATE)) then {missionNamespace setVariable [QGVAR(DEBUG_CIVSTATE),([missionConfigFile >> "cfgGradCivs","debugCivState",0] call BIS_fnc_returnConfigEntry) == 1]}; - if (isNil QGVAR(INFOCHANNEL)) then {GRAD_CIVS_INFOCHANNEL = 0;}; - - [] call FUNC(playerLoop); - [] call FUNC(registerAceInteractionHandler); - [] call FUNC(addCivInteractions); - [] call FUNC(setupZeusModules); - if (GVAR(DEBUG_CIVSTATE)) then { - [] call FUNC(showWhatTheyThink); - - [{!isNull (findDisplay 12)}, {[] call FUNC(mapMarkers)}, []] call CBA_fnc_waitUntilAndExecute; - }; -}; diff --git a/functions/init/fn_initServer.sqf b/functions/init/fn_initServer.sqf deleted file mode 100644 index a1642e05..00000000 --- a/functions/init/fn_initServer.sqf +++ /dev/null @@ -1,11 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_mode", "runtime"] -]; -if (_mode == "postInit" && {([missionConfigFile >> "cfgGradCivs", "autoInit", 0] call BIS_fnc_returnConfigEntry) != 1}) exitWith {INFO("autoInit disabled, not running initServer right now...")}; - -if (isServer) then { - INFO("server init running..."); - missionNamespace setVariable ["GRAD_CIVS_INFOCHANNEL", [] call grad_civs_fnc_createInfoChannel, true]; -}; diff --git a/functions/player/fn_playerLoop.sqf b/functions/player/fn_playerLoop.sqf deleted file mode 100644 index 3a8d6086..00000000 --- a/functions/player/fn_playerLoop.sqf +++ /dev/null @@ -1,39 +0,0 @@ -#include "..\..\component.hpp" - -[{ - if (!isGameFocused || isGamePaused) exitWith {}; - [] call grad_civs_fnc_checkWeaponOnCivilianPointer; -}, 0.5, []] call CBA_fnc_addPerFrameHandler; - -[{ - if (!isGameFocused || isGamePaused) exitWith {}; - if ([] call grad_civs_fnc_isPlayerHonking) then { - [] call grad_civs_fnc_checkHonkingOnCivilian; - }; -}, 0.1, []] call CBA_fnc_addPerFrameHandler; - -GRAD_CIVS_PLAYERSIDE = sideUnknown; -[{ - if (!isGameFocused || isGamePaused) exitWith {}; - if !(alive player) exitWith {}; - if (GRAD_CIVS_PLAYERSIDE == side player) exitWith {}; - if ((["HEALTHY", "INJURED"] find (lifeState player)) == -1) exitWith {}; - - if (side player == civilian) then { - GRAD_CIVS_INFOCHANNEL radioChannelAdd [player]; - ["you are CIVILIAN now"] call grad_civs_fnc_showCivHint; - } else { if (GRAD_CIVS_PLAYERSIDE == civilian) then { - ["you are NO LONGER CIVILIAN"] call grad_civs_fnc_showCivHint; - GRAD_CIVS_INFOCHANNEL radioChannelRemove [player]; - }}; - GRAD_CIVS_PLAYERSIDE = side player; -}, 5, []] call CBA_fnc_addPerFrameHandler; - -[ - "server_fps", - { - if (GRAD_CIVS_DEBUG_FPS) then { - systemChat format ["%1 fps on %2", _this select 1, _this select 0]; - }; - } -] call CBA_fnc_addEventHandler; diff --git a/functions/sm_activities/fn_sm_activities_trans_business_panic_condition.sqf b/functions/sm_activities/fn_sm_activities_trans_business_panic_condition.sqf deleted file mode 100644 index 17c9e6a7..00000000 --- a/functions/sm_activities/fn_sm_activities_trans_business_panic_condition.sqf +++ /dev/null @@ -1,2 +0,0 @@ -(vehicle _this == _this) && - ([_this, GRAD_CIVS_STATE_EMOTIONS] call CBA_statemachine_fnc_getCurrentState) == "emo_panic" diff --git a/functions/sm_activities/fn_sm_activities_trans_business_surrendered_condition.sqf b/functions/sm_activities/fn_sm_activities_trans_business_surrendered_condition.sqf deleted file mode 100644 index a0bfac1f..00000000 --- a/functions/sm_activities/fn_sm_activities_trans_business_surrendered_condition.sqf +++ /dev/null @@ -1 +0,0 @@ -_this call grad_civs_fnc_sm_activities_helper_surrenderCondition && (vehicle _this == _this) diff --git a/functions/sm_activities/fn_sm_activities_trans_dismount_surrendered_condition.sqf b/functions/sm_activities/fn_sm_activities_trans_dismount_surrendered_condition.sqf deleted file mode 100644 index f0569d53..00000000 --- a/functions/sm_activities/fn_sm_activities_trans_dismount_surrendered_condition.sqf +++ /dev/null @@ -1,2 +0,0 @@ -// transition if surrendering and has dismounted -(_this call grad_civs_fnc_sm_activities_helper_surrenderCondition) && (vehicle _this == _this) diff --git a/functions/sm_activities/fn_sm_activities_trans_surrendered_business_condition.sqf b/functions/sm_activities/fn_sm_activities_trans_surrendered_business_condition.sqf deleted file mode 100644 index 52a1ae1e..00000000 --- a/functions/sm_activities/fn_sm_activities_trans_surrendered_business_condition.sqf +++ /dev/null @@ -1 +0,0 @@ -(_this call grad_civs_fnc_sm_activities_helper_freeCondition) && (([_this, GRAD_CIVS_STATE_EMOTIONS] call CBA_statemachine_fnc_getCurrentState) != "emo_panic") diff --git a/functions/sm_activities/fn_sm_activities_trans_surrendered_panic_condition.sqf b/functions/sm_activities/fn_sm_activities_trans_surrendered_panic_condition.sqf deleted file mode 100644 index 2dd6910e..00000000 --- a/functions/sm_activities/fn_sm_activities_trans_surrendered_panic_condition.sqf +++ /dev/null @@ -1 +0,0 @@ -(_this call grad_civs_fnc_sm_activities_helper_freeCondition) && (([_this, GRAD_CIVS_STATE_EMOTIONS] call CBA_statemachine_fnc_getCurrentState) == "emo_panic") diff --git a/functions/sm_business/fn_sm_business.sqf b/functions/sm_business/fn_sm_business.sqf deleted file mode 100644 index ed071068..00000000 --- a/functions/sm_business/fn_sm_business.sqf +++ /dev/null @@ -1,196 +0,0 @@ -/* - everything the civs want to do in their day-to-day life -*/ - -private _business = [[], true] call CBA_statemachine_fnc_create; - -// entry point -private _bus_rally = [ - _business, - { _this call grad_civs_fnc_sm_business_state_rally_loop }, - { _this call grad_civs_fnc_sm_business_state_rally_enter }, - { }, - "bus_rally" -] call grad_civs_fnc_addState; - -/** - * most simple thing to do: go on patrol. yay! - */ -private _bus_patrol = [ - _business, - {}, - { _this call grad_civs_fnc_sm_business_state_patrol_enter }, - { _this call grad_civs_fnc_sm_business_state_patrol_exit }, - "bus_patrol" -] call grad_civs_fnc_addState; - - -/** - * part of the voyage cycle: mount up, voyage, dismount - */ -private _bus_mountUp = [ - _business, - {}, - { _this call grad_civs_fnc_sm_business_state_mountUp_enter }, - { _this call grad_civs_fnc_sm_business_state_mountUp_exit }, - "bus_mountUp" -] call grad_civs_fnc_addState; - -private _bus_voyage = [ - _business, - { _this call grad_civs_fnc_sm_business_state_voyage_loop }, - { _this call grad_civs_fnc_sm_business_state_voyage_enter }, - { _this call grad_civs_fnc_sm_business_state_voyage_exit }, - "bus_voyage" -] call grad_civs_fnc_addState; - -private _bus_dismount = [ - _business, - {}, - { _this call grad_civs_fnc_sm_business_state_dismount_enter }, - {}, - "bus_dismount" -] call grad_civs_fnc_addState; - -/* - * residence-cycle: housework, meetNeighbor, chat - * - * - */ -private _bus_housework = [ - _business, - {}, - { _this call grad_civs_fnc_sm_business_state_housework_enter }, - { _this call grad_civs_fnc_sm_business_state_housework_exit }, - "bus_housework" -] call grad_civs_fnc_addState; - -private _bus_meetNeighbor = [ - _business, - { _this call grad_civs_fnc_sm_business_state_meetNeighbor_loop }, - { _this call grad_civs_fnc_sm_business_state_meetNeighbor_enter }, - { _this call grad_civs_fnc_sm_business_state_meetNeighbor_exit }, - "bus_meetNeighbor" -] call grad_civs_fnc_addState; -private _bus_chat = [ - _business, - { _this call grad_civs_fnc_sm_business_state_chat_loop }, - { _this call grad_civs_fnc_sm_business_state_chat_enter }, - { _this call grad_civs_fnc_sm_business_state_chat_exit }, - "bus_chat" -] call grad_civs_fnc_addState; - - // TRANSITIONS housework: - -assert ([ - _business, - _bus_rally, _bus_housework, - { _this call grad_civs_fnc_sm_business_trans_rally_housework_condition }, - {}, - _bus_rally + _bus_housework -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_housework, _bus_meetNeighbor, - { _this call grad_civs_fnc_sm_business_trans_housework_meetNeighbor_condition }, - {}, - _bus_housework + _bus_meetNeighbor -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_meetNeighbor, _bus_chat, - { _this call grad_civs_fnc_sm_business_trans_meetNeighbor_chat_condition }, - {}, - _bus_meetNeighbor + _bus_chat -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_chat, _bus_housework, - { _this call grad_civs_fnc_sm_business_trans_chat_housework_condition }, - {}, - _bus_chat + _bus_housework -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_housework, _bus_housework, - { _this call grad_civs_fnc_sm_business_trans_housework_housework_condition }, - {}, - _bus_housework + _bus_housework -] call grad_civs_fnc_addTransition); - - - // TRANSITIONS patrol: - -assert ([ - _business, - _bus_rally, _bus_patrol, - { _this call grad_civs_fnc_sm_business_trans_rally_patrol_condition }, - {}, - _bus_rally + _bus_patrol -] call grad_civs_fnc_addTransition); - - - // TRANSITIONS voyage: - -assert ([ - _business, - _bus_rally, _bus_mountUp, - { _this call grad_civs_fnc_sm_business_trans_rally_mountUp_condition }, - {}, - _bus_rally + _bus_mountUp -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_mountUp, _bus_voyage, - { _this call grad_civs_fnc_sm_business_trans_mountUp_voyage_condition }, - {}, - _bus_mountUp + _bus_voyage -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_voyage, _bus_dismount, - { _this call grad_civs_fnc_sm_business_trans_voyage_dismount_condition }, - { - if (!(canMove vehicle _this)) then { - [_this, nil] call grad_civs_fnc_setGroupVehicle; - } - }, - _bus_voyage + _bus_dismount -] call grad_civs_fnc_addTransition); - -assert ([ - _business, - _bus_voyage, _bus_dismount, - ["grad_civs_panicking"], - { _this setSpeedMode "FULL"; speed vehicle _this < 30 }, - {}, - _bus_voyage + _bus_dismount -] call CBA_statemachine_fnc_addEventTransition); - -assert ([ - _business, - _bus_mountUp, _bus_dismount, - { _this call grad_civs_fnc_sm_business_trans_mountUp_dismount_condition }, - {}, - _bus_mountUp + _bus_dismount -] call grad_civs_fnc_addTransition); - - -assert ([ - _business, - _bus_dismount, _bus_rally, - { _this call grad_civs_fnc_sm_business_trans_dismount_rally_condition }, - {}, - _bus_dismount + _bus_rally -] call grad_civs_fnc_addTransition); - -GRAD_CIVS_STATE_BUSINESS = _business; -GRAD_CIVS_STATEMACHINES setVariable ["business", _business]; - -_business diff --git a/functions/sm_business/fn_sm_business_state_chat_enter.sqf b/functions/sm_business/fn_sm_business_state_chat_enter.sqf deleted file mode 100644 index ad30e021..00000000 --- a/functions/sm_business/fn_sm_business_state_chat_enter.sqf +++ /dev/null @@ -1,9 +0,0 @@ -private _chatTime = GRAD_CIVS_CHAT_TIME * random [0.2, 1, 5]; -_this setVariable ["grad_civs_chat_time", _chatTime]; - -private _neighbor = _this getVariable ["grad_civs_neighborToMeet", objNull]; -if (isNull _neighbor) exitWith {}; - -[_this, format ["chatting with %1", _neighbor]] call grad_civs_fnc_setCurrentlyThinking; - -_this lookAt _neighbor; diff --git a/functions/sm_business/fn_sm_business_state_meetNeighbor_exit.sqf b/functions/sm_business/fn_sm_business_state_meetNeighbor_exit.sqf deleted file mode 100644 index ad987b6f..00000000 --- a/functions/sm_business/fn_sm_business_state_meetNeighbor_exit.sqf +++ /dev/null @@ -1 +0,0 @@ -_this call grad_civs_fnc_clearCurrentlyThinking; diff --git a/functions/sm_business/fn_sm_business_state_mountUp_enter.sqf b/functions/sm_business/fn_sm_business_state_mountUp_enter.sqf deleted file mode 100644 index b4434395..00000000 --- a/functions/sm_business/fn_sm_business_state_mountUp_enter.sqf +++ /dev/null @@ -1,7 +0,0 @@ -_veh = _this call grad_civs_fnc_getGroupVehicle; -if (canMove _veh) then { - _this assignAsDriver _veh; - [_this] orderGetIn true; -} else { - [_this, nil] call grad_civs_fnc_setGroupVehicle; -}; diff --git a/functions/sm_business/fn_sm_business_state_voyage_enter.sqf b/functions/sm_business/fn_sm_business_state_voyage_enter.sqf deleted file mode 100644 index 35c01940..00000000 --- a/functions/sm_business/fn_sm_business_state_voyage_enter.sqf +++ /dev/null @@ -1,5 +0,0 @@ -[_this, _this, 2500, 3, [0,0,0], false, true] call grad_civs_fnc_taskPatrol; // vehicle patrol: wide range -_this setSpeedMode "LIMITED"; -_this forceSpeed -1; -_this enableDynamicSimulation true; -_this doFollow _this; diff --git a/functions/sm_business/fn_sm_business_state_voyage_exit.sqf b/functions/sm_business/fn_sm_business_state_voyage_exit.sqf deleted file mode 100644 index 57d79ce0..00000000 --- a/functions/sm_business/fn_sm_business_state_voyage_exit.sqf +++ /dev/null @@ -1,2 +0,0 @@ -[group _this] call CBA_fnc_clearWaypoints; -_this call grad_civs_fnc_clearCurrentlyThinking; diff --git a/functions/sm_business/fn_sm_business_trans_dismount_rally_condition.sqf b/functions/sm_business/fn_sm_business_trans_dismount_rally_condition.sqf deleted file mode 100644 index 603aac61..00000000 --- a/functions/sm_business/fn_sm_business_trans_dismount_rally_condition.sqf +++ /dev/null @@ -1,2 +0,0 @@ -(vehicle _this == _this) && - ([_this, GRAD_CIVS_STATE_EMOTIONS] call CBA_statemachine_fnc_getCurrentState) != "emo_panic" diff --git a/functions/sm_business/fn_sm_business_trans_mountUp_dismount_condition.sqf b/functions/sm_business/fn_sm_business_trans_mountUp_dismount_condition.sqf deleted file mode 100644 index dd949c4d..00000000 --- a/functions/sm_business/fn_sm_business_trans_mountUp_dismount_condition.sqf +++ /dev/null @@ -1 +0,0 @@ -(([_this, GRAD_CIVS_STATE_EMOTIONS] call CBA_statemachine_fnc_getCurrentState) == "emo_panic") || (_this call grad_civs_fnc_sm_activities_helper_surrenderCondition) diff --git a/functions/sm_business/fn_sm_business_trans_rally_mountUp_condition.sqf b/functions/sm_business/fn_sm_business_trans_rally_mountUp_condition.sqf deleted file mode 100644 index 9b4ec84f..00000000 --- a/functions/sm_business/fn_sm_business_trans_rally_mountUp_condition.sqf +++ /dev/null @@ -1,12 +0,0 @@ - -private _haveVehicle = (canMove (_this call grad_civs_fnc_getGroupVehicle)); - -assert(_stateMachine == GRAD_CIVS_STATE_BUSINESS); - -private _grpUnits = units _this; -private _nonRallyCount = { - ([_x, _stateMachine] call CBA_statemachine_fnc_getCurrentState) != "bus_rally" -} count _grpUnits; -private _allRallying = _nonRallyCount == 0; - -_allRallying && _haveVehicle && (leader _this == _this) diff --git a/functions/sm_business/fn_sm_business_trans_rally_patrol_condition.sqf b/functions/sm_business/fn_sm_business_trans_rally_patrol_condition.sqf deleted file mode 100644 index d655dd1e..00000000 --- a/functions/sm_business/fn_sm_business_trans_rally_patrol_condition.sqf +++ /dev/null @@ -1,11 +0,0 @@ -private _haveNoVehicle = !(canMove (_this call grad_civs_fnc_getGroupVehicle)); - -assert(_stateMachine == GRAD_CIVS_STATE_BUSINESS); - -private _grpUnits = units _this; -private _nonRallyCount = { - ([_x, _stateMachine] call CBA_statemachine_fnc_getCurrentState) != "bus_rally" -} count _grpUnits; -private _allRallying = _nonRallyCount == 0; - -_allRallying && _haveNoVehicle && ((_this getVariable ["grad_civs_primaryTask", ""]) in ["voyage", "patrol"]) diff --git a/functions/sm_business/fn_sm_business_trans_voyage_dismount_condition.sqf b/functions/sm_business/fn_sm_business_trans_voyage_dismount_condition.sqf deleted file mode 100644 index a3b6ba18..00000000 --- a/functions/sm_business/fn_sm_business_trans_voyage_dismount_condition.sqf +++ /dev/null @@ -1 +0,0 @@ -(_this call grad_civs_fnc_sm_activities_helper_surrenderCondition) || !(canMove vehicle _this) diff --git a/functions/sm_lifecycle/fn_sm_lifecycle_trans_life_despawn_condition.sqf b/functions/sm_lifecycle/fn_sm_lifecycle_trans_life_despawn_condition.sqf deleted file mode 100644 index 04bcf6b8..00000000 --- a/functions/sm_lifecycle/fn_sm_lifecycle_trans_life_despawn_condition.sqf +++ /dev/null @@ -1,19 +0,0 @@ -#include "..\..\component.hpp" - -private _idx = GVAR(LOCAL_CIVS) find _this; - -if (_idx == -1) exitWith {false}; // should not happen, really - -if (((floor CBA_missionTime) mod 10) != (_idx mod 10)) exitWith {false}; // check only every 10s for a given unit - -if (_this getVariable ["grad_civs_excludeFromCleanup",false]) exitWith {false}; - -private _cleanupDistance = GVAR(SPAWNDISTANCEINVEHICLESMAX) * 1.2; -if (isNull (_this call FUNC(getGroupVehicle))) then { - _cleanupDistance = GVAR(SPAWNDISTANCEONFOOTMAX) * 1.5; -}; -if (_this call FUNC(isInHouse)) then { - _cleanupDistance = GVAR(SPAWNDISTANCERESIDENTMAX) * 1.2; -}; - -[ALL_HUMAN_PLAYERS, getPos _this, _cleanupDistance] call FUNC(isInDistanceFromOtherPlayers); diff --git a/functions/sm_panic/fn_sm_panic_state_hide_exit.sqf b/functions/sm_panic/fn_sm_panic_state_hide_exit.sqf deleted file mode 100644 index fee57938..00000000 --- a/functions/sm_panic/fn_sm_panic_state_hide_exit.sqf +++ /dev/null @@ -1 +0,0 @@ -_this call grad_civs_fnc_clearCurrentlyThinking diff --git a/functions/sm_panic/fn_sm_panic_trans_hide_hidden_handler.sqf b/functions/sm_panic/fn_sm_panic_trans_hide_hidden_handler.sqf deleted file mode 100644 index 916b2142..00000000 --- a/functions/sm_panic/fn_sm_panic_trans_hide_hidden_handler.sqf +++ /dev/null @@ -1 +0,0 @@ -_this stop true diff --git a/functions/spawn/fn_addCarCrew.sqf b/functions/spawn/fn_addCarCrew.sqf deleted file mode 100644 index d2a24b30..00000000 --- a/functions/spawn/fn_addCarCrew.sqf +++ /dev/null @@ -1,47 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_allPlayers", []], - ["_forcePosition", []] -]; - -private _pos = if (_forcePosition isEqualTo []) then { - private _segment = [ - _allPlayers, - GRAD_CIVS_SPAWNDISTANCEINVEHICLESMIN, - GRAD_CIVS_SPAWNDISTANCEINVEHICLESMAX, - ["voyage"] call FUNC(getGlobalCivs) - ] call FUNC(findSpawnRoadSegment); - LOGTIME_END("findSpawnPos_vehicle"); - - if (isNull _segment) exitWith { - LOG("could not find spawn position for car at this time"); - }; - LOGTIME_START("findSpawnPos_vehicle"); - getPos _segment -} else { - _forcePosition -}; - - -private _house = [ - _allPlayers, - 0, - GRAD_CIVS_SPAWNDISTANCEINVEHICLESMAX * 1.5, - "house" -] call FUNC(findSpawnPosition); - - -private _vehicleClass = selectRandom GRAD_CIVS_VEHICLES; - -_veh = [_pos, _vehicleClass] call grad_civs_fnc_spawnVehicle; - -private _groupSize = floor random GRAD_CIVS_INITIALGROUPSIZE; -if (GRAD_CIVS_AUTOMATICVEHICLEGROUPSIZE) then { - private _maxCount = count ((fullCrew [_veh, "", true]) select { - !(_veh lockedCargo _x#2); - }); - _groupSize = (floor random [0, 1, _maxCount]) + 1 -}; - -_group = [_pos, _groupSize, _veh, _house, "voyage"] call grad_civs_fnc_spawnCivilianGroup; diff --git a/functions/spawn/fn_addFootsy.sqf b/functions/spawn/fn_addFootsy.sqf deleted file mode 100644 index 37f22eda..00000000 --- a/functions/spawn/fn_addFootsy.sqf +++ /dev/null @@ -1,24 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_allPlayers", []] -]; - -LOGTIME_START("findSpawnPos_onFoot"); -private _house = [ - _allPlayers, - GRAD_CIVS_SPAWNDISTANCEONFOOTMIN, - GRAD_CIVS_SPAWNDISTANCEONFOOTMAX, - "house" -] call grad_civs_fnc_findSpawnPosition; -LOGTIME_END("findSpawnPos_onFoot"); - -if (isNull _house) exitWith { - LOG("could not find house for patrol"); -}; - -private _groupSize = floor random GRAD_CIVS_INITIALGROUPSIZE; - -LOGTIME_START("spawnCiv_onFoot"); -_group = [getPos _house, _groupSize, objNull, _house, "patrol"] call grad_civs_fnc_spawnCivilianGroup; -LOGTIME_END("spawnCiv_onFoot"); diff --git a/functions/spawn/fn_addResident.sqf b/functions/spawn/fn_addResident.sqf deleted file mode 100644 index 1a9b56aa..00000000 --- a/functions/spawn/fn_addResident.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_allPlayers", []] -]; - -private _house = [ - _allPlayers, - GRAD_CIVS_SPAWNDISTANCERESIDENTMIN, - GRAD_CIVS_SPAWNDISTANCERESIDENTMAX, - "house" -] call grad_civs_fnc_findSpawnPosition; - -if (isNil "_house") exitWith {LOG("could not find spawn position for resident this time (nil)")}; -if (isNull _house) exitWith {LOG("could not find spawn position for resident this time (null)")}; - -private _groupSize = floor random GRAD_CIVS_INITIALGROUPSIZE; - -private _group = [getPos _house, _groupSize, objNull, _house, "reside"] call FUNC(spawnCivilianGroup); -if (isNull _group) exitWith {}; - -_group diff --git a/functions/spawn/fn_createSideRoadVehicles.sqf b/functions/spawn/fn_createSideRoadVehicles.sqf deleted file mode 100644 index 73a1c0f7..00000000 --- a/functions/spawn/fn_createSideRoadVehicles.sqf +++ /dev/null @@ -1,85 +0,0 @@ -#include "..\..\component.hpp" - -params ["_locationPosition","_locationRadius","_amountFactor","_houseFactor","_minDistance","_maxAmount"]; - -if (GRAD_CIVS_VEHICLES isEqualTo []) exitWith {}; -private _vehiclePositions = []; - -//LOCAL FUNCTIONS ============================================================== -private _fnc_nearbyVehiclePositions = { - params ["_pos"]; - - _nearbyVehiclePositions = []; - {if (_pos distance2D _x < _minDistance) then {_nearbyVehiclePositions pushBack _x}} forEach _vehiclePositions; - _nearbyVehiclePositions -}; - -private _fnc_isSafe = { - params ["_pos"]; - !(([_pos,0,1,0,0,0.6,0,[],[[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos) isEqualTo [0,0,0]) -}; - - -//MAIN ========================================================================= -private _thesePositions = []; -private _roads = _locationPosition nearRoads _locationRadius; -private _vehiclesToCreate = (round ((count _roads) * 0.07 * _amountFactor)); -_vehiclesToCreate = round ((2 max (_vehiclesToCreate + ((random (_vehiclesToCreate * 0.4)) - _vehiclesToCreate * 0.2))) min _maxAmount); - -while {count _roads > 0 && count _thesePositions < _vehiclesToCreate} do { - private ["_vehPos","_canCreate","_chosenDirection","_offRoadFound"]; - - _randomRoadID = round (random ((count _roads)-1)); - _road = _roads deleteAt _randomRoadID; - - if (!isNull _road) then { - if (count (roadsConnectedTo _road) == 0) exitWith {}; - _roadDir = _road getDir ((roadsConnectedTo _road) select 0); - _boundingBox = boundingBox _road; - _width = ((_boundingBox select 1) select 0) - ((_boundingBox select 0) select 0); - - _startDirection = selectRandom [1,-1]; - { - _chosenDirection = _x; - _offRoadFound = false; - for [{_i=1}, {_i<50}, {_i=_i+1}] do { - _testPos = _road getRelPos [1.5 + _i*0.2,_roadDir+90*_chosenDirection]; - _vehPos = _testPos; - if (!isOnRoad _testPos) exitWith {_offRoadFound = true}; - }; - - _enoughHouses = if (_houseFactor < 0) then {true} else { - (count ([_vehPos, 20] call grad_civs_fnc_findBuildings)) * _houseFactor > random 100 - }; - - _canCreate = switch (true) do { - case (!_offRoadFound): {"ONROAD"}; - case (count (getPos _road nearRoads 10) > 2): {"ONINTERSECTION"}; - case (!_enoughHouses): {"NOHOUSES"}; - case (count ([_vehPos] call _fnc_nearbyVehiclePositions) > 0): {"TOOCLOSE"}; - case (!([_vehPos] call _fnc_isSafe)): {"UNSAFE"}; - default {"CANCREATE"}; - }; - - if (_forEachIndex == 1) then {_roadDir = _roadDir + 180}; - if (_canCreate == "CANCREATE") exitWith {}; - } forEach [_startDirection,-_startDirection]; - - if (_canCreate == "CANCREATE") then { - _type = selectRandom GRAD_CIVS_VEHICLES; - _thesePositions pushBack _vehPos; - _vehiclePositions pushBack _vehPos; - _veh = createVehicle [_type,[0,0,0],[],0,"CAN_COLLIDE"]; - [{!isNull (_this select 0)}, { - params ["_veh","_roadDir","_chosenDirection","_vehPos"]; - _veh setDir _roadDir + (90 + 90*_chosenDirection); - _veh setPos _vehPos; - _veh setVelocity [0,0,1]; - _veh lock 2; - [_veh] call grad_civs_fnc_deleteIfDamaged; - }, [_veh,_roadDir,_chosenDirection,_vehPos]] call CBA_fnc_waitUntilAndExecute; - }; - }; -}; - -count _vehiclePositions diff --git a/functions/spawn/fn_isInDistanceFromOtherPlayers.sqf b/functions/spawn/fn_isInDistanceFromOtherPlayers.sqf deleted file mode 100644 index 1056c5e8..00000000 --- a/functions/spawn/fn_isInDistanceFromOtherPlayers.sqf +++ /dev/null @@ -1,10 +0,0 @@ -params [ - ["_allPlayers", []], - ["_pos", [0, 0]], - ["_minDistance", 0] -]; - -{ - if (((getPos _x) distance _pos) < _minDistance) exitWith {false}; - true -} forEach _allPlayers; diff --git a/functions/spawn/fn_spawnCivilian.sqf b/functions/spawn/fn_spawnCivilian.sqf deleted file mode 100644 index 40dce9c3..00000000 --- a/functions/spawn/fn_spawnCivilian.sqf +++ /dev/null @@ -1,18 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_pos", [0, 0, 0]], - ["_group", grpNull], - ["_primaryTask", ""] -]; - -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; - - -_civ setVariable ["grad_civs_primaryTask", _primaryTask, true]; -_civ setVariable ["acex_headless_blacklist", true, true]; - -_civ diff --git a/functions/spawn/fn_spawnCivilianGroup.sqf b/functions/spawn/fn_spawnCivilianGroup.sqf deleted file mode 100644 index cb45a18a..00000000 --- a/functions/spawn/fn_spawnCivilianGroup.sqf +++ /dev/null @@ -1,48 +0,0 @@ -#include "..\..\component.hpp" - -params [ - ["_pos", [0, 0, 0]], - ["_groupSize", 1], - ["_vehicle", objNull], - ["_house", objNull], - ["_primaryTask", ""] -]; - -if (_pos isEqualTo [0, 0, 0]) exitWith {ERROR("tried to spawn civs at 0,0,0"); grpNull}; - -private _group = createGroup [civilian, true]; -_group setCombatMode "GREEN"; - -for "_i" from 1 to _groupSize do { - private _civ = [_pos, _group, _primaryTask] call FUNC(spawnCivilian); - - // for convenience & speed: shortcut so units dont have to lengthily embark on their own - // also, prevents issues with civs spawning inside their vehicle, - // which for some reason happens to lone drivers regardless of "NONE" collision flag on spawn - if (!(isNull _vehicle)) then { - if (_i == 1) then { - _civ moveInDriver _vehicle; - _civ assignAsDriver _vehicle; - } else { - _civ moveInCargo _vehicle; - _civ assignAsCargo _vehicle; - }; - - }; -}; - -if (!(isNull _vehicle)) then { - [_group, _vehicle] call FUNC(setGroupVehicle); -}; - -if (isNull _house) then { - WARNING_2("no house for group %1 (primaryTask=%2)",_group, _primaryTask); -} else { - _group setVariable ["grad_civs_home", _house, true]; - _house setVariable ["grad_civs_residents", units _group, true]; - { - _x setVariable ["grad_civs_home", _house, true]; - } forEach units _group; -}; - -_group diff --git a/functions/spawn/fn_spawnPass.sqf b/functions/spawn/fn_spawnPass.sqf deleted file mode 100644 index bc17ee91..00000000 --- a/functions/spawn/fn_spawnPass.sqf +++ /dev/null @@ -1,25 +0,0 @@ -#include "..\..\component.hpp" - -private _allPlayers = ALL_HUMAN_PLAYERS; -if (_allPlayers isEqualTo []) exitWith {}; - -private _fps = diag_fps; -if (_fps < GRAD_CIVS_MINFPS) exitWith {INFO_2("not spawning additional civs: less FPS than required (%1/%2)", _fps, GRAD_CIVS_MINFPS)}; -if ((_fps * GRAD_CIVS_MINCIVUPDATETIME) < (count GRAD_CIVS_LOCAL_CIVS)) exitWith {INFO_3("not spawning additional civs: cannot guarantee update times less than %1 for %2 civs with %3 fps", GRAD_CIVS_MINCIVUPDATETIME, count GRAD_CIVS_LOCAL_CIVS, _fps)}; - -if (GRAD_CIVS_ENABLEDONFOOT) then { - if ((count (["patrol"] call grad_civs_fnc_getGlobalCivs)) < GRAD_CIVS_MAXCIVSONFOOT) then { - [_allPlayers] call grad_civs_fnc_addFootsy; - }; -}; - -if (GRAD_CIVS_ENABLEDINVEHICLES) then { - assert(count GRAD_CIVS_VEHICLES > 0); - if ((count (["voyage"] call grad_civs_fnc_getGlobalCivs)) < GRAD_CIVS_MAXCIVSINVEHICLES) then { - [_allPlayers] call grad_civs_fnc_addCarCrew; - }; -}; - -if ((count (["reside"] call grad_civs_fnc_getGlobalCivs)) < GRAD_CIVS_MAXCIVSRESIDENTS) then { - [_allPlayers] call grad_civs_fnc_addResident; -}; diff --git a/hemtt.toml b/hemtt.toml new file mode 100644 index 00000000..dc403fba --- /dev/null +++ b/hemtt.toml @@ -0,0 +1,7 @@ +name = "grad_civs" +prefix = "grad_civs" +author = "Fusselwurm" +template = "cba" +mainprefix = "z" +folder_optionals = true +sig_version = 3 diff --git a/include/x/cba/addons/main/script_macros_common.hpp b/include/x/cba/addons/main/script_macros_common.hpp new file mode 100644 index 00000000..18f33c78 --- /dev/null +++ b/include/x/cba/addons/main/script_macros_common.hpp @@ -0,0 +1,1810 @@ +/* + Header: script_macros_common.hpp + + Description: + A general set of useful macro functions for use by CBA itself or by any module that uses CBA. + + Authors: + Sickboy and Spooner +*/ + +/* **************************************************** + New - Should be exported to general addon + Aim: + - Simplify (shorten) the amount of characters required for repetitive tasks + - Provide a solid structure that can be dynamic and easy editable (Which sometimes means we cannot adhere to Aim #1 ;-) + An example is the path that is built from defines. Some available in this file, others in mods and addons. + + Follows Standard: + Object variables: PREFIX_COMPONENT + Main-object variables: PREFIX_main + Paths: MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\SCRIPTNAME.sqf + e.g: x\six\addons\sys_menu\fDate.sqf + + Usage: + define PREFIX and COMPONENT, then include this file + (Note, you could have a main addon for your mod, define the PREFIX in a macros.hpp, + and include this script_macros_common.hpp file. + Then in your addons, add a component.hpp, define the COMPONENT, + and include your mod's script_macros.hpp + In your scripts you can then include the addon's component.hpp with relative path) + + TODO: + - Try only to use 1 string type " vs ' + - Evaluate double functions, and simplification + - Evaluate naming scheme; current = prototype + - Evaluate "Debug" features.. + - Evaluate "create mini function per precompiled script, that will load the script on first usage, rather than on init" + - Also saw "Namespace" typeName, evaluate which we need :P + - Single/Multi player gamelogics? (Incase of MP, you would want only 1 gamelogic per component, which is pv'ed from server, etc) + */ + +#ifndef MAINPREFIX + #define MAINPREFIX x +#endif + +#ifndef SUBPREFIX + #define SUBPREFIX addons +#endif + +#ifndef MAINLOGIC + #define MAINLOGIC main +#endif + +#ifndef VERSION + #define VERSION 0 +#endif + +#ifndef VERSION_AR + #define VERSION_AR VERSION +#endif + +#ifndef VERSION_CONFIG + #define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION); versionAr[] = {VERSION_AR} +#endif + +#define ADDON DOUBLES(PREFIX,COMPONENT) +#define MAIN_ADDON DOUBLES(PREFIX,main) + +/* ------------------------------------------- +Group: Debugging +------------------------------------------- */ + +/* ------------------------------------------- +Macros: DEBUG_MODE_x + Managing debugging based on debug level. + + According to the *highest* level of debugging that has been defined *before* script_macros_common.hpp is included, + only the appropriate debugging commands will be functional. With no level explicitely defined, assume DEBUG_MODE_NORMAL. + + DEBUG_MODE_FULL - Full debugging output. + DEBUG_MODE_NORMAL - All debugging except and (Default setting if none specified). + DEBUG_MODE_MINIMAL - Only and enabled. + +Examples: + In order to turn on full debugging for a single file, + (begin example) + // Top of individual script file. + #define DEBUG_MODE_FULL + #include "script_component.hpp" + (end) + + In order to force minimal debugging for a single component, + (begin example) + // Top of addons\\script_component.hpp + // Ensure that any FULL and NORMAL setting from the individual files are undefined and MINIMAL is set. + #ifdef DEBUG_MODE_FULL + #undef DEBUG_MODE_FULL + #endif + #ifdef DEBUG_MODE_NORMAL + #undef DEBUG_MODE_NORMAL + #endif + #ifndef DEBUG_MODE_MINIMAL + #define DEBUG_MODE_MINIMAL + #endif + #include "script_macros.hpp" + (end) + + In order to turn on full debugging for a whole addon, + (begin example) + // Top of addons\main\script_macros.hpp + #ifndef DEBUG_MODE_FULL + #define DEBUG_MODE_FULL + #endif + #include "\x\cba\addons\main\script_macros_common.hpp" + (end) + +Author: + Spooner +------------------------------------------- */ + +// If DEBUG_MODE_FULL, then also enable DEBUG_MODE_NORMAL. +#ifdef DEBUG_MODE_FULL +#define DEBUG_MODE_NORMAL +#endif + +// If DEBUG_MODE_NORMAL, then also enable DEBUG_MODE_MINIMAL. +#ifdef DEBUG_MODE_NORMAL +#define DEBUG_MODE_MINIMAL +#endif + +// If no debug modes specified, use DEBUG_MODE_NORMAL (+ DEBUG_MODE_MINIMAL). +#ifndef DEBUG_MODE_MINIMAL +#define DEBUG_MODE_NORMAL +#define DEBUG_MODE_MINIMAL +#endif + +#define LOG_SYS_FORMAT(LEVEL,MESSAGE) format ['[%1] (%2) %3: %4', toUpper 'PREFIX', 'COMPONENT', LEVEL, MESSAGE] + +#ifdef DEBUG_SYNCHRONOUS +#define LOG_SYS(LEVEL,MESSAGE) diag_log text LOG_SYS_FORMAT(LEVEL,MESSAGE) +#else +#define LOG_SYS(LEVEL,MESSAGE) LOG_SYS_FORMAT(LEVEL,MESSAGE) call CBA_fnc_log +#endif + +#define LOG_SYS_FILELINENUMBERS(LEVEL,MESSAGE) LOG_SYS(LEVEL,format [ARR_4('%1 %2:%3',MESSAGE,__FILE__,__LINE__ + 1)]) + +/* ------------------------------------------- +Macro: LOG() + Log a debug message into the RPT log. + + Only run if is defined. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + LOG("Initiated clog-dancing simulator."); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifdef DEBUG_MODE_FULL + +#define LOG(MESSAGE) LOG_SYS_FILELINENUMBERS('LOG',MESSAGE) +#define LOG_1(MESSAGE,ARG1) LOG(FORMAT_1(MESSAGE,ARG1)) +#define LOG_2(MESSAGE,ARG1,ARG2) LOG(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) LOG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) LOG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) LOG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) LOG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) LOG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) LOG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +#else + +#define LOG(MESSAGE) /* disabled */ +#define LOG_1(MESSAGE,ARG1) /* disabled */ +#define LOG_2(MESSAGE,ARG1,ARG2) /* disabled */ +#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ +#define LOG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ +#define LOG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ +#define LOG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ +#define LOG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ +#define LOG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ + +#endif + +/* ------------------------------------------- +Macro: INFO() + Record a message without file and line number in the RPT log. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + INFO("Mod X is loaded, do Y"); + (end) + +Author: + commy2 +------------------------------------------- */ +#define INFO(MESSAGE) LOG_SYS('INFO',MESSAGE) +#define INFO_1(MESSAGE,ARG1) INFO(FORMAT_1(MESSAGE,ARG1)) +#define INFO_2(MESSAGE,ARG1,ARG2) INFO(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define INFO_3(MESSAGE,ARG1,ARG2,ARG3) INFO(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define INFO_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) INFO(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define INFO_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) INFO(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define INFO_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) INFO(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define INFO_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) INFO(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define INFO_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) INFO(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: WARNING() + Record a non-critical error in the RPT log. + + Only run if or higher is defined. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + WARNING("This function has been deprecated. Please don't use it in future!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifdef DEBUG_MODE_NORMAL + +#define WARNING(MESSAGE) LOG_SYS_FILELINENUMBERS('WARNING',MESSAGE) +#define WARNING_1(MESSAGE,ARG1) WARNING(FORMAT_1(MESSAGE,ARG1)) +#define WARNING_2(MESSAGE,ARG1,ARG2) WARNING(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) WARNING(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) WARNING(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) WARNING(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) WARNING(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) WARNING(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) WARNING(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +#else + +#define WARNING(MESSAGE) /* disabled */ +#define WARNING_1(MESSAGE,ARG1) /* disabled */ +#define WARNING_2(MESSAGE,ARG1,ARG2) /* disabled */ +#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) /* disabled */ +#define WARNING_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) /* disabled */ +#define WARNING_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) /* disabled */ +#define WARNING_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) /* disabled */ +#define WARNING_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) /* disabled */ +#define WARNING_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) /* disabled */ + +#endif + +/* ------------------------------------------- +Macro: ERROR() + Record a critical error in the RPT log. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + ERROR("value of frog not found in config ...yada...yada..."); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ERROR(MESSAGE) LOG_SYS_FILELINENUMBERS('ERROR',MESSAGE) +#define ERROR_1(MESSAGE,ARG1) ERROR(FORMAT_1(MESSAGE,ARG1)) +#define ERROR_2(MESSAGE,ARG1,ARG2) ERROR(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_3(MESSAGE,ARG1,ARG2,ARG3) ERROR(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: ERROR_MSG() + Record a critical error in the RPT log and display on screen error message. + + Newlines (\n) in the MESSAGE will be put on separate lines. + +Parameters: + MESSAGE - Message to record + +Example: + (begin example) + ERROR_MSG("value of frog not found in config ...yada...yada..."); + (end) + +Author: + commy2 +------------------------------------------- */ +#define ERROR_MSG(MESSAGE) ['PREFIX', 'COMPONENT', nil, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error +#define ERROR_MSG_1(MESSAGE,ARG1) ERROR_MSG(FORMAT_1(MESSAGE,ARG1)) +#define ERROR_MSG_2(MESSAGE,ARG1,ARG2) ERROR_MSG(FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_MSG_3(MESSAGE,ARG1,ARG2,ARG3) ERROR_MSG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_MSG_4(MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_MSG(FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_MSG_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_MSG(FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_MSG_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_MSG(FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_MSG_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_MSG(FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_MSG_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_MSG(FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: ERROR_WITH_TITLE() + Record a critical error in the RPT log. + + The title can be specified (in the heading is always just "ERROR") + Newlines (\n) in the MESSAGE will be put on separate lines. + +Parameters: + TITLE - Title of error message + MESSAGE - Body of error message + +Example: + (begin example) + ERROR_WITH_TITLE("Value not found","Value of frog not found in config ...yada...yada..."); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ERROR_WITH_TITLE(TITLE,MESSAGE) ['PREFIX', 'COMPONENT', TITLE, MESSAGE, __FILE__, __LINE__ + 1] call CBA_fnc_error +#define ERROR_WITH_TITLE_1(TITLE,MESSAGE,ARG1) ERROR_WITH_TITLE(TITLE,FORMAT_1(MESSAGE,ARG1)) +#define ERROR_WITH_TITLE_2(TITLE,MESSAGE,ARG1,ARG2) ERROR_WITH_TITLE(TITLE,FORMAT_2(MESSAGE,ARG1,ARG2)) +#define ERROR_WITH_TITLE_3(TITLE,MESSAGE,ARG1,ARG2,ARG3) ERROR_WITH_TITLE(TITLE,FORMAT_3(MESSAGE,ARG1,ARG2,ARG3)) +#define ERROR_WITH_TITLE_4(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4) ERROR_WITH_TITLE(TITLE,FORMAT_4(MESSAGE,ARG1,ARG2,ARG3,ARG4)) +#define ERROR_WITH_TITLE_5(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5) ERROR_WITH_TITLE(TITLE,FORMAT_5(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5)) +#define ERROR_WITH_TITLE_6(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ERROR_WITH_TITLE(TITLE,FORMAT_6(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) +#define ERROR_WITH_TITLE_7(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ERROR_WITH_TITLE(TITLE,FORMAT_7(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)) +#define ERROR_WITH_TITLE_8(TITLE,MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ERROR_WITH_TITLE(TITLE,FORMAT_8(MESSAGE,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8)) + +/* ------------------------------------------- +Macro: MESSAGE_WITH_TITLE() + Record a single line in the RPT log. + +Parameters: + TITLE - Title of log message + MESSAGE - Body of message + +Example: + (begin example) + MESSAGE_WITH_TITLE("Value found","Value of frog found in config "); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define MESSAGE_WITH_TITLE(TITLE,MESSAGE) LOG_SYS_FILELINENUMBERS(TITLE,MESSAGE) + +/* ------------------------------------------- +Macro: RETDEF() + If a variable is undefined, return the default value. Otherwise, return the + variable itself. + +Parameters: + VARIABLE - the variable to check + DEFAULT_VALUE - the default value to use if variable is undefined + +Example: + (begin example) + // _var is undefined + hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=5" + _var = 7; + hintSilent format ["_var=%1", RETDEF(_var,5)]; // "_var=7" + (end example) +Author: + 654wak654 +------------------------------------------- */ +#define RETDEF(VARIABLE,DEFAULT_VALUE) (if (isNil {VARIABLE}) then [{DEFAULT_VALUE}, {VARIABLE}]) + +/* ------------------------------------------- +Macro: RETNIL() + If a variable is undefined, return the value nil. Otherwise, return the + variable itself. + +Parameters: + VARIABLE - the variable to check + +Example: + (begin example) + // _var is undefined + hintSilent format ["_var=%1", RETNIL(_var)]; // "_var=any" + (end example) + +Author: + Alef (see CBA issue #8514) +------------------------------------------- */ +#define RETNIL(VARIABLE) RETDEF(VARIABLE,nil) + +/* ------------------------------------------- +Macros: TRACE_n() + Log a message and 1-8 variables to the RPT log. + + Only run if is defined. + + TRACE_1(MESSAGE,A) - Log 1 variable. + TRACE_2(MESSAGE,A,B) - Log 2 variables. + TRACE_3(MESSAGE,A,B,C) - Log 3 variables. + TRACE_4(MESSAGE,A,B,C,D) - Log 4 variables. + TRACE_5(MESSAGE,A,B,C,D,E) - Log 5 variables. + TRACE_6(MESSAGE,A,B,C,D,E,F) - Log 6 variables. + TRACE_7(MESSAGE,A,B,C,D,E,F,G) - Log 7 variables. + TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) - Log 8 variables. + TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) - Log 9 variables. + +Parameters: + MESSAGE - Message to add to the trace [String] + A..H - Variable names to log values of [Any] + +Example: + (begin example) + TRACE_3("After takeoff",_vehicle player,getPos (_vehicle player), getPosASL (_vehicle player)); + (end) + +Author: + Spooner +------------------------------------------- */ +#define PFORMAT_1(MESSAGE,A) \ + format ['%1: A=%2', MESSAGE, RETNIL(A)] + +#define PFORMAT_2(MESSAGE,A,B) \ + format ['%1: A=%2, B=%3', MESSAGE, RETNIL(A), RETNIL(B)] + +#define PFORMAT_3(MESSAGE,A,B,C) \ + format ['%1: A=%2, B=%3, C=%4', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C)] + +#define PFORMAT_4(MESSAGE,A,B,C,D) \ + format ['%1: A=%2, B=%3, C=%4, D=%5', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D)] + +#define PFORMAT_5(MESSAGE,A,B,C,D,E) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E)] + +#define PFORMAT_6(MESSAGE,A,B,C,D,E,F) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F)] + +#define PFORMAT_7(MESSAGE,A,B,C,D,E,F,G) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G)] + +#define PFORMAT_8(MESSAGE,A,B,C,D,E,F,G,H) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H)] + +#define PFORMAT_9(MESSAGE,A,B,C,D,E,F,G,H,I) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9, I=%10', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H), RETNIL(I)] + + +#ifdef DEBUG_MODE_FULL +#define TRACE_1(MESSAGE,A) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_1(str diag_frameNo + ' ' + (MESSAGE),A)) +#define TRACE_2(MESSAGE,A,B) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_2(str diag_frameNo + ' ' + (MESSAGE),A,B)) +#define TRACE_3(MESSAGE,A,B,C) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_3(str diag_frameNo + ' ' + (MESSAGE),A,B,C)) +#define TRACE_4(MESSAGE,A,B,C,D) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_4(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D)) +#define TRACE_5(MESSAGE,A,B,C,D,E) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_5(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E)) +#define TRACE_6(MESSAGE,A,B,C,D,E,F) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_6(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F)) +#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_7(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G)) +#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_8(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H)) +#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) LOG_SYS_FILELINENUMBERS('TRACE',PFORMAT_9(str diag_frameNo + ' ' + (MESSAGE),A,B,C,D,E,F,G,H,I)) +#else +#define TRACE_1(MESSAGE,A) /* disabled */ +#define TRACE_2(MESSAGE,A,B) /* disabled */ +#define TRACE_3(MESSAGE,A,B,C) /* disabled */ +#define TRACE_4(MESSAGE,A,B,C,D) /* disabled */ +#define TRACE_5(MESSAGE,A,B,C,D,E) /* disabled */ +#define TRACE_6(MESSAGE,A,B,C,D,E,F) /* disabled */ +#define TRACE_7(MESSAGE,A,B,C,D,E,F,G) /* disabled */ +#define TRACE_8(MESSAGE,A,B,C,D,E,F,G,H) /* disabled */ +#define TRACE_9(MESSAGE,A,B,C,D,E,F,G,H,I) /* disabled */ +#endif + +/* ------------------------------------------- +Group: General +------------------------------------------- */ + +// ************************************* +// Internal Functions +#define DOUBLES(var1,var2) ##var1##_##var2 +#define TRIPLES(var1,var2,var3) ##var1##_##var2##_##var3 +#define QUOTE(var1) #var1 + +#ifdef MODULAR + #define COMPONENT_T DOUBLES(t,COMPONENT) + #define COMPONENT_M DOUBLES(m,COMPONENT) + #define COMPONENT_S DOUBLES(s,COMPONENT) + #define COMPONENT_C DOUBLES(c,COMPONENT) + #define COMPONENT_F COMPONENT_C +#else + #define COMPONENT_T COMPONENT + #define COMPONENT_M COMPONENT + #define COMPONENT_S COMPONENT + #define COMPONENT_F COMPONENT + #define COMPONENT_C COMPONENT +#endif + +/* ------------------------------------------- +Macro: INC() + +Description: + Increase a number by one. + +Parameters: + VAR - Variable to increment [Number] + +Example: + (begin example) + _counter = 0; + INC(_counter); + // _counter => 1 + (end) + +Author: + Spooner +------------------------------------------- */ +#define INC(var) var = (var) + 1 + +/* ------------------------------------------- +Macro: DEC() + +Description: + Decrease a number by one. + +Parameters: + VAR - Variable to decrement [Number] + +Example: + (begin example) + _counter = 99; + DEC(_counter); + // _counter => 98 + (end) + +Author: + Spooner +------------------------------------------- */ +#define DEC(var) var = (var) - 1 + +/* ------------------------------------------- +Macro: ADD() + +Description: + Add a value to a variable. Variable and value should be both Numbers or both Strings. + +Parameters: + VAR - Variable to add to [Number or String] + VALUE - Value to add [Number or String] + +Examples: + (begin example) + _counter = 2; + ADD(_counter,3); + // _counter => 5 + (end) + (begin example) + _str = "hello"; + ADD(_str," "); + ADD(_str,"Fred"); + // _str => "hello Fred" + (end) + +Author: + Sickboy +------------------------------------------- */ +#define ADD(var1,var2) var1 = (var1) + (var2) + +/* ------------------------------------------- +Macro: SUB() + +Description: + Subtract a value from a number variable. VAR and VALUE should both be Numbers. + +Parameters: + VAR - Variable to subtract from [Number] + VALUE - Value to subtract [Number] + +Examples: + (begin example) + _numChickens = 2; + SUB(_numChickens,3); + // _numChickens => -1 + (end) +------------------------------------------- */ +#define SUB(var1,var2) var1 = (var1) - (var2) + +/* ------------------------------------------- +Macro: REM() + +Description: + Remove an element from an array each time it occurs. + + This recreates the entire array, so use BIS_fnc_removeIndex if modification of the original array is required + or if only one of the elements that matches ELEMENT needs to be removed. + +Parameters: + ARRAY - Array to modify [Array] + ELEMENT - Element to remove [Any] + +Examples: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + REM(_array,3); + // _array = [1, 2, 4, 8]; + (end) + +Author: + Spooner +------------------------------------------- */ +#define REM(var1,var2) SUB(var1,[var2]) + +/* ------------------------------------------- +Macro: PUSH() + +Description: + Appends a single value onto the end of an ARRAY. Change is made to the ARRAY itself, not creating a new array. + +Parameters: + ARRAY - Array to push element onto [Array] + ELEMENT - Element to push [Any] + +Examples: + (begin example) + _fish = ["blue", "green", "smelly"]; + PUSH(_fish,"monkey-flavoured"); + // _fish => ["blue", "green", "smelly", "monkey-flavoured"] + (end) + +Author: + Spooner +------------------------------------------- */ +#define PUSH(var1,var2) (var1) pushBack (var2) + +/* ------------------------------------------- +Macro: MAP() +Description: + Applies given code to each element of the array, then assigns the + resulting array to the original +Parameters: + ARRAY - Array to be modified + CODE - Code that'll be applied to each element of the array. +Example: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + MAP(_array,_x + 1); + // _array is now [2, 3, 4, 5, 4, 9]; + (end) +Author: + 654wak654 +------------------------------------------- */ +#define MAP(ARR,CODE) ARR = ARR apply {CODE} + +/* ------------------------------------------- +Macro: FILTER() +Description: + Filters an array based on given code, then assigns the resulting array + to the original +Parameters: + ARRAY - Array to be filtered + CODE - Condition to pick elements +Example: + (begin example) + _array = [1, 2, 3, 4, 3, 8]; + FILTER(_array,_x % 2 == 0) + // _array is now [2, 4, 8]; + (end) +Author: + Commy2 +------------------------------------------- */ +#define FILTER(ARR,CODE) ARR = ARR select {CODE} + +/* ------------------------------------------- +Macro: UNIQUE() +Description: + Removes duplicate values in given array +Parameters: + ARRAY - The array to be modified +Example: + (begin example) + _someArray = [4, 4, 5, 5, 5, 2]; + UNIQUE(_someArray); + // _someArray is now [4, 5, 2] + (end) +Author: + Commy2 +------------------------------------------- */ +#define UNIQUE(ARR) ARR = ARR arrayIntersect ARR + +/* ------------------------------------------- +Macro: INTERSECTION() +Description: + Finds unique common elements between two arrays and assigns them + to the first array +Parameters: + ARRAY0 - The array to be modified + ARRAY1 - The array to find intersections with +Example: + (begin example) + _someArray = [1, 2, 3, 4, 5, 5]; + _anotherArray = [4, 5, 6, 7]; + INTERSECTION(_someArray,_anotherArray); + // _someArray is now [4, 5] + (end) +Author: + 654wak654 +------------------------------------------- */ +#define INTERSECTION(ARG0,ARG1) ARG0 = ARG0 arrayIntersect (ARG1) + +/* ------------------------------------------- +Macro: ISNILS() + +Description: + Sets a variable with a value, but only if it is undefined. + +Parameters: + VARIABLE - Variable to set [Any, not nil] + DEFAULT_VALUE - Value to set VARIABLE to if it is undefined [Any, not nil] + +Examples: + (begin example) + // _fish is undefined + ISNILS(_fish,0); + // _fish => 0 + (end) + (begin example) + _fish = 12; + // ...later... + ISNILS(_fish,0); + // _fish => 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define ISNILS(VARIABLE,DEFAULT_VALUE) if (isNil #VARIABLE) then { ##VARIABLE = ##DEFAULT_VALUE } +#define ISNILS2(var1,var2,var3,var4) ISNILS(TRIPLES(var1,var2,var3),var4) +#define ISNILS3(var1,var2,var3) ISNILS(DOUBLES(var1,var2),var3) +#define ISNIL(var1,var2) ISNILS2(PREFIX,COMPONENT,var1,var2) +#define ISNILMAIN(var1,var2) ISNILS3(PREFIX,var1,var2) + +#define CREATELOGICS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"] +#define CREATELOGICLOCALS(var1,var2) ##var1##_##var2## = "LOGIC" createVehicleLocal [0, 0, 0] +#define CREATELOGICGLOBALS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"]; publicVariable QUOTE(DOUBLES(var1,var2)) +#define CREATELOGICGLOBALTESTS(var1,var2) ##var1##_##var2## = ([sideLogic] call CBA_fnc_getSharedGroup) createUnit [QUOTE(DOUBLES(ADDON,logic)), [0, 0, 0], [], 0, "NONE"] + +#define GETVARS(var1,var2,var3) (##var1##_##var2 getVariable #var3) +#define GETVARMAINS(var1,var2) GETVARS(var1,MAINLOGIC,var2) + +#ifndef PATHTO_SYS + #define PATHTO_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3.sqf +#endif +#ifndef PATHTOF_SYS + #define PATHTOF_SYS(var1,var2,var3) \MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 +#endif + +#ifndef PATHTOF2_SYS + #define PATHTOF2_SYS(var1,var2,var3) MAINPREFIX\##var1\SUBPREFIX\##var2\##var3 +#endif + +#define PATHTO_R(var1) PATHTOF2_SYS(PREFIX,COMPONENT_C,var1) +#define PATHTO_T(var1) PATHTOF_SYS(PREFIX,COMPONENT_T,var1) +#define PATHTO_M(var1) PATHTOF_SYS(PREFIX,COMPONENT_M,var1) +#define PATHTO_S(var1) PATHTOF_SYS(PREFIX,COMPONENT_S,var1) +#define PATHTO_C(var1) PATHTOF_SYS(PREFIX,COMPONENT_C,var1) +#define PATHTO_F(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) + +// Already quoted "" +#define QPATHTO_R(var1) QUOTE(PATHTO_R(var1)) +#define QPATHTO_T(var1) QUOTE(PATHTO_T(var1)) +#define QPATHTO_M(var1) QUOTE(PATHTO_M(var1)) +#define QPATHTO_S(var1) QUOTE(PATHTO_S(var1)) +#define QPATHTO_C(var1) QUOTE(PATHTO_C(var1)) +#define QPATHTO_F(var1) QUOTE(PATHTO_F(var1)) + +// This only works for binarized configs after recompiling the pbos +// TODO: Reduce amount of calls / code.. +#define COMPILE_FILE2_CFG_SYS(var1) compile preprocessFileLineNumbers var1 +#define COMPILE_FILE2_SYS(var1) COMPILE_FILE2_CFG_SYS(var1) + +#define COMPILE_FILE_SYS(var1,var2,var3) COMPILE_FILE2_SYS('PATHTO_SYS(var1,var2,var3)') +#define COMPILE_FILE_CFG_SYS(var1,var2,var3) COMPILE_FILE2_CFG_SYS('PATHTO_SYS(var1,var2,var3)') + +#define SETVARS(var1,var2) ##var1##_##var2 setVariable +#define SETVARMAINS(var1) SETVARS(var1,MAINLOGIC) +#define GVARMAINS(var1,var2) ##var1##_##var2## +#define CFGSETTINGSS(var1,var2) configFile >> "CfgSettings" >> #var1 >> #var2 +//#define SETGVARS(var1,var2,var3) ##var1##_##var2##_##var3 = +//#define SETGVARMAINS(var1,var2) ##var1##_##var2 = + +// Compile-Once, JIT: On first use. +// #define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = { ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_fnc_##var3 } else { _this call ##var1##_fnc_##var3 } } +// #define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = { ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var3 } else { _this call ##var1##_##var2##_fnc_##var3 } } +// #define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = { ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)); if (isNil "_this") then { call ##var1##_##var2##_fnc_##var4 } else { _this call ##var1##_##var2##_fnc_##var4 } } + +// Compile-Once, at Macro. As opposed to Compile-Once, on first use. +#define PREPMAIN_SYS(var1,var2,var3) ##var1##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS(var1,var2,var3) ##var1##_##var2##_fnc_##var3 = COMPILE_FILE_SYS(var1,var2,DOUBLES(fnc,var3)) +#define PREP_SYS2(var1,var2,var3,var4) ##var1##_##var2##_fnc_##var4 = COMPILE_FILE_SYS(var1,var3,DOUBLES(fnc,var4)) + +#define LSTR(var1) TRIPLES(ADDON,STR,var1) + +#ifndef DEBUG_SETTINGS + #define DEBUG_SETTINGS [false, true, false] +#endif + +#define MSG_INIT QUOTE(Initializing: ADDON version: VERSION) + +// ************************************* +// User Functions +#define CFGSETTINGS CFGSETTINGSS(PREFIX,COMPONENT) +#define PATHTO(var1) PATHTO_SYS(PREFIX,COMPONENT_F,var1) +#define PATHTOF(var1) PATHTOF_SYS(PREFIX,COMPONENT,var1) +#define PATHTOEF(var1,var2) PATHTOF_SYS(PREFIX,var1,var2) +#define QPATHTOF(var1) QUOTE(PATHTOF(var1)) +#define QPATHTOEF(var1,var2) QUOTE(PATHTOEF(var1,var2)) + +#define COMPILE_FILE(var1) COMPILE_FILE_SYS(PREFIX,COMPONENT_F,var1) +#define COMPILE_FILE_CFG(var1) COMPILE_FILE_CFG_SYS(PREFIX,COMPONENT_F,var1) +#define COMPILE_FILE2(var1) COMPILE_FILE2_SYS('var1') +#define COMPILE_FILE2_CFG(var1) COMPILE_FILE2_CFG_SYS('var1') + + +#define VERSIONING_SYS(var1) class CfgSettings \ +{ \ + class CBA \ + { \ + class Versioning \ + { \ + class var1 \ + { \ + }; \ + }; \ + }; \ +}; + +#define VERSIONING VERSIONING_SYS(PREFIX) + +/* ------------------------------------------- +Macro: GVAR() + Get full variable identifier for a global variable owned by this component. + +Parameters: + VARIABLE - Partial name of global variable owned by this component [Any]. + +Example: + (begin example) + GVAR(frog) = 12; + // In SPON_FrogDancing component, equivalent to SPON_FrogDancing_frog = 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define GVAR(var1) DOUBLES(ADDON,var1) +#define EGVAR(var1,var2) TRIPLES(PREFIX,var1,var2) +#define QGVAR(var1) QUOTE(GVAR(var1)) +#define QEGVAR(var1,var2) QUOTE(EGVAR(var1,var2)) +#define QQGVAR(var1) QUOTE(QGVAR(var1)) +#define QQEGVAR(var1,var2) QUOTE(QEGVAR(var1,var2)) + +/* ------------------------------------------- +Macro: GVARMAIN() + Get full variable identifier for a global variable owned by this addon. + +Parameters: + VARIABLE - Partial name of global variable owned by this addon [Any]. + +Example: + (begin example) + GVARMAIN(frog) = 12; + // In SPON_FrogDancing component, equivalent to SPON_frog = 12 + (end) + +Author: + Sickboy +------------------------------------------- */ +#define GVARMAIN(var1) GVARMAINS(PREFIX,var1) +#define QGVARMAIN(var1) QUOTE(GVARMAIN(var1)) +#define QQGVARMAIN(var1) QUOTE(QGVARMAIN(var1)) +// TODO: What's this? +#define SETTINGS DOUBLES(PREFIX,settings) +#define CREATELOGIC CREATELOGICS(PREFIX,COMPONENT) +#define CREATELOGICGLOBAL CREATELOGICGLOBALS(PREFIX,COMPONENT) +#define CREATELOGICGLOBALTEST CREATELOGICGLOBALTESTS(PREFIX,COMPONENT) +#define CREATELOGICLOCAL CREATELOGICLOCALS(PREFIX,COMPONENT) +#define CREATELOGICMAIN CREATELOGICS(PREFIX,MAINLOGIC) +#define GETVAR(var1) GETVARS(PREFIX,COMPONENT,var1) +#define SETVAR SETVARS(PREFIX,COMPONENT) +#define SETVARMAIN SETVARMAINS(PREFIX) +#define IFCOUNT(var1,var2,var3) if (count ##var1 > ##var2) then { ##var3 = ##var1 select ##var2 }; + +/* ------------------------------------------- +Macro: PREP() + +Description: + Defines a function. + + Full file path: + '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' + + Resulting function name: + 'PREFIX_COMPONENT_' + + The PREP macro should be placed in a script run by a XEH preStart and XEH preInit event. + + The PREP macro allows for CBA function caching, which drastically speeds up load times. + Beware though that function caching is enabled by default and as such to disable it, you need to + #define DISABLE_COMPILE_CACHE above your #include "script_components.hpp" include! + + The function will be defined in ui and mission namespace. It can not be overwritten without + a mission restart. + +Parameters: + FUNCTION NAME - Name of the function, unquoted + +Examples: + (begin example) + PREP(banana); + call FUNC(banana); + (end) + +Author: + dixon13 + ------------------------------------------- */ +//#define PREP(var1) PREP_SYS(PREFIX,COMPONENT_F,var1) + +#ifdef DISABLE_COMPILE_CACHE + #define PREP(var1) TRIPLES(ADDON,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' + #define PREPMAIN(var1) TRIPLES(PREFIX,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))' +#else + #define PREP(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(ADDON,fnc,var1)'] call SLX_XEH_COMPILE_NEW + #define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW +#endif + +/* ------------------------------------------- +Macro: PATHTO_FNC() + +Description: + Defines a function inside CfgFunctions. + + Full file path in addons: + '\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_.sqf' + Define 'RECOMPILE' to enable recompiling. + Define 'SKIP_FUNCTION_HEADER' to skip adding function header. + +Parameters: + FUNCTION NAME - Name of the function, unquoted + +Examples: + (begin example) + // file name: fnc_addPerFrameHandler.sqf + class CfgFunctions { + class CBA { + class Misc { + PATHTO_FNC(addPerFrameHandler); + }; + }; + }; + // -> CBA_fnc_addPerFrameHandler + (end) + +Author: + dixon13, commy2 + ------------------------------------------- */ +#ifdef RECOMPILE + #undef RECOMPILE + #define RECOMPILE recompile = 1 +#else + #define RECOMPILE recompile = 0 +#endif +// Set function header type: -1 - no header; 0 - default header; 1 - system header. +#ifdef SKIP_FUNCTION_HEADER + #define CFGFUNCTION_HEADER headerType = -1 +#else + #define CFGFUNCTION_HEADER headerType = 0 +#endif + +#define PATHTO_FNC(func) class func {\ + file = QPATHTOF(DOUBLES(fnc,func).sqf);\ + CFGFUNCTION_HEADER;\ + RECOMPILE;\ +} + +#define FUNC(var1) TRIPLES(ADDON,fnc,var1) +#define FUNCMAIN(var1) TRIPLES(PREFIX,fnc,var1) +#define FUNC_INNER(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2) +#define EFUNC(var1,var2) FUNC_INNER(var1,var2) +#define QFUNC(var1) QUOTE(FUNC(var1)) +#define QFUNCMAIN(var1) QUOTE(FUNCMAIN(var1)) +#define QFUNC_INNER(var1,var2) QUOTE(FUNC_INNER(var1,var2)) +#define QEFUNC(var1,var2) QUOTE(EFUNC(var1,var2)) +#define QQFUNC(var1) QUOTE(QFUNC(var1)) +#define QQFUNCMAIN(var1) QUOTE(QFUNCMAIN(var1)) +#define QQFUNC_INNER(var1,var2) QUOTE(QFUNC_INNER(var1,var2)) +#define QQEFUNC(var1,var2) QUOTE(QEFUNC(var1,var2)) + +#ifndef PRELOAD_ADDONS + #define PRELOAD_ADDONS class CfgAddons \ +{ \ + class PreloadAddons \ + { \ + class ADDON \ + { \ + list[]={ QUOTE(ADDON) }; \ + }; \ + }; \ +} +#endif + +/* ------------------------------------------- +Macros: ARG_#() + Select from list of array arguments + +Parameters: + VARIABLE(1-8) - elements for the list + +Author: + Rommel +------------------------------------------- */ +#define ARG_1(A,B) ((A) select (B)) +#define ARG_2(A,B,C) (ARG_1(ARG_1(A,B),C)) +#define ARG_3(A,B,C,D) (ARG_1(ARG_2(A,B,C),D)) +#define ARG_4(A,B,C,D,E) (ARG_1(ARG_3(A,B,C,D),E)) +#define ARG_5(A,B,C,D,E,F) (ARG_1(ARG_4(A,B,C,D,E),F)) +#define ARG_6(A,B,C,D,E,F,G) (ARG_1(ARG_5(A,B,C,D,E,F),G)) +#define ARG_7(A,B,C,D,E,F,G,H) (ARG_1(ARG_6(A,B,C,D,E,E,F,G),H)) +#define ARG_8(A,B,C,D,E,F,G,H,I) (ARG_1(ARG_7(A,B,C,D,E,E,F,G,H),I)) + +/* ------------------------------------------- +Macros: ARR_#() + Create list from arguments. Useful for working around , in macro parameters. + 1-8 arguments possible. + +Parameters: + VARIABLE(1-8) - elements for the list + +Author: + Nou +------------------------------------------- */ +#define ARR_1(ARG1) ARG1 +#define ARR_2(ARG1,ARG2) ARG1, ARG2 +#define ARR_3(ARG1,ARG2,ARG3) ARG1, ARG2, ARG3 +#define ARR_4(ARG1,ARG2,ARG3,ARG4) ARG1, ARG2, ARG3, ARG4 +#define ARR_5(ARG1,ARG2,ARG3,ARG4,ARG5) ARG1, ARG2, ARG3, ARG4, ARG5 +#define ARR_6(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 +#define ARR_7(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7 +#define ARR_8(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8 + +/* ------------------------------------------- +Macros: FORMAT_#(STR, ARG1) + Format - Useful for working around , in macro parameters. + 1-8 arguments possible. + +Parameters: + STRING - string used by format + VARIABLE(1-8) - elements for usage in format + +Author: + Nou & Sickboy +------------------------------------------- */ +#define FORMAT_1(STR,ARG1) format[STR, ARG1] +#define FORMAT_2(STR,ARG1,ARG2) format[STR, ARG1, ARG2] +#define FORMAT_3(STR,ARG1,ARG2,ARG3) format[STR, ARG1, ARG2, ARG3] +#define FORMAT_4(STR,ARG1,ARG2,ARG3,ARG4) format[STR, ARG1, ARG2, ARG3, ARG4] +#define FORMAT_5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5] +#define FORMAT_6(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6] +#define FORMAT_7(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7] +#define FORMAT_8(STR,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8) format[STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8] + +// CONTROL(46) 12 +#define DISPLAY(A) (findDisplay A) +#define CONTROL(A) DISPLAY(A) displayCtrl + +/* ------------------------------------------- +Macros: IS_x() + Checking the data types of variables. + + IS_ARRAY() - Array + IS_BOOL() - Boolean + IS_BOOLEAN() - UI display handle(synonym for ) + IS_CODE() - Code block (i.e a compiled function) + IS_CONFIG() - Configuration + IS_CONTROL() - UI control handle. + IS_DISPLAY() - UI display handle. + IS_FUNCTION() - A compiled function (synonym for ) + IS_GROUP() - Group. + IS_INTEGER() - Is a number a whole number? + IS_LOCATION() - World location. + IS_NUMBER() - A floating point number (synonym for ) + IS_OBJECT() - World object. + IS_SCALAR() - Floating point number. + IS_SCRIPT() - A script handle (as returned by execVM and spawn commands). + IS_SIDE() - Game side. + IS_STRING() - World object. + IS_TEXT() - Structured text. + +Parameters: + VARIABLE - Variable to check if it is of a particular type [Any, not nil] + +Author: + Spooner +------------------------------------------- */ +#define IS_META_SYS(VAR,TYPE) (if (isNil {VAR}) then {false} else {(VAR) isEqualType TYPE}) +#define IS_ARRAY(VAR) IS_META_SYS(VAR,[]) +#define IS_BOOL(VAR) IS_META_SYS(VAR,false) +#define IS_CODE(VAR) IS_META_SYS(VAR,{}) +#define IS_CONFIG(VAR) IS_META_SYS(VAR,configNull) +#define IS_CONTROL(VAR) IS_META_SYS(VAR,controlNull) +#define IS_DISPLAY(VAR) IS_META_SYS(VAR,displayNull) +#define IS_GROUP(VAR) IS_META_SYS(VAR,grpNull) +#define IS_OBJECT(VAR) IS_META_SYS(VAR,objNull) +#define IS_SCALAR(VAR) IS_META_SYS(VAR,0) +#define IS_SCRIPT(VAR) IS_META_SYS(VAR,scriptNull) +#define IS_SIDE(VAR) IS_META_SYS(VAR,west) +#define IS_STRING(VAR) IS_META_SYS(VAR,"STRING") +#define IS_TEXT(VAR) IS_META_SYS(VAR,text "") +#define IS_LOCATION(VAR) IS_META_SYS(VAR,locationNull) + +#define IS_BOOLEAN(VAR) IS_BOOL(VAR) +#define IS_FUNCTION(VAR) IS_CODE(VAR) +#define IS_INTEGER(VAR) (if (IS_SCALAR(VAR)) then {floor (VAR) == (VAR)} else {false}) +#define IS_NUMBER(VAR) IS_SCALAR(VAR) + +#define FLOAT_TO_STRING(num) (if (_this == 0) then {"0"} else {str parseNumber (str (_this % _this) + str floor abs _this) + "." + (str (abs _this - floor abs _this) select [2]) + "0"}) + +/* ------------------------------------------- +Macro: SCRIPT() + Sets name of script (relies on PREFIX and COMPONENT values being #defined). + Define 'SKIP_SCRIPT_NAME' to skip adding scriptName. + +Parameters: + NAME - Name of script [Indentifier] + +Example: + (begin example) + SCRIPT(eradicateMuppets); + (end) + +Author: + Spooner +------------------------------------------- */ +#ifndef SKIP_SCRIPT_NAME + #define SCRIPT(NAME) scriptName 'PREFIX\COMPONENT\NAME' +#else + #define SCRIPT(NAME) /* nope */ +#endif + +/* ------------------------------------------- +Macros: EXPLODE_n() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Splitting an ARRAY into a number of variables (A, B, C, etc). + + Note that this NOT does make the created variables private. + _PVT variants do. + + EXPLODE_1(ARRAY,A,B) - Split a 1-element array into separate variable. + EXPLODE_2(ARRAY,A,B) - Split a 2-element array into separate variables. + EXPLODE_3(ARRAY,A,B,C) - Split a 3-element array into separate variables. + EXPLODE_4(ARRAY,A,B,C,D) - Split a 4-element array into separate variables. + EXPLODE_5(ARRAY,A,B,C,D,E) - Split a 5-element array into separate variables. + EXPLODE_6(ARRAY,A,B,C,D,E,F) - Split a 6-element array into separate variables. + EXPLODE_7(ARRAY,A,B,C,D,E,F,G) - Split a 7-element array into separate variables. + EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) - Split a 8-element array into separate variables. + EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) - Split a 9-element array into separate variables. + +Parameters: + ARRAY - Array to read from [Array] + A..H - Names of variables to set from array [Identifier] + +Example: + (begin example) + _array = ["fred", 156.8, 120.9]; + EXPLODE_3(_array,_name,_height,_weight); + (end) + +Author: + Spooner +------------------------------------------- */ +#define EXPLODE_1_SYS(ARRAY,A) A = ARRAY param [0] +#define EXPLODE_1(ARRAY,A) EXPLODE_1_SYS(ARRAY,A); TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) +#define EXPLODE_1_PVT(ARRAY,A) ARRAY params [#A]; TRACE_1("EXPLODE_1, " + QUOTE(ARRAY),A) + +#define EXPLODE_2_SYS(ARRAY,A,B) EXPLODE_1_SYS(ARRAY,A); B = ARRAY param [1] +#define EXPLODE_2(ARRAY,A,B) EXPLODE_2_SYS(ARRAY,A,B); TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) +#define EXPLODE_2_PVT(ARRAY,A,B) ARRAY params [#A,#B]; TRACE_2("EXPLODE_2, " + QUOTE(ARRAY),A,B) + +#define EXPLODE_3_SYS(ARRAY,A,B,C) EXPLODE_2_SYS(ARRAY,A,B); C = ARRAY param [2] +#define EXPLODE_3(ARRAY,A,B,C) EXPLODE_3_SYS(ARRAY,A,B,C); TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) +#define EXPLODE_3_PVT(ARRAY,A,B,C) ARRAY params [#A,#B,#C]; TRACE_3("EXPLODE_3, " + QUOTE(ARRAY),A,B,C) + +#define EXPLODE_4_SYS(ARRAY,A,B,C,D) EXPLODE_3_SYS(ARRAY,A,B,C); D = ARRAY param [3] +#define EXPLODE_4(ARRAY,A,B,C,D) EXPLODE_4_SYS(ARRAY,A,B,C,D); TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) +#define EXPLODE_4_PVT(ARRAY,A,B,C,D) ARRAY params [#A,#B,#C,#D]; TRACE_4("EXPLODE_4, " + QUOTE(ARRAY),A,B,C,D) + +#define EXPLODE_5_SYS(ARRAY,A,B,C,D,E) EXPLODE_4_SYS(ARRAY,A,B,C,D); E = ARRAY param [4] +#define EXPLODE_5(ARRAY,A,B,C,D,E) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) +#define EXPLODE_5_PVT(ARRAY,A,B,C,D,E) ARRAY params [#A,#B,#C,#D,#E]; TRACE_5("EXPLODE_5, " + QUOTE(ARRAY),A,B,C,D,E) + +#define EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F) EXPLODE_5_SYS(ARRAY,A,B,C,D,E); F = ARRAY param [5] +#define EXPLODE_6(ARRAY,A,B,C,D,E,F) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) +#define EXPLODE_6_PVT(ARRAY,A,B,C,D,E,F) ARRAY params [#A,#B,#C,#D,#E,#F]; TRACE_6("EXPLODE_6, " + QUOTE(ARRAY),A,B,C,D,E,F) + +#define EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G) EXPLODE_6_SYS(ARRAY,A,B,C,D,E,F); G = ARRAY param [6] +#define EXPLODE_7(ARRAY,A,B,C,D,E,F,G) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) +#define EXPLODE_7_PVT(ARRAY,A,B,C,D,E,F,G) ARRAY params [#A,#B,#C,#D,#E,#F,#G]; TRACE_7("EXPLODE_7, " + QUOTE(ARRAY),A,B,C,D,E,F,G) + +#define EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_7_SYS(ARRAY,A,B,C,D,E,F,G); H = ARRAY param [7] +#define EXPLODE_8(ARRAY,A,B,C,D,E,F,G,H) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) +#define EXPLODE_8_PVT(ARRAY,A,B,C,D,E,F,G,H) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H]; TRACE_8("EXPLODE_8, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H) + +#define EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_8_SYS(ARRAY,A,B,C,D,E,F,G,H); I = ARRAY param [8] +#define EXPLODE_9(ARRAY,A,B,C,D,E,F,G,H,I) EXPLODE_9_SYS(ARRAY,A,B,C,D,E,F,G,H,I); TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) +#define EXPLODE_9_PVT(ARRAY,A,B,C,D,E,F,G,H,I) ARRAY params [#A,#B,#C,#D,#E,#F,#G,#H,#I]; TRACE_9("EXPLODE_9, " + QUOTE(ARRAY),A,B,C,D,E,F,G,H,I) + +/* ------------------------------------------- +Macro: xSTRING() + Get full string identifier from a stringtable owned by this component. + +Parameters: + VARIABLE - Partial name of global variable owned by this component [Any]. + +Example: + ADDON is CBA_Balls. + (begin example) + // Localized String (localize command must still be used with it) + LSTRING(Example); // STR_CBA_Balls_Example; + // Config String (note the $) + CSTRING(Example); // $STR_CBA_Balls_Example; + (end) + +Author: + Jonpas +------------------------------------------- */ +#ifndef STRING_MACROS_GUARD +#define STRING_MACROS_GUARD + #define LSTRING(var1) QUOTE(TRIPLES(STR,ADDON,var1)) + #define ELSTRING(var1,var2) QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) + #define CSTRING(var1) QUOTE(TRIPLES($STR,ADDON,var1)) + #define ECSTRING(var1,var2) QUOTE(TRIPLES($STR,DOUBLES(PREFIX,var1),var2)) + + #define LLSTRING(var1) localize QUOTE(TRIPLES(STR,ADDON,var1)) + #define LELSTRING(var1,var2) localize QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2)) +#endif + + +/* ------------------------------------------- +Group: Managing Function Parameters +------------------------------------------- */ + +/* ------------------------------------------- +Macros: PARAMS_n() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Setting variables based on parameters passed to a function. + + Each parameter is defines as private and set to the appropriate value from _this. + + PARAMS_1(A) - Get 1 parameter from the _this array (or _this if it's not an array). + PARAMS_2(A,B) - Get 2 parameters from the _this array. + PARAMS_3(A,B,C) - Get 3 parameters from the _this array. + PARAMS_4(A,B,C,D) - Get 4 parameters from the _this array. + PARAMS_5(A,B,C,D,E) - Get 5 parameters from the _this array. + PARAMS_6(A,B,C,D,E,F) - Get 6 parameters from the _this array. + PARAMS_7(A,B,C,D,E,F,G) - Get 7 parameters from the _this array. + PARAMS_8(A,B,C,D,E,F,G,H) - Get 8 parameters from the _this array. + +Parameters: + A..H - Name of variable to read from _this [Identifier] + +Example: + A function called like this: + (begin example) + [_name,_address,_telephone] call recordPersonalDetails; + (end) + expects 3 parameters and those variables could be initialised at the start of the function definition with: + (begin example) + recordPersonalDetails = { + PARAMS_3(_name,_address,_telephone); + // Rest of function follows... + }; + (end) + +Author: + Spooner +------------------------------------------- */ +#define PARAMS_1(A) EXPLODE_1_PVT(_this,A) +#define PARAMS_2(A,B) EXPLODE_2_PVT(_this,A,B) +#define PARAMS_3(A,B,C) EXPLODE_3_PVT(_this,A,B,C) +#define PARAMS_4(A,B,C,D) EXPLODE_4_PVT(_this,A,B,C,D) +#define PARAMS_5(A,B,C,D,E) EXPLODE_5_PVT(_this,A,B,C,D,E) +#define PARAMS_6(A,B,C,D,E,F) EXPLODE_6_PVT(_this,A,B,C,D,E,F) +#define PARAMS_7(A,B,C,D,E,F,G) EXPLODE_7_PVT(_this,A,B,C,D,E,F,G) +#define PARAMS_8(A,B,C,D,E,F,G,H) EXPLODE_8_PVT(_this,A,B,C,D,E,F,G,H) +#define PARAMS_9(A,B,C,D,E,F,G,H,I) EXPLODE_9_PVT(_this,A,B,C,D,E,F,G,H,I) + +/* ------------------------------------------- +Macro: DEFAULT_PARAM() + DEPRECATED - Use param/params commands added in Arma 3 1.48 + + Getting a default function parameter. This may be used together with to have a mix of required and + optional parameters. + +Parameters: + INDEX - Index of parameter in _this [Integer, 0+] + NAME - Name of the variable to set [Identifier] + DEF_VALUE - Default value to use in case the array is too short or the value at INDEX is nil [Any] + +Example: + A function called with optional parameters: + (begin example) + [_name] call myFunction; + [_name, _numberOfLegs] call myFunction; + [_name, _numberOfLegs, _hasAHead] call myFunction; + (end) + 1 required parameter and 2 optional parameters. Those variables could be initialised at the start of the function + definition with: + (begin example) + myFunction = { + PARAMS_1(_name); + DEFAULT_PARAM(1,_numberOfLegs,2); + DEFAULT_PARAM(2,_hasAHead,true); + // Rest of function follows... + }; + (end) + +Author: + Spooner +------------------------------------------- */ +#define DEFAULT_PARAM(INDEX,NAME,DEF_VALUE) \ + private [#NAME,"_this"]; \ + ISNILS(_this,[]); \ + NAME = _this param [INDEX, DEF_VALUE]; \ + TRACE_3("DEFAULT_PARAM",INDEX,NAME,DEF_VALUE) + +/* ------------------------------------------- +Macro: KEY_PARAM() + Get value from key in _this list, return default when key is not included in list. + +Parameters: + KEY - Key name [String] + NAME - Name of the variable to set [Identifier] + DEF_VALUE - Default value to use in case key not found [ANY] + +Example: + + +Author: + Muzzleflash +------------------------------------------- */ +#define KEY_PARAM(KEY,NAME,DEF_VALUE) \ + private #NAME; \ + NAME = [toLower KEY, toUpper KEY, DEF_VALUE, RETNIL(_this)] call CBA_fnc_getArg; \ + TRACE_3("KEY_PARAM",KEY,NAME,DEF_VALUE) + +/* ------------------------------------------- +Group: Assertions +------------------------------------------- */ + +#define ASSERTION_ERROR(MESSAGE) ERROR_WITH_TITLE("Assertion failed!",MESSAGE) + +/* ------------------------------------------- +Macro: ASSERT_TRUE() + Asserts that a CONDITION is true. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as true [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is false [String] + +Example: + (begin example) + ASSERT_TRUE(_frogIsDead,"The frog is alive"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_TRUE(CONDITION,MESSAGE) \ + if (not (CONDITION)) then \ + { \ + ASSERTION_ERROR('Assertion (CONDITION) failed!\n\n' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: ASSERT_FALSE() + Asserts that a CONDITION is false. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as false [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is true [String] + +Example: + (begin example) + ASSERT_FALSE(_frogIsDead,"The frog died"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_FALSE(CONDITION,MESSAGE) \ + if (CONDITION) then \ + { \ + ASSERTION_ERROR('Assertion (not (CONDITION)) failed!\n\n' + (MESSAGE)) \ + } + +/* ------------------------------------------- +Macro: ASSERT_OP() + Asserts that (A OPERATOR B) is true. When an assertion fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display if (A OPERATOR B) is false. [String] + +Example: + (begin example) + ASSERT_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_OP(A,OPERATOR,B,MESSAGE) \ + if (not ((A) OPERATOR (B))) then \ + { \ + ASSERTION_ERROR('Assertion (A OPERATOR B) failed!\n' + 'A: ' + (str (A)) + '\n' + 'B: ' + (str (B)) + "\n\n" + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: ASSERT_DEFINED() + Asserts that a VARIABLE is defined. When an assertion fails, an error is raised with the given MESSAGE.. + +Parameters: + VARIABLE - Variable to test if defined [String or Function]. + MESSAGE - Message to display if variable is undefined [String]. + +Examples: + (begin example) + ASSERT_DEFINED("_anUndefinedVar","Too few fish!"); + ASSERT_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); + (end) + +Author: + Spooner +------------------------------------------- */ +#define ASSERT_DEFINED(VARIABLE,MESSAGE) \ + if (isNil VARIABLE) then \ + { \ + ASSERTION_ERROR('Assertion (VARIABLE is defined) failed!\n\n' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Group: Unit tests +------------------------------------------- */ +#define TEST_SUCCESS(MESSAGE) MESSAGE_WITH_TITLE("Test OK",MESSAGE) +#define TEST_FAIL(MESSAGE) ERROR_WITH_TITLE("Test FAIL",MESSAGE) + +/* ------------------------------------------- +Macro: TEST_TRUE() + Tests that a CONDITION is true. + If the condition is not true, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to assert as true [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is false [String] + +Example: + (begin example) + TEST_TRUE(_frogIsDead,"The frog is alive"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_TRUE(CONDITION, MESSAGE) \ + if (CONDITION) then \ + { \ + TEST_SUCCESS('(CONDITION)'); \ + } \ + else \ + { \ + TEST_FAIL('(CONDITION) ' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: TEST_FALSE() + Tests that a CONDITION is false. + If the condition is not false, an error is raised with the given MESSAGE. + +Parameters: + CONDITION - Condition to test as false [Boolean] + MESSSAGE - Message to display if (A OPERATOR B) is true [String] + +Example: + (begin example) + TEST_FALSE(_frogIsDead,"The frog died"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_FALSE(CONDITION, MESSAGE) \ + if (not (CONDITION)) then \ + { \ + TEST_SUCCESS('(not (CONDITION))'); \ + } \ + else \ + { \ + TEST_FAIL('(not (CONDITION)) ' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Macro: TEST_OP() + Tests that (A OPERATOR B) is true. + If the test fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display if (A OPERATOR B) is false. [String] + +Example: + (begin example) + TEST_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_OP(A,OPERATOR,B,MESSAGE) \ + if ((A) OPERATOR (B)) then \ + { \ + TEST_SUCCESS('(A OPERATOR B)') \ + } \ + else \ + { \ + TEST_FAIL('(A OPERATOR B)') \ + }; + +/* ------------------------------------------- +Macro: TEST_DEFINED_AND_OP() + Tests that A and B are defined and (A OPERATOR B) is true. + If the test fails, an error is raised with the given MESSAGE. + +Parameters: + A - First value [Any] + OPERATOR - Binary operator to use [Operator] + B - Second value [Any] + MESSSAGE - Message to display [String] + +Example: + (begin example) + TEST_OP(_fish,>,5,"Too few fish!"); + (end) + +Author: + Killswitch, PabstMirror +------------------------------------------- */ +#define TEST_DEFINED_AND_OP(A,OPERATOR,B,MESSAGE) \ + if (isNil #A) then { \ + TEST_FAIL('(A is not defined) ' + (MESSAGE)); \ + } else { \ + if (isNil #B) then { \ + TEST_FAIL('(B is not defined) ' + (MESSAGE)); \ + } else { \ + if ((A) OPERATOR (B)) then { \ + TEST_SUCCESS('(A OPERATOR B) ' + (MESSAGE)) \ + } else { \ + TEST_FAIL('(A OPERATOR B) ' + (MESSAGE)) \ + }; }; }; + + +/* ------------------------------------------- +Macro: TEST_DEFINED() + Tests that a VARIABLE is defined. + +Parameters: + VARIABLE - Variable to test if defined [String or Function]. + MESSAGE - Message to display if variable is undefined [String]. + +Examples: + (begin example) + TEST_DEFINED("_anUndefinedVar","Too few fish!"); + TEST_DEFINED({ obj getVariable "anUndefinedVar" },"Too many fish!"); + (end) + +Author: + Killswitch +------------------------------------------- */ +#define TEST_DEFINED(VARIABLE,MESSAGE) \ + if (not isNil VARIABLE) then \ + { \ + TEST_SUCCESS('(' + VARIABLE + ' is defined)'); \ + } \ + else \ + { \ + TEST_FAIL('(' + VARIABLE + ' is not defined)' + (MESSAGE)); \ + } + +/* ------------------------------------------- +Group: Managing Deprecation +------------------------------------------- */ + +/* ------------------------------------------- +Macro: DEPRECATE_SYS() + Allow deprecation of a function that has been renamed. + + Replaces an old OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION + (PREFIX_ prepended) with the intention that the old function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, but runs the new function. + +Parameters: + OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] + NEW_FUNCTION - Full name of new function [Function] + +Example: + (begin example) + // After renaming CBA_fnc_frog as CBA_fnc_fish + DEPRECATE_SYS(CBA_fnc_frog,CBA_fnc_fish); + (end) + +Author: + Sickboy +------------------------------------------- */ +#define DEPRECATE_SYS(OLD_FUNCTION,NEW_FUNCTION) \ + OLD_FUNCTION = { \ + WARNING('Deprecated function used: OLD_FUNCTION (new: NEW_FUNCTION) in ADDON'); \ + if (isNil "_this") then { call NEW_FUNCTION } else { _this call NEW_FUNCTION }; \ + } + +/* ------------------------------------------- +Macro: DEPRECATE() + Allow deprecation of a function, in the current component, that has been renamed. + + Replaces an OLD_FUNCTION (which will have PREFIX_ prepended) with a NEW_FUNCTION + (PREFIX_ prepended) with the intention that the old function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, but runs the new function. + +Parameters: + OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] + NEW_FUNCTION - Name of new function, assuming PREFIX [Function] + +Example: + (begin example) + // After renaming CBA_fnc_frog as CBA_fnc_fish + DEPRECATE(fnc_frog,fnc_fish); + (end) + +Author: + Sickboy +------------------------------------------- */ +#define DEPRECATE(OLD_FUNCTION,NEW_FUNCTION) \ + DEPRECATE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),DOUBLES(PREFIX,NEW_FUNCTION)) + +/* ------------------------------------------- +Macro: OBSOLETE_SYS() + Replace a function that has become obsolete. + + Replace an obsolete OLD_FUNCTION with a simple COMMAND_FUNCTION, with the intention that anyone + using the function should replace it with the simple command, since the function will be disabled in the future. + + Shows a warning in RPT each time the deprecated function is used, and runs the command function. + +Parameters: + OLD_FUNCTION - Full name of old function [Identifier for function that does not exist any more] + COMMAND_CODE - Code to replace the old function [Function] + +Example: + (begin example) + // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: + OBSOLETE_SYS(CBA_fMyWeapon,{ currentWeapon player }); + (end) + +Author: + Spooner +------------------------------------------- */ +#define OBSOLETE_SYS(OLD_FUNCTION,COMMAND_CODE) \ + OLD_FUNCTION = { \ + WARNING('Obsolete function used: (use: OLD_FUNCTION) in ADDON'); \ + if (isNil "_this") then { call COMMAND_CODE } else { _this call COMMAND_CODE }; \ + } + +/* ------------------------------------------- +Macro: OBSOLETE() + Replace a function, in the current component, that has become obsolete. + + Replace an obsolete OLD_FUNCTION (which will have PREFIX_ prepended) with a simple + COMMAND_CODE, with the intention that anyone using the function should replace it with the simple + command. + + Shows a warning in RPT each time the deprecated function is used. + +Parameters: + OLD_FUNCTION - Name of old function, assuming PREFIX [Identifier for function that does not exist any more] + COMMAND_CODE - Code to replace the old function [Function] + +Example: + (begin example) + // In Arma2, currentWeapon command made the CBA_fMyWeapon function obsolete: + OBSOLETE(fMyWeapon,{ currentWeapon player }); + (end) + +Author: + Spooner +------------------------------------------- */ +#define OBSOLETE(OLD_FUNCTION,COMMAND_CODE) \ + OBSOLETE_SYS(DOUBLES(PREFIX,OLD_FUNCTION),COMMAND_CODE) + +#define BWC_CONFIG(NAME) class NAME { \ + units[] = {}; \ + weapons[] = {}; \ + requiredVersion = REQUIRED_VERSION; \ + requiredAddons[] = {}; \ + version = VERSION; \ +} + +// XEH Specific +#define XEH_CLASS CBA_Extended_EventHandlers +#define XEH_CLASS_BASE DOUBLES(XEH_CLASS,base) +#define XEH_DISABLED class EventHandlers { class XEH_CLASS {}; }; SLX_XEH_DISABLED = 1 +#define XEH_ENABLED class EventHandlers { class XEH_CLASS { EXTENDED_EVENTHANDLERS }; }; SLX_XEH_DISABLED = 0 + +// TODO: These are actually outdated; _Once ? +#define XEH_PRE_INIT QUOTE(call COMPILE_FILE(XEH_PreInit_Once)) +#define XEH_PRE_CINIT QUOTE(call COMPILE_FILE(XEH_PreClientInit_Once)) +#define XEH_PRE_SINIT QUOTE(call COMPILE_FILE(XEH_PreServerInit_Once)) + +#define XEH_POST_INIT QUOTE(call COMPILE_FILE(XEH_PostInit_Once)) +#define XEH_POST_CINIT QUOTE(call COMPILE_FILE(XEH_PostClientInit_Once)) +#define XEH_POST_SINIT QUOTE(call COMPILE_FILE(XEH_PostServerInit_Once)) + +/* ------------------------------------------- +Macro: IS_ADMIN + Check if the local machine is an admin in the multiplayer environment. + + Reports 'true' for logged and voted in admins. + +Parameters: + None + +Example: + (begin example) + // print "true" if player is admin + systemChat str IS_ADMIN; + (end) + +Author: + commy2 +------------------------------------------- */ +#define IS_ADMIN_SYS(x) x##kick +#define IS_ADMIN serverCommandAvailable 'IS_ADMIN_SYS(#)' + +/* ------------------------------------------- +Macro: IS_ADMIN_LOGGED + Check if the local machine is a logged in admin in the multiplayer environment. + + Reports 'false' if the player was voted to be the admin. + +Parameters: + None + +Example: + (begin example) + // print "true" if player is admin and entered in the server password + systemChat str IS_ADMIN_LOGGED; + (end) + +Author: + commy2 +------------------------------------------- */ +#define IS_ADMIN_LOGGED_SYS(x) x##shutdown +#define IS_ADMIN_LOGGED serverCommandAvailable 'IS_ADMIN_LOGGED_SYS(#)' + +/* ------------------------------------------- +Macro: FILE_EXISTS + Check if a file exists on machines with interface + + Reports "false" if the file does not exist and throws an error in RPT. + +Parameters: + FILE - Path to the file + +Example: + (begin example) + // print "true" if file exists + systemChat str FILE_EXISTS("\A3\ui_f\data\igui\cfg\cursors\weapon_ca.paa"); + (end) + +Author: + commy2 +------------------------------------------- */ +#define FILE_EXISTS(FILE) (call {\ + private _return = false;\ + isNil {\ + private _control = (uiNamespace getVariable ["RscDisplayMain", displayNull]) ctrlCreate ["RscHTML", -1];\ + if (isNull _control) then {\ + _return = loadFile (FILE) != "";\ + } else {\ + _control htmlLoad (FILE);\ + _return = ctrlHTMLLoaded _control;\ + ctrlDelete _control;\ + };\ + };\ + _return\ +}) diff --git a/mod.cpp b/mod.cpp new file mode 100644 index 00000000..3112bf5d --- /dev/null +++ b/mod.cpp @@ -0,0 +1,6 @@ +name = "grad_civs"; +dir = "@grad_civs"; +author = "Fusselwurm"; +actionName = "Website"; +action = "https://github.com/gruppe-adler/grad-civs"; +description = "Ambient Civilians"; diff --git a/package.json b/package.json deleted file mode 100644 index a8796f00..00000000 --- a/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "grad-civs", - "description": "ambient civilians", - "version": "2.1.0", - "contributors": [ - { - "name": "nomisum" - }, - { - "name": "McDiod" - }, - { - "name": "Fusselwurm " - } - ], - - "dependencies": { - - } -}