Jump to content
Gunter Severloh

Civilian AI does not set off trigger with civilian present prior to joining my group

Recommended Posts

Hey guys, having a small issue here maybe someone can clear up my confusion or help me figure out why this isn't working?

Heres my situation, I'm trying to update one of my missions and add a new task where you rescue a scientist.

 

In my test mission for this:

Blufor solder is the player.

Civilian Scientist is the AI to be rescued.

 

Civilian is named pow1

Surrounding the civilian is an area trigger its about 5,5,2 in size.

Trigger Activation

[pow1] join (group player);  
pow1 globalChat "Thanks for saving me!";

Trigger is set to any player present.

So when i enter the trigger the Scientist joins my group, and is under my command, so np there.

===========

Next

I have a task setup that is synced to an area trigger.

The Trigger is synced to the task and the settings for the trigger are:

Activation:    Civilian

Activation Type:   present

 

In the trigger's activation box is the following:

hint "The scientist has been rescued!"; [pow1] joinSilent grpNull; deletemarker "sc1";

So apon entering the trigger to which i send him to by command, a hint pops up, the task goes off, the civilian gets dismissed from my

group which is what i want, and i have a marker with a question mark that gets deleted, as in the mission im adding this too, you need to locate the scientist so

the marker is kinda of a visual que on the map that you need to look for aside the task.

=============

 

Problem

The problem is when the civilian enters the trigger nothing happens, and this is only occurs when  the trigger is set to:

Activation:    Civilian

Activation Type:   present

if i set it to Activation Type:   anybody   

the trigger fires off, i get the task complete and all is good, so this has me confused,

 

So my question

is the civilian changing from a civilian faction to a blufor faction when he joins my group?

Or what is happening that the trigger is not firing off?

 

Is there another workaround to this rather then not having the trigger set to anyone, as in the mission which is SP/Coop

i dont want anyone setting off the trigger accidentally.

 

Share this post


Link to post
Share on other sites

I'm not up on this stuff as some of the fellas around here  including yourself but....

 

"is the civilian changing from a civilian faction to a blufor faction when he joins my group?"

 Pretty sure that this is what is happening Gunter, You can verify by going to zeus and seeing if the pow changes colour from purple to blue.

 

"Is there another workaround to this rather then not having the trigger set to anyone, as in the mission which is SP/Coop"

You could activate a trigger after the pow's release.

 

 

 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

The civilian may have changed factions, but it still carries its variable name "pow1." Make it the owner of the trigger? Set trigger to Anyone with condition pow1 in thislIst? You have a few options.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for the replies guys, much appreciated!

2 hours ago, fawlty said:

Pretty sure that this is what is happening Gunter, You can verify by going to zeus and seeing if the pow changes colour from purple to blue. 

Wont work in Zeus because the two units weren't placed by zeus and wont show up, however i did go to spectator and it confirms it

that the civilian is indeed switching to Blufor!

 

   Another test i just tried was setting the

Activation:    Blufor

Activation Type:   present

and the trigger fired off, so both confirm that the civilian is being changed to the blufor faction.

2 hours ago, fawlty said:

You could activate a trigger after the pow's release.

That could work, but in the mission im updating, once you locate the scientist and hes under your command, the fact is where you are

at in the AO is your in enemy territory, so the goal is to return the scientist back to base to this area where the trigger is at and complete the

task of rescuing him, so you literally have to travel with him and return him back to safety.

2 hours ago, Harzach said:

Make it the owner of the trigger? Set trigger to Anyone with condition pow1 in thislIst?

That did the trick!

I tried this myself to be sure it wasn't just anyone that would enter the trigger could set it off, so i entered it and nothing happened

after the Civilian joining my group, i sent him into the trigger and the trigger went off. Works!

   Thanks fellas for your insights into this, if i had checked to see why the civilian were changing factions earlier, i probably would have saved

myself some time and headache, goes to show even vets to this are still learning. Cheers!

  • Like 2

Share this post


Link to post
Share on other sites

Have another question related to this.

Having the area trigger which only fires when the scientist enters it and completes the task i have set for it,

