Jump to content
HonzaVinCZ

Need your help with this script

Recommended Posts

Hey guys, today I have problem with this script. I have been working on this thing for like 4 hours now and can't make it work without problems. I have tried many different ways to solve the described problem below but without effect. 
Basically this script is executed from init field of IED and if player enters proximity of 5 meters around the IED (IED is placed on table), it will create task informing player he found IED factory and it must be destroyed. 
The problem is, there are no errors popping out when mission is started and task is created well as it should but the task missing place and if the IED is destroyed or disarmed, mission is not succeeded.

Btw ignore the _table, I'm working on it.

_ied = _this select 0;
_iedPos = getPosATL _ied;
_table = nearestObject [_iedPos, "Land_WoodenTable_small_F"];

_iedTrig1 = createTrigger ["EmptyDetector", _iedPos , true];
_iedTrig1 setTriggerArea [5, 5, 0, false, 5];
_iedTrig1 setTriggerActivation ["WEST", "PRESENT", false];
_iedTrig1 setTriggerStatements [
	"this",
	"[west, ['iedFactoryTask_'], ['Our forces found enemy IED factory, your task is destroy it.', 'Destroy IED factory'], objNull, 1, 3, true, '', true] call BIS_fnc_taskCreate;
	['iedFactoryTask_', _iedPos] call BIS_fnc_taskSetDestination;
	deleteVehicle thisTrigger;",
	""];

_iedTrig2 = createTrigger ["EmptyDetector", _iedPos , true];
_iedTrig2 setTriggerActivation ["NONE", "PRESENT", false];
_iedTrig2 setTriggerStatements [
	"!alive _ied",
	"['iedFactoryTask_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;
	deleteVehicle thisTrigger;",
	""];

 

Share this post


Link to post
Share on other sites
3 hours ago, HonzaVinCZ said:

['iedFactoryTask_', _iedPos] call BIS_fnc_taskSetDestination;

3 hours ago, HonzaVinCZ said:

"!alive _ied",

Both these references (_iedPos, _ied) will be undefined. Store the values needed on each of the triggers and reference the values from there instead.

Spoiler

_iedTrig1 setVariable[ "iedPos", _iedPos ];
_iedTrig1 setTriggerStatements [
	"this",
	"
		[west, ['iedFactoryTask_'], ['Our forces found enemy IED factory, your task is destroy it.', 'Destroy IED factory'], objNull, 1, 3, true, '', true] call BIS_fnc_taskCreate;
		['iedFactoryTask_', thisTrigger getVariable 'iedPos'] call BIS_fnc_taskSetDestination;
		deleteVehicle thisTrigger;
	",
	""];

//** snip

_iedTrig2 setVariable[ "ied", _ied ];
_iedTrig2 setTriggerStatements [
	"!alive ( thisTrigger getVariable 'ied' )",
	"
		['iedFactoryTask_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;
		deleteVehicle thisTrigger;
	",
	""
];

 

 

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, Larrow said:

Both these references (_iedPos, _ied) will be undefined. Store the values needed on each of the triggers and reference the values from there instead.

  Hide contents


_iedTrig1 setVariable[ "iedPos", _iedPos ];
_iedTrig1 setTriggerStatements [
	"this",
	"
		[west, ['iedFactoryTask_'], ['Our forces found enemy IED factory, your task is destroy it.', 'Destroy IED factory'], objNull, 1, 3, true, '', true] call BIS_fnc_taskCreate;
		['iedFactoryTask_', thisTrigger getVariable 'iedPos'] call BIS_fnc_taskSetDestination;
		deleteVehicle thisTrigger;
	",
	""];

//** snip

_iedTrig2 setVariable[ "ied", _ied ];
_iedTrig2 setTriggerStatements [
	"!alive ( thisTrigger getVariable 'ied' )",
	"
		['iedFactoryTask_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;
		deleteVehicle thisTrigger;
	",
	""
];

 

 

 

Thank you very much, I thought these vaules are undefined in trigger but had no idea how to define them in trigger. So if I want define any values in trigger, I must define them by _trigg setVariable ... ? Also does it work for multiple values? For example if I wanted to store two values, I just write more setVariable ? 

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, HonzaVinCZ said:

For example if I wanted to store two values, I just write more setVariable 

better store everything in one array
like:
trigger setVariable ["MyVariables",[myvar1,myvar2,myvarN],true];

to retrieve:
(trigger getVariable "MyVariables") params ['_myvar1','_myvar2','_myvarN'];

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

So I have solved half of the problem. Now I have problem with mission variable. If I place two objects with same init, the script can't make variable for each object when creating mission ID. Any idea how can I make mission ID variable, please?
 

_ied = _this select 0;
_iedPos = getPosATL _ied;
_table = nearestObject [_iedPos, "Land_WoodenTable_small_F"];

_iedTrig1 = createTrigger ["EmptyDetector", _iedPos , true];
_iedTrig1 setTriggerArea [10, 10, 10, false, 5];
_iedTrig1 setTriggerActivation ["WEST", "PRESENT", false];
_iedTrig1 setVariable[ "ied", _ied ];
_iedTrig1 setVariable[ "iedPos", _iedPos ];
_iedTrig1 setTriggerStatements [
	"this && (thisTrigger getVariable 'ied') mineDetectedBy west && alive (thisTrigger getVariable 'ied')",
	"[west, ['mission_'], ['Our forces found enemy IED factory, your task is to destroy it.', 'Destroy IED factory'], thisTrigger getVariable 'iedPos', 1, 3, true, 'destroy', true] call BIS_fnc_taskCreate;",
	""];

_iedTrig2 = createTrigger ["EmptyDetector", _iedPos , true];
_iedTrig2 setTriggerActivation ["NONE", "PRESENT", false];
_iedTrig2 setVariable[ "ied", _ied ];
_iedTrig2 setVariable[ "iedTrig1", _iedTrig1 ];
_iedTrig2 setTriggerStatements [
	"!alive (thisTrigger getVariable 'ied') && triggerActivated (thisTrigger getVariable 'iedTrig1')",
	"['mission_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;",
	""];

waitUntil {triggerActivated _iedTrig2};
deleteVehicle _iedTrig1;
deleteVehicle _iedTrig2;

 

Share this post


Link to post
Share on other sites
missionNamespace setVariable[ format[ "SomeVarName_%1", someObject call BIS_fnc_netID ], someValue ];

? Is that what you mean. Not quite sure I'm understanding the question.

Share this post


Link to post
Share on other sites
1 hour ago, Larrow said:

missionNamespace setVariable[ format[ "SomeVarName_%1", someObject call BIS_fnc_netID ], someValue ];

? Is that what you mean. Not quite sure I'm understanding the question.


Yes, that is what I'm looking for. But I'm not sure how to use that properly in my script. 

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

×