Description
RESpect - The Effective Calculation Process. Manages "respect" values: an Array of Numbers in range -1..1, one per faction in the order returned by BIS_fnc_getFactions, stored in the public "respect" variable of a unit or of a town logic. "ADD" and "KILLED" work with town logics as used by Ambient Civilians (the unit's "ALICE_twn" variable, the town's "neighbors" variable). No Arma 3 script calls this function.
An unknown mode shows an error with hintC and returns -1.
Syntax
Syntax 1
["SET", unit] call BIS_fnc_respect
Parameters:
"SET": String - creates default respect values (case-sensitive)unit: Object - (Optional) unit whose faction gets respect 1; the result is also stored in its "respect" variable
Returns: Array of Numbers - 0 for every faction, 1 for the faction of unit
Syntax 2
["ADD", unit, range] call BIS_fnc_respect
Parameters:
"ADD": String - gives a unit the respect values of its town (case-sensitive)unit: Object - unit whose "ALICE_twn" variable holds its town logicrange: Number - each town value is changed by a random amount between -range/2 and +range/2
Returns: Array of Numbers - unit's new respect values
Syntax 3
["MODIFY", unit, faction, formula] call BIS_fnc_respect
Parameters:
"MODIFY": String - changes one respect value (case-sensitive)unit: Object - unit or town logic whose respect is changed; if it has no respect yet, "SET" is applied firstfaction: String, Number or Object - faction class name, faction index, or any object to use unit's own factionformula: String or Number - code computing the new value, the current value being available as _r (e.g. "_r / 2"); a Number sets the value directly
Returns: Number - new respect value, clamped to -1..1. If unit has Code in its "respect_handler" variable, it is spawned with [unit, factionIndex, oldValue, newValue].
Syntax 4
["KILLED", killer, town, changeNeighbors, coefficient] call BIS_fnc_respect
Parameters:
"KILLED": String - lowers a town's respect after a civilian was killed (case-sensitive)killer: Object - the killer; for every faction, the town value is lowered by the killer's respect for that faction multiplied by coefficienttown: Object - town logicchangeNeighbors: Boolean - (Optional, default false) if true and the town has a "neighbors" variable, the killer's respect for its own faction is multiplied by 0.9 and every neighbouring town is processed with half the coefficientcoefficient: Number - (Optional, default2 + random 4) change coefficient
Returns: Array of Numbers - town's new respect values
Examples
Example 1
["SET", player] call BIS_fnc_respect; // the player respects their own faction only
["MODIFY", player, "OPF_F", "_r - 0.5"] call BIS_fnc_respect; // lowers the player's respect for CSAT by 0.5
["MODIFY", player, "IND_F", 0.25] call BIS_fnc_respect; // sets the player's respect for AAF to 0.25