![]() |
spawn airgroups?
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? |
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: Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) |
thx but doesnt seem to work...
|
... and doesn't seem to work for me either (spawning a bomber group every x seconds) :(
|
Mmh, you are using a script like the following and named your triggers and actions accordingly, also in the script? (Triggername = Actionname)
Code:
using System; |
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 Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) Check if both action and trigger are defined correctly (trigger type, airgroup, etc.) and saved in FMB. |
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:
|
Quote:
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; } } |
Quote:
Try without the delay. |
1 Attachment(s)
Made a sample mission, the Doniers spawn after 10sec.
|
Sorry after reading the OP post I was thinking the trigger is airgroup destroyed, not TTime 10. My bad :)
Quote:
|
Quote:
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"); }); } } } |
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). |
Thankyou Kodiak, I've got it now.
|
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. |
1 Attachment(s)
thats what i did so far...
|
1 Attachment(s)
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. Code:
using System; 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. |
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. |
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?? |
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. |
Quote:
Quote:
Quote:
actor.Name().Contains("BoB_RAF_F_FatCat_Early") so every plane in the goup counted. Quote:
Quote:
you can improve the script. For example: Code:
using System; Quote:
|
1 Attachment(s)
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... |
It's possible, the easy way.
Code:
using System; 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. |
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. |
Quote:
"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: Code:
using System; |
.
|
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 |
It's ok, I blanked it and I've done some reading, but I'm getting just plain frustrated that's all:
Quote:
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?? Quote:
|
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. |
Can you upload your complete mission, please. So it's easier to debug. ;)
|
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.. |
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? |
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.... |
@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: Code:
GamePlay.gpLogServer(null, "InternalTypeName: {0}", new object[]{(actor as AiAircraft).InternalTypeName()}); 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 Code:
GamePlay.gpLogServer(null, "ActorName: {0}", new object[] { (actor as AiAircraft).Name() }); Code:
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor) 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: Code:
if (actor is AiAircraft && actor.Name().Contains("BoB_LW_KuFlGr_706")) Code:
if (actor is AiAircraft && actor.Name().Contains("BoB_LW_KuFlGr_706.010")) |
Quote:
|
1 Attachment(s)
there it is...
|
Ok, i see couldn't work
this is the main block: Code:
using System; 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: Code:
using System; |
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. |
No, that works, but you have to clear the trigger again, after it was triggered.
If you have the following for the trigger: Code:
Code:
if (MissionTimer1IntA.Elapsed.Minutes >= 30) //wieder freischalten des Triggers |
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... PHP Code:
|
Quote:
The best place for the MissionNumberListener is a method that called at the begin of a Mission. Normaly i use OnBattleStarted() Code:
public override void OnBattleStarted() Quote:
Code:
Random ZufaelligeMission = new Random(); |
ok tried it, but i still dont know when and how i use those parts....
this is what i have so far.... PHP Code:
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 |
Script modified (added a timer) and corrected:
Code:
using System; |
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? |
Quote:
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) Quote:
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. Quote:
Don't know whats faster, a modulo calculation or a simple stopwatch request. But stopwatch is much more accurate. ;) |
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? Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) |
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. |
@Ataros:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
1 Attachment(s)
Quote:
|
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... PHP Code:
|
Can i have the complete mission please?
|
1 Attachment(s)
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. |
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/showpos...1&postcount=10 Thanks again! |
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: Code:
using System; Code:
using System; I'd appreciate any help or suggestions. Danke schön Gromic |
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. Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) Frustrating to say the least. ;) |
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. |
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. Code:
Excerpt from triggers and actions group in non working .mis: <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 |
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. |
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
|
All times are GMT. The time now is 06:52 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.