diff --git a/docs/wiki/development/coding-guidelines.md b/docs/wiki/development/coding-guidelines.md index e3cbefc410..c71e2d49bf 100644 --- a/docs/wiki/development/coding-guidelines.md +++ b/docs/wiki/development/coding-guidelines.md @@ -181,7 +181,7 @@ This ensures every function starts off in an uniform way and enforces function d ### 3.2 Headers Every function should have a header of the following format appear before any code: -```js +```cpp /* * Author: [Name of Author(s)] * [Description] @@ -260,7 +260,7 @@ class Something : Or { When using `if`/`else`, it is encouraged to put `else` on the same line as the closing brace to save space: -```js +```cpp if (alive player) then { player setDamage 1; } else { @@ -284,7 +284,7 @@ Every new scope should be on a new indent. This will make the code easier to und Good: -```js +```cpp call { call { if (/* condition */) then { @@ -296,7 +296,7 @@ call { Bad: -```js +```cpp call { call { if (/* condition */) then { @@ -311,7 +311,7 @@ Inline comments should use `//`. Usage of `/* */` is allowed for larger comment Example: -```js +```cpp //// Comment // < incorrect // Comment // < correct /* Comment */ // < correct @@ -324,7 +324,7 @@ Comments within the code shall be used when they are describing a complex and cr Good: -```js +```cpp // find the object with the most blood loss _highestObj = objNull; _highestLoss = -1; @@ -338,28 +338,28 @@ _highestLoss = -1; Good: -```js +```cpp // Check if the unit is an engineer (_obj getvariable [QGVAR(engineerSkill), 0] >= 1); ``` Bad: -```js +```cpp // Get the engineer skill and check if it is above 1 (_obj getvariable [QGVAR(engineerSkill), 0] >= 1); ``` Bad: -```js +```cpp // Get the variable myValue from the object _myValue = _obj getvariable [QGVAR(myValue), 0]; ``` Bad: -```js +```cpp // Loop through all units to increase the myvalue variable { _x setvariable [QGVAR(myValue), (_x getvariable [QGVAR(myValue), 0]) + 1]; @@ -369,19 +369,19 @@ Bad: ### 5.5 Brackets around code When making use of brackets `( )`, use as few as possible, unless doing so decreases readability of the code. Avoid statements such as: -```js +```cpp if (!(_value)) then { }; ``` However the following is allowed: -```js +```cpp _value = (_array select 0) select 1; ``` Any conditions in statements shall always be wrapped around brackets. -```js +```cpp if (!_value) then {}; if (_value) then {}; ``` @@ -402,14 +402,14 @@ When using array notation `[]`, always use a space between elements to improve c Good: -```js +```cpp params ["_unit", "_vehicle"]; private _pos = [0, 0, 0]; ``` Bad: -```js +```cpp params ["_unit","_vehicle"]; private _pos = [0,0,0]; ``` @@ -436,19 +436,19 @@ All private variables shall make use of the `private` keyword on initialization. Good: -```js +```cpp private _myVariable = "hello world"; ``` Good: -```js +```cpp _myArray params ["_elementOne", "_elementTwo"]; ``` Bad: -```js +```cpp _elementOne = _myArray select 0; _elementTwo = _myArray select 1; ``` @@ -461,7 +461,7 @@ Declarations should be at the smallest feasible scope. Good: -```js +```cpp if (call FUNC(myCondition)) then { private _areAllAboveTen = true; // <- smallest feasable scope @@ -479,7 +479,7 @@ if (call FUNC(myCondition)) then { Bad: -```js +```cpp private _areAllAboveTen = true; // <- this is bad, because it can be initialized in the if statement if (call FUNC(myCondition)) then { { @@ -499,7 +499,7 @@ Private variables will not be introduced until they can be initialized with mean Good: -```js +```cpp private _myVariable = 0; // good because the value will be used { _x params ["_value", "_amount"]; @@ -511,7 +511,7 @@ private _myVariable = 0; // good because the value will be used Bad: -```js +```cpp private _myvariable = 0; // Bad because it is initialized with a zero, but this value does not mean anything if (_condition) then { _myVariable = 1; @@ -522,7 +522,7 @@ if (_condition) then { Good: -```js +```cpp private _myvariable = [1, 2] select _condition; ``` @@ -537,20 +537,20 @@ When using `getVariable`, there shall either be a default value given in the sta Bad: -```js +```cpp _return = obj getvariable "varName"; if (isnil "_return") then {_return = 0 }; ``` Good: -```js +```cpp _return = obj getvariable ["varName", 0]; ``` Good: -```js +```cpp _return = obj getvariable "varName"; if (isnil "_return") exitwith {}; ``` @@ -560,27 +560,27 @@ Global variables should not be used to pass along information from one function Bad: -```js +```cpp fnc_example = { hint GVAR(myVariable); }; ``` -```js +```cpp GVAR(myVariable) = "hello my variable"; call fnc_example; ``` Good: -```js +```cpp fnc_example = { params ["_content"]; hint _content; }; ``` -```js +```cpp ["hello my variable"] call fnc_example; ``` @@ -625,7 +625,7 @@ More information on the [CBA Events System](https://github.com/CBATeam/CBA_A3/wi **Warning about BIS event handlers:** BIS's event handlers (`addEventHandler`, `addMissionEventHandler`) are slow when passing a large code variable. Use a short code block that calls the function you want. -```js +```cpp player addEventHandler ["Fired", FUNC(handleFired)]; // bad player addEventHandler ["Fired", {call FUNC(handleFired)}]; // good ``` @@ -638,7 +638,7 @@ Hashes are a variable type that store key value pairs. They are not implemented The following example is a simple usage using our macros which will be explained further below. -```js +```cpp _hash = HASHCREATE; HASH_SET(_hash,"key","value"); if (HASH_HASKEY(_hash,"key")) then { @@ -664,7 +664,7 @@ A description of the above macros is below. A hashlist is an extension of a hash. It is a list of hashes! The reason for having this special type of storage container rather than using a normal array is that an array of normal hashes that are similar will duplicate a large amount of data in their storage of keys. A hashlist on the other hand uses a common list of keys and an array of unique value containers. The following will demonstrate its usage. -```js +```cpp _defaultKeys = ["key1", "key2", "key3"]; // create a new hashlist using the above keys as default _hashList = HASHLIST_CREATELIST(_defaultKeys); @@ -712,19 +712,19 @@ When adding new elements to an array, `pushBack` shall be used instead of the bi Good: -```js +```cpp _a pushBack _value; ``` Also good: -```js +```cpp _a append [1, 2, 3]; ``` Bad: -```js +```cpp _a set [ count _a, _value]; _a = a + _[value]; ``` @@ -742,14 +742,14 @@ Where possible `[0, 0, 0]` position shall be used, except on `#` objects (e.g. ` This code requires ~1.00ms and will be higher with more objects near wanted position: -```js +```cpp _vehicle = _type createVehicleLocal _posATL; _vehicle setposATL _posATL; ``` While this one requires ~0.04ms: -```js +```cpp _vehicle = _type createVehicleLocal [0, 0, 0]; _vehicle setposATL _posATL; ``` @@ -765,13 +765,13 @@ When checking if an array is empty `isEqualTo` shall be used. ### 8.7 `for` Loops -```js +```cpp for "_y" from # to # step # do { ... } ``` shall be used instead of -```js +```cpp for [{ ... },{ ... },{ ... }] do { ... }; ``` @@ -782,7 +782,7 @@ While is only allowed when used to perform a unknown finite amount of steps with Good: -```js +```cpp _original = _obj getvariable [QGVAR(value), 0]; while {_original < _weaponThreshold} do { _original = [_original, _weaponClass] call FUNC(getNewValue); @@ -791,7 +791,7 @@ while {_original < _weaponThreshold} do { Bad: -```js +```cpp while {true} do { // anything }; @@ -799,7 +799,7 @@ while {true} do { ### 8.9 `waitUntil` The `waitUntil` command shall not be used. Instead, make use of CBA's `CBA_fnc_waitUntilAndExecute` -```js +```cpp [{ params ["_unit"]; _unit getVariable [QGVAR(myVariable), false] diff --git a/docs/wiki/feature/medical-system.md b/docs/wiki/feature/medical-system.md index 67c239b92a..7846413b08 100644 --- a/docs/wiki/feature/medical-system.md +++ b/docs/wiki/feature/medical-system.md @@ -189,7 +189,7 @@ Feel free to tweak the values of the settings to adjust it to your likings. #### 2.1.1 Preset 1 -```c++ +```cpp force ace_medical_fatalDamageSource = 1; // Sum of Trauma death condition force ace_medical_AIDamageThreshold = 0.2; // Decreased AI damage threshold so AI dies in single headshot and few torso taps depending on vest force ace_medical_playerDamageThreshold = 3.5; // Increased damage threshold for players, high caliber weapons should still be fatal @@ -202,7 +202,7 @@ force ace_medical_statemachine_cardiacArrestTime = 630; #### 2.1.2 "Basic" Preset -```c++ +```cpp force ace_medical_AIDamageThreshold = 0.2; // Decreased AI damage threshold so AI dies in single headshot and few torso taps depending on vest force ace_medical_playerDamageThreshold = 3.5; // Increased damage threshold for players, high caliber weapons should still be fatal force ace_medical_bleedingCoefficient = 0.25; @@ -217,7 +217,7 @@ force ace_medical_treatment_advancedMedication = false; // Disabled advanced med #### 2.1.3 "Advanced" Preset -```c++ +```cpp force ace_medical_fractures = 1; // Splints Fully Heal Fractures - set to "2" to keep sprinting disabled after fracture force ace_medical_limping = 1; // Limp on Open Wounds force ace_medical_spontaneousWakeUpChance = 0.15; // 15% chance of waking up from unconscious after stable @@ -245,7 +245,7 @@ force ace_medical_treatment_medicSurgicalKit = 1; // Medics can stitch #### 2.2.1 Preset 1 -```c++ +```cpp force ace_medical_fatalDamageSource = 1; // Sum of Trauma death condition force ace_medical_feedback_painEffectType = 2; // Forced pain effect type to ensure that everyone is handicapped in the same way force ace_medical_spontaneousWakeUpChance = 0.15; // don't let players wake up too fast diff --git a/docs/wiki/framework/advanced-throwing-framework.md b/docs/wiki/framework/advanced-throwing-framework.md index 925b9c9779..83de2f9405 100644 --- a/docs/wiki/framework/advanced-throwing-framework.md +++ b/docs/wiki/framework/advanced-throwing-framework.md @@ -15,6 +15,6 @@ version: Pick-up interaction can be disabled for ammo (e.g. chemlights) attached to an object. -```js +```cpp OBJECT setVariable ["ace_advanced_throwing_disablePickUp", true, true]; ``` diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index abaa06f4a7..1380b717f0 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -228,7 +228,7 @@ Calls a globally synchronized event, which will also be run on JIP players unles ### 3.4 Example -```js +```cpp // Event handler added on a target machine ["ace_interact_tapShoulder", ace_example_fnc_onTapShoulder] call CBA_fnc_addEventHandler; diff --git a/docs/wiki/framework/respawn-framework.md b/docs/wiki/framework/respawn-framework.md index 9b36aa6221..395c14df25 100644 --- a/docs/wiki/framework/respawn-framework.md +++ b/docs/wiki/framework/respawn-framework.md @@ -47,7 +47,7 @@ To enable other units to move them reference [Scripting](#allow-units-to-move-ra To change the texture of the flag use the following line on the rally point object: -```js +```cpp this setFlagTexture 'path\to\my\texture\my_awesome_clan_logo.paa'; ``` @@ -55,6 +55,6 @@ this setFlagTexture 'path\to\my\texture\my_awesome_clan_logo.paa'; To enable other units to move rally points, such as JIP units, use the following line on the units: -```js +```cpp _unit setVariable ["ACE_canMoveRallypoint", true, true]; ``` diff --git a/docs/wiki/framework/switchunits-framework.md b/docs/wiki/framework/switchunits-framework.md index eb8bd86cc4..631a583185 100644 --- a/docs/wiki/framework/switchunits-framework.md +++ b/docs/wiki/framework/switchunits-framework.md @@ -26,6 +26,6 @@ The module settings define which side a player can control or how big the radius To enable a player to control AI execute the following on it: -```js +```cpp this setVariable ["ACE_CanSwitchUnits", true]; ``` diff --git a/docs/wiki/framework/vehiclelock-framework.md b/docs/wiki/framework/vehiclelock-framework.md index 2838fa4f5f..46aa5645e6 100644 --- a/docs/wiki/framework/vehiclelock-framework.md +++ b/docs/wiki/framework/vehiclelock-framework.md @@ -52,7 +52,7 @@ Sync the module with vehicles and players. Custom keys will be handed to players To override a vehicle's side, allowing locking and unlocking using a different side's key, use the following on that vehicle (use wanted side instead of `west`): -```js +```cpp this setVariable ["ace_vehiclelock_lockSide", west]; ``` @@ -60,6 +60,6 @@ this setVariable ["ace_vehiclelock_lockSide", west]; To override default lock pick strength for a vehicle, that is how long lock picking will take, use the following on that vehicle (use wanted time in seconds instead of `5`): -```js +```cpp this setVariable ["ace_vehiclelock_lockpickStrength", 5]; ```