Jump to content
denzo

Creating Trigger via Script help

Recommended Posts

Hello,

 

I'm currently trying to write a script that creates a trigger via the radio Alpha channel and that can be activated by the player.

The trigger statemesnts should set another unit (hunter1) into a combatmode Red and also have a line of sideChat from the player.


Here is what I have so far

_trig1 = createTrigger ["EmptyDetector", [0,0,0]]; 
_trig1 setTriggerArea [0, 0, 0, false];
_trig1 setTriggerActivation ["ALPHA", "present", false];
_trig1 setTriggerText "Sniper Cover - Geronimo";
_trig1 setTriggerStatements
[
		"this", 
		"hunter1 setcombatmode "RED"", 
		"player sidechat "OPEN UP!"
	];
};

I keep getting an error message saying I'm missing a "]" but I cant for the life of me figure it out.

 

Any help would be greatly appreciated.

 

Thanks in advance,

Denzo

Share this post


Link to post
Share on other sites

remove the: };   it's unnecessary

  • Like 2

Share this post


Link to post
Share on other sites

_trig1 = createTrigger ["EmptyDetector", [0,0,0]];

_trig1 setTriggerActivation ["ALPHA", "present", false];

_trig1 setTriggerText "Sniper Cover - Geronimo";

_trig1 setTriggerStatements [ "this", "hunter1 setcombatmode 'RED' ; player sidechat 'OPEN UP!' ","" ];

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi and @gc8 thank you both for your response. I dont get the error anymore but unfortunately the radio command doesn't show (0-0-1) to the player and nothing happens.

 

Any input would be greatly appreciated.

 

Regards,

Denzo

Share this post


Link to post
Share on other sites

My code works. As you can compare, i corrected your mistakes. Tested. So, verify where you run it. 😉

  • Like 1

Share this post


Link to post
Share on other sites

This is my code from the script called chat1.sqf

 

hunter1 doWatch player;
hunter1 GetDir player;
hunter1 setBehaviour "Careless";
hunter1 DisableAI "MOVE";


[ 
  ["Local Hunter","Hey! Hey you! You're not one of them are you?",0], 
  ["Gastovski","I'm no-one. I'm not here...",5], 
  ["Local Hunter","Haha! Likewise my friend. Maybe we can help each other? My brother and Uncle were killed by those monsters. I can cover you with my rifle.",15], 
  ["Gastovski","Okay, I'll signal you when to open fire. Got it?",10]   
] spawn BIS_fnc_EXP_camp_playSubtitles; //Displays 4 subtitles, with 5 seconds in between them

sleep 10;

[ 
["Local Hunter","Oh, don't worry about me my friend...Old 'Angelina' here has never let me down. I'll move into postion now. You just radio me when you need cover. Good luck.",20]   
] spawn BIS_fnc_EXP_camp_playSubtitles; //Displays 4 subtitles, with 5 seconds in between them

 
sleep 25;

cutText ["","BLACK OUT",3];

sleep 5;

hunter1 setcaptive False;
hunter1 SetPos [10938.7,1963.45,0.0211945];
hunter1 setunitpos "DOWN";
hunter1 setDir 230.847;

cutText ["","BLACK IN",3];

 "dynamicBlur" ppEffectEnable true;
 "FilmGrain" ppEffectEnable true;
 "dynamicBlur" ppEffectAdjust [10];   
 "dynamicBlur" ppEffectCommit 0;     
 "dynamicBlur" ppEffectAdjust [0.0];  
 "dynamicBlur" ppEffectCommit 2; 
 
[hunter1, player] call BIS_fnc_spotter;

"mat1" setMarkerAlpha 1;
_trig1 = createTrigger ["EmptyDetector", [0,0,0]];
_trig1 setTriggerActivation ["ALPHA", "present", false];
_trig1 setTriggerText "Sniper Cover - Geronimo";
_trig1 setTriggerStatements [ "this", "hunter1 setcombatmode 'RED' ; player sidechat 'OPEN UP!' ","" ];

Thanks again for your help!

Share this post


Link to post
Share on other sites

Your code don't work because you're running:

[hunter1, player] call BIS_fnc_spotter;

 

The Bis_fnc_spotter is not supposed to be called because it runs:

while {alive _sniper && alive _spotter} do {...};  without any chance to stop the report easily until player or spotter die.

You must have to spawn the function:

 

[hunter1, player] spawn BIS_fnc_spotter;

NB: not sure you'll succeed in transmitting a spotting report anyway with this function.

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi thank you very much mate, removing that line of code has worked and now the trigger shows on the radio option.

To give my sniper a little better target acquisition and range, do you have any suggestions? I've heard and tried to use the Reveal command but not having much luck so far.

Thanks again and kind regards,

Denzo

Share this post


Link to post
Share on other sites

The problem is: what do you want to reveal? the target is not clear in your code.

Share this post


Link to post
Share on other sites

Essentially I'd like the Sniper unit to acquire targets in a certain area and cover the player whilst they complete objectives.

 

Ive tried KnowsAbout and Reveal but the sniper only engages the QRF helicopter that appears after the player has been discovered. 

Share this post


Link to post
Share on other sites

I have a similar question so will use this thread and not make a new one. Can't resolve this:

 

_trg= createTrigger ["EmptyDetector", [0, 0, 0], true];
_trg setTriggerArea [0, 0, 0, false, 0];
_trg setTriggerActivation ["NONE", "", false];
_trg setTriggerType "NONE";
_trg setTriggerStatements ["!alive damaged","["6","SUCCEEDED"] call BIS_fnc_taskSetState","R02 removeAction check","systemChat 'working'"];

 

So I need condition: !alive damaged 
and onAct: 1-task to be succeeded   2-remove action from unit and   3-message

damaged is part of the pipeline I need to check for (so it is a regular object). Please any suggestions? Thank's in advance!

Share this post


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

I have a similar question

 

Use code blocks!

 

Your syntax in setTriggerStatements is incorrect - you have double quotes inside double quotes, commas instead of semi-colons, and no deactivation param.

_trg= createTrigger ["EmptyDetector", [0, 0, 0], true];
_trg setTriggerArea [0, 0, 0, false, 0];
_trg setTriggerActivation ["NONE", "", false];
_trg setTriggerType "NONE";  //  "NONE" is default, this line is not needed
_trg setTriggerStatements ["!alive damaged", "['6','SUCCEEDED'] call BIS_fnc_taskSetState; R02 removeAction check; systemChat 'working';", ""];

removeAction also requires a number.

  • Thanks 1

Share this post


Link to post
Share on other sites

This is golden important for me to understand! Thank you bro, working fantastic! 

34 minutes ago, Harzach said:

removeAction also requires a number

but I created one first, with the name "check"?

Share this post


Link to post
Share on other sites
5 minutes ago, Nemanjic said:

but I created one first, with the name "check"?

 

See the link.

 

Quote

Syntax:                 unit removeAction actionID

Parameters:        unit: Object - unit, vehicle or static object

                              actionID: Number - Action ID returned by addAction

Return Value:     Nothing

 

Also, see addAction:

Quote

Return Value:     Number - The added action's ID. Action can be removed with removeAction (see also removeAllActions). IDs are incrementing, the first given action to each unit has the ID 0, the second the ID 1, etc. IDs are also passed to the called script (see the script parameter)

 

Share this post


Link to post
Share on other sites

Understand. The script gives a name but stores it as a number in memory. I don't know how, but this way also works for some reason...

  • Like 1

Share this post


Link to post
Share on other sites
32 minutes ago, Nemanjic said:

this way also works

 

Well, you're absolutely correct. Of course your handle "check" contains the actionID, I don't know what I was thinking. Maybe it's too early.

 

Everyone point and laugh at ol' Harz!

  • Haha 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

×