Jump to content
Sign in to follow this  
Phantom Six

AI Not Spawning On Trigger

Recommended Posts

I made a trigger where if a unit in a camp is killed, a message would go up and say that an alarm has been triggered and it would exec my AI spawn script and order them to move to a certain waypoint.

Trigger

Condition: (!alive a1) OR (!alive a2) OR (!alive a3) OR (!alive a4) OR (!alive a5) OR (!alive a6) OR (!alive a7) OR (!alive a8) OR (!alive a9) OR (!alive a10) OR (!alive a11) OR (!alive a12) OR (!alive a13) OR (!alive a14) OR (!alive a15) OR (!alive a16) OR (!alive a17) OR (!alive a18) OR (!alive a19) OR (!alive a20) OR (!alive a21) OR (!alive a22) OR (!alive a23) OR (!alive a24) OR (!alive a25) OR (!alive a26) OR (!alive a27) OR (!alive a28) OR (!alive a29) OR (!alive a30) OR (!alive a31) OR (!alive a32) OR (!alive a33) OR (!alive a34) OR (!alive a35) OR (!alive a36) OR (!alive a37) OR (!alive a38) OR (!alive a39) OR (!alive a40) OR (!alive a41) OR (!alive a42) OR (!alive a43) OR (!alive a44) OR (!alive a45) OR (!alive a46) OR (!alive a47) OR (!alive a48) OR (!alive a49) OR (!alive a49) OR (!alive a50) OR (!alive a51) OR (!alive a52) OR (!alive a53)

On Activation: null = this execVM "snipertango.sqf"

(At first I used [30,0] exec "snipertango.sqf")

I tried testing this and when I shot an enemy and he dies. The words that tells me that I triggered the alarm appear but the AI won't spawn. Can someone help me? Here is the snipertango.sqf

_point1 = getmarkerPos "awp1-1";// marker names

_point2 = getmarkerPos "awp1-2";

group1 = createGroup EAST;

for [{_i = 0}, {_i <= 11}, {_i = _i + 1}] do

{

_unit= group1 createUnit ["TK_Soldier_SL_EP1","TK_Soldier_GL_EP1","TK_Soldier_MG_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1",[(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 0, "form"];

};

_awp1-1 = group1 addWaypoint [ _point1, 10];

_awp1-1 setWaypointType "SAD";

_awp1-1 setWaypointStatements ["true", ""];

_awp1-1 setWaypointBehaviour "COMBAT";

_awp1-1 setWaypointCombatMode "RED";

_awp1-2 = group1 addWaypoint [_point2, 10];

_awp1-2 setWaypointType "SAD";

_awp1-2 setWaypointStatements ["true", ""];

_awp1-2 setWaypointBehaviour "COMBAT";

_awp1-2 setWaypointCombatMode "RED";

Share this post


Link to post
Share on other sites

createUnit create a single unit, for group look into BIS_fnc_spawnGroup

---------- Post added at 06:01 PM ---------- Previous post was at 05:36 PM ----------

PS: you need the function module on map for the BIS_fnc_spawngroup

Share this post


Link to post
Share on other sites

You have !alive a49 twice.

There should be some easier way, like making an array out of a List, out of the soldiers in a trigger. Not exactly sure how you could do that and check for any individual's damage.

You have ORs for 53 (54) soldiers there; if you are to employ this more than once, or for a larger group, it might be prudent to run the script initially and with a sleep/waituntil embedded. That way Arma only checks at X second intervals, instead of on a frame basis. See http://forums.bistudio.com/showthread.php?t=113181

Share this post


Link to post
Share on other sites

group1 = createGroup EAST;

_leader = group1 createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_leader = leader group1;

wp1 = group1 addWaypoint [position awp1-1, 0];

wp1 setWaypointType "SAD";

wp1 setWaypointBehaviour "COMBAT";

wp1 setWaypointCombatMode "RED";

wp1 setWaypointFormation "Delta";

wp1 setWaypointSpeed "NORMAL";

wp2 = group1 addWaypoint [position awp1-2, 0];

wp2 setWaypointType "SAD";

wp2 setWaypointBehaviour "COMBAT";

wp2 setWaypointCombatMode "RED";

wp2 setWaypointFormation "Delta";

wp2 setWaypointSpeed "NORMAL";

that's the .sqf now but umm... how do i do the x_array part, I quite don't get it.

nul=[] execVM "snipertango.sqf"

They still haven't spawn, I'm kind of stuck, if I can get a rubric that would probably be helpful.

Share this post


Link to post
Share on other sites

No soldiers will spawn if a soldier of that side does not already exist. Maybe that's your problem?

If that is your problem.....place an EAST soldier on the map and delete it right away by placing "deleteVehicle this" in the units init.

Edit:-

...also what's going on here in this position array?

_leader = group1 createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "Squad1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

The x position comes from marker "Squad1" and the y position comes from "pawn1".....is this intentional?

Edited by twirly
Added text

Share this post


Link to post
Share on other sites

Twirly is right, you can also just add this at the top of the script group1 = createCenter East;

You will also have a problem with wp1 = group1 addWaypoint [position awp1-1, 0]; and wp2 = group1 addWaypoint [position awp1-2, 0]; you will need to change this bit awp1-1 and awp1-2 to awp1_1, awp1_2 or they won't be valid names.

There are also a couple of easier ways to check for dead units, as hinted at by SCAJolly you place a trigger over all the units you wish to check for (they don't need names)

If they are BLUFOR you would set the trigger like this

Blufor

present

not repeating

name trig

on act

who = list trig

then in your other trigger instead of !(alive a1) ect just use {alive _x} count who< 5

Or

just place your main trigger over the units

and place this in the cond, name the rigger trig1

west countSide list trig1 <50

That will work as long as they don't leave the trigger area.

Or

Create an array of all units you wish to check, you will have to name the units

who = [a1,a2,a3,a4] ect placed in a game logic or unit init.

Then in your main trigger {alive _x} count who < 50

Edited by F2k Sel

Share this post


Link to post
Share on other sites
....you can also just add this at the top of the script group1 = createCenter East;

@F2k ....Thanks for that. I needed it also. I was searching for it. Maybe this time it will stick in my friggin' head.

Share this post


Link to post
Share on other sites

Oh, thanks twirly, I was copying some other example for a group spawn from someone. Thanks F2K but ummm, when I use the method where you do this...

If they are BLUFOR you would set the trigger like this

Blufor

present

not repeating

name trig

on act

who = list trig

then in your other trigger instead of !(alive a1) ect just use {alive _x} count who< 5

Nothin happen. I try the alive unit one I did earlier again... only one guy spawns but he only stands there. Here's my script now.

group1 = createCenter East;

group1 = createGroup EAST;

_leader = group1 createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_unit = group1 createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

_leader = leader group1;

wp1 = group1 addWaypoint [position awp1_1, 0];

wp1 setWaypointType "SAD";

wp1 setWaypointBehaviour "COMBAT";

wp1 setWaypointCombatMode "RED";

wp1 setWaypointFormation "Delta";

wp1 setWaypointSpeed "NORMAL";

wp2 = group1 addWaypoint [position awp1_2, 0];

wp2 setWaypointType "SAD";

wp2 setWaypointBehaviour "COMBAT";

wp2 setWaypointCombatMode "RED";

wp2 setWaypointFormation "Delta";

wp2 setWaypointSpeed "NORMAL";

Share this post


Link to post
Share on other sites

your second line has an error.

_unit = group1 createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];

it's missing a " infront of the first pawn1

As for the trigger you would have it over the group of units you want to check. There was a slight mistake it should be 50 not 5, I was only using a few units to test with.

If they are BLUFOR you would set the trigger like this

Blufor

present

not repeating

name trig

on act

who = list trig

then in your other trigger instead of !(alive a1) ect just use {alive _x} count who< 50

That would go in a second triggers condition and that would be the one that calls the main script.

It would have worked with 5 but only when 46 of them were dead.

Share this post


Link to post
Share on other sites
Thanks F2k, they spawned now. Now I need to get them to go their waypoints.

Your waypoints are fine, I'm using game logics for the positions named awp1_1 and awp1_2

To make it easier to see them move try these commands in the Waypoint for testing.

wp1 setWaypointType "MOVE";

wp1 setWaypointBehaviour "SAFE";

BTW do you have -showScriptErrors in your short cut as that would have shown the missing quote error.

Share this post


Link to post
Share on other sites

Oh, that would be useful. Thanks. Well, I used the custom launcher and put -showScriptErrors and this is what I see.

error.png

Edited by Phantom Six

Share this post


Link to post
Share on other sites

I get the exact same message if the two game logic names are spelt incorrectly.

Share this post


Link to post
Share on other sites

I got it working, thanks for the help guys. This seems to do the trick

_wp0 = group1 addWaypoint [getMarkerPos "awp1_0", 0];

_wp0 setWaypointType "SAD";

_wp0 setWaypointBehaviour "COMBAT";

_wp0 setWaypointCombatMode "RED";

_wp0 setWaypointFormation "Wedge";

_wp0 setWaypointSpeed "NORMAL";

_wp0 setWaypointStatements ["true", ""];

_wp1 = group1 addWaypoint [getmarkerpos "awp1_1", 0];

_wp1 setWaypointType "SAD";

_wp1 setWaypointBehaviour "COMBAT";

_wp1 setWaypointCombatMode "RED";

_wp1 setWaypointFormation "Wedge";

_wp1 setWaypointSpeed "NORMAL";

_wp1 setWaypointStatements ["true", ""];

---------- Post added at 09:34 PM ---------- Previous post was at 07:47 PM ----------

one last question, if I'm triggering multiple spawns and waypoints... do I have to make another script and cannot put it all on the same one?

Share this post


Link to post
Share on other sites

The answer is yes and no, this script will make multiple groups and they will follow what the script tells them to do.

However oustide the script only the last group created will have the group name group1.

I'm not sure how you can change the group name each time, nothing I do seems to work.

Sorted it now, this will give multiple groups, you just need to name each group by entereing in the execvm.

// null=[red] execvm "code.sqf"
// null=[mygroup] execvm "code.sqf"


private "_group";
_groupname = _this select 0;
call compile format ["%1 = creategroup EAST; _group = %1",_groupname];



_leader = _group createUnit ["TK_Soldier_SL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _group createUnit ["TK_Soldier_GL_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_unit = _group createUnit ["TK_Soldier_EP1", [(getMarkerPos "pawn1") select 0,(getMarkerPos "pawn1") select 1,0], [], 3, "FORM"];
_leader = leader _group;

_wp0 = _group addWaypoint [getMarkerPos "awp1_0", 0];
_wp0 setWaypointType "SAD";
_wp0 setWaypointBehaviour "COMBAT";
_wp0 setWaypointCombatMode "RED";
_wp0 setWaypointFormation "Wedge";
_wp0 setWaypointSpeed "NORMAL";
_wp0 setWaypointStatements ["true", ""];

_wp1 = _group addWaypoint [getmarkerpos "awp1_1", 0];
_wp1 setWaypointType "SAD";
_wp1 setWaypointBehaviour "COMBAT";
_wp1 setWaypointCombatMode "RED";
_wp1 setWaypointFormation "Wedge";
_wp1 setWaypointStatements ["true", ""];

Edited by F2k Sel

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  

×