Jump to content
killshot

createVehicle BIS Interactive Targets

Recommended Posts

Hello everybody,

 

I would like to spawn in BIS Interactive Targets "TargetBootcampHuman_F" via script, but without their default settings.

(Using Zeus you get a few options to change settings for the object)

 

I managed to change the texture, but failed to make the targets not popup again. This is what I have so far:

 

   t1 = createVehicle ["TargetBootcampHuman_F", [3123.2107,3980.2239,0], [], 0, "CAN_COLLIDE"];
   t1 setDir 251.553;
   _targetPopup = t1 getVariable ["RscAttributeTargetPopup", getNumber (configFile >> "CfgVehicles" >> typeOf t1 >> "popup")];
   t1 setVariable ["_targetPopup",0,true];
   //t1 setVariable ["Popup",0,true];

   _texture = ((getArray (configFile >> "CfgVehicles" >> typeOf t1 >> "textures")) select 1) select 1;
   t1 setObjectTextureGlobal [0, _texture];

 

 

I guess the solution is somewhere in BIS_fnc_target (?)

 

Maybe someone of you can help :)

 

 

Kind regards.

Share this post


Link to post
Share on other sites

nopop= true; works on some targets but not the interactive one.

 

The only work around I found was to override the default code and use animate to take control.

 

You will need to add an eventhandler to detect when the target has been hit.

t1 addeventhandler ["Hit",{(_this select 0) spawn {sleep 0.01;_this animate ["terc", 0];sleep 0.1;_this animate ["terc", 1];_this removeeventHandler ["hit",0]}}];

Share this post


Link to post
Share on other sites

Thanks for your response.

 

I actually used your idea from a script of you (popup.sqf).

 

[t1] call fnc_noPop;

 

 

fnc_noPop = {

    private ["_target"];
    
    _target = (_this select 0);
    
    while {(_target animationPhase "terc") < 0.9 } do {
    
    if ((_target animationPhase "terc") == 1) then
    
    {_target animate ["terc",1]};
    
    };
};

 

 

Would the eventHandler solution be the better one? There will be round about 25 targets get spawned.

Share this post


Link to post
Share on other sites

I did some popup stuff so long ago I forgot most of it.

 

If your running multiple targets you will need some way to determine which target has been hit and then call the function passing the _target to the script.

 

  You could use the above EVH for each target or if you prefer to call the function

t1 addeventhandler ["Hit",{[_this select 0] call fnc_noPop;];

They're basically doing the same thing although when I tried using animationphase that last night it didn't stay down for me on the interactive target so I may have messed up if it's working for you.

 

I don't know which would be the better method, one thing to watch for is that neither record multiple hits.

Share this post


Link to post
Share on other sites

Having this in initPlayerLocal worked.

fnc_nopop = {    private ["_target"];

   
    _target = (_this select 0);
    
    while {alive _target} do {
    
    if ((_target animationPhase "terc") == 1) then
    
    {_target animate ["terc",1]};
    
    };

};



fnc_spwnTrgt = {

    
     z1 = createVehicle ["TargetBootcampHuman_F", [3123.2107,3980.2239,0], [], 0, "CAN_COLLIDE"];
     z1 setDir 251.553;
    [z1] call fnc_nopop;

   _texture = ((getArray (configFile >> "CfgVehicles" >> typeOf z1 >> "textures")) select 1) select 1;
   z1 setObjectTextureGlobal [0, _texture];
};

_spwnTrgt      = player addAction ["SpawnTarget","call fnc_spwnTrgt","",198,false,true,"",""];

 

 


 

But I have problems to get it to work in the actual script like you said, but nevermind, I will go with the eventHandler-solution, it seems to work great.

 

Thanks again. :)

Share this post


Link to post
Share on other sites

Hello again,
 
so I decided to not use the interactive targets, since the provided informations are quite useless in my opinion and now I just go with the "standard" ones (static and moving), but unfortunately the eventHandler solution for nopop seems not to work with them?
 
I've made a function and everything looks like it's working, but I can't get the last part to work, I've googled and tried a couple ways, without success.
 

