Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2012, 03:10 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default HUD Log Script?

Would this work?

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)
{
base.OnTrigger(missionNumber, shortName, active);

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

List<Player> players = new List<Player>();
if (GamePlay.gpPlayer() != null)
players.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
players.AddRange(GamePlay.gpRemotePlayers());

Player[] Reds = players.FindAll(item => item.Army() == 1).ToArray();
Player[] Blues = players.FindAll(item => item.Army() == 2).ToArray();
}

if (("ScoreBlue50".Equals(shortName) && active) && (MissionTimer1M1.Elapsed.Minutes <= 5 ) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The LW succeeded and inflicted heavy damage on Port of Dover");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("ScoreRed51".Equals(shortName) && active) //Trigger 1 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("ScoreRed49".Equals(shortName) && active) //Trigger 2 Message
{
GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if (("Trigger2ALL".Equals(shortName) && active) && (Reds.Length > 0) ) //Trigger 2 Message
{
GamePlay.gpHUDLogCenter(Reds,"German build-up over Calais plotted, heading N!", new object[] { }, 3);
GamePlay.gpGetTrigger(shortName).Enable = false;

}

}

public override void OnTickGame()
{
if (Time.tickCounter() % 864000 == 63000) // 864000 = 8 hour repeat, 63000 = 35 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940_v10/Missionen/Mission2.mis");

if (Reds.Length > 0)
{
GamePlay.gpHUDLogCenter(Reds, "RAF- Fly CAP between Calais and Dover", new object[] { }, 5);
GamePlay.gpLogServer(Reds, "RAF- Fly CAP between Calais and Dover", new object[] { });
}
if (Blues.Length > 0)
{
GamePlay.gpHUDLogCenter(Blues, "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!", new object[] { }, 5);
GamePlay.gpLogServer(Blues, "LW- Meet a flight of HE111's 5000m over Calais.\n In appr. 10 minutes into mission! Escort them to Dover!", new object[] { });
}
}
}

//Section 4 : AI remove

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
if (actor is AiGroundActor)
Timeout(3599, () =>
{
if (actor != null)
{ (actor as AiGroundActor).Destroy(); }
}
);
}

}
Reply With Quote
  #2  
Old 06-28-2012, 04:29 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

No it would not to many errors


I ve corrected your script:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

    public Player[] AllPlayers()
    {
        List<Player> players = new List<Player>();

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

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

        return players.ToArray();
    }


    public Player[] Red()
    {
        List<Player> players = new List<Player>();

        if (AllPlayers() != null)
        {
            players.AddRange(AllPlayers());
            return players.FindAll(item => item.Army() == 1).ToArray();
        }
        return null;
    }


    public Player[] Blue()
    {
        List<Player> players = new List<Player>();

        if (AllPlayers() != null)
        {
            players.AddRange(AllPlayers());
            return players.FindAll(item => item.Army() == 2).ToArray();
        }
        return null;
    }


    public void SendChatMessageTo(Player[] players, string msg, params object[] args)
    {
        if (players == null) return;

        GamePlay.gpLogServer(players, msg, args);
    }


    public void SendScreenMessageTo(Player[] players, string msg, params object[] args)
    {
        if (players == null) return;

        GamePlay.gpHUDLogCenter(players, msg, args);
    }



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

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

        if ("ScoreBlue50".Equals(shortName) && active) //Trigger 1 Message
        {
            GamePlay.gpHUDLogCenter("The LW succeeded and inflicted heavy damage on Port of Dover");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("ScoreRed51".Equals(shortName) && active) //Trigger 1 Message
        {
            GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("ScoreRed49".Equals(shortName) && active) //Trigger 2 Message
        {
            GamePlay.gpHUDLogCenter("The RAF inflicted heavy losses on the LW bombers");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

        if ("Trigger2ALL".Equals(shortName) && active) //Trigger 2 Message
        {
            SendScreenMessageTo(Red(), "German build-up over Calais plotted, heading N!");
            GamePlay.gpGetTrigger(shortName).Enable = false;
        }

    }

    public override void OnTickGame()
    {
        if (Time.tickCounter()%864000 == 63000) // 864000 = 8 hour repeat, 63000 = 35 min delay.
        {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940_v10/Missionen/Mission2.mis");

            SendScreenMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");
            SendChatMessageTo(Red(), "RAF- Fly CAP between Calais and Dover");

            SendScreenMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
            SendChatMessageTo(Blue(), "LW- Meet a flight of HE111's 5000m over Calais. Escort them to Dover!");
        }

    }

    //Section 4 : AI remove

    public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorCreated(missionNumber, shortName, actor);
        if (actor is AiGroundActor)
            Timeout(3599, () =>
                              {
                                  if (actor != null)
                                  {
                                      (actor as AiGroundActor).Destroy();
                                  }
                              }
                );
    }

}
Explanations:

with AllPlayers() you get all players in the game.
with Red() only the red players.
with Blue() only the blue.

if created two method
public void SendChatMessageTo(Player[] players, string msg, params object[] args)
and
public void SendScreenMessageTo(Player[] players, string msg, params object[] args)

the first sends the message to the chat window and the second to the screen, to use them use:

to all players in game
SendChatMessageTo(AllPlayers(), "Your Message");
to the red side
SendChatMessageTo(Red(), "Your Message");
to the blue side:
SendChatMessageTo(Blue(), "Your Message");

if you would like to show variables, points for example you can use:
int redpoints = 50;
SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints);

btw in the string {0} is a placeholder for the first variable, {1} for the second, {2} for the third and so on..
you should take care that the number of placeholders and the number of the variables are the same.
For example this will work:
SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints, overallPoints);

this will also work, but the value of the second variable is not shown
SendChatMessageTo(Red(), "Red Side gets {0} points", redpoints, overallPoints);

but this will get an error:
SendChatMessageTo(Red(), "Red Side gets {0}/{1} points", redpoints);

hope it helps

Last edited by FG28_Kodiak; 06-28-2012 at 06:10 PM.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:15 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.