Jump to content
Sign in to follow this  
Tonmeister

Trigger Question

Recommended Posts

Hi guys,

I'm trying to create a random ied from a number of civ vehicles positioned on the editor. Within each vehicle init i've put;

nul=[this] execVM "carbomb.sqf" 

carbomb.sqf is

_object =  _this select 0;
_loc = getPos _object;
_bomb = "R_57mm_HE" createVehicle _loc;
_value = random 100;

if (_value <25) then {
_trg=createTrigger["EmptyDetector", _loc]; 
_trg setTriggerArea[15,15,0,false];
_trg setTriggerActivation["WEST","PRESENT",false];
_trg setTriggerStatements["this", "_bomb", ""]; 
};

as a test if _value is set to <250, then all my vehicles on the map will have ieds when they run this script on initialisation.

My problem however, is with the TriggerActivation of the ied.

When I run the test I'm finding that if WEST is not in the TriggerArea, all the vehicles explode on startup... I dont understand why.

I must be reading this incorrectly, but I from what I understand from the code, the trigger should only activate once WEST is detected within a 15m radius of the vehicle...

:confused:

any advice would be great!

thanks

ok I think this is causing some problems at the start of the script..

_bomb = "R_57mm_HE" createVehicle _loc;

and now its here;

_trg setTriggerStatements["this", "bomb = "R_57mm_HE" createVehicle _loc", ""];

hmmm

Edited by Ebolavirus

Share this post


Link to post
Share on other sites

Hi, the line :

_bomb = "R_57mm_HE" createVehicle _loc;

makes the ammunition explodes as soon as it is created, at the "_loc" position. The "createvehicle" command should be used within triggerstatement, in the on activation part of it.

Share this post


Link to post
Share on other sites

Hi ProfTournesol,

thanks, yes got it, but for some reason the triggerstatement doesnt seem to like it, or my formatting is incorrect.

maybe _bomb means nothing to the machine... Should I create a marker at the vehicle? Dunno, I'm thinking work arounds now,

Share this post


Link to post
Share on other sites
Hi guys,

I'm trying to create a random ied from a number of civ vehicles positioned on the editor. Within each vehicle init i've put;

nul=[this] execVM "carbomb.sqf" 

carbomb.sqf is

_object =  _this select 0;
_loc = getPos _object;
_bomb = "R_57mm_HE" createVehicle _loc;
_value = random 100;

if (_value <25) then {
_trg=createTrigger["EmptyDetector", _loc]; 
_trg setTriggerArea[15,15,0,false];
_trg setTriggerActivation["WEST","PRESENT",[color="Red"]false[/color]];
_trg setTriggerStatements["this", "_bomb", ""]; 
};

as a test if _value is set to <250, then all my vehicles on the map will have ieds when they run this script on initialisation.

My problem however, is with the TriggerActivation of the ied.

When I run the test I'm finding that if WEST is not in the TriggerArea, all the vehicles explode on startup... I dont understand why.

I must be reading this incorrectly, but I from what I understand from the code, the trigger should only activate once WEST is detected within a 15m radius of the vehicle...

:confused:

any advice would be great!

thanks

ok I think this is causing some problems at the start of the script..

_bomb = "R_57mm_HE" createVehicle _loc;

and now its here;

_trg setTriggerStatements["this", "bomb = "R_57mm_HE" createVehicle _loc", ""];

hmmm

try with:

_trg setTriggerActivation["WEST","PRESENT",true];

Share this post


Link to post
Share on other sites

ok tried it using true, but no dice. This argument sets the trigger to repeating if true. I'm sure this whole

_trg setTriggerStatements["this", "bomb = "R_57mm_HE" createVehicle _loc", ""];

stuff is somehow incorrect. I've tried using hints and I can see the triggers activating and deactivating but as soon as I want to createVehicle nothing happens, weird... and painfully so...

Share this post


Link to post
Share on other sites