fnc_spawnPopUp = {

/*
nul = ["objName","markerName",[ [[pos],dir,"type","texture","popUp"],[[pos],dir,"type","texture","popUp"],[[pos],dir,"type","texture","popUp"] ]] call fnc_spawnPopUp;
*/

private ["_dice","_obj"];
params [["_objName", "", [""]],["_mrk", "", [""]],["_array", [],[]]];

_dice = count _array;
_dice = floor(random (_dice));
_array = _array select _dice;
_array params [["_pos", [0,0,0], [[],"",objNull]], "_dir", ["_type","S"],["_texture","INF1"],["_popUp","NO"]];

//Static
if (_type isEqualTo "S") then { _type = "TargetP_Inf_F"; };
//Moving Left-Right
if (_type isEqualTo "MM") then { _type = "Target_Swivel_01_ground_F"; };
//Moving Right
if (_type isEqualTo "RM") then { _type = "Target_Swivel_01_right_F"; };
//Moving Left
if (_type isEqualTo "LM") then { _type = "Target_Swivel_01_left_F"; };

//Soldier
if (_texture isEqualTo "INF1") then { _texture = "TargetP_Inf_F"; };
//Soldier Aiming
if (_texture isEqualTo "INF2") then { _texture = "TargetP_Inf2_F"; };
//Soldier Lowered Weapon
if (_texture isEqualTo "INF3") then { _texture = "TargetP_Inf3_F"; };
//Soldier Aiming (Mask)
if (_texture isEqualTo "INF4") then { _texture = "TargetP_Inf4_F"; };
//General
if (_texture isEqualTo "GEN") then { _texture = "TargetP_HVT1_F"; };
//Officer
if (_texture isEqualTo "OFF") then { _texture = "TargetP_HVT2_F"; };
//Civilian Man
if (_texture isEqualTo "CIV1") then { _texture = "TargetP_Civ_F"; };
//Civilian Woman
if (_texture isEqualTo "CIV2") then { _texture = "TargetP_Civ2_F"; };
//Hostage
if (_texture isEqualTo "HOST") then { _texture = "TargetP_Civ3_F"; };

_obj = createVehicle [_type, markerPos _mrk, [], 0, "CAN_COLLIDE"];

_obj SetVehicleVarName _objName;
_obj call compile format ["%1=_This ; PublicVariable ""%1""",_objName];

_texture = ((getArray (configfile >> "CfgVehicles" >> _texture >> "hiddenSelectionsTextures")) select 0 );
_obj setObjectTextureGlobal [0, _texture];

_obj setPosATL _pos;
_obj setFormDir _dir;
_obj setDir _dir;

if (_popUp isEqualTo "YES") then {}
else {
_obj addEventHandler ["Hit",{(_this select 0) spawn {sleep 0.01;_this animate ["terc", 0];sleep 0.1;_this animate ["terc", 1];_this removeEventHandler ["hit",0]}}];
};
};


 
 
Any help would be highly appreciated :)
 
 
Kind regards.
 
Edit:
 
Using just noPop = true; in init.sqf will work for the static target "TargetP_Inf_F". Using BIS PopUpTarget.sqf gives the possibility to make them popup again.

 

Still the moving targets aren't influenced by that, unfortunately.

 

This is what I've changed so far:

	if (_popUp isEqualTo "YES") then {
		if (_type isEqualTo "TargetP_Inf_F") then {
		
				_obj addEventHandler ["HitPart", "[(_this select 0)] execVM 'PopUpTarget.sqf';"];
				_obj setVariable ["_nopop", false, true];
				
		} else {
		
			//code for moving targets
		
		};
		} else {
		
		if !(_type isEqualTo "TargetP_Inf_F") then {
		
			//code for moving targets
		
		};
		
		};

The following commands do work (e.g. in the console) for "Target_Swivel_01_ground_F" etc. but I can't get them to work within the function/eventHandlers.

 

t1 animate ["Terc",1,true];
t1 setVariable ["BIS_poppingEnabled", false]; // prevents pop-down after bullet hits
t1 setVariable ["BIS_isPopping", true]; // prevents left-right swinging +(all other possible animations(?) including popdown)

Share this post


Link to post
Share on other sites

Finally I've conquered my cluelessness.

 

Maybe it's not possible to achieve it from within the function itself, but probably I'm just too stupid ^^

 

So it's done in the same script, where the function gets called:

[] spawn {

    nul = ["t1","spawnMrk",[ [[1896.26,5750.96,0.00143862],107.79,"MM","INF2","NO"] ]] call fnc_spawnPopUp;
    nul = ["t2","spawnMrk",[ [[1895.26,5747.83,0.00145149],108.039,"RM","INF2","NO"] ]] call fnc_spawnPopUp;    
    nul = ["t3","spawnMrk",[ [[1897.43,5754.45,0.00144434],108.174,"LM","INF2","NO"] ]] call fnc_spawnPopUp;
    nul = ["t4","spawnMrk",[ [[1898.59,5757.97,0.00143862],108.174,"S","INF2","NO"] ]] call fnc_spawnPopUp;
    
    t1 addEventHandler ["HitPart",{t1 spawn {sleep 0.01; t1 setVariable ["BIS_poppingEnabled",false, true]; sleep 0.01; t1 animate ["terc",1];};}];
    t2 addEventHandler ["HitPart",{t2 spawn {sleep 0.01; t2 setVariable ["BIS_poppingEnabled",false, true]; sleep 0.01; t2 animate ["terc",1];};}];
    t3 addEventHandler ["HitPart",{t3 spawn {sleep 0.01; t3 setVariable ["BIS_poppingEnabled",false, true]; sleep 0.01; t3 animate ["terc",1];};}];
};

Good night. :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×