Jump to content

Recommended Posts

Hello,

If only I could use "else if" that would have made it easier for me.

Anyways, I am making a multiplayer mission in which I need an AI to make a decision. I am trying to figure out how to make the AI decide where to go based on :

1. The vehicle is alive.

2. The distance from the vehicle.

I currently have 2 vehicles which I placed for the AI to plan and escape with, if they are alive. First condition has to be that if both vehicles are alive or not destroyed the AI will then determine which one is the closest and move to that, and then get into it and drive it to an escape object which is place in the body of water. By the way the two vehicles are a chopper, and a boat. Also this AI is randomly spawned using a grouped marker at 3 locations, also he is moved with the setPos inside the buildings.

The second option is if 1 vehicle is destroyed and another is active, the AI would be able to determine which one it is and move to it to try and escape, to the escape object placed in the body of water.

If both vehicles are destroyed the AI stays in his position and disableAI"Move" is applied to him.

I would like to keep this in a trigger in game, but if an outside script is the only solution, that is okay.

I have tried this in my triggers but did not work:

Trigger 1:
Blufor, Once, Detected by OPFOR

Cond:
this && (alive GomezHeli || alive GomezBoat)

Activation:
if(alive GomezHeli) then{Gomez doMove position GomezHeli; waitUntil{Gomez distance GomezHeli<5}; Gomez moveInDriver GomezHeli; Gomez doMove position escape} else{boatTrigger setTriggerActivation ["WEST", "EAST D", false]};

Trigger 2 (Trigger Name: boatTrigger):
None(Changed by the previous trigger to Blufor), Once, Detected by Opfor

Cond:
this && (alive GomezHeli || alive GomezBoat)

Activation:
if(alive GomezBoat) then{Gomez doMove position GomezBoat; waitUntil{Gomez distance GomezBoat<5}; Gomez moveInDriver GomezBoat; Gomez doMove position escape} else{Gomez disableAI "Move"};

Any help would be greatly appreciated.

unknownx9

Share this post


Link to post
Share on other sites

I'd push all that to a script, then use a switch command.

switch (true) do {
    case (!alive boat && alive heli): {
         // send them to the heli
    };
    case (!alive heli  && alive boat): {
         // send them to the boat
    };
    case (alive heli && alive boat) : {
         // check distances to both and send to closer.
    }
    default {
         // both objects are dead, panic!
    };
};

Share this post


Link to post
Share on other sites

I was thinking of using a "switch" but did not know what to put in the condition field.

Will give it a try, thank you for your reply.

unknownx9

Share this post


Link to post
Share on other sites

Learned that trick from Big Dawg KS the other week, a switch (true) lets you use conditions in each of the case statements.

Share this post


Link to post
Share on other sites

Here is what I have added and going to try it now, please let me know if I have anything wrong, thanks.

switch (true) do 
{
    case (!alive boat && alive heli): 
 {
         Gomez doMove position GomezHeli;
	  waitUntil{Gomez distance GomezHeli<5}; 
	  Gomez moveInDriver GomezHeli; 
	  Gomez doMove position escape;
    };
    case (!alive heli  && alive boat): 
 {
         	Gomez doMove position GomezBoat;
		waitUntil{Gomez distance GomezBoat<5}; 
		Gomez moveInDriver GomezBoat;
		Gomez doMove position escape;
    };
    case (alive heli && alive boat) : 
 {
         if(Gomez distance GomezBoat < Gomez distance GomezHeli)then
	  {
		Gomez doMove position GomezBoat;
		waitUntil{Gomez distance GomezBoat<5}; 
		Gomez moveInDriver GomezBoat;
		Gomez doMove position escape;
	  }
	  else
	  {
		Gomez doMove position GomezHeli;
		waitUntil{Gomez distance GomezHeli<5}; 
		Gomez moveInDriver GomezHeli; 
		Gomez doMove position escape;
	  };
    };
    default 
 {
         Gomez disableAI "Move";
    };
};

Share this post


Link to post
Share on other sites
switch (true) do 
{
    case (!alive boat && alive heli): 
 {
         Gomez doMove position GomezHeli;
	  waitUntil{Gomez distance GomezHeli<5}; 
[color="Red"]                  Gomez assignasDriver GomezHeli;
	  [Gomez] orderGetIn true;[/color] 
	  Gomez doMove position escape;
    };
    case (!alive heli  && alive boat): 
 {
         	Gomez doMove position GomezBoat;
		waitUntil{Gomez distance GomezBoat<5};
                      [color="Red"]Gomez assignasdriver GomezBoat; 
		[Gomez] orderGetIn true;[/color]
		Gomez doMove position escape;
    };
    case (alive heli && alive boat) : 
 {
         if(Gomez distance GomezBoat < Gomez distance GomezHeli)then
	  {
		Gomez doMove position GomezBoat;
		waitUntil{Gomez distance GomezBoat<5}; 
                       [color="Red"]Gomez assignasdriver GomezBoat;
		[Gomez] orderGetIn true;[/color]
		Gomez doMove position escape;
	  }
	  else
	  {
		Gomez doMove position GomezHeli;
		waitUntil{Gomez distance GomezHeli<5}; 
                       [color="Red"]Gomez assignasdriver GomezHeli;
		[Gomez] orderGetIn true; [/color]
		Gomez doMove position escape;
	  };
    };
    default 
 {
         Gomez disableAI "Move";
    };
};

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  

×