Well, it seems that the trouble is the "_pos" variable which isn't understood out of the script scope. One solution could be to create the bomb at the position of the first soldier that triggers the trigger, thanks to the "thislist" command which returns the array of the units that activates the trigger.

Then :

_trg setTriggerStatements["this", "bomb = 'R_57mm_HE' createVehicle getpos (thislist select 0)", ""];

Another thing : add "-showscripterrors" as a parameter at the end of your ArmA2 shortcut target to see scripting errors on the screen ingame (helpful when debugging).

Share this post


Link to post
Share on other sites

ah yes interesting, well that worked, nice thinking. I think you are correct, the pos of the vehicle is outside the scope of the trigger, but I'm thinking in order to attach the bomb to the car, I may have to use something like triggerAttachVehicle, which I'm not sure of how to, or maybe create a marker which is created by that trigger on the position of the car...

Is there a way to get the scope of the cars position into the trigger?

ahh also thanks for the info on the debugger, didn't know 'bout that!

Share this post


Link to post
Share on other sites

okie,

so I'm still bamboozaled by this problem. I'm wondering if anyone may know how I could get the trigger to createVehicle at the trigger location through the above script.

If I do this manually through the editor it works peachy, but as soon as I try to implement it through the script it seems to be a whole 'nother ball game.

many thanks

edit: oh and ProfTournesol's suggestion is quite cool as a work around, but its a bit disconcerting visually, as its as if my own men are carrying the ieds.

Edited by Ebolavirus

Share this post


Link to post
Share on other sites

Well, you could use the nearestobject command to create the bomb at the nearest car from the soldier. Something like :

_trg setTriggerStatements["this", "bomb = 'R_57mm_HE' createVehicle getpos (thislist select 0) nearestObject 'Car'", ""];

Just have to find the correct config name of the car, but it should inherit from the "car" class.

Share this post


Link to post
Share on other sites

ah thanks ProfTournesol, I'll give it a go.

with the (thislist select 0) statement, obviously thislist is a global variable right? So 0 being the first element in the array.... where ever that array is held.

Is thislist some kind of placeholder for the trigger... or the entire datascape of objects?

thanks

Share this post


Link to post
Share on other sites
ah thanks ProfTournesol, I'll give it a go.

with the (thislist select 0) statement, obviously thislist is a global variable right? So 0 being the first element in the array.... where ever that array is held.

Is thislist some kind of placeholder for the trigger... or the entire datascape of objects?

thanks

Thislist is the array of the all units triggering the trigger, inside the trigger's scope. So thislist select 0 is the first (alive) unit of this array. If you wanna use this array outside of the trigger scope (ie outside of the on activation or deactivation lines of the given trigger) in a script or in another trigger for example, you can name it this way in the on activation line :

my_beautiful_trigger_list = thislist

or simply name the trigger (such as My_beautiful_trigger in the naming line) and access the array with the command "list", such as

list My_Beautiful_Trigger

then the first unit of the array will be accessed that way :

list My_Beautiful_Trigger select 0

If the trigger is set to repeatedly and whatever side "present" or "spotted", the array will constantly be updated.

Share this post


Link to post
Share on other sites

ProfTournesol - pardon if this is now wrong at all - i just came back after a 3/4 years

break but i seem to remember from old ofp that arraya = arrayb would cause that

if you change arrayb afterwards arraya was changed aswell then.

I really can't say anything for sure about that now but it's just that feeling i got

that there was something about this 4/5 years ago. ;)

~S~ CD

Share this post


Link to post
Share on other sites
ProfTournesol - pardon if this is now wrong at all - i just came back after a 3/4 years

break but i seem to remember from old ofp that arraya = arrayb would cause that

if you change arrayb afterwards arraya was changed aswell then.

I really can't say anything for sure about that now but it's just that feeling i got

that there was something about this 4/5 years ago. ;)

~S~ CD

True, that's why when "thislist" is updated, "my_beautiful_trigger_list" is also updated which is very useful.

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
Sign in to follow this  

×