PDA

View Full Version : Script?


king1hw
07-15-2011, 09:02 PM
I was trying to set up a Historical Day of Battle of Britain events:

The script I would like to fix is:

if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.

First misson starts at 1100, Then the second they come in 2 hours 25 min at 1325 then, a mid evening hit followed by a 2130 to 0530 attack on airfields.

I also need search lights if anyone can help.

PLS

king1hw
07-16-2011, 03:08 AM
Below is a script I cam up with but I guess it is not correct also the hours i am looking for are as follows.

1. mission load 30 sec

2. spaced to load every 2 hours

1100
1325
1530
2130

If any one can help thanks.


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

public class Mission : AMission
{

public override void OnTickGame()
{


if (Time.tickCounter() % 866000 == 216000) // 480 min repeat, 5 min delay.

{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Blue1.mis");
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Red1.mis");

double initTime = 0.0;
Timeout(initTime += 30, () =>
{
GamePlay.gpHUDLogCenter("10 July 1940 1100hrs German attack on shipping convoy!");
});

}

if (Time.tickCounter() % 215999 == 432000) // 480 min repeat, 240 min delay.

{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Blue2.mis");
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Red2.mis");

double initTime = 0.0;
Timeout(initTime += 30, () =>
{
GamePlay.gpHUDLogCenter("10 July 1940 1325hrs German attack on shipping convoy!");
});

}

if (Time.tickCounter() % 431999 == 648000) // 480 min repeat, 480 min delay.

{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Blue3.mis");

double initTime = 0.0;
Timeout(initTime += 30, () =>
{
GamePlay.gpHUDLogCenter("10 July 1940 German bomber attack on sothwest England!");
}

if (Time.tickCounter() % 647999 == 866000) // 240 min repeat, 720 min delay.

{
GamePlay.gpPostMissionLoad("missions/channelv6/BM1/Blue4.mis");

double initTime = 0.0;
Timeout(initTime += 30, () =>
{
GamePlay.gpHUDLogCenter("10 July 1940 2130-0530 German bomber attack o airfields!");
});

}
}

SNAFU
07-18-2011, 01:50 PM
Check this line: delay > than repeat -> Problem, but I am no expert...

if (Time.tickCounter() % 215999 == 432000) // 480 min repeat, 240 min delay
.
.
.if (Time.tickCounter() % 647999 == 866000) // 240 min repeat, 720 min delay.

FG28_Kodiak
07-18-2011, 02:35 PM
if (Time.tickCounter() % 215999 == 432000)
if (Time.tickCounter() % 431999 == 648000)
if (Time.tickCounter() % 647999 == 866000)

You use the modulo operator in c# (http://en.wikipedia.org/wiki/Modulo_operation)
So the result can never be greater or equal the divisor. The result of a modulo operation is the remainder of the division.
For example 9 mod 3 is 0,
10 mod 3 is 1
11 mod 3 is 2
12 mod 3 is 0
13 mod 3 is 1
14 mod 3 is 2
15 mod 3 is 0
you see there will never be a result like three or greater.
Same for your code your if clauses will never became true.

Also check:
double initTime = 0.0;
Timeout(initTime += 30, () =>
{
GamePlay.gpHUDLogCenter("10 July 1940 German bomber attack on sothwest England!");
} //<= missing );


double initTime = 0.0;
Timeout(initTime += 30, ...
doesn't make any sense to me. :/
if you want a 30sek delay simple use
Timeout(30, () =>