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 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
  #2  
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
  #3  
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
  #4  
Old 04-27-2011, 04:53 PM
mcler002 mcler002 is offline
Approved Member
 
Join Date: Mar 2011
Location: UK
Posts: 277
Exclamation

Quote:
Originally Posted by FG28_Kodiak View Post
The % is the modulus operator in C# (C, C++ and others)
http://en.wikipedia.org/wiki/Modulo_operation
You trying to blow my brains out haha?
Reply With Quote
  #5  
Old 04-27-2011, 05:21 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Regarding ticks.

1) naryv (dev) said that 30 ticks are around 1 second. Because of that "around", you can get errors.

2) No one said that single tick always takes the same amount of time (if so, lag can screw your timing badly).
Reply With Quote
  #6  
Old 04-27-2011, 07:09 PM
mcler002 mcler002 is offline
Approved Member
 
Join Date: Mar 2011
Location: UK
Posts: 277
Thumbs down

Quote:
Originally Posted by ZaltysZ View Post
Regarding ticks.

1) naryv (dev) said that 30 ticks are around 1 second. Because of that "around", you can get errors.

2) No one said that single tick always takes the same amount of time (if so, lag can screw your timing badly).
Wants 30 ticks to equal 1 seconds on the dot ! or 1 tick to equal one second!

please
Reply With Quote
  #7  
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
  #8  
Old 04-27-2011, 09:36 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

30 ticks ~ 1 sec

Tested this. Works most of the time I think ))

Thanks to all for scripts!

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

public class Mission : AMission
{

    // loads my sub-missions
    public override void OnTickGame()
    {

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

            if (Time.tickCounter() % 72000 == 71999) // 40-40 
            {
                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
			{
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0a.mis");
                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to red airfields in France!"); 
			}

         
    }

    // destroys aircraft abandoned by a player
    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);
    }
    // destroys crushlanded aircraft in 10 minutes
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(600, () =>
        {
            aircraft.Destroy();
        });
    }
}
Runs at Repka server.
Reply With Quote
  #9  
Old 04-28-2011, 08:13 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Valuable note from a developer here

Quote:
Originally Posted by MuxaHuk View Post
With new engine you can create your own game inside our game, for example: you connect to server, and server sends to you completly new user interface (no restriction, but protected by sandbox, no one can read, write or modify your data that out border of game).
New GUI, new rules of game, new score system with ranks and etc.
It can do right now, anyone for their game server.
Of course you need some knowledge of scripting and design. We will assist wherever possible to all comers.
We are working to create examples.

Imagine in the future, each server will be unique, different battles on land, in air or under water, or global war
Anyone wants to write an interface for an online war?

ATM we have some knowledge on the following:
- triggers to check if mission objectives are complete
- scripts to load new mission objectives into a current mission based on triggers
- simple interface to give players new objectives GamePlay.gpHUDLogCenter

Say if enemy tanks are destroyed in a mission, we can move frontline, change one airfield spawnpoint from blue to red and load next mission objectives. But a good interface mod would be extremely useful to show different briefings based on airfields selected, to allow relocating airgroups from airfield to airfield, manage fuel resources, routes of supply convoys, voting for a commander, etc.
There is a great game-mode mod called "Warfare" in ArmA2. I hope we can create something similar and better.
Reply With Quote
  #10  
Old 04-28-2011, 08:34 AM
MuxaHuk MuxaHuk is offline
Approved Member
 
Join Date: Nov 2009
Posts: 19
Default

This sample to use Time.current()
count in seconds from started battle.
Code:
 private double nextMsgTime = 0;
 public override void OnTickGame() {
    base.OnTickGame();
    // Time. current() in seconds from Battle Start
    if ( Time.current() > nextMsgTime ) {
      nextMsgTime = Time.current() + 10.0; // 10 seconds to next message
      GamePlay.gpHUDLogCenter( "Time elapsed (in seconds) = " + Time.current() + ", next message will be at "+nextMsgTime);
    }
  }
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 08:30 PM.


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