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 01-12-2012, 01:24 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Script Help!

I was wondering if I changed this script right:

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

public override void OnTickGame()
{

if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice.mis");
GamePlay.gpHUDLogCenter("The Battle of Britain is about to begin");

double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
});
}

if (Time.tickCounter() % 108000 == 54000) // 108000 = 60 min repeat, 54000 = 30 min delay.
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice1.mis");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Lympne");

}

if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
});
}
}
Reply With Quote
  #2  
Old 01-12-2012, 01:49 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

double initTime = 0.0;

public override void OnTickGame()
{

    if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice.mis");
        GamePlay.gpHUDLogCenter("The Battle of Britain is about to begin");

        Timeout(initTime += 600, () =>
        {
            GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
        });
    }

    if (Time.tickCounter() % 108000 == 54000) // 108000 = 60 min repeat, 54000 = 30 min delay.
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice1.mis");
        GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Lympne");

    }

    if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
    {
        GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");
        GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
    }
}

}
two problems
double initTime = 0.0;
Timeout(initTime += 600, () =>
made not much sense in OnTickGame. Every time the if clause is true initTime is reset to 0, and the message is send after 600 seconds.
initTime +=600 means initTime = initTime + 600;
if you like to send a message 600sec a mission is loaded you can use "Timeout(600, () =>" only
if you like to send a message 600sec a mission is loaded and then after the second time 1200sec then 1800sec you should place the double initTime = 0.0; outside to make it global in the class.

btw this makes more sense:
double initTime = 0.0;
Timeout(initTime, () =>
{
GamePlay.gpHUDLogCenter("Attention Reds");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intercept them");
});
the first message is send directly the second 5 second later and the third 10 seconds, this is nessesary if you try for example these
GamePlay.gpHUDLogCenter("Attention Reds");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
GamePlay.gpHUDLogCenter("Intercept them");
only the last message "Intercept them" is shown.

and there was a
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
}); <======= this is an error
}

Last edited by FG28_Kodiak; 01-12-2012 at 02:01 PM.
Reply With Quote
  #3  
Old 01-12-2012, 02:15 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Is this any better?

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

public override void OnTickGame()
{

if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice.mis");
GamePlay.gpHUDLogCenter("The Battle of Britain is about to begin");

double initTime = 0.0;
Timeout(initTime, () =>
{
GamePlay.gpHUDLogCenter("Attention Airbases");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Hawkinge");
});
Timeout(initTime += 5, () =>
{
GamePlay.gpHUDLogCenter("Intercept them");
});
}

if (Time.tickCounter() % 108000 == 54000) // 108000 = 60 min repeat, 54000 = 30 min delay.
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice1.mis");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Lympne");

}

if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");
GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
});
}
}
Reply With Quote
  #4  
Old 01-12-2012, 02:25 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Yes but

GamePlay.gpHUDLogCenter("Intell German Bomber Raids Heading For Manston/Ramsgate");
}); <====== error

delete the needless
});
at the end of your script, its an error
Reply With Quote
  #5  
Old 01-12-2012, 02:35 PM
king1hw king1hw is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Thanks

Thanks.
Reply With Quote
  #6  
Old 01-12-2012, 07:50 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

If I may interject some simple additions, I have some Basic experience from programming data loggers, but relatively new user to C# scripting myself however some rules apply to all programming all scripters should consider always to keep track of things.

Number 1
Document.

You should always date the lastest mods(keen programmers will even document mod changes in separate txt file)

For this sort of stuff, probably not essential, but do put a "Last Mod date" at the top of your script, maybe with any specific operational notes
ie
//Last update 12/01/2012

If you work with 2 or 3 others and pass the mis set about it is easy to get versions mixed up, a last mod date will help keep this error low.

Documentation of what the programe does helps, and helps development aswell.

2nd major consideration is repeat programming.
It can be far more effective to lower syntax errors by using commonly used components once and pull that item into code elsewhere by it's name.

For example the file path for missions.
if you do this at the start of the script,

string MissionPath = "missions/channelv6/BM1/";

When you call missions you only have to add the mis name
from this
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Practice2.mis");

to this
GamePlay.gpPostMissionLoad(MissionPath + "Practice2.mis");

The advantage is 2 fold, one, if you alter the folder naming you only have to do it once and two(more importantly) you are less likely to make simple syntax errors when adding multi missions to a larger script.
Reply With Quote
  #7  
Old 01-12-2012, 08:27 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

Was feeling keen so ,

I have taken the liberty to take your layout and make it how i would do it.
This is an example of how I would do it, others will do it differently and by know means the be all end of examples.

The example i am attempting to show is input areas for easy programe mods.
I have also added messages to armys(from the collections at 1C)

note how the early part of the setup is for all the mission naming and timing triggers for those missions to load, this means you dont have to alter the core of the script(potential errors)

This layout means you can use the script for all mission sets by altering the the main cs name, file paths and mission names.

You will also probably need to add despawning code for excess planes, something everyone ends up adding.
I again have modified others coding for our own design and need.

by all means try this layout, modify as desired.


Code:
/**mymission.cs**/
//By king1hw
//lastmod 13/1/2012

using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
using System.Diagnostics;
public class Mission : AMission
{ 
    /*=========================================*/

    #region Mission paths and Inputs

    //Mission setup     
    //1mins=60sec=1800ticks 
    
    string MissionPath = "missions/channelv6/BM1/";
    
    string Mis0 = "Practice.mis";//mission name
    string Msg0 = "The Battle of Britain is about to begin";//msg to all
    string Msg0r = "Intell German Bomber Raids Heading For Hawkinge";//to Allies
    string Msg0b = "Auctung Hurricanes !";//to axis
    //note, r value must be bigger than d value
    private int rt0 = 108000;//60 min repeat
    private int dt0 = 18000;//30 min delay.   

    string Mis1 = "Practice1.mis";//mission name 
    string Msg1 = "Bombers!";
    string Msg1r = "Intell German Bomber Raids Heading For Lympne";
    string Msg1b = "Escort Bombers to Lympne!";
    private int rt1 = 108000;//60 min repeat
    private int dt1 = 54000;//50 min delay     

    string Mis2 = "Practice2.mis";//mission name 
    string Msg2 = "Bombers!";//to all
    string Msg2r = "Intell German Bomber Raids Heading For Manston/Ramsgate";//to Allies
    string Msg2b = "Escort Bombers to Ramsgate!";//to axis
    //note, r value must be bigger than d value
    private int rt2 = 108000;//60 min repeat
    private int dt2 = 90000;//90 min delay   

    #endregion  

    /*=========================================*/

    /*=========================================*/

    #region const's and params

    //Msg's To
    private const int All = -1;
    private const int Allies = 1;
    private const int Axis = 2;

    //listen to events from all missions.
    public override void OnBattleStarted()
    {
        base.OnBattleStarted();
        MissionNumberListener = -1;       
    }

    #endregion

    
    /*=========================================*/

    /*=========================================*/

   #region Main mission operation

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

        //sub-mission loaders
        //tick counter mission loader types
        if (Time.tickCounter() % rt0 == dt0)
        {
            GamePlay.gpPostMissionLoad(MissionPath + Mis0);
            ScreenMsg(-1, Msg0);
            Timeout(2.0, () =>
            {
                ScreenMsg(1, Msg0r);
                ScreenMsg(2, Msg0b);
            });
        }

        if (Time.tickCounter() % rt1 == dt1)
        {
            GamePlay.gpPostMissionLoad(MissionPath + Mis1);
            ScreenMsg(-1, Msg1);
            Timeout(2.0, () =>
            {
                ScreenMsg(1, Msg1r);
                ScreenMsg(2, Msg1b);
            });
        }

        if (Time.tickCounter() % rt2 == dt2)
        {
            GamePlay.gpPostMissionLoad(MissionPath + Mis2);
            ScreenMsg(-1, Msg2);
            Timeout(2.0, () =>
            {
                ScreenMsg(1, Msg2r);
                ScreenMsg(2, Msg2b);
            });
        }
    }
  
    #endregion

    /*=========================================*/

    /*=========================================*/    

    #region Messages to army

    /*      Bits with it...  
    private const int All = -1;
    private const int Allies = 1;
    private const int Axis = 2;

    ScreenMsg(-1, "Test to All");
    ScreenMsg(1, "test to red");
    ScreenMsg(2, "test to blue");    
*/
    //object[] parms
    private void ScreenMsg(int army, string msg)
    {
        if (army != -1)
        {
            //Singleplayer (for Testing)
            if (GamePlay.gpRemotePlayers() == null || GamePlay.gpRemotePlayers().Length <= 0)
            {
                if (GamePlay.gpPlayer() != null && GamePlay.gpPlayer().Army() == army)
                    GamePlay.gpHUDLogCenter(null, msg);
            }
            else // Multiplayer
            {
                List<Player> Players = new List<Player>();

                foreach (Player p in GamePlay.gpRemotePlayers())
                {
                    if (p.Army() == army)
                        Players.Add(p);
                }
                GamePlay.gpHUDLogCenter(Players.ToArray(), msg);
            }
        }
        else GamePlay.gpHUDLogCenter(null, msg);
    }

    #endregion

    /*=========================================*/    
}
//note the last bracket wraps Amission

Last edited by Smokeynz; 01-12-2012 at 09:13 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 01:24 PM.


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