Jump to content

Recommended Posts

Hi everyone I hope you are all well this days.. I continue to work on one mission I have started before corona and now I try to make it live finally. Old problem is still problem and I will try to explain as clear as I can (that is not real problem, just mine short knowledge) so:

I manage to create vehicle and put crew inside, set patrol areas with random waypoints, also infantry groups etc... Thing I can not figure out is how to create trigger to react on those units and vehicles due to fact they have not Variable names because they are not placed from eden but through very beautiful scripts for me from SayUnkl https://www.youtube.com/watch?v=Z7l1vvd91ak and this superguy https://securitronlinux.com/bejiitaswrath/how-to-spawn-a-randomly-placed-building-in-arma-3/. Now I am trying to create a triggers and ask them to monitor this scripted units and vehicles in the ways that triggers react on units death, wounding and similar states..

 

CLEAR EXAMPLE: 

_mrk = "m2";   
_area = markerSize _mrk;   
_nul = _area pushBack markerDir _mrk;   
_nul = _area pushBack ( markerShape _mrk isEqualTo "Circle" );   
_pos = [ _mrk, _area ] call BIS_fnc_randomPosTrigger;   
_randPos = [_pos , 0, 800, 12, 0, 10, 0] call BIS_fnc_findSafePos;   
_veh = createVehicle ["I_G_Van_02_vehicle_F", _randPos, [], 0, "NONE"]; 
createVehicleCrew _veh;

so I create this van vehicle inside marker called m2, now I need to know when vehicle is destroyed. Placing triggers in eden and making them simulation enabled and not isn't working because area of vehicle probability placing is random and big and collision with other trigger areas impacting them. Second solution was to set triggers condition to "thisList" but it is impossible because I dont have Variable Names which will eventually meet the conditions of triggers again same reason - units and vehicles are placed through scripts. So my question is how to script trigger and connect it to scripted vehicles/units?

 

CODES I TRIED:

_mrk = "m1";   
_area = markerSize _mrk;   
_nul = _area pushBack markerDir _mrk;   
_nul = _area pushBack ( markerShape _mrk isEqualTo "Circle" );   
_pos = [ _mrk, _area ] call BIS_fnc_randomPosTrigger;   
_randPos = [_pos , 0, 3000, 12, 0, 10, 0] call BIS_fnc_findSafePos;   
_veh = createVehicle ["B_APC_Tracked_01_AA_F", _randPos, [], 0, "NONE"]; 
createVehicleCrew _veh;

sleep 3;

_trg = createTrigger ["EmptyDetector", getPos player];
_trg setTriggerStatements ["!alive _veh", "hint 'veh oboren'", "hint 'trigger off'"];     //and or
_trg setTriggerActivation ["_veh", "not present", true];

 

Last 3 lines of code is my creation only and trying to hit the target, not a code from some authors like other parts are. 

 

Thanks everyone who can tell me something about this and maybe give final solution  //sorry on my English it is far from best, I know..

 

 

Share this post


Link to post
Share on other sites

@Nemanjic,
If you must use a trigger consider @pierremgi's solution below.


Otherwise, forget about the trigger and just loop for a condition (area distance?),

null=[_veh, "m1", _area] spawn {	params ["_veh", "_mark", "_area"];
    waitUntil {sleep 1;
        if (_veh distance (getMarkerPos _mark)> _area || !alive _veh) then {
		if (!alive _veh) exitWith {"vehicle is destroyed, exit loop"; true};
		"vehicle is out of area, exit loop";
		true
	}else{
		"vehicle is in area, continue loop";
		false
	}
    }
};

Have fun!

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

There is a simple mean to write with local variable passed to the trigger statement. Just set variable on it:

_trg = createTrigger ["EmptyDetector", getPos player];

_trg setVariable ["veh",_veh];
_trg setTriggerStatements ["!alive (thistrigger getVariable ['veh',objNull])", "hint 'veh oboren'", "hint 'trigger off'"];

 

Especially, when you are using multiple triggers.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

SOLVED! Both ways work! Loop system is perfect but hard for me to understand what exactly going under the hub until today morning finally I got some idea how it works. Not just you helped me to pass the problem away, also you teach me some things. Thank you guys! @wogz187 @pierremgi

Second solution I was tested yesterday before you post this answers, was to create trigger BEFORE spawning units with this:

 cond: !alive veh1;   onAct: hint "veh1 destroyed"; anybody; not present; repeatable; size 0; 0; 0; 

 

and after that I spawn vehicle using predefined varName:

_area = markerSize _mrk;   
_nul = _area pushBack markerDir _mrk;   
_nul = _area pushBack ( markerShape _mrk isEqualTo "Circle" );   
_pos = [ _mrk, _area ] call BIS_fnc_randomPosTrigger;   
_randPos = [_pos , 0, 800, 12, 0, 10, 0] call BIS_fnc_findSafePos;   
veh1 = createVehicle ["I_G_Van_02_vehicle_F", _randPos, [], 0, "NONE"]; 
createVehicleCrew veh1;

 

And everything works like charm because there was not need to set areas anymore, triggers was able to monitoring "future" units and vehicles with predefined names 🙂  

 

Thank you guys very much! Hope this will help someone else too like it helped me.

 

  • Like 1

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

×