summaryrefslogtreecommitdiffstats
path: root/Common/Functions/Common_CreateUnit.sqf
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.pro>2026-06-11 19:54:45 +0300
committerhybrid <hybrid@hybridlabs.pro>2026-06-11 19:54:45 +0300
commit68d4c9bbd80ed2e6528244569c79676b87295bd1 (patch)
tree6efd42fbf6f1281874ae0ff1f8816b01fe0c7153 /Common/Functions/Common_CreateUnit.sqf
downloada2wf_takistan-68d4c9bbd80ed2e6528244569c79676b87295bd1.tar.gz
a2wf_takistan-68d4c9bbd80ed2e6528244569c79676b87295bd1.tar.bz2
a2wf_takistan-68d4c9bbd80ed2e6528244569c79676b87295bd1.zip
init
Diffstat (limited to 'Common/Functions/Common_CreateUnit.sqf')
-rw-r--r--Common/Functions/Common_CreateUnit.sqf28
1 files changed, 28 insertions, 0 deletions
diff --git a/Common/Functions/Common_CreateUnit.sqf b/Common/Functions/Common_CreateUnit.sqf
new file mode 100644
index 0000000..8a42df6
--- /dev/null
+++ b/Common/Functions/Common_CreateUnit.sqf
@@ -0,0 +1,28 @@
+Private ["_get","_position","_side","_skill","_team","_type","_unit"];
+_type = _this select 0;
+_team = _this select 1;
+_position = _this select 2;
+_side = _this select 3;
+
+_get = _type Call GetNamespace;
+_skill = if !(isNil '_get') then {_get select QUERYUNITSKILL} else {'WFBE_AISKILL' Call GetNamespace};
+_unit = _team createUnit [_type,_position,[],0,"FORM"];
+_unit setSkill _skill;
+if (_side != resistance) then {
+ if (paramTrackAI) then {
+ _unit setVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side];
+ processInitCommands;
+ } else {
+ if (isPlayer leader _team) then {[_unit,_side] ExecVM 'Common\Common_InitUnit.sqf'};
+ };
+ Call Compile Format ["_unit addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}];",_side];
+} else {
+ //--- Note To be optimized, 1.03 BIS BUG, cannot add resistance side via call compile format.
+ _unit addEventHandler ['Killed',{[_this select 0,_this select 1,resistance] Spawn UnitKilled}];
+};
+
+if (('WFBE_ISIS' Call GetNamespace) == 2) then {_unit addEventHandler['handleDamage',{_this Call ISIS_Wound}]};
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%5 | ticktime:%6] Common_CreateUnit: A '%1' unit was created (position: %2) and has joined the %3 %4 Team",_type,_position,str _side,_team,diag_frameno,diag_tickTime];
+
+_unit \ No newline at end of file