![]() |
#41
|
|||
|
|||
![]() 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() { base.OnBattleStarted(); MissionNumberListener = -1; } Quote:
Code:
Random ZufaelligeMission = new Random(); switch (ZufaelligeMission.Next(1,5)) { case 1: GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub1.mis"); break; case 2: GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub2.mis"); break; case 3: GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub3.mis"); break; case 4: GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub4.mis"); break; } |
#42
|
||||
|
||||
![]()
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 Last edited by David198502; 10-17-2011 at 05:33 PM. |
#43
|
|||
|
|||
![]()
Script modified (added a timer) and corrected:
Code:
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; } } } } |
#44
|
|||
|
|||
![]()
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? |
#45
|
|||
|
|||
![]() 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. ![]() Last edited by FG28_Kodiak; 10-18-2011 at 05:09 AM. |
#46
|
|||
|
|||
![]()
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) { 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 } ![]() Last edited by Ataros; 10-18-2011 at 09:32 AM. |
#47
|
||||
|
||||
![]()
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. Last edited by David198502; 10-18-2011 at 11:50 AM. |
#48
|
|||||||
|
|||||||
![]()
@Ataros:
Quote:
Quote:
![]() Quote:
Quote:
Quote:
Quote:
Quote:
Last edited by FG28_Kodiak; 10-18-2011 at 11:37 AM. |
#49
|
|||
|
|||
![]()
Thank you very much! This is a very WIP version. Many things changed for testing. Please find it attached.
|
#50
|
||||
|
||||
![]()
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:
Last edited by David198502; 10-18-2011 at 06:54 PM. |
![]() |
|
|