diff --git a/addons/arsenal/missions/Arsenal.VR/fnc_createTarget.sqf b/addons/arsenal/missions/Arsenal.VR/fnc_createTarget.sqf index 7f473a40ba..ee1dadfaa9 100644 --- a/addons/arsenal/missions/Arsenal.VR/fnc_createTarget.sqf +++ b/addons/arsenal/missions/Arsenal.VR/fnc_createTarget.sqf @@ -1,57 +1,58 @@ #include "script_component.hpp" -private ["_pos","_side","_obj","_grp","_type","_target"]; -//_pos = [_this,0,[],[[],objnull]] call bis_fnc_param; -//_type = [_this,1,"B_Soldier_VR_F",["",objnull]] call bis_fnc_param; -params ["_type", "_pos"]; +params ["_type", "_position", ["_group", grpNull], "_varName"]; +private _player = player; -_obj = _pos; -_grp = grpnull; -_var = ""; - -if (typename _obj == typename objnull) then { - _grp = group _obj; - _type = typeof _obj; - _pos = _obj getvariable ["pos",position objnull]; - _var = _obj getvariable ["var",""]; - [_obj,true] call bis_fnc_VREffectKilled; -} else { - _grp = creategroup east; +if (isNull _group) then { + _group = creategroup east; }; -if (_var == "") then {_var = "t" + str round random 999999;}; -_target = _grp createunit [_type,[10,10,0],[],0,"none"]; -if !(isnull (missionnamespace getvariable ["BIS_fnc_arsenal_target",objnull])) then {_target hideobject true}; -_target setpos _pos; -_target setdir ([_pos,player] call bis_fnc_dirto); -_target dowatch position player; -_target addrating -10e10; -_target setunitpos "up"; -_target setbehaviour "careless"; -_target setcombatmode "blue"; -_target setspeedmode "limited"; -_target disableai "target"; -_target disableai "autotarget"; -_target allowfleeing 0; -_target setspeaker "base"; -_target spawn {_this setspeaker "base";}; -player reveal [_target,4]; +private _target = _group createUnit [_type, [10,10,0], [], 0, "NONE"]; -_target addvest vest player; -_target addbackpack backpack player; -_target addheadgear headgear player; -_target addgoggles goggles player; -_target addweapon primaryweapon player; -_target addweapon secondaryweapon player; -_target addweapon handgunweapon player; +if (isNil "_varName") then { + _varName = _target call BIS_fnc_netId; +}; -_target setvehiclevarname _var; -missionnamespace setvariable [_var,_target]; +_target setPos _position; +_target setDir (_position getDir _player); +_target doWatch position _player; +_target addRating -10e10; +_target setUnitPos "UP"; +_target setBehaviour "CARELESS"; +_target setCombatMode "BLUE"; +_target setSpeedMode "LIMITED"; +_target disableAI "TARGET"; +_target disableAI "AUTOTARGET"; +_target allowFleeing 0; +_target setSpeaker "BASE"; +[{_this setSpeaker "BASE"}, _target] call CBA_fnc_execNextFrame; +_player reveal [_target, 4]; -_target switchmove "amovpercmstpslowwrfldnon"; -_target setvariable ["pos",_pos]; -_target setvariable ["var",_var]; -_target addeventhandler ["killed", FUNC(createTarget)]; -[_target] call bis_fnc_VRHitpart; +_target addVest vest _player; +_target addBackpack backpack _player; +_target addHeadgear headgear _player; +_target addGoggles goggles _player; +_target addWeapon primaryWeapon _player; +_target addWeapon secondaryWeapon _player; +_target addWeapon handgunWeapon _player; +_target setVehicleVarName _varName; +missionNamespace setvariable [_varName, _target]; + +_target switchMove "amovpercmstpslowwrfldnon"; +_target setVariable ["origin", _position]; + +_target addEventHandler ["killed", { + params ["_target"]; + private _position = _target getVariable ["origin", position _target]; + private _varName = vehicleVarName _target; + + [_target, true] spawn BIS_fnc_VREffectKilled; + + [{isNull (_this select 0)}, { + (_this select 1) call FUNC(createTarget); + }, [_target, [typeOf _target, _position, group _target, _varName]]] call CBA_fnc_waitUntilAndExecute; +}]; + +_target call BIS_fnc_VRHitpart; _target