Quote:
Originally Posted by TheEnlightenedFlorist
Hi klem, I think the best way to accomplish that would be to use a trigger, action, and a script..........................
The script will look like this:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
{
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
//call base classes OnTrigger method.
base.OnTrigger(missionNumber, shortName, active);
//if the trigger that was called is the trigger that we're looking for
if (shortName.Equals("attackConvoyDelay") && active)
{
AiAction action = GamePlay.gpGetAction("attackConvoy"));
if (action != null)
action.Do();
}
}
So if you put this code into the mission's script file, it will trigger your action whenever your trigger... triggers.
Note that I've named the trigger "attackConvoyDelay" and the action "attackConvoy". You can change them to whatever you want, just make sure they are the same in both the mission and the script.
I hope this helps. 
|
Thought I'd report back on this, I eventually got the following to work:
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
//call base classes OnTrigger method.
base.OnTrigger(missionNumber, shortName, active);
GamePlay.gpHUDLogCenter("shortname = " + shortName);
//if the trigger that was called is the trigger that we're looking for
if (shortName.Equals("AttackConvoy2Delay1"))
{
AiAction action = GamePlay.gpGetAction("AttackConvoy2_1") ;
if (action != null)
{ action.Do(); }
}
}
The '&& active' didn't work because:
1. It seems it should be + not &&
2. You can see I tested for the shortname and of course ("AttackConvoy2Delay1" + active) isn't equal to "AttackConvoy2Delay1". I don't know what 'active' comes back as but it would make the strings unequal.
Also, I put { } around the if(action != null) output as { action.Do(); } although that may not havebeen necessary.
Anyway it works !
Thanks for the help TheEnlightenedFlorist.