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 05-14-2011, 09:16 PM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Thanks for the thread Ataros. Very helpful.

Is there a reason you guys are using "ticks" to measure time. C# has a few different ways of keeping track of time. Here's an example using the Stopwatch class. Don't get me wrong, modulus is great but this stopwatch is probably more accurate and it's a heck of a lot more readable.

Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
using System.Diagnostics;   //contains Stopwatch class

public class Mission : AMission
{
    int timesRun = 0;   //count how many times sub-mission has been run

    Stopwatch timer = new Stopwatch();   //timer. Counts... time...

    public override void OnTickGame()
    {
        
        //if sub-mission has never been run, run it
        if (timesRun == 0) 
        {
            //start timer
            timer.Start();

            GamePlay.gpPostMissionLoad("missions/Multi/MyMissions/mission1.mis");
            timesRun++;

            // prints message on screen after mission load
            GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");
        }

        //if five or more minutes have elapsed since the timer was started, run sub-mission
        if (timer.Elapsed.Minutes >= 5)
        {
            GamePlay.gpPostMissionLoad("missions/Multi/MyMissions/mission1.mis");
            timesRun++;

            GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");

            //reset timer to zero and restart it
            timer.Restart();
        }
    }
}
Reply With Quote
  #2  
Old 05-14-2011, 09:58 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Quote:
Originally Posted by TheEnlightenedFlorist View Post
Don't get me wrong, modulus is great but this stopwatch is probably more accurate and it's a heck of a lot more readable.
The problem with external timing is that you will get time according to your system and not to game. Simulation can slow down because of lag, and external timer won't take that into account, i.e. briefing can say that bombers start at 9:00, however you may see that start greatly off its planned time (according to game clock), if you use external timer.

If you want to get rid of counting ticks, you can use this:
Code:
	//Runs once, when mission is loaded
	public override void Init(maddox.game.ABattle battle, int missionNumber)
	{
		base.Init(battle,missionNumber);
		//Planned missions
		MissionLoader(30,10,"missions/Multi/Dogfight/bombers1.mis");  // 10s from main mission start and repeatedly every 30s
		MissionLoader(100,60,"missions/Multi/Dogfight/bombers2.mis"); // 60s from main mission start and repeatedly every 100s
	}
	
	public void MissionLoader(int period, int offset, string mission)
	{
		if (offset > 0)
			Timeout(offset, () => {MissionLoader(period,0,mission);});
		else
			{
				GamePlay.gpPostMissionLoad(mission);	
				Timeout(period, () => {MissionLoader(period,0,mission);});		
			}
	}

Last edited by ZaltysZ; 05-15-2011 at 07:09 AM.
Reply With Quote
  #3  
Old 05-15-2011, 11:19 PM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Oh, I'm sorry. I thought that you guys wanted to base the intervals that missions run on on real time not on game time.
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 06:10 PM.


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