#11
|
|||
|
|||
I have a more general question which I hope someone can answer:
My mission loads submission with some parameters (attacker army, mission type, attack sector, etc), then gets trigger status, calculates mission results and shows results messages using the same parameters. It goes fine when submissions are loaded one by one. I want to add different types of submissions and make them overlap in time. Naturally I have to store parameters of every submissions as different variables to prevent them mixing up. How can I do this? Should I create a list for each parameter and send it to array when each new submission loads or there is a more elegant way to do this. I will not have more then 10 submissions going on simultaneously and do not have to create arrays with the length of total past submissions quantity. |
#12
|
|||
|
|||
Make a class with all infos you need and then store the objects in a list.
For example : Code:
using System; using System.Collections.Generic; using maddox.game; using maddox.game.world; public class Mission : AMission { public static string SubMissionsPath = @"missions\Multi\Dogfight\test\subs\"; public class Mis { public string Missionfilename {get; set;} public string PathToMission { get; set; } public DateTime MissionBegin{get; set;} public DateTime MissionEnd{get; set;} public double MissionLengh{get; set;} public bool IsMissionRunning { get; set; } public Mis(string Filename, string Path, double Lengh) { this.Missionfilename = Filename; this.PathToMission = Path; this.MissionLengh = Lengh; } } public List<Mis> MissionPool = new List<Mis>() { new Mis ("Mission1.mis",SubMissionsPath ,1000.0), new Mis ("Mission2.mis",SubMissionsPath ,1000.0), }; public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; try { foreach (Mis mi in MissionPool) GamePlay.gpPostMissionLoad(mi.PathToMission + mi.Missionfilename); } catch { GamePlay.gpLogServer(null, "File not found", null); } } public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) { base.OnPlaceEnter(player, actor, placeIndex); } } Last edited by FG28_Kodiak; 10-20-2011 at 02:13 PM. |
#13
|
|||
|
|||
Thank yoг for a good example. I will try creating a class for my needs and will come back with more questions if any.
S! |
#14
|
|||
|
|||
I did the exercise, sure with many mistakes but will do some reading on classes creation to correct them.
However I am stuck in OnTrigger method completely. I have several submissions running at the same time with the same filenames and the same trigger names. This happens because they are randomly loaded and the same submission can be loaded 2-4 times within an hour. How can I identify which trigger of which submission is triggered OnTrigger? I number my missions as "mi.MisMissionNumber" but their numbers are different from OnTrigger "missionNumber". The file is renamed to a .txt. If you have time to answer other questions I will appreciate it. Last edited by Ataros; 10-21-2011 at 02:44 PM. |
#15
|
|||
|
|||
Will take a look at it.
Short answers: Code:
public static string SubMissionsPath = @"missions\Multi\Dogfight\r_steppe\subs\"; // is @ necessary here? did not use it in other missions. Code:
// what does this block do? public Mis(string Filename, string misType, int Lengh) // should I include all the above variables here? { this.Missionfilename = Filename; // You use mi.Missionfilename instead of mi.Filename in your example when load missions. Why? this.MissionLengh = Lengh; this.MissionType = misType; this.TrgWasTriggered = wasTriggered; } So i can use Code:
public List<Mis> MissionPool = new List<Mis>() { new Mis ("Mission1.mis",SubMissionsPath ,1000.0), new Mis ("Mission2.mis",SubMissionsPath ,1000.0), }; // You use mi.Missionfilename instead of mi.Filename in your example when load missions. Why? I use the public method Missionfilename to get access to the variable in the object. Filename is only used in the constructor to give the value to the variable Missionfilename. More to come, must take a deeper look at it, but no time at the moment. But it seems you think a bit too complicated |
#16
|
|||
|
|||
Quote:
this.MissionLengh = 30; Ah, it looks like the only purpose of it is to allow data input like here: Code:
public List<Mis> MissionPool = new List<Mis>() { new Mis ("Mission1.mis",SubMissionsPath ,1000.0), new Mis ("Mission2.mis",SubMissionsPath ,1000.0), }; mi.Missionfilename = ...; mi.SubMissionsPath = ...; mi.MissionLengh = ...; Instead after parsing a file name I can: Code:
string[] MisParams; MisParams = (mi.Missionfilename).Split('_'); Mis mi = new Mis (MisParams[1], MisParams[2],MisParams[3]); Last edited by Ataros; 10-21-2011 at 05:30 PM. |
#17
|
|||
|
|||
first sorry for bumping an old thread.
im facing an issue implementing a "similar" (based) on this method script. my issue is, with multi-sit aircriaft. when you spawn in one of those and change seats with will result in decrease of 1 to the pool by each seat. much of the following CODE is not mine (around 90%) so no credit for it. Credit goes for Ataros, Kodiak, and some other guys, i cant recall everyone i steal from Quote:
|
#18
|
|||
|
|||
You can check if a player is already in a plane
Code:
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) { base.OnPlaceEnter(player, actor, placeIndex); int playercount = 0; if (actor != null && actor is AiAircraft) { AiAircraft aircraft = actor as AiAircraft; for (int i = 0; i < aircraft.Places(); i++) { if (aircraft.Player(i) != null) { if (aircraft.Player(i) == player) playercount++; } } } if (playercount == 1) .. } or you check PlaceSecondary, PlaceSecondary is -1 if a player is 'new' in a plane, if not new PlaceSecondary gets the value of the last secondary place. Code:
if (player.PlaceSecondary() != -1) .. Last edited by FG28_Kodiak; 05-20-2012 at 06:42 PM. |
#19
|
|||
|
|||
A bit unrelated to the actual discussion, but what you say about primary and secondary places confirms my observations about AI gunners.
We all know that if you switch to a gunner position the AI no longer mans the turret. Flying a Blenheim on ATAG one night, i happened to find out completely by chance that if your aircraft has a bombardier position you can give back gun control to the AI: simply cycle between pilot and bombardier once and your gunners will revert to AI control. This was also reflected on the net stats overlay, where next to my nickname i could see "pilot, gunner" initially and "pilot, bombardier" after cycling positions. Thanks for confirming my suspicions |
#20
|
|||
|
|||
thank you!
Worked like a charm! |
|
|