PDA

View Full Version : spawn airgroups?


David198502
09-27-2011, 09:54 AM
just cannot get airplanes to spawn.
in the FMB i want to spawn a group of planes after another is destroyed, but nothing happens.:confused:
after i destroyed the first group, the second will just not appear.
can someone please explain how to do that?

SNAFU
09-27-2011, 10:34 AM
The Trigger-Action was broken a few patchs ago. You have to activate the Action by script.

First define Triggers as usual (Groupdead Triggers must have same Name as the Spawn-Action) and then implement the following into your script:


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("YourTriggerName".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("YourActionName"); //same as YourTriggerName
GamePlay.gpLogServer(null, " Your Trigger was triggered ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}


You can also work around the trigger by script methods, but that`s another story. ;)

David198502
09-27-2011, 11:15 AM
thx but doesnt seem to work...

salmo
10-04-2011, 12:59 PM
... and doesn't seem to work for me either (spawning a bomber group every x seconds) :(

SNAFU
10-04-2011, 01:43 PM
Mmh, you are using a script like the following and named your triggers and actions accordingly, also in the script? (Triggername = Actionname)


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


public class Mission : AMission
{
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("YourTriggerName".Equals(shortName) && active) //Edit "YourTriggerName"
{
AiAction action = GamePlay.gpGetAction("YourActionName"); //same as "YourTriggerName"
GamePlay.gpLogServer(null, " Your Trigger was triggered ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}


At least that works for me in multiplayer enviroment. Maybe you test you map in multiplayer hosting as server? Some triggers do not work on a dedicated server, but I understood that is not your question.

Ataros
10-04-2011, 02:11 PM
If you do not use any script FMB triggers would work if name of a trigger and action are the same.

If you have any script working with your mission you have to add a trigger section to it to allow triggers to work. The most simple one is
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);
AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
if (action != null)
action.Do();
}



Your FMB trigger and action must have the same name if you use this script.

Check if both action and trigger are defined correctly (trigger type, airgroup, etc.) and saved in FMB.

SNAFU
10-04-2011, 02:19 PM
I don´t know if it was fixed in the Beta, but the action (spawn airgroup) of triggers was broken, some patches ago. So you have to use a script to link triggers and actions. I supposed you set the trigger and the action in the FMB. :cool:

salmo
10-04-2011, 03:27 PM
I don´t know if it was fixed in the Beta, but the action (spawn airgroup) of triggers was broken, some patches ago. So you have to use a script to link triggers and actions. I supposed you set the trigger and the action in the FMB. :cool:

That's what I've done. The info window reports that the group has spawned in my test, indicating that the script has executed, but alas no planes actually spawned :(

Here's the script I used, the trigger & the spawn airgroup (after 60s) actions are both named 'Dorniers'...

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("Dorniers".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Dorniers"); //same as YourTriggerName
GamePlay.gpLogServer(null, " German bomber group spawned ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}

Ataros
10-04-2011, 03:38 PM
after 60s

:confused: How is this possible?

Try without the delay.

FG28_Kodiak
10-04-2011, 03:50 PM
Made a sample mission, the Doniers spawn after 10sec.

Ataros
10-04-2011, 05:31 PM
Sorry after reading the OP post I was thinking the trigger is airgroup destroyed, not TTime 10. My bad :)

... and doesn't seem to work for me either (spawning a bomber group every x seconds) :(

But anyway, I think it is not possible to repeat spawn with a trigger only. It is better to use ontickgame method in a script described for instance in link #2 in my sig.

salmo
10-05-2011, 11:18 AM
Sorry after reading the OP post I was thinking the trigger is airgroup destroyed, not TTime 10. My bad :)



But anyway, I think it is not possible to repeat spawn with a trigger only. It is better to use ontickgame method in a script described for instance in link #2 in my sig.

Thankyou Ataros. I'm aiming to spawn a group of Dorniers every XX min, so I've created the main mission (has all ground objects etc), and a sub-mission with only the Dornier bombers flight & waypoints. Here's my script so far which seem to be working, but I'm a little unsure of the timing parameters & their meaning ...

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

public class Mission : AMission
{

public override void OnTickGame()
{
// Timing parameters
int Repeat = 108000; // ?? repeat mission every 60 min
int Dlay = 18000; // ?? launch Dorniers flights every 10 min

// load the Dornier's bombers sub-mission every ??10 min
if (Time.tickCounter() % Repeat == Dlay) // what does repeat parameter do? Dlay seems to spawn bombers every 10min OK
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Test/Dorniers.mis");

// prints message on screen after mission load
GamePlay.gpHUDLogCenter("Another wave of German bombers heading towards Lympne airfield");

// prints message on screen in 10 minutes / 600 seconds
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Another wave of German bombers heading towards Lympne airfield");
});

}
}
}

FG28_Kodiak
10-05-2011, 11:37 AM
if (Time.tickCounter() % Repeat == Dlay) //


Ok % is the Modulo operator in c#

Repeat has a value of 108000
Dlay has a value of 1800

So your mission would load first after 10min and then every 60min.

for every 10min you should use
if (Time.tickCounter() % 1800 == 1799)
so it waits ~10min and then repeat the doniers every 10min
30ticks are around 1sec, but can vary (so often 34Ticks is a second).

salmo
10-05-2011, 03:58 PM
Thankyou Kodiak, I've got it now.

David198502
10-15-2011, 10:20 AM
im still not able to spawn a single plane after another one gets destroyed!!!
why the heck has this to be sooo hard to achieve...damn
triggers dont seem to work and the scripts showed here in this thread dont seem to work either if i copy and paste them in the mission cs file.

David198502
10-15-2011, 11:13 AM
thats what i did so far...

FG28_Kodiak
10-15-2011, 11:47 AM
I've tested your mission, the problem is that the trigger is never triggered (testet it with different numbers of planes and plane types), then remove the trigger and made a new one but no effect, may be a bug in the Beta. Normaly your code should work.

So I made a workaroung without trigger.


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


public class Mission : AMission
{

public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnAircraft");

if (actor != null && MakeNewAircraft != null)
{
if (actor.Name().Contains("BoB_RAF_F_FatCat_Early.000"))
{

MakeNewAircraft.Do();
GamePlay.gpHUDLogCenter("New Enemy spawned!");
}
}
}
}

What you need:
The script, a action in your Mission (i labled it "SpawnAircraft"), the name of the plane to destroy.
A new Airplane spawns after the previous is shoot down, you can improve it by adding a Planecount, etc.

David198502
10-15-2011, 02:00 PM
thx Kodiak, really kind of you!and finally this works!
-if i understand it correctly, if i shoot the hurri, another one spawns, and i could repeat that to infinity???
i ask this, cause so far i tried the mission several times, and after i shot down the 4th hurri, no plane will spawn anymore....
i also expierence many game crashes, i think mainly when im near the spawning aera..

-can i just increase the number of the hurris without changing the script?i did and made a flight of six hurris, and after i shot down the 4th, the message "New Enemy spawned!" appeared, but unfortunately my game crashed.

-how do i determine the name of the plane???
-whats the planecount you mentioned to improve the mission???

i know i have many questions and im really greatful for your help.

David198502
10-15-2011, 02:33 PM
ok tried again and answered some question by myself...its possible to increase the number of the planes...
after i let the hurri spawn further away and let it start on an airfield, the came doesnt crash anymore when spawning.

but it seems that after i shot down the first hurri, another spawns as expected, but after a few seconds, another one spawns without obvious reason....
happens everytime.so if i begin with one hurri, after i shot it down, i will have suddenly two enemies.
if i increase the the number from the beginning, the same thing seems to happen....but im still not sure when the respawn does take place in that situation....do i have to shoot down the first plane of the flight to trigger a respawn, or do i have to kill all planes of the flight??

Osprey
10-15-2011, 02:44 PM
From what I understand so far is that if you set up triggers in the FMB then they are no longer working and you have to use a script to fire them?

I am trying to airspawn a fighter escort when the bomber group pass through their sector, otherwise they all spawn together and the fighters are off into the distance and gone.

I have set a trigger for Blue when they enter the fighter area but they are spawning in on map start. I am selecting File>Play mission in order to test.

FG28_Kodiak
10-15-2011, 02:49 PM
thx Kodiak, really kind of you!and finally this works!
-if i understand it correctly, if i shoot the hurri, another one spawns, and i could repeat that to infinity???
i ask this, cause so far i tried the mission several times, and after i shot down the 4th hurri, no plane will spawn anymore....

Hm normaly yes, seems i misinterpreted your posting.


i also expierence many game crashes, i think mainly when im near the spawning aera..

Could also be the steppe map, must try this but on my computer i didn't have a crash. May be its better to spawn an other group of planes not the same again and again.


-can i just increase the number of the hurris without changing the script?i did and made a flight of six hurris, and after i shot down the 4th, the message "New Enemy spawned!" appeared, but unfortunately my game crashed.

It depens which aircraft you shot down. BoB_RAF_F_FatCat_Early.000 is the leading Airplane. You can change the "actor.Name().Contains("BoB_RAF_F_FatCat_Early.000")" in
actor.Name().Contains("BoB_RAF_F_FatCat_Early") so every plane in the goup counted.


-how do i determine the name of the plane???

The easy way with external view, you have the option "show object name" if enabled the game shows you the name you need.


-whats the planecount you mentioned to improve the mission???

At the moment a new plane spawns after the leader plane is shot down. But
you can improve the script. For example:

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


public class Mission : AMission
{
int planecounter = 0;


public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnAircraft");

if (actor != null && MakeNewAircraft != null)
{
if (actor.Name().Contains("BoB_RAF_F_FatCat_Early"))
{
planecounter++;

if (planecounter >= 2)
{
MakeNewAircraft.Do();
GamePlay.gpHUDLogCenter("New Enemy spawned!");
}
}
}
}

}

Now you must shot down two planes of the group, before other spawns.



i know i have many questions and im really greatful for your help.

No problem.

David198502
10-15-2011, 04:23 PM
hey Kodiak!thx again will try that out immediately.....

but yet i have another question:i want to build a mission, where london gets continually bombed....i mean really destroyed, that if one flies over the city, one can see the damage everywhere...for that i used the script called "scripting for dummies" i think where one can create a main mission and 3submissions which will load after a certain time...it works, but now i have the problem that my He's stay on the map, and every ten minutes 30new He's spawn to bomb the city...so after 30minutes the mission grinds my pc to a halt because i have over 100 planes in the air...so i want the He's to dissapear again after they reached a certain waypoint...is that possible???and how??
this is what i have so far...

FG28_Kodiak
10-15-2011, 05:11 PM
It's possible, the easy way.


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


public class Mission : AMission
{

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{
case "bob:Aircraft.Ju-87B-2":
case "bob:Aircraft.Ju-88A-1":
case "bob:Aircraft.He-111H-2":
case "bob:Aircraft.He-111P-2":

Timeout(60, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}

}


The script destroy()ing the planes after an amount of time (in the example 60sec). So by creation of the plane you give a "selfdestruct" command that are executed the time you specified. To avoid vanishing of other planes you should specify the planes. In example only the Stukas, Ju88, He111H2 und P2 will be destroy()ed. Destroy() means the plane is removed from game.

An other possibility is to check if the plane reach the last waypoint and then destroy it, but this is a little bit more complicated.

David198502
10-15-2011, 06:50 PM
hey Kodiak....thx will try that too!if that works, the fmb will become a whole new world of possibilities for me...
i tried the script with the planecounter command.but when i fly the mission, the second group spawns after i shot down only one plane...it will spawn a new group everytime i shoot a single plane.

FG28_Kodiak
10-16-2011, 04:38 AM
i tried the script with the planecounter command.but when i fly the mission, the second group spawns after i shot down only one plane...it will spawn a new group everytime i shoot a single plane.


Yes the script is not complete ;), there are two problems unsolved in it, i always hope the "students" find the problems and eliminate them. :rolleyes:
"I've a dream" :grin:

OK what are the Problems.
The first, not only the plane itself has a name which contains "BoB_RAF_F_FatCat_Early", the pilot (and gunners) also contains it.
We need something that checked if it is a plane. For this we need a if-clause that check: if (actor is AiAircraft) so we only get the plane. If we want examine the crew extra we could use: if (actor is AiPerson)
So now we only get the plane, but an other problem still exist.
i use the if - clause:
if (planecounter >= 2)
but whats the problem, with this if-clause the planes spawn after shooting down two, but also after three , four ....
so it should changed in
if (planecounter == 2)

so the script should now look like:

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


public class Mission : AMission
{
int planecounter = 0;


public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnAircraft");

if (actor != null && MakeNewAircraft != null && actor is AiAircraft)
{
if (actor.Name().Contains("BoB_RAF_F_FatCat_Early"))
{
planecounter++;

if (planecounter == 2)
{
MakeNewAircraft.Do();
GamePlay.gpHUDLogCenter("New Enemy spawned!");
}
}
}
}
}


:rolleyes:

Osprey
10-16-2011, 09:27 AM
.

David198502
10-16-2011, 09:37 AM
thx Kodiak..believe me, yesterday i started too have closer look in those scripts,and i also looked at your really detailed tutorials on sturmovik.de,and i wanted to solve the problem by myself....i have the same dream...will look at it and try to understand.


@sorry Osprey if it was due to me that your question was overheard

Osprey
10-16-2011, 10:50 AM
It's ok, I blanked it and I've done some reading, but I'm getting just plain frustrated that's all:

Made a sample mission, the Doniers spawn after 10sec.

I put this into my dogfight folder and opened in FMB, and then did 'Play Mission'. It worked perfectly. BUT, when I used the same code on my mission (obviously with the triggername edited) it was ignored.

I have an historical mission I am making. There is a bomber attack spawning deep in France and it requires a fighter sweep 5 mins ahead. The fighter bases are nearer to the coast so at present they all spawn in together and naturally the fighters have completed their run well before the bombers are in the area. Here's what I have done and stumbled on:

1. An area trigger for the fighters so that when the bombers pass through the trigger zone they spawn in. The outcome is that the trigger is totally ignored. There is another bug where DOUBLE the number of aircraft are spawned in as you've set up in the mission. No idea why.
2. I changed the trigger to a time delay copying your script but again, the fighters simply spawned in. This time I had them groundstart but on one base the ground wasn't rendered in time and all the fighters nosedived into the sea - in the middle of France!!!
3. I changed the trigger time delay to match your script for a single fighter but again the trigger was ignored.

What I really don't understand is how your script works and mine doesn't yet the only difference is the fighter group selected and the map. Why would your script be run but mine ignored??

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

public class Mission : AMission
{

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("FighterSweep".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("FighterSweep"); //same as YourTriggerName
GamePlay.gpLogServer(null, "Fighter sweep spawned ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
.mis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~

[Trigger]
FighterSweep TTime 60
[Action]
FighterSweep ASpawnGroup 1 BoB_LW_JG3_I.01

Osprey
10-16-2011, 11:05 AM
OK I've just found out something interesting. What appears to be happening is that the FMB is spawning in double the number of objects for these fighters, no idea why. I've been running the script and instantly seeing the spawning in fighters thus assumed that it hadn't worked. This time I let it run a little and et voila! upon 60 seconds, the designated time, a NEW group spawned in - this caused the others to explode because they hadn't yet moved off their spawn position!!!

So this is a result, this means that it's a case of getting rid of these initial airgroups in the mission. Has anyone seen this before??? Is this some weird cahcing problem because I can't see a problem in the .mis file.

FG28_Kodiak
10-16-2011, 12:54 PM
Can you upload your complete mission, please. So it's easier to debug. ;)

David198502
10-16-2011, 01:49 PM
Kodiak your script to destroy planes works fine.i tried it with 6He's and they disappeared after a minute like they should.yesterday i tried to replace the He's with Hurricanes and edited the script to destroy them instead of He's.it didnt work cause i used a wrong name for them.so i looked again at your script and how you defined the name for the He's.your script states He-111P-2, but i in the FMB the He's are defined as He 111P-2...so without the first hyphen.today i looked in the mission file itself and there the aircraft is defined as in your script...so i assume that if i want to destroy hurricanes or any other planes, i have to look in the .mis file first to know the correct designation for them...!?...is that correct?

i also tried to destroy only certain groups, so that not all He's disappear after a minute. so i added two seperate flights of He's and displaced the section:

case "bob:Aircraft.He-111H-2":

with:

case "bob:Aircraft.0.BoB_LW_KuFIGr_706.03":

didnt work, so i tried:

case "bob:AirGroup.0.BoB_LW_KuFIGr_706.03":


...but that didnt work as well...

i also tried to destroy only one single plane of the group, but that didnt work either, but im sure its possible.



another question about this script:
as it is now, the planes will disappear after a period of 60seconds.
but do the 60seconds count from the beginning of the mission, or from the moment when the airplane is spawned?
cause if i would have different flights of He's all spawning at different times, but after 60seconds of the mission they destroy themself again, all flights which would normally spawn after one minute, wouldnt appear at all, because they are destroyed before they are born..

Osprey
10-16-2011, 02:10 PM
It's ok, I found the problem! This is the trouble with no documentation, there's nothing to tell you the minor little bits and bobs. It was "Script spawn or" unchecked. It works now :D

I do find something weird though, don't know if others get it but seems that at some airfields when the AI spawn in they drop into the sea underneath the land. Ever seen it?

David198502
10-16-2011, 03:34 PM
hey Kodiak, godfather of COD scripting,how do i correctly combine two scripts?
i tried to kombine your script where the airplanes get destroyed after a certain period with the script which combines a main and three submissions....both of their own work well, but as soon as i paste the "destroying" script into the other, none of them will work....

FG28_Kodiak
10-16-2011, 04:01 PM
@David:
I use the InternalTypeName of the plane, here others for the flyable planes:
bob:Aircraft.Bf-109E-3
bob:Aircraft.Bf-109E-3B
bob:Aircraft.Bf-109E-1
bob:Aircraft.Bf-109E-4
bob:Aircraft.Bf-109E-4B
bob:Aircraft.Bf-110C-4
bob:Aircraft.Bf-110C-7
bob:Aircraft.Ju-87B-2
bob:Aircraft.Ju-88A-1
bob:Aircraft.He-111H-2
bob:Aircraft.He-111P-2
bob:Aircraft.SpitfireMkIa
bob:Aircraft.SpitfireMkI
bob:Aircraft.HurricaneMkI
bob:Aircraft.HurricaneMkI_dH5-20
bob:Aircraft.BlenheimMkIV
bob:Aircraft.SpitfireMkIIa

to figure this out the KI-Only Planes you can add:

GamePlay.gpLogServer(null, "InternalTypeName: {0}", new object[]{(actor as AiAircraft).InternalTypeName()});

to OnActorCreated(...) so you see the internal name in the chatbar and in the log (if enabled in conf.ini).

To destroy the planes from a specific Airgroup is not possible in OnActorCreated(..) at the time of creation there is no Airgroup.
But you can use the ActorName

GamePlay.gpLogServer(null, "ActorName: {0}", new object[] { (actor as AiAircraft).Name() });


If i use:

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor != null && actor is AiAircraft)
{

GamePlay.gpLogServer(null, "InternalTypeName: {0}", new object[] { (actor as AiAircraft).InternalTypeName() });

GamePlay.gpLogServer(null, "ActorName: {0}", new object[] { (actor as AiAircraft).Name() });
}
}


i get this in the chatbar (from earlier example)
Server: InternalTypeName: bob:Aircraft.Bf-109E-4
Server: ActorName: 0:BoB_LW_LG2_I.000
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.000
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.001
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.002
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.010
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.011
Server: InternalTypeName: bob:Aircraft.He-111H-2
Server: ActorName: 0:BoB_LW_KuFlGr_706.012

so if you like to destroy planes from a Airgroup you could use:

if (actor is AiAircraft && actor.Name().Contains("BoB_LW_KuFlGr_706"))
{
Timeout(60, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
}


or a specific plane

if (actor is AiAircraft && actor.Name().Contains("BoB_LW_KuFlGr_706.010"))
{
Timeout(60, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
}

FG28_Kodiak
10-16-2011, 04:05 PM
hey Kodiak, godfather of COD scripting,how do i correctly combine two scripts?
i tried to kombine your script where the airplanes get destroyed after a certain period with the script which combines a main and three submissions....both of their own work well, but as soon as i paste the "destroying" script into the other, none of them will work....

Could you poste the code please?

David198502
10-16-2011, 04:45 PM
there it is...

FG28_Kodiak
10-16-2011, 05:39 PM
Ok, i see couldn't work

this is the main block:


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

public class Mission : AMission
{


}

You must place your code between the two brackets { ... }

so you must place
public override void OnActorCreated(....)
{
.....
.....
}

and
public override void OnTickGame(...)
{
.....
.....
}
between the brackets.
Your fault was that you placed the OnActorCreated into the OntickGame and this is not allowed in C#.
Hint: Open your Clod Console and you will see error messages if anything goes wrong.

So should your code look like:

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

public class Mission : AMission
{

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{

case "bob:Aircraft.He-111P-2":

Timeout(600, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}




public override void OnTickGame()
{

// loads the 1st sub-mission in 10 min and repeates it every 60 min.
if (Time.tickCounter() % 10800 == 180) // 108000 = 60 min repeat. 1800 = 10 min delay.
// pls. note!!! the 1st figure above must be always larger than 2nd!
{
GamePlay.gpPostMissionLoad("missions/Single/mission1.mis");

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

// prints message on screen in 10 minutes
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
});

// prints message on screen in 5 minutes
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
});

}

// loads the 2nd sub-mission, etc. the same way
if (Time.tickCounter() % 10800 == 1000) // 108000 = 60 min repeat, 54000 = 30 min delay.
{
GamePlay.gpPostMissionLoad("missions/Single/mission2.mis");
GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission2 10 min message!");
});

Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Mission2 15 min message!");
});
}

// loads the 3rd sub-mission
if (Time.tickCounter() % 10800 == 2000) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/Multi/Single/mission3.mis");
GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
});
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
});
}
}
}


btw i've not tested the script in Clod so may be there are other errors are present, but normaly it should work.

Ataros
10-16-2011, 06:32 PM
Very interesting thread. Thank you, Kodiak.

I guess spawning the same group OnTrigger again and again may not work because when the group spawns the 2nd time it belongs to the second mission, etc. The game engine includes mission counter as far as I understand from naryv's examples. I think a long_name of a group may include a mission (submission) number.

Maybe the way to load the same group OnTrigger is to make a sub-mission which includes both an airgroup and a trigger. Then load the same submission OnTrigger. Can not grasp it 100% myself, just thinking aloud.

SNAFU
10-17-2011, 09:29 AM
No, that works, but you have to clear the trigger again, after it was triggered.

If you have the following for the trigger:


if (("RedIntercept1".Equals(shortName) && active) && (CountAIAirplanes(1) <= maxRedAI))
{
AiAction action = GamePlay.gpGetAction("RedIntercept1");
if (action != null)
MissionTimer1Int.Restart();
MissionTimer1IntA.Start();
GamePlay.gpLogServer(null, "Intercept 1 triggered ", new object[] { }); //Testmeldung
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}


You can clear the trigger again by something like this:

if (MissionTimer1IntA.Elapsed.Minutes >= 30) //wieder freischalten des Triggers
{
GamePlay.gpGetTrigger("RedIntercept1").Enable = true;
MissionTimer1IntA.Reset();
GamePlay.gpLogServer(null, "Trigger 1 clear", new object[] { }); //Testmeldung
}

David198502
10-17-2011, 01:11 PM
ok Kodiak...i tried the script.
the He's of the main mission disappear after the 60seconds, but all other He's of the submissions will stay on the map...

so i pasted the relevant part of the script in all the submissios to destroy these He's as well.....this works!

...but is it possible to edit the script of the main mission, that all He's, including the ones of the submissions, disappear?

i looked at your brilliant tutorials on sturmovik.de and saw that its possible to destroy planes not only after a certain time, but when they cross a certain waypoint...but honestly im a bit overwhelmed by all its details that i dont consider myself capable of doing this by myself....

i also saw that it is possible to load submissions randomly...but in your tutorial you have some conditions which determine whether a mission is loaded or not(mission x will not be loaded if one destroys friendly vehicle)...i would like to load submissions randomly, regardless of any conditions, every xx seconds.is that possible?

i think its a better solution for my purpose to load submissions by random than loading mission after mission in determined sequence, because this would add an surprising factor, and i think it would shorten the script drastically, if i want to have 20 or more submissions.


btw, i really appreciate your help, and admire your patience with me!thx in advance...




/****
* Brief startup guide to scripting.
* This is a sample script to create a small online 'campaign' containing a main mission and 3 sub-missions.
*
* Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g.
* C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
* Scripts have to be saved with .cs extension and have the same name as the main mission.
* Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs.
* Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder):
* C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
* Create and edit 3 missions you want to be loaded into the main mission with FMB.
* Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis.
* That's it.
*
* In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , than edit 3 filepaths in this file.
* e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission. *
*
* Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map).
* The text in this example is visible to both sides for simplicity.
*
* You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand.
* Download link http://www.microsoft.com/express/Downloads/#2010-Visual-CS
*
* All text after // marks are comments describing what the script does.
* You may play your mission in MP or as a SP mission if you create a passworded server.
* Have fun! and S! from 3GIAP
*
* Feel free to delete all the comments above and including this line from this file. ****/

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

public class Mission : AMission
{

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{

case "bob:Aircraft.He-111P-2":

Timeout(60, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}



public override void OnTickGame()
{

// loads the 1st sub-mission in 10 min and repeates it every 60 min.
if (Time.tickCounter() % 20000 == 320) // 108000 = 60 min repeat. 1800 = 10 min delay.
// pls. note!!! the 1st figure above must be always larger than 2nd!
{
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission1.mis");

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

// prints message on screen in 10 minutes
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
});

// prints message on screen in 5 minutes
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
});

}

// loads the 2nd sub-mission, etc. the same way
if (Time.tickCounter() % 10800 == 1000) // 108000 = 60 min repeat, 54000 = 30 min delay.
{
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission2.mis");
GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission2 10 min message!");
});

Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Mission2 15 min message!");
});
}

// loads the 3rd sub-mission
if (Time.tickCounter() % 10800 == 1500) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission3.mis");
GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
});
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
});
}

// loads the 4th sub-mission
if (Time.tickCounter() % 10800 == 2000) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission4.mis");
GamePlay.gpHUDLogCenter("Mission4.mis loaded!");

double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
});
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
});
}


}


}

FG28_Kodiak
10-17-2011, 04:14 PM
ok Kodiak...i tried the script.
the He's of the main mission disappear after the 60seconds, but all other He's of the submissions will stay on the map...

so i pasted the relevant part of the script in all the submissios to destroy these He's as well.....this works!

...but is it possible to edit the script of the main mission, that all He's, including the ones of the submissions, disappear?


Yes it's possible, you must set the MissionNumberListener = -1, -1 means the script 'listen' to all events in all missions. If you only want one mission are listen you must specify the MissionNumber of the mission.
The best place for the MissionNumberListener is a method that called at the begin of a Mission. Normaly i use OnBattleStarted()

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

MissionNumberListener = -1;
}



i also saw that it is possible to load submissions randomly...but in your tutorial you have some conditions which determine whether a mission is loaded or not(mission x will not be loaded if one destroys friendly vehicle)...i would like to load submissions randomly, regardless of any conditions, every xx seconds.is that possible?

i think its a better solution for my purpose to load submissions by random than loading mission after mission in determined sequence, because this would add an surprising factor, and i think it would shorten the script drastically, if i want to have 20 or more submissions.

Yes its possible the only thing you need is in OnTickGame()

Random ZufaelligeMission = new Random();

switch (ZufaelligeMission.Next(1,5))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\Missio nNachladen6Sub1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\Missio nNachladen6Sub2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\Missio nNachladen6Sub3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\Missio nNachladen6Sub4.mis");
break;

}

David198502
10-17-2011, 05:30 PM
ok tried it, but i still dont know when and how i use those parts....
this is what i have so far....

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

public class Mission : AMission
{

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

MissionNumberListener = -1;
}

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{

case "bob:Aircraft.He-111P-2":

Timeout(420, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}



public override void OnTickGame()
{
Random ZufaelligeMission = new Random();

switch (ZufaelligeMission.Next(1,5))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\mission1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission4.mis");
break;

}

}
}
}
}

there is a main mission, with a bf109 and 9He's(which should be destroyed after xx seconds)

after xx seconds i want the game to load one mission ,selected randomly out of 4 submissions.
i also want the He's loaded with the submission to be destroyed after the xx seconds, like the ones from the main mission.
and i want the game to repeat that process, so that every xx seconds a new mission is loaded randomly.....so that the mission can run forever

FG28_Kodiak
10-17-2011, 06:36 PM
Script modified (added a timer) and corrected:


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


public class Mission : AMission
{
Stopwatch MissionTimer = new Stopwatch();

public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionTimer.Start();
MissionNumberListener = -1;
}


public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{

case "bob:Aircraft.He-111P-2":

Timeout(420, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}



public override void OnTickGame()
{

if(MissionTimer.Elapsed.TotalSeconds >= 60) //Loads a mission every 60s
{
Random ZufaelligeMission = new Random();

MissionTimer.Restart(); // Sets timer to 0 and start again

switch (ZufaelligeMission.Next(1,5))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission4.mis");
break;
}
}
}

}

Ataros
10-17-2011, 08:31 PM
I did not try using Stopwatch() yet. Is it a part of C# or CloD only?

Can it be used inside the onTickGame method only or in any other method as well?

If it is placed inside the onTickGame method won't the "if" statement checked every tick, i.e. 30 times a second?

FG28_Kodiak
10-18-2011, 05:04 AM
I did not try using Stopwatch() yet. Is it a part of C# or CloD only?

Stopwatch is part of the .Net-Framework, it provides the most accurate time measurement. So it's very usefull if you need accurate timing.
you need to include the namespace System.Diagnostics for usage.

For the query time can be for example (MissionTimer1 is the stop watch)
MissionTimer1.Elapsed.Days
MissionTimer1.Elapsed.Hours
MissionTimer1.Elapsed.Minutes
MissionTimer1.Elapsed.Seconds
MissionTimer1.Elapsed.Milliseconds
MissionTimer1.Elapsed.Ticks
MissionTimer1.Elapsed.TotalDays
MissionTimer1.Elapsed.TotalHours
MissionTimer1.Elapsed.TotalMinutes
MissionTimer1.Elapsed.TotalSeconds
MissionTimer1.Elapsed.TotalMilliseconds

There is a difference between for example Minutes and TotalMinutes etc.:
MissionTimer1.Elapsed.Minutes has e.g. the range -59 to 59 minutes, only indicates the minute proportion of the total time. at 2h 43m 12s would be the 43rd
MissionTimer1.Elapsed.TotalMinutes provides e.g. the total number of minutes since launch. 2h 43m 12s min at 163.12 then.


Methods
MissionTimer1.Start () / / Starts the timer
MissionTimer1.Stop () / / Pauses the timer can be resume with Start ()
MissionTimer1.Restart () / / Starts the timer at 0 newly
MissionTimer1.Reset () / / Resets the timer to 0 and stops the time measurement
MissionTimer1.IsRunning / / bool indicates whether the timer is running (true) or not (false)


Can it be used inside the onTickGame method only or in any other method as well?

Its depend not on OnTickGame.
You can for example measure the time between two events etc.
You need to declare a Stopwatch global and start it once, normaly OnBattleStarted(). Then you can use it in every way you like.


If it is placed inside the onTickGame method won't the "if" statement checked every tick, i.e. 30 times a second?

Yes, but this is no problem, normaly.
Don't know whats faster, a modulo calculation or a simple stopwatch request. But stopwatch is much more accurate. ;)

Ataros
10-18-2011, 08:40 AM
Thank you very much for great explanation! I will be using it in the future.

Currently I am struggling with triggers for my R2 and R3 mission and hope you can advise what I should look at.

I am loading 2 submissions 1_E3_air0.mis , 1_E3_air1.mis randomly.
2nd one is a copied 1st one with aircraft changed from Wellington to Blenheim. Name of airgroup remained the same.

Triggers in submissions are called 1_E3_air and 1_E3_air. Same name now but I tried also checking 1_E3_air0 and 1_E3_air1 in a loop with the same result. The trigger was created in the 1st submission and copied to the 2nd in a notepad.
1_E3_air TPassThrough 1 gb02.07 53073 33421 2000
1_E3_air TPassThrough 1 gb02.07 53073 33421 2000

As a result, the 1st submission trigger does not work at all. The second submission trigger works 2 or 5 times (maybe depending on number of aircraft in the group?)

Questions:
Why the trigger in 1st submission may not wark?
In which cases && active) check must be added?
When GamePlay.gpGetTrigger(shortName).Enable = false; must be edded? Naryv does not use it in some of his examples.
How to make 2nd trigger "work" only once per mission?
Can all triggers have the same name?
When I copy a mission file should I change a name of an airgroup in it by hand?
If I include all the triggers into the host-mission only would they trigger when submission airgroups pass-through?


public override void OnTrigger(int missionNumber, string shortName, bool active)
{ base.OnTrigger(missionNumber, shortName, active);


string[] attackSector = { "C5", "D4", "E3" }; // sectors attacked

// air missions
#region air missions

string currMissType = "air";

for (int j = 1; j < 3 ; j++) // Army
{
for (int i = 0; i < attackSector.Length ; i++)
{
string str = (j).ToString() + "_" + attackSector[i].ToString() + "_" + currMissType; // +k.ToString(); // + missionType[1].ToString() //string str = i.ToString() + "_" + (j).ToString() + "_gg";
// && active) is this needed?
if (str.Equals(shortName)) // && active) is this needed? // test
{
sendChatMessageTo(-1, str , null); // test msg

if (j == 1) // red win
{
currBonusLoss = allowed109s - min109s;
if (currBonusLoss < 1) currBonusLoss++;

allowed109s = min109s;
ScoreRed += 1;

sendScreenMessageTo(-1, new string[] { "ru" }, "The Allies bombed the Axis' airfield! Limit of available Bf-109E4 is reduced by {0}!", new object[] { currBonusLoss });
sendScreenMessageTo(-1, "Красные разбомбили синий аэродром! Лимит доступных Bf-109E4 снижен на {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, new string[] { "ru" }, "The Allies bombed the Axis' airfield! Limit of available Bf-109E4 is reduced by {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, "ru", "Красные разбомбили синий аэродром! Лимит доступных Bf-109E4 снижен на {0}!", new object[] { currBonusLoss });
// testing
sendScreenAndChatMessageTo( -1, new object[] { currBonusLoss },
"Testing! sendScreenAndChatMessageTo Bf-109E4 is reduced by {0}!",
"Тест! sendScreenAndChatMessageTo Bf-109E4 is reduced by {0}!");


}

else // blue win
{

allowedSpit2s = minSpit2s;
ScoreBlue += 1;

sendScreenMessageTo(-1, new string[] { "ru" }, "The Axis bombed the Allies' airfield! Limit of available Spitfire IIa is reduced by {0}!", new object[] { currBonusLoss });
sendScreenMessageTo(-1, "Синие разбомбили красный аэродром! Лимит доступных Spitfire IIa снижен на {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, new string[] { "ru" }, "The Axis bombed the Allies' airfield! Limit of available Spitfire IIa is reduced by {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, "ru", "Синие разбомбили красный аэродром! Лимит доступных Spitfire IIa снижен на {0}!", new object[] { currBonusLoss });

}
// do I need this?
//GamePlay.gpGetTrigger(shortName).Enable = false;

break;
}

}
}
#endregion
}

If you would like to see the complete mission please let me know. But it is a mess now :)

David198502
10-18-2011, 09:16 AM
thx Kodiak!you are really helpful and supportive not only for me, but i think for the whole community...i think with every question i ask, this thread gains worth...
this script works, and finally i have what i wanted to achieve, a infinite bomb raid on london...i have 50 submissions, each with 18 He's, and in every mission they bomb another area of the city...so after playing an hour, the center of london resembles Dresden in 45.combined with massive AAA this mission really looks nice...

however now i want to have british fighters as well in that mission... but i will try that for myself first, and if i run into trouble, i'm sure your knowledge will once again be useful...thx again Kodiak.....if this thread was more structured, it could serve as a knowledge-base.

FG28_Kodiak
10-18-2011, 11:21 AM
@Ataros:

Why the trigger in 1st submission may not wark?

Could i have the complete script please?

In which cases && active) check must be added?

active shows if a trigger is enabled (true) or (disabled), normaly its not needed if a trigger is not active OnTrigger(..) is not called, but may be changes in future ;)

When GamePlay.gpGetTrigger(shortName).Enable = false; must be edded? Naryv does not use it in some of his examples.

Depends on trigger type you use, by time there is no need but by others there can be, you should use it if there is a chance that the trigger can be activated a second time, by passthru for example it could happen

How to make 2nd trigger "work" only once per mission?

I need to see the complete script, but normaly disable it with ActorName.Full().

Can all triggers have the same name?

Yes. If the missionNumber is different.

When I copy a mission file should I change a name of an airgroup in it by hand?

Not nessesary, depens on our code.

If I include all the triggers into the host-mission only would they trigger when submission airgroups pass-through?

If MissionNumberListener = -1 they should.

Ataros
10-18-2011, 11:41 AM
@Ataros:

Could i have the complete script please?

Thank you very much! This is a very WIP version. Many things changed for testing. Please find it attached.

David198502
10-18-2011, 06:50 PM
ok i tried to combine your last script with the one where the same airgroup gets respawned everytime you shot a certain amount down....

doesnt work...


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


public class Mission : AMission
{
Stopwatch MissionTimer = new Stopwatch();

public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionTimer.Start();
MissionNumberListener = -1;
}


public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
switch ((actor as AiAircraft).InternalTypeName())
{

case "bob:Aircraft.He-111P-2":

Timeout(240, () => // Time in Seconds
{
(actor as AiAircraft).Destroy();
});
break;
}
}
}
int planecounter = 0;


public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnAircraft");

if (actor != null && MakeNewAircraft != null && actor is AiAircraft)
{
if (actor.Name().Contains("BoB_RAF_F_FatCat_Early"))
{
planecounter++;

if (planecounter == 2)
{
MakeNewAircraft.Do();
GamePlay.gpHUDLogCenter("New Enemy spawned!");
}
}
}
}

public override void OnTickGame()
{

if(MissionTimer.Elapsed.TotalSeconds >= 180) //Loads a mission every 180s
{
Random ZufaelligeMission = new Random();

MissionTimer.Restart(); // Sets timer to 0 and start again

switch (ZufaelligeMission.Next(1,65))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission4.mis");
break;
case 5:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission5.mis");
break;
case 6:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission6.mis");
break;
case 7:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission7.mis");
break;
case 8:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission8.mis");
break;
case 9:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission9.mis");
break;
case 10:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission10.mis");
break;
case 11:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission11.mis");
break;
case 12:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission12.mis");
break;
case 13:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission13.mis");
break;
case 14:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission14.mis");
break;
case 15:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission15.mis");
break;
case 16:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission16.mis");
break;
case 17:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission17.mis");
break;
case 18:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission18.mis");
break;
case 19:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission19.mis");
break;
case 20:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission20.mis");
break;
case 21:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission21.mis");
break;
case 22:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission22.mis");
break;
case 23:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission23.mis");
break;
case 24:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission24.mis");
break;
case 25:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission25.mis");
break;
case 26:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission26.mis");
break;
case 27:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission27.mis");
break;
case 28:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission28.mis");
break;
case 29:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission29.mis");
break;
case 30:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission30.mis");
break;
case 31:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission31.mis");
break;
case 32:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission32.mis");
break;
case 33:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission33.mis");
break;
case 34:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission34.mis");
break;
case 35:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission35.mis");
break;
case 36:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission36.mis");
break;
case 37:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission37.mis");
break;
case 38:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission38.mis");
break;
case 39:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission39.mis");
break;
case 40:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission40.mis");
break;
case 41:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission41.mis");
break;
case 42:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission42.mis");
break;
case 43:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission43.mis");
break;
case 44:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission44.mis");
break;
case 45:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission45.mis");
break;
case 46:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission46.mis");
break;
case 47:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission47.mis");
break;
case 48:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission48.mis");
break;
case 49:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission49.mis");
break;
case 50:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission50.mis");
break;
case 51:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission51.mis");
break;
case 52:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission52.mis");
break;
case 53:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission53.mis");
break;
case 54:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission54.mis");
break;
case 55:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission55.mis");
break;
case 56:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission56.mis");
break;
case 57:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission57.mis");
break;
case 58:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission58.mis");
break;
case 59:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission59.mis");
break;
case 60:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission60.mis");
break;
case 61:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission61.mis");
break;
case 62:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission62.mis");
break;
case 63:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission63.mis");
break;
case 64:
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission64.mis");
break;

}
}
}

}

FG28_Kodiak
10-18-2011, 07:01 PM
Can i have the complete mission please?

David198502
10-18-2011, 08:18 PM
here it is...

it also would be great if the hurris of the main mission-could be destroyed after a while as well, but they should remain longer on the map then the He's...tried that by myself, but without luck, so i deleted the part again from the script.

Ataros
10-19-2011, 04:01 PM
FG28_Kodiak, it looks like PassThrough trigger works 2 times, when entering the zone and when exiting it. If there are several aircraft they can triger it several time as well. A solution is not to do any calculations or actions in onTrigger method but make them in some other method like OnTickGame if the trigger was active before. It looks like my mission works now with this workaround but it is not very convenient. If you have any advice I will be grateful.

The mission is here http://forum.1cpublishing.eu/showpost.php?p=351551&postcount=10

Thanks again!

Gromic
02-03-2012, 05:00 PM
Evening Chaps,

got a strange problem using a TTime trigger that isn't firing while being called though a submission that is loaded via the GamePlay.gpPostMissionLoad function.

If I load the mission by itself then the TTime trigger works fine. Apparently there's something within the main mission that seems to void a TTime trigger within a submission.

I've read through the entire thread but since I'm a noob at coding, I haven't found anything that adresses the issue specifically.

I'm sure most here will recognise the basic script. The Bold portion in the script below loads the submission:

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

public class Mission : AMission
{


AiAircraft PlayerPlane;

// destroys aircraft abandoned by a player.
private bool isAiControlledPlane (AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}

Player [] players = GamePlay.gpRemotePlayers ();
foreach (Player p in players)
{
if (p != null && (p.Place () is AiAircraft) && (p.Place () as AiAircraft) == aircraft)
{
return false;
}
}

return true;
}

private void destroyPlane (AiAircraft aircraft) {
if (aircraft != null) {
aircraft.Destroy ();
}
}

private void explodeFuelTank (AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Exploded);
}
}

private void destroyAiControlledPlane (AiAircraft aircraft) {
if (isAiControlledPlane (aircraft)) {
destroyPlane (aircraft);
}
}

private void damageAiControlledPlane (AiActor actor) {
if (actor == null || !(actor is AiAircraft)) {
return;
}

AiAircraft aircraft = (actor as AiAircraft);

if (!isAiControlledPlane (aircraft)) {
return;
}

if (aircraft == null) {
return;
}

aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled);
aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled);
aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled);
aircraft.hitNamed (part.NamedDamageTypes.FuelPumpFailure);

int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
aircraft.hitNamed((part.NamedDamageTypes)Enum.Pars e(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}

/***Timeout (240, () =>
{explodeFuelTank (aircraft);}
);
* ***/

Timeout (300, () =>
{destroyPlane (aircraft);}
);
}

//////////////////////////////////////////

public override void OnPlaceLeave (Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave (player, actor, placeIndex);
Timeout (1, () =>
{damageAiControlledPlane (actor);}
);
}

public override void OnAircraftCrashLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded (missionNumber, shortName, aircraft);
Timeout (300, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}

/////////////////////////////////////////////////////////////////////////////
//Listen to events of every (sub)mission
public override void Init(maddox.game.ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1; //Listen to events of every mission
}

//////////////////////////////////////////////////////////////////////////////
// Loads random submissions

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
if ("trigger01".Equals(shortName) && active)
{
DoDamage();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}


private void DoDamage()
{
PlayerPlane = (AiAircraft)GamePlay.gpPlayer().Place();
// Initial Mission - can be any type
Random RandomIncident = new Random();

switch (RandomIncident.Next(1, 13))
{
case 1:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB3.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB4.mis");
break;
case 5:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB5.mis");
break;
case 6:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
break;
case 7:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB7.mis");
break;
case 8:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB8.mis");
break;
case 9:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB9.mis");
break;
case 10:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB10.mis");
break;
case 11:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB11.mis");
break;
case 12:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB12.mis");
break;
}

}
public override void OnTickGame()
{


// loads the 1st sub-mission in 5 min and repeates it every 10 min.
if (Time.tickCounter() % 18000 == 9000) // 18000 = 10 min repeat. 9000 = 5 min delay.
// the 1st figure above must be always larger than 2nd!
{
Random RandomIncident = new Random();
// Fighter mission generation
switch (RandomIncident.Next(1, 7))
{
case 1:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB3.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB4.mis");
break;
case 4:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB9.mis");
break;
case 5:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB11.mis");
break;
case 6:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB12.mis");
break;

}

}

// Loads Missions consecutively

if (Time.tickCounter() % 756000 == 1800) // 756000 = 420 (7 Hours) min repeat. 1800 = 1 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB7.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:01 am");
}
}
/* if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
}
if (Time.tickCounter() % 108000 == 1800) // 108000 = 60 min repeat. 18000 = 10 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/GHSCRIPTED/SUB6.mis");
{
GamePlay.gpHUDLogCenter("Monday, August 12 1940 08:00 am");
}
} */
}

}

And here is the script that is loaded with the submission itself. The bolded portions call the trigger itself.

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

public class Mission : AMission
{
private const int All = -1;
private const int Allies = 1;
private const int Axis = 2;

public override void OnMissionLoaded(int missionNumber)
{
base.OnMissionLoaded(missionNumber);
}


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

//Triggers for RAF actions
//Report Examples
//SendScreenMessageTo(Allies, "Message to Red");
//SendScreenMessageTo(Axis, "Message to Blue");
if ((shortName == "LW_Spawn_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7A"); //TriggerName
if (action != null)
{
action.Do();
}

}
if ((shortName == "LW_Spawn_7B") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7B"); //TriggerName
if (action != null)
{
action.Do();
}

}
if ((shortName == "LW_Spawn_7C") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7C"); //TriggerName
if (action != null)
{
action.Do();
}

}

if ((shortName == "ALL_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("ALL_Radio_7A"); //TriggerName
SendScreenMessageTo(Allies, "CH reports heavy buildup rallying at AX-16 flying low. We're loosing contact.");
SendScreenMessageTo(Axis, "Bodo reports EG210 massing at AX-16. Low level Jabo to attack radar at AP-17 and AR-18.");
if (action != null)
{
action.Do();
}

}
if ((shortName == "LW_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Radio_7A"); //TriggerName
SendScreenMessageTo(Axis, "Bodo reports EG210 now AR-16. Attacking AP-17 and AR-18 radar in 5 minutes.");
if (action != null)
{
action.Do();
}

}
if ((shortName == "GB_Radio_7A") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7A"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AP-17 Eastbourne is under attack!");
if (action != null)
{
action.Do();
}

}
if ((shortName == "GB_Radio_7B") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7B"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AR-18 Rye is under attack!");
if (action != null)
{
action.Do();
}

}
if ((shortName == "GB_Radio_7C") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7C"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AV-21 Dover is under attack!");
if (action != null)
{
action.Do();
}

}
if ((shortName == "GB_Radio_7D") && active)
{
AiAction action = GamePlay.gpGetAction("GB_Radio_7C"); //TriggerName
SendScreenMessageTo(Allies, "SC reporting: Chain home station AS-22 Dunkirk is under attack!");
if (action != null)
{
action.Do();
}

}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
private void SendScreenMessageTo(int army, string message)
{
if (army == All)
{
GamePlay.gpHUDLogCenter(message);
}
else
{
//Singleplayer (for Testing)
if (GamePlay.gpRemotePlayers() == null ||
GamePlay.gpRemotePlayers().Length <= 0)
{
if (GamePlay.gpPlayer() != null &&
GamePlay.gpPlayer().Army() == army)
{
GamePlay.gpHUDLogCenter(message);
}
}
else // Multiplayer
{
var playersInArmy = new List<Player>();

foreach (var player in GamePlay.gpRemotePlayers())
{
if (player.Army() == army)
{
playersInArmy.Add(player);
}
}

GamePlay.gpHUDLogCenter(playersInArmy.ToArray(), message);
}
}
}
}

The triggers themselves are also properly defined within the .mis file of the submission, so that shouldn't be a problem. As stated, everything works fine when I load the mission by itself.

I'd appreciate any help or suggestions.

Danke schön

Gromic

Gromic
02-03-2012, 07:14 PM
Update

Been doing some "debugging" with a squadie who works in the field and now we're both scratching our heads.

We've implimented a gpHUDLogCenter Message just to see if the triggers are actually meeting thier requirements. They definately are and this begs the question why those three flights aren't spawning. This has us both stumped.

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
//base.OnTrigger(missionNumber, shortName, active);
{
GamePlay.gpHUDLogCenter(string.Format("Mission {0}, Name {1}, Active={2}", missionNumber, shortName, active));
}
//Triggers for RAF actions
//Report Examples
//SendScreenMessageTo(Allies, "Message to Red");
//SendScreenMessageTo(Axis, "Message to Blue");
if ((shortName == "LW_Spawn_7A") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7A"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}

}
if ((shortName == "LW_Spawn_7B") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7B"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}

}
if ((shortName == "LW_Spawn_7C") && active)
{
AiAction action = GamePlay.gpGetAction("LW_Spawn_7C"); //TriggerName
if (action != null)
{
GamePlay.gpHUDLogCenter(string.Format("We have action {0}", action.Name));
action.Do();
}

}

We are getting messages stating the trigger number, name and its active status so now we know that the actual trigger is firing and getting passed through to action.Do(). Still, the aircraft tied to those triggers aren't spawning at the airfield. I figured it might be a problem with the airfield itself (spawn points) and tested with air starts. No luck.

Frustrating to say the least.

;)

Smokeynz
02-04-2012, 05:45 AM
Have you tried compiling the whole cs, including the new loaded sub mis into one complete cs?

As it stands the triggers are a little buggy, especially as dedicated style hosting. I suspect the DS is simplified allowing for basic operation and missing many advanced ops awaiting final Dedicated proper to be created.

I have been trying to get passthru triggers too work for players, proved to be quite difficult but have something semi functioning now.

Gromic
02-04-2012, 07:39 AM
Fixed.

But don't ask me why as I can't explain it. I figured if it's not the script itself then maybe there's a problem with the trigger itself (although I couldn't find any). So I deleted the 3 triggers (LW_Spawn_7C / LW_Spawn_7B / LW_Spawn_7A) using the FMB, saved the mission, restarted the game and proceeded to create them again using the exact same groups, times, etc. I didn't have much to lose after wasting a day banging my head on the table over this problem.

Sure enough. The triggers fired as they had always done with the side effect of the groups actually spawning and the mission purring along as initially intended. At this point my house was filled with loud, booming vocal expletives #censored# because it made absolutly no sense whatsoever and (repeat) - scratch one day with the kind help of CloDs FMB.

This morning I decided to compare the mission files themselves since I make regular 2 hour incremental backups with storagecraft and therefore always have a copy of any files past gone. There is no deviation between yesterday (mission not working) and todays (mission working) portions of the mis file that pertain to the triggers except for the listed order.

Excerpt from triggers and actions group in non working .mis:

[Trigger]
LW_Spawn_7C TTime 15
LW_Spawn_7B TTime 25
LW_Spawn_7A TTime 65
GB_Radio_7B TPassThrough 1 BoB_LW_ErprGr210.22 206231 212690 2000
GB_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.36 178666 197324 2000
LW_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.22 202886 180347 2000
GB_Radio_7D TPassThrough 1 BoB_LW_ErprGr210.02 217559 252014 1900
GB_Radio_7C TPassThrough 1 BoB_LW_ErprGr210.12 246488 235993 2000
ALL_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.12 262178 197723 2000
[Action]
LW_Spawn_7C ASpawnGroup 0 BoB_LW_ErprGr210.12
LW_Spawn_7B ASpawnGroup 0 BoB_LW_ErprGr210.02
LW_Spawn_7A ASpawnGroup 0 BoB_LW_ErprGr210.36
GB_Radio_7C ASpawnGroup 0 Empty
LW_Radio_7A ASpawnGroup 0 Empty
GB_Radio_7A ASpawnGroup 0 Empty
GB_Radio_7B ASpawnGroup 0 Empty
GB_Radio_7D ASpawnGroup 0 Empty
ALL_Radio_7A ASpawnGroup 0 Empty

Excerpt from triggers and actions group in working .mis:

[Trigger]
GB_Radio_7B TPassThrough 1 BoB_LW_ErprGr210.22 206231 212690 2000
GB_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.36 178666 197324 2000
LW_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.22 202886 180347 2000
GB_Radio_7D TPassThrough 1 BoB_LW_ErprGr210.02 217559 252014 1900
GB_Radio_7C TPassThrough 1 BoB_LW_ErprGr210.12 246488 235993 2000
LW_Spawn_7C TTime 15
ALL_Radio_7A TPassThrough 1 BoB_LW_ErprGr210.12 262178 197723 2000
LW_Spawn_7B TTime 25
LW_Spawn_7A TTime 65
[Action]
GB_Radio_7C ASpawnGroup 0 Empty
LW_Radio_7A ASpawnGroup 0 Empty
GB_Radio_7A ASpawnGroup 0 Empty
GB_Radio_7B ASpawnGroup 0 Empty
LW_Spawn_7C ASpawnGroup 1 BoB_LW_ErprGr210.12
GB_Radio_7D ASpawnGroup 0 Empty
ALL_Radio_7A ASpawnGroup 0 Empty
LW_Spawn_7A ASpawnGroup 1 BoB_LW_ErprGr210.36
LW_Spawn_7B ASpawnGroup 1 BoB_LW_ErprGr210.02

There's a lesson of insanity in all this. FMB scripted missions don't function properly using logical (human) load orders. They need anarchy to work properly.

<sideswipe> Probably the reason why the patch is taking so long </sideswipe>

Hats off and cheers to all you masochistic FMB junkies out there

Grom

Ataros
02-04-2012, 07:51 AM
S!

Try loading an airgroup via loading sub-submission with the airgroup, not via action included into the submision. It may be more reliable.

Every time you open a trigger/action window in FMB you have to save it even if you do not edit it. Otherwise it may revert to some default values.
Also clearing cache folder may help.

Osprey
02-04-2012, 12:11 PM
Stirling work for the war effort there Gromic. Whilst I was out partying on my 1 day pass into the City I had no idea that you boffins were working so hard at it breaking the Jerry code. Top work and a 3 day pass with skirt thrown in for you. :D