{"name":"BIS_fnc_moduleFriendlyFire","title":"BIS fnc moduleFriendlyFire","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_moduleFriendlyFire","revid":379568,"updated":"2026-10-31T13:56:44Z","groups":["Modules"],"status":"ok","games":{"arma3":"1.00"},"since":"arma3 1.00","arma3_since":"1.00","description":"Handles friendly fire. This is the function of the Friendly Fire module (*ModuleFriendlyFire_F*): when the module is placed in the editor, it is called with the module logic and the units synchronised to the module are checked. It can also be called by scripts with one of the modes below.\n\"Init\" creates the global logic *BIS_FriendlyFire* and checks once per second whether the player committed friendly fire, which happens when:\n\n- the player becomes a renegade (side sideEnemy),\n- the player (or the player's vehicle or connected UAV) kills one of the checked men,\n- the player hits one of the checked vehicles whose priority is above 0, or hits it so that it can no longer move (canMove).\n\nThe mission then ends for everyone with the failed ending \"FriendlyFire\" (see BIS_fnc_endMission).\nEvery mode except \"Init\" returns false while the module is not initialised.","syntaxes":[{"syntax":"[\"Init\", [units, activated]] call BIS_fnc_moduleFriendlyFire","params":[{"name":"\"Init\"","type":"String","description":"initialises the module","type_expr":"String"},{"name":"units","type":"Array of Objects","optional":true,"default":"`[]`","description":"units and vehicles to check; the crew of a given vehicle is checked as well","type_expr":"Array<Object>","text":"units: Array of Objects - (Optional, default `[]`) units and vehicles to check; the crew of a given vehicle is checked as well"},{"name":"activated","type":"Boolean","optional":true,"default":"true","description":"not used","type_expr":"Boolean","text":"activated: Boolean - (Optional, default true) not used"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"false if the module was already initialised, otherwise true"}},{"syntax":"[\"Destroy\"] call BIS_fnc_moduleFriendlyFire","params":[{"name":"\"Destroy\"","type":"String","description":"deletes the module logic","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"true"}},{"syntax":"[\"AddUnits\", [units]] call BIS_fnc_moduleFriendlyFire","params":[{"name":"\"AddUnits\"","type":"String","description":"adds units to the checked units","type_expr":"String"},{"name":"units","type":"Array of Objects","description":"units and vehicles to add (vehicle crews are not added)","type_expr":"Array<Object>"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"true"}},{"syntax":"[\"RemoveUnits\", [units]] call BIS_fnc_moduleFriendlyFire","params":[{"name":"\"RemoveUnits\"","type":"String","description":"removes units from the checked units","type_expr":"String"},{"name":"units","type":"Array of Objects","description":"units to remove","type_expr":"Array<Object>"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"true"}},{"syntax":"[\"ChangePriority\", [vehicle, priority]] call BIS_fnc_moduleFriendlyFire","params":[{"name":"\"ChangePriority\"","type":"String","description":"changes the priority of a checked vehicle","type_expr":"String"},{"name":"vehicle","type":"Object","description":"checked vehicle","type_expr":"Object"},{"name":"priority","type":"Number","optional":true,"default":"0","description":"if above 0, a single hit by the player counts as friendly fire","type_expr":"Number","text":"priority: Number - (Optional, default 0) if above 0, a single hit by the player counts as friendly fire"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"true"}}],"examples":[{"text":"```sqf\n[\"Init\", [[BIS_vip1, BIS_vip2, BIS_vipCar]]] call BIS_fnc_moduleFriendlyFire;    // BIS_vip1, BIS_vip2, BIS_vipCar and its crew are checked\n[\"AddUnits\", [[BIS_vip3]]] call BIS_fnc_moduleFriendlyFire;                        // BIS_vip3 is checked too\n[\"ChangePriority\", [BIS_vipCar, 1]] call BIS_fnc_moduleFriendlyFire;            // one hit on BIS_vipCar is friendly fire\n[\"RemoveUnits\", [[BIS_vip1]]] call BIS_fnc_moduleFriendlyFire;                    // BIS_vip1 is no longer checked\n```","code":["[\"Init\", [[BIS_vip1, BIS_vip2, BIS_vipCar]]] call BIS_fnc_moduleFriendlyFire;\t// BIS_vip1, BIS_vip2, BIS_vipCar and its crew are checked\n[\"AddUnits\", [[BIS_vip3]]] call BIS_fnc_moduleFriendlyFire;\t\t\t\t\t\t// BIS_vip3 is checked too\n[\"ChangePriority\", [BIS_vipCar, 1]] call BIS_fnc_moduleFriendlyFire;\t\t\t// one hit on BIS_vipCar is friendly fire\n[\"RemoveUnits\", [[BIS_vip1]]] call BIS_fnc_moduleFriendlyFire;\t\t\t\t\t// BIS_vip1 is no longer checked"]},{"code":["[\"Init\", []] call BIS_fnc_moduleFriendlyFire; // only the renegade state is checked"]}],"see_also":["BIS_fnc_endMission","rating","addRating"]}