PDA

View Full Version : Script help for Storm of War Campaign


notafinger!
11-04-2012, 10:58 AM
Hi,

I need a script to flash a screen message using a trigger, TTime. I tried with onticktime but there was alot of variation in the timings of the messages between different servers. I need it spelled out for me exactly like you would a child. :-P

FG28_Kodiak
11-04-2012, 12:54 PM
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;

public class Mission : AMission
{

public override void OnBattleStarted()
{
base.OnBattleStarted();

MissionNumberListener = -1;
}



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


if (shortName.Equals("TimerTriggerName"))
{
GamePlay.gpHUDLogCenter("yourMessage");
}


AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));

if (action != null)
{
action.Do();
}
}
}


Change TimerTriggerName and yourMessage to your needs.

notafinger!
11-04-2012, 02:20 PM
Would this be the same for a pass through trigger? Also, I would want the message to be sent to one side only.

For example, I want a group of blue AI bombers that once they pass a certain point a screen message would go for red saying that bombers were inbound.

5./JG27.Farber
11-04-2012, 03:01 PM
Kodiak,

Thanks for your help once again. If I recall there was a piece of script to make this only trigger once, was there not?

FG28_Kodiak
11-04-2012, 04:30 PM
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;

public class Mission : AMission
{
public override void OnBattleStarted()
{
base.OnBattleStarted();

MissionNumberListener = -1;
}


public List<Player> GetAllPlayer()
{
List<Player> players = new List<Player>();

if (GamePlay.gpIsServerSingle())
if (GamePlay.gpPlayer()!= null)
players.Add(GamePlay.gpPlayer());

if (GamePlay.gpRemotePlayers()!= null)
players.AddRange(GamePlay.gpRemotePlayers());

return players;
}

public Player[] BlueSide()
{
if (GetAllPlayer().Exists(item => item.Army() == 2))
return GetAllPlayer().FindAll(item => item.Army() == 2).ToArray();

return null;
}

public Player[] RedSide()
{
if (GetAllPlayer().Exists(item => item.Army() == 1))
return GetAllPlayer().FindAll(item => item.Army() == 1).ToArray();

return null;
}

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


if (shortName.Equals("TimerTriggerName"))
{
GamePlay.gpHUDLogCenter("yourMessage");
}



if (shortName.Equals("RedTriggerName"))
{
if (RedSide()!=null)
GamePlay.gpHUDLogCenter(RedSide(), "yourMessage");
}


if (shortName.Equals("BlueTriggerName"))
{
if (BlueSide() != null)
GamePlay.gpHUDLogCenter(BlueSide(), "yourMessage");
}


if (shortName.Equals("TPassThruTriggerName"))
{
AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));

if (action != null)
{
action.Do();
}

//Add this for deaktivate the tpassthru trigger
GamePlay.gpGetTrigger(shortName).Enable = false;


}
}
}

_79_dev
11-07-2012, 12:53 PM
Hi Kodiak, in this part of script:

if (shortName.Equals("TPassThruTriggerName"))
{
AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));

if (action != null)
{
action.Do();
}

//Add this for deaktivate the tpassthru trigger
GamePlay.gpGetTrigger(shortName).Enable = false;


}

does this:

if (action != null)
{
action.Do();
}


have to be inside "if (shortName.Equals("TPassThruTriggerName"))" ?

does it mean that action will be done only for TPassThruTrigger?

Also deactivating trigger means to disable theme for good or after they invoked?

//Add this for deaktivate the tpassthru trigger
GamePlay.gpGetTrigger(shortName).Enable = false;

FG28_Kodiak
11-07-2012, 01:55 PM
the action is only activated if the trigger is triggered, you can also place it outside if you like.


Also deactivating trigger means to disable theme for good or after they invoked?

All other triggers are deactivated after activation, exept TGroupDestroyed is also deaktivated if the group reached the last waypoint. TPassThru is not deaktivated after activation so you must do it via script.
In my case above the passthru tigger must be activated once. But you can disable a trigger at any time. For example you have two condition one win and one fail.
Maybe the win condition is to destroy groundtargets and you use a TGroundDestroy trigger and the fail condition you must make it before the time is over. To avoid the activation of the second trigger you can disable it.
Example:

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


if (shortName.Equals("TimerTriggerName"))
{
GamePlay.gpHUDLogCenter("You failed Time is over");
GamePlay.gpGetTrigger("GroundDestroyed").Enable = false;
}

if (shortName.Equals("GroundDestroyed"))
{
GamePlay.gpHUDLogCenter("You win you destroyed the Groundtargets");
GamePlay.gpGetTrigger("TimerTriggerName").Enable = false;

}
}

Osprey
11-09-2012, 06:32 AM
Gruber, the script that I emailed you had pass through events triggering successfully. Did this not work?