how can i fail that task if the scientist gets killed?

 

I tried creating a task synced to the current task set as failure, problem is its not going to work as there is nothing to check to see that he is alive, and

the current trigger is only checking for presence, i tried adding a trigger syncing it to the task with !alive pow1; in the condition but it dont work.

 

It works on its own trigger but not in relation to the main task which is to rescue him, then i tried this  !alive pow1; pow1 in thislist;

in the condition of the same area trigger all i got was:  type bool, nothing expected

    Any idea on how to fail this task if the scientist gets killed?

Share this post


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

Have another question related to this.

Having the area trigger which only fires when the scientist enters it and completes the task i have set for it,

how can i fail that task if the scientist gets killed?

 

I tried creating a task synced to the current task set as failure, problem is its not going to work as there is nothing to check to see that he is alive, and

the current trigger is only checking for presence, i tried adding a trigger syncing it to the task with !alive pow1; in the condition but it dont work.

 

It works on its own trigger but not in relation to the main task which is to rescue him, then i tried this  !alive pow1; pow1 in thislist;

in the condition of the same area trigger all i got was:  type bool, nothing expected

    Any idea on how to fail this task if the scientist gets killed?

 

Not quite following but how about creating a loop while/do, to keep tabs on the scientist's lifestate and assigning a variable to each which could be carried over to Trigger

Share this post


Link to post
Share on other sites

About the only time you got to worry about the scientist is when you locate and free him, and he joins your group, and

 your moving him back to base for the rescue and task complete or tell him to sit tight.

Other then maybe if you accidentally drop a mortar in the area he may be in, but the scientist will be randomly moved to 1 of 9 markers

among 7 compounds at every mission start.

1 hour ago, froggyluv said:

how about creating a loop while/do, to keep tabs on the scientist's lifestate and assigning a variable

It sounds like a good idea but have no idea what it looks like put together or even how to implement it,  why i go to Rydygier alot for certain things, lol

        The existing task for the scientist is basically saying, locate and bring back the scientist, when you do, theres a trigger back at base

he walks into that trigger and you get a task complete, at the same time he leaves your command.

 

     I had figured since i used !alive quite a bit in the past that it could check to see if the scientist is alive,

but have no idea on how to make it work with the existing task which already has a trigger connected to it and is set

only for the presence of the scientist.

Share this post


Link to post
Share on other sites

@Gunter Severloh
Sync a Task State to the task for the rescue and the sync a Trigger to the Task State and set the Task State to Failed.

in the Cond inside trigger you write !alive pow1.

So if the Pow1 dies then task fails.

That how do it in my missions.

  • Like 1

Share this post


Link to post
Share on other sites

Not a big trigger user here, but I am thinking whether you could "emulate" the activation condition of the trigger yourself. Since the trigger is checking its condition every (roughly) 0.5 seconds, you could set the trigger's activation condition to None (this will make the trigger go off only when the custom condition is met) and write your own condition, which will also be checked every (roughly) 0.5 seconds.

This way, you could set the condition to something like

/*
 * First alternative where you can call a
 * a script to set the task to "failed" when the
 * POW is killed.
 */
