Jump to content
Sign in to follow this  
epicgoldenwarrior

Trig condition

Recommended Posts

Forgot how to write it

I have end trigger set to 4 units deaths, but if I disable AI and kill the only player, then mission doesnt end.

So !alive and something else

Ty

Share this post


Link to post
Share on other sites

maybe this way? not tested.

if all your playable units is these 4.

{!alive _x} count playableUnits == {!isNull _x} count playableUnits

if not, you have more than 4 playable units, but these 4 specific ones only needed for end check:

{!isNull _x AND !alive _x} count [unitName1, unitName2, unitName3, unitName4] == {!isNull _x} count [unitName1, unitName2, unitName3, unitName4]

Share this post


Link to post
Share on other sites
maybe this way? not tested.

if all your playable units is these 4.

{!alive _x} count playableUnits == {!isNull _x} count playableUnits

if not, you have more than 4 playable units, but these 4 specific ones only needed for end check:

{!isNull _x AND !alive _x} count [unitName1, unitName2, unitName3, unitName4] == {!isNull _x} count [unitName1, unitName2, unitName3, unitName4]

You wouldn't (by chance) know how to use logic (similar to what you have here) to make a trigger that could be used in a "Rearm at ammo box" task would you? I would start a new thread for this, but I am not allowed to apparently... All the tutorials I see about triggers are "Kill target". None of them have been able to show me how to set a task for "Use ammo box" or even "Go to ammo box"... Any advice would be appreciated :)

Share this post


Link to post
Share on other sites
You wouldn't (by chance) know how to use logic (similar to what you have here) to make a trigger that could be used in a "Rearm at ammo box" task would you? I would start a new thread for this, but I am not allowed to apparently... All the tutorials I see about triggers are "Kill target". None of them have been able to show me how to set a task for "Use ammo box" or even "Go to ammo box"... Any advice would be appreciated :)

I think you could use the following to better suit your needs:

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#ContainerOpened

Put the following in the ammobox's init field (where you see "_taskID" put the name/ID of the task):

this addEventHandler
[
"ContainerOpened",
{
	_taskID = "";//<<your task name/ID
	[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;
	(_this select 0) removeEventHandler ["ContainerOpened",0];
}
];

Share this post


Link to post
Share on other sites
You wouldn't (by chance) know how to use logic (similar to what you have here) to make a trigger that could be used in a "Rearm at ammo box" task would you? I would start a new thread for this, but I am not allowed to apparently... All the tutorials I see about triggers are "Kill target". None of them have been able to show me how to set a task for "Use ammo box" or even "Go to ammo box"... Any advice would be appreciated :)

What JShock wrote would work fine i think.

But im guessing that you would have a purpose for the use of rearm, like getting a specific weapon or item, for that i would use the other EH containerClosed

this addEventHandler
[
"[color="#0000FF"]ContainerClosed[/color]",
{
	if ("srifle_LRR_SOS_F" in (weapons player)) then {
		_taskID = "";//<<your task name/ID
		[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;
		(_this select 0) removeEventHandler ["ContainerClosed",0];
	};
}
];

basically this eventhandler triggers when container is closed, and checks if you have taken a specific weapon in this case a sniper rifle, if yes, remove EH and complete task just like JShock wrote, if not do nothing.

Can also switch out weapon with item or whatever like this for example, a mine detector:

this addEventHandler
[
"[color="#0000FF"]ContainerClosed[/color]",
{
	if ("MineDetector" in (items player + assignedItems player)) then {
		_taskID = "";//<<your task name/ID
		[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;
		(_this select 0) removeEventHandler ["ContainerClosed",0];
	};
}
];

Share this post


Link to post
Share on other sites

Wow, you guys rock! I didn't think I would get a response that quick... I will try those out! A couple questions though...

EpicGoldenWarrior - Thank you! I appreciate it!

JShock - The addEventHandler in JShock's code- is the 'ContainerOpened' a predefined event attached to ammo boxes in a config file? I'm curious if there is such an even as 'ContainerClosed' or (for a vehicle maybe...) 'DoorClosed'? If there are these predefined even handlers, are they viewable in the 'Config Viewer'?

Demonized - what is the difference between '(weapons player)' and '(items player + assignedItems player)'? I've looked at their explanations in the wiki, but it is not clear to me what the difference is (when used as you have above)...

Last question - So I will create the task module in the editor, then use your guys' code in the ammo box's init... That's it? The tutorials I've found have like x3 modules (Task, Task State and Task Destination). Do I need all of those modules using what you guys have given me? Do I link/sync the "player" to the task module still?

Share this post


Link to post
Share on other sites
JShock - The addEventHandler in JShock's code- is the 'ContainerOpened' a predefined event attached to ammo boxes in a config file? I'm curious if there is such an even as 'ContainerClosed' or (for a vehicle maybe...) 'DoorClosed'? If there are these predefined even handlers, are they viewable in the 'Config Viewer'?

Yes it's a predefined event attached to all containers (anything you can access via the "Inventory" action), and no you can't view it AFAIK, EH's are so far one of the few things there isn't much info on as it seems they are mostly handled in the engine.

Here are all the available EH's: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

what is the difference between '(weapons player)' and '(items player + assignedItems player)'? I've looked at their explanations in the wiki, but it is not clear to me what the difference is (when used as you have above)...

All units have weapons, items, and magazines so each of the different things Demonzied used is gathering an array of those specific weapons/items/or magazines.

So I will create the task module in the editor, then use your guys' code in the ammo box's init... That's it? The tutorials I've found have like x3 modules (Task, Task State and Task Destination). Do I need all of those modules using what you guys have given me?

You will need to create the task, and set a destination/description/etc. at your leisure, the only module you don't need to worry about is the set state module. When you use the create task module, where you have the Task ID/Task Name use that in the code that we have provided, and then yes, simply put "this addEventHandler..." into the init field of the ammobox. As soon as a player accesses the ammobox the task will be completed and the EH will be removed from the box (so it doesn't re-complete the task every time the box is accessed).

Share this post


Link to post
Share on other sites

So the scripts you guys provided both work great... The only thing I can't figure out is why there is no notification saying that the "Rearm" task is assigned... I load into the mission, and can see the waypoint (that leads to the ammo box), but there is nothing that says the task is available... It DOES show up in the journal...

Then I have a "Set Task State" Module with "State" set to

Create Task (Module)

- Task ID: Task_Rearm

- Title: Rearm

- Descritption: Some text

- Destination: Module Position

- State: Created

Set Task State (Module)

- State: Assigned

Set Task Destination (Module)

Destination: Synchronized object

I have the following linked/synced:

Ammo Box <--> Set Task Destination

Set Task Destination <--> Create Task

Set Task State <--> Create Task

Create Task <--> Player (unit)

And I moved the scripts you guys gave me into a .SQF and have that .SQF script called from my "init.sqf".

Just so you guys know this is my first attempt ever at making a task... lol So I'm sorry if this stuff is common knowledge.

---------- Post added at 23:20 ---------- Previous post was at 23:17 ----------

JSHock - Right on, Thanks for the info! :)

Share this post


Link to post
Share on other sites

Just a quick note, when I removed the "Set Task State" module from the above (after insterting the script you guys provided), the waypoint that led to the ammo box disappeared. And I still haven't figured out how to get the task to show up on the screen (notify the player that the task is assigned). I will make some other tasks and see if any of them notify the player that the task is assigned... Thanks again guys!

---------- Post added at 04:22 ---------- Previous post was at 03:37 ----------

Yeah guys, I am trying to figure out where to put 'player setCurrentTask Task_Rearm;'. I get a script error when I put it right after the script JShock provided. I assume 'setCurrentTask' is what I want to notify the player that they need to complete the task (without having to look at the journal...). Am I wrong? In addition to this, I would love to know how to set the next task after this "Rearm" task is completed... I'll keep searching google. I have found some stuff. I'm having a hard time adapting it to my script.

Here is my script (that is throwing the error):

AmmoSups addEventHandler

[

"ContainerClosed",

{

_taskID = "Task_Rearm";

[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;

(_this select 0) removeEventHandler ["ContainerClosed",0];

}

];

player setCurrentTask Task_Rearm;

-----

And in my init.sqf:

execVM "tasks.sqf"; // Which is the script above

Is the error being displayed because the task (created via editor GUI) not "alive" yet, so 'setCurrentTask' is looking for a task that doesn't exist yet? I tried putting 'sleep 10;' before the 'setCurrentTask' (to see if that would make it work), but no dice.

Share this post


Link to post
Share on other sites

Maybe try putting quotes around the task:

player setCurrentTask "Task_Rearm";

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  

×