{"name":"BIS_fnc_respect","title":"BIS fnc respect","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_respect","revid":379570,"updated":"2026-10-31T13:59:21Z","groups":["Sides"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","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.\n\"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.\n\nAn unknown mode shows an error with hintC and returns -1.","syntaxes":[{"syntax":"[\"SET\", unit] call BIS_fnc_respect","params":[{"name":"\"SET\"","type":"String","description":"creates default respect values (**case-sensitive**)","type_expr":"String"},{"name":"unit","type":"Object","optional":true,"description":"unit whose faction gets respect 1; the result is also stored in its \"respect\" variable","type_expr":"Object","text":"unit: Object - (Optional) unit whose faction gets respect 1; the result is also stored in its \"respect\" variable"}],"returns":{"type":"Array of Numbers","type_expr":"Array<Number>","description":"0 for every faction, 1 for the faction of unit","text":"Array of Numbers - 0 for every faction, 1 for the faction of *unit*"}},{"syntax":"[\"ADD\", unit, range] call BIS_fnc_respect","params":[{"name":"\"ADD\"","type":"String","description":"gives a unit the respect values of its town (**case-sensitive**)","type_expr":"String"},{"name":"unit","type":"Object","description":"unit whose \"ALICE_twn\" variable holds its town logic","type_expr":"Object"},{"name":"range","type":"Number","description":"each town value is changed by a random amount between -range/2 and +range/2","type_expr":"Number"}],"returns":{"type":"Array of Numbers","type_expr":"Array<Number>","description":"unit's new respect values"}},{"syntax":"[\"MODIFY\", unit, faction, formula] call BIS_fnc_respect","params":[{"name":"\"MODIFY\"","type":"String","description":"changes one respect value (**case-sensitive**)","type_expr":"String"},{"name":"unit","type":"Object","description":"unit or town logic whose respect is changed; if it has no respect yet, \"SET\" is applied first","type_expr":"Object"},{"name":"faction","type":"String, Number or Object","description":"faction class name, faction index, or any object to use *unit*'s own faction","type_expr":"String | Number | Object"},{"name":"formula","type":"String or Number","description":"code computing the new value, the current value being available as *_r* (e.g. \"_r / 2\"); a Number sets the value directly","type_expr":"String | Number"}],"returns":{"type":"Number","type_expr":"Number","description":"new respect value, clamped to -1..1. If unit has Code in its \"respect_handler\" variable, it is spawned with [unit, factionIndex, oldValue, newValue].","text":"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":"[\"KILLED\", killer, town, changeNeighbors, coefficient] call BIS_fnc_respect","params":[{"name":"\"KILLED\"","type":"String","description":"lowers a town's respect after a civilian was killed (**case-sensitive**)","type_expr":"String"},{"name":"killer","type":"Object","description":"the killer; for every faction, the town value is lowered by the killer's respect for that faction multiplied by *coefficient*","type_expr":"Object"},{"name":"town","type":"Object","description":"town logic","type_expr":"Object"},{"name":"changeNeighbors","type":"Boolean","optional":true,"default":"false","description":"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 coefficient","type_expr":"Boolean","text":"changeNeighbors: 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 coefficient"},{"name":"coefficient","type":"Number","optional":true,"default":"`2 + random 4`","description":"change coefficient","type_expr":"Number","text":"coefficient: Number - (Optional, default `2 + random 4`) change coefficient"}],"returns":{"type":"Array of Numbers","type_expr":"Array<Number>","description":"town's new respect values"}}],"examples":[{"text":"```sqf\n[\"SET\", player] call BIS_fnc_respect;                    // the player respects their own faction only\n[\"MODIFY\", player, \"OPF_F\", \"_r - 0.5\"] call BIS_fnc_respect;    // lowers the player's respect for CSAT by 0.5\n[\"MODIFY\", player, \"IND_F\", 0.25] call BIS_fnc_respect;        // sets the player's respect for AAF to 0.25\n```","code":["[\"SET\", player] call BIS_fnc_respect;\t\t\t\t\t// the player respects their own faction only\n[\"MODIFY\", player, \"OPF_F\", \"_r - 0.5\"] call BIS_fnc_respect;\t// lowers the player's respect for CSAT by 0.5\n[\"MODIFY\", player, \"IND_F\", 0.25] call BIS_fnc_respect;\t\t// sets the player's respect for AAF to 0.25"]}],"see_also":["BIS_fnc_getFactions","addRating","Ambient Civilians"]}