if(alive pow1) then {
	if(pow1 inArea thisTrigger) then {
		true; // If POW in trigger activate
	else {
		false; // Do not activate
	};
} else {
	// Call script to set the task to failed and delete the trigger
	[] execVM "taskFailed.sqf";
};

/*
 * Second alternative where you activate the
 * trigger and in there you perform the
 * necessary actions to set the task to failed.
 */
if(alive pow1) then {
	if(pow1 inArea thisTrigger) then {
		true; // If POW in trigger activate
	else {
		false; // Do not activate
	};
} else {
	true; // Activate if POW died
              // (Must check inside the activation for "alive pow1")
};

I have provided two alternatives. The condition checks are identical, it's just the approach when the POW dies that changes. It is up to personal preferences at to which one is best. Both have their pros and cons. In the first, you will have to take care of the trigger inside the "taskFailed.sqf" script, while in the second you will have to perform the "alive pow1" check to see whether you have to set the task to failed or succeeded. The second one might seem better but your activation code will be cluttered with code to handle both outcomes (failure/success). Again, it's up to you to pick the one that suits your needs and taste best (and to be honest, I am sure you'll manage to find a better way to handle it than what I provided 😂).

 

Please do note though that this code is NOT TESTED, so treat with caution.

 

================================================== EDIT ==================================================

After pierremgi's post (two posts below this). I changed the code (had thisList in it but it seems that it is empty when the condition is None).

Edited by ZaellixA
Corrected script
  • Like 1

Share this post


Link to post
Share on other sites

Thanks to both your replies and information, i will try both, and get back to you, im running out of time atm about bedtime so

when i get up i'll get right on it and let you guys know, i really appreciate the help in this, i will add you guys to the credits

list in the mission for your support too! Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

About CIVILIAN PRESENT in a trigger.

Every snake, rabbit, and probably bee, butterfly will trigger it .

Topping on the cake:   same for empty vehicle, crate, house and any edited object (empty),...  sun chair,... weapon on ground...

 

Cherry on the cake: same for ANYBODY PPRESENT

Just test that on activation:

 hint str (thisList apply {typeOf _x})    🤪

YEEPEE!

 

The workaround is to use the trigger for its area, and not a preset condition but your condition. So, set it to none, none, forget thisList (always [] here) and write something like:

(pow1 inArea thisTrigger && alive pow1)


 

Spoiler

 

Note: for people willing the keep a CIVILIAN (or ANYBODY) PRESENT trigger, you can add an extra condition like : this && (thisList findIf {_x isKindOf "CAManbase" or _x isKindOf "landVehicle"} > -1) and grab the list by : thisList select {_x isKindOf "CAManbase" or _x isKindOf "landVehicle"}

But, truly, it's a pain in the b... to avoid rabbits, snakes (they are type of "man", "allVehicles" !!!),... or empty objects that are true in vehicles (command) Ugly!

 

 

 

  • Like 3

Share this post


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

pow1 inArea thisTrigger && alive pow1

 

It won't change performance, but it's definitely "cleaner" which appeals to my particular type of OCD.

 

As for the civilian's "alive" status, you could also just add a Killed EH to him, then set the task to fail when it fires.

  • Like 3

Share this post


Link to post
Share on other sites
10 hours ago, pierremgi said:

pow1 inArea thisTrigger && alive pow1

This wont work for the setup i have with the trigger, i show you a screenshot of my test mission of what i was

doing and what i did which works with what i had in mind.

9E566EF1B9A44DCBBEC3EA784627D1FA90591D66

Heres how it works:

 

1. Scientist is named pow1

2. In the scientists init box i have the following code:

this setVariable ["NoRandom",true,true]; 
pow1 setpos (getMarkerPos (selectRandom ["a1","a2","a3", "a4", "a5", "a6", "a7", "a8", "a9"])); 
 
 _newpos = pow1 modelToWorld [1,-2,0]; 

3. i have 9 markers named a1 - a9 (not seen in the screenshot).

4. Then i have a small trigger which the scientist is standing in atm,  in the trigger is the following:

Activation:  any player

Activation type:  present

Condition: this

Activation:   [pow1] join (group player);   pow1 globalChat "Thanks for saving me!";

 

5. 3 tasks are setup, 1 for the create task with the task info ef,. rescue the scientist, 1 succeeded task, 1 failed task.

6. 1 Trigger synced to the failed task seen at the top.

7. Inside the trigger for the trigger for the failed task is this:

Condition:  !alive pow1

 

8. Large trigger in front of the building (this is essentially how its setup in my mission im updating, idea is to locate the scientist in the enemy AO and bring him back to base

and since the scientist is under your command in your squad when you rescue him in the AO, you bring him back to base and send him into this trigger).

So the trigger has the following:

Activation:    Anybody

Activation Type:   Present

Condition:  pow1 in thislist;

Activation:   hint "The scientist has been rescued!"; [pow1] joinSilent grpNull; deletemarker "sc1";

===========

 

    Heres something i need a better way of doing, maybe i need to name 1 trigger and put all the marker names in it but

basically the trigger the player walks into to rescue the scientist where the scientist then joins the player's group,

the trigger per marker is this:

Quote

 

4. Then i have a small trigger which the scientist is standing in atm,  in the trigger is the following:

Activation:  any player

Activation type:  present

Condition: this

Activation:   [pow1] join (group player);   pow1 globalChat "Thanks for saving me!";

 

So i have 9 triggers per marker that the scientist gets randomly moved too, my question is, instead of having 9 triggers, cant i just use one trigger that will somehow

check or fire off when the player comes within range of the scientist once the player has found him?

 

Otherwise it works as is for what i wanted to accomplish.

  • Like 1

Share this post


Link to post
Share on other sites

Move the trigger along with the scientist at the beginning?

  • Like 1

Share this post


Link to post
Share on other sites

Hmm 🤔never thought of that, nice Harzach,  good idea but how using the same code to move the scientist and adding the trigger name

in there dont work, unit and trigger entities arent the same... material so to speak ones an object whereas the other is an invisible entity.

    Would have to be along the lines of    trig getpos of pow1  or something along those lines with the word trig being the trigger name.

Share this post


Link to post
Share on other sites
this setVariable ["NoRandom",true,true]; 

_pos = (getMarkerPos (selectRandom ["a1","a2","a3", "a4", "a5", "a6", "a7", "a8", "a9"])); 

pow1 setPos _pos;
trig setPos _pos;
 
_newpos = pow1 modelToWorld [1,-2,0]; 

What are you doing with the position _newpos?

 

  • Like 1

Share this post


Link to post
Share on other sites

@Gunter Severloh It might actually work the same way as if you linked a civilian to a BLUFOR group in editor. The civilian will become a hostile to OPFOR and will fire weapons and so on. The trigger won't detect him as "civilian" anymore.

Share this post


Link to post
Share on other sites
2 hours ago, Harzach said:

What are you doing with the position _newpos?

I had used  _newpos = pow1 modelToWorld [1,-2,0]; in a mission i put together for ravage, so i borrowed the code from that.

      The whole code in the scientists init box is from that, i had about 30 markers being used unlike 9 for this one on some maps, and basically the player would start

somewhere along with a pickup truck almost out of fuel at the start of the mission, it was used because of the terrain.

 

Not fully understanding the code i had a rough idea of what it was for, i dont recall been a few years but i think on Ravage thread someone helped

me sort out some code with an idea to start randomly all over a map, and that code im guess was to make sure the player didn't end up in the air,

or below the terrain, or something else i believe thats what it means.

      For my current mission i been updating other then some slight hills, the scientist gets moved to 1 of 9 locations, but each location is inside a building

my guess is the newpos part moves him while the modeltoworld enables the pow1 to "work" with the spot he is moved to at the start.

The code there dont work btw, i get invalid expression.

1 hour ago, Kalle M. said:

It might actually work the same way as if you linked a civilian to a BLUFOR group in editor.

Once a civilian becomes part of a blufor group hes no longer civilian at least when he joins the group.

            Civilian at the start is set captive, and made hostage so hes moved to one of the nine markers with those and sitting

there with his hands behind his back until you get 2m from him and he joins your group, then from there you need to think how your going to get

this guy back to base without getting him or you killed to complete the task, so the mission is a real thinking man's game with the idea of best time to

employ certain tactics and the available assets you can call on.

 

     So do i release the hostage when i locate him and then go and risk us both getting killed, or do i clear the way, mark

where hes at and then come back for him when its clear and then go from there thats what the player has to decide, no hand holding in this mission.

============

Think i will just stick with what i have as it works, i very much appreciate the help, you guys saved me alot of time and i learned some things,

will add you all to my credits for the mission. Cheers!

  • Like 2

Share this post


Link to post
Share on other sites

You can attach the trigger to pow1:     yourtrg attachTo [pow1,[0,0,0]]
and teleport pow1.

  • Like 2

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

×