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
  #41  
Old 04-27-2011, 02:11 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Disable fuel pump doesn't help, the engines wouldn't stop. Fuel pump is only nessesary at altitudes above 2500m.

You are right IsAirborne() can be very usefull in this script.

Corrected Version

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

public class  Mission : AMission
{
	public void _DespawnEmptyPlane(AiActor actor)
	{
					if (actor == null)
						{ return;}

					Player[] Players = GamePlay.gpRemotePlayers();
					
					bool PlaneIsEmpty = true;
					
					foreach (Player i in Players)
					{	
						if ((i.Place() as AiAircraft) == (actor as AiAircraft))
							{ 
								PlaneIsEmpty = false;
								break;
							}
					}
					
					if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
						{ 
							  
							  (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
							  (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
							  (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
							  (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                 //for 2mots
                (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);
                
						     //then wait 10min
                 Timeout(600.0, () => {	
						         (actor as AiAircraft).Destroy(); 
						     });	
							
					  }
					  else if (PlaneIsEmpty)
					  {
					  	  (actor as AiAircraft).Destroy();
					  }
	}

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
         	_DespawnEmptyPlane(actor);
    }
}

Last edited by FG28_Kodiak; 04-27-2011 at 02:37 PM.
Reply With Quote
  #42  
Old 04-27-2011, 02:56 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Thanks again!
Copied to my mission script. Is it OK?

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

public class Mission : AMission
{


    public override void OnTickGame()
    {

            if (Time.tickCounter() % 90000 == 18000) // 50-10 60-10 108000 == 18000
            {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmGroundv1_0.mis");
            GamePlay.gpHUDLogCenter("Protect friendly shipping in the channel near France!");
            }

            if (Time.tickCounter() % 72000 == 72000) // 40-40 45-35 81000 == 63000
            {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0.mis");
				GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to blue airfields!"); 
			}
        
            if (Time.tickCounter() % 72000 == 45000) // 40-25 45-45 81000 == 81000
			{
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0a.mis");
                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to red airfields in France!"); 
			}

         
    }

    public void _DespawnEmptyPlane(AiActor actor)
    {
        if (actor == null)
        { return; }

        Player[] Players = GamePlay.gpRemotePlayers();

        bool PlaneIsEmpty = true;

        foreach (Player i in Players)
        {
            if ((i.Place() as AiAircraft) == (actor as AiAircraft))
            {
                PlaneIsEmpty = false;
                break;
            }
        }

        if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
        {

            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
            //for 2mots
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);

            //then wait 10min
            Timeout(600.0, () =>
            {
                (actor as AiAircraft).Destroy();
            });

        }
        else if (PlaneIsEmpty)
        {
            (actor as AiAircraft).Destroy();
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        _DespawnEmptyPlane(actor);
    }

}
Reply With Quote
  #43  
Old 04-27-2011, 03:22 PM
mcler002 mcler002 is offline
Approved Member
 
Join Date: Mar 2011
Location: UK
Posts: 277
Default More to learn...

Quote:
Originally Posted by Ataros View Post


if (Time.tickCounter() % 72000 == 45000) // 40-25 45-45 81000 == 81000

[/CODE]
Dude, what do those numbers do?

I have noticed that the time counter isnt 100% accurate - the planes appears a couple of minutes soon than what they should... bug?

Ross
Reply With Quote
  #44  
Old 04-27-2011, 03:32 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Destroys crashlanded aircraft in 5 seconds ))
Code:
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(5, () =>
        {
            aircraft.Destroy();
        });
    }
Have to figure out how to use it though.

Quote:
Originally Posted by mcler002 View Post
Dude, what do those numbers do?
Just notes for myself on timing. Not processed by program.

if (Time.tickCounter() % 72000 == 72000) is wrong probably.

Last edited by Ataros; 04-27-2011 at 03:34 PM.
Reply With Quote
  #45  
Old 04-27-2011, 04:15 PM
mcler002 mcler002 is offline
Approved Member
 
Join Date: Mar 2011
Location: UK
Posts: 277
Unhappy What the?

someone help me here :S
Main map starts at 05:00 - like the rest of the "sub" maps


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

public class Mission : AMission
{


    public override void OnTickGame()
    {

            if (Time.tickCounter() %  54000 == 18000)
            {
                
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBb1.mis");
				GamePlay.gpHUDLogCenter("Intel: 4x He115's, Heading for Convoy!"); 
			}
		        
            if (Time.tickCounter() %  99000 == 36000)
            {
                
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBb2.mis");
				GamePlay.gpHUDLogCenter("Intel: 8x He111's, Heading for Lympne!"); 
			}

            if (Time.tickCounter() %  108000 == 27000)
            {
                
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBr1.mis");
				GamePlay.gpHUDLogCenter("Intel: 12xBlenheim, Heading for Calais Marck!"); 
			}

    }

   public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        Timeout(1, () =>
        {
            AiAircraft CurAircraft = player.Place() as AiAircraft;
            AiAircraft PrevAircraft = actor as AiAircraft;
            if (CurAircraft != PrevAircraft)   
                { (actor as AiAircraft).Destroy(); }
        });
    }

}
But actual results...

He 115 starts at 05:09 - 1 min fast
Blenheim starts at 05:13 - 7 min fast!!
He 111 starts at 05:18 - 3 min late?!

Whats going on :S :S :S
Reply With Quote
  #46  
Old 04-27-2011, 04:18 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Quote:
Originally Posted by Ataros View Post
if (Time.tickCounter() % 72000 == 72000) is wrong probably.
This will always result in FALSE. % gives you a remainder of division (Остаток от деления), so this operation will always give result greater or equal to 0 and less than divisor (assuming positive numbers).

Code:
if (Time.tickCounter() % 72000 == 0)
Will be TRUE every time tickCounter() returns multiple of 72000 (i.e. every time 72000 ticks pass, when counted from 0: 72000, 2*72000, 3*72000 and so on).

Last edited by ZaltysZ; 04-27-2011 at 04:21 PM.
Reply With Quote
  #47  
Old 04-27-2011, 04:20 PM
mcler002 mcler002 is offline
Approved Member
 
Join Date: Mar 2011
Location: UK
Posts: 277
Question Some timings ive got

Check attachment...

Is the last comment for me or :S
Attached Files
File Type: zip my mission timings CORRECT.zip (11.1 KB, 7 views)

Last edited by mcler002; 04-27-2011 at 04:40 PM. Reason: Noticed a mistake from human error :D
Reply With Quote
  #48  
Old 04-27-2011, 04:30 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by ZaltysZ View Post
Code:
if (Time.tickCounter() % 72000 == 0)
Will be TRUE every time tickCounter() returns multiple of 72000 (i.e. every time 72000 ticks pass, when counted from 0: 72000, 2*72000, 3*72000 and so on).
And if I want to delay the first execution by 71999 ticks it should be like follows?
Code:
if (Time.tickCounter() % 72000 == 71999)
Thanks a lot for your help.
Reply With Quote
  #49  
Old 04-27-2011, 04:52 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

The % is the modulus operator in C# (C, C++ and others)
http://en.wikipedia.org/wiki/Modulo_operation

Last edited by FG28_Kodiak; 04-27-2011 at 05:16 PM.
Reply With Quote
  #50  
Old 04-27-2011, 04:53 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Quote:
Originally Posted by Ataros View Post
And if I want to delay the first execution by 71999 ticks it should be like follows?
Code:
if (Time.tickCounter() % 72000 == 71999)
Yes. The general formula is:

Code:
if (Time.tickCounter() % A == B)
where:

A = 30 * amount second of seconds you want to repeat something
B = 30 * amount second you want to offset (delay) from beginning of mission

I suppose you want to delay something by 72000 and not by 71999 (although the difference is only 1/30s). So:

Code:
if (Time.tickCounter() % 72000 == 0 &&  Time.tickCounter()-72000==0)
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:32 PM.


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