PDA

View Full Version : AI triggers/scripts



69th_Spiritus_Mortem
Apr-18-2014, 14:26
Question.

Hans Gruber gave me the great advice to keeping the AI in missions at 30 or below. So here is my question. I have 24 ships for both red and blue so that leaves me 6 AI to play with.

I have one train each side that starts at the start of the mission but want to be able to trigger trains to randomly start at times of the map and/or when aircraft fly into certain areas. I know this has to be possible because the AI aircraft can do this, I don't know how but I've seen it in other missions (with aircraft). So, once a train is destroyed or reaches its last waypoint, I want it to despawn so I can have more trains spawning. That is possible correct? And maybe a couple hints on how to accomplish this as well would be awesome!

Thanks

bolox
Apr-18-2014, 15:47
completely possible to spawn trains via a trigger- in object properties for trai go to actor tab and tick the box 'script spawn or'. Then have a pass thru trigger set by say flying a plane thru, and set the action of the trigger as air spawn group and point it to you train.

In SP this will work 'as is', but as you are running a script, you will have to include the trigger (and action) in your script.


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("56".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("56");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("56");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("264".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("264");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("264");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

shows an example of triggering the spawning of 2 groups by triggers "56" and "264".
The GamePlay.gpHUDLogCenter line in each trigger I use for testing- the trigger name (or whatever) shows on screen when trigger occurs. // out the line after testing.

Despawns I will leave to someone else

Kling
Apr-18-2014, 16:22
AI bombers!!! :p

69th_Spiritus_Mortem
Apr-18-2014, 16:34
Thanks bolox, I must admit doing this for the first time is a bit daunting. I know once I get it to work the first time though I will start catching on!

Thanks again, I will start messing around with it later tonight.

As far as AI bombers, I am tempted to make two missions, exactly the same and on one have AI bombers and let another server take the mission if they want it.