View Single Post
  #5  
Old 05-24-2011, 02:56 PM
klem's Avatar
klem klem is offline
Approved Member
 
Join Date: Nov 2007
Posts: 1,653
Default

Quote:
Originally Posted by TheEnlightenedFlorist View Post
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.
__________________
klem
56 Squadron RAF "Firebirds"
http://firebirds.2ndtaf.org.uk/



ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU
Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders
Reply With Quote