![]() |
|
#1
|
|||
|
|||
![]()
~S
I would appear Beta 4 breaks all of these kill actor scripts... well it does 4 me |
#2
|
|||
|
|||
![]()
Phew its not just our server then, I rolled back to Beta 1 and the scripts work again.
|
#3
|
|||
|
|||
![]()
And it reintroduces the stutters online which I kinda missed .....NOT!....lol. Rolled client back to 14305 will try on Matoni's OGN later.
![]() |
#4
|
|||
|
|||
![]() Quote:
Code:
// v.1.6.17 trig NEW using System; using maddox.game; using maddox.game.world; using System.Collections.Generic; public class Mission : AMission { // 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); aircraft.hitNamed (part.NamedDamageTypes.Eng0TotalFailure); aircraft.hitNamed (part.NamedDamageTypes.Eng1TotalFailure); /***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); } ); } } |
#5
|
|||
|
|||
![]()
Sample shows moving frontline and changing spawnpoints from red to blue and vice versa based on trigger (flyby above an airfield).
Can someone program a small 3 airfields battle based on it? Say a middle airfield becomes red or blue based on which tanks remain alive after taking the airfield. Then spawn new groups of tanks in say 20 minutes for a new round. Code:
using System; using System.Collections; using maddox.game; using maddox.game.world; public class Mission : AMission { internal class MissionMarker { internal double x; internal double y; internal int army; internal MissionMarker(double x, double y, int army) { this.x = x; this.y = y; this.army = army; } } private MissionMarker[] MissionMarkers = new MissionMarker[] { new MissionMarker(17100.80,14515.20,2), new MissionMarker(20428.80, 8934.40, 2), new MissionMarker(12492.80, 17203.20, 1), new MissionMarker(11801.60, 21555.20, 1) }; internal ISectionFile CreateNewFrontLineMission(int markerNum, int newArmy) { MissionMarkers[markerNum].army = newArmy; foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces()) { if (bp != null) bp.destroy(); } ISectionFile f = GamePlay.gpCreateSectionFile(); string sect; string key; string value; sect = "FrontMarker"; for (int i = 0; i < MissionMarkers.Length; i++) { key = "FrontMarker" + i.ToString(); value = MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].army.ToString(); f.add(sect, key, value); } sect = "BirthPlace"; for (int i = 0; i < MissionMarkers.Length; i++) { key = "BirthPlace_" + i.ToString(); value = " " + MissionMarkers[i].army.ToString() + " " + MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " 0 10 1 0 . . ."; f.add(sect, key, value); } return f; } public override void OnTrigger(int missionNumber, string shortName, bool active) { base.OnTrigger(missionNumber, shortName, active); for (int i = 0; i < MissionMarkers.Length; i++) for (int j = 1; j < 3; j++) { string str = "changeArmy" + i.ToString() + "_" + (j).ToString(); if (str.Equals(shortName)) { string armyOwner; if (j == 1) { armyOwner = " Red army"; } else { armyOwner = " Blue army"; } GamePlay.gpHUDLogCenter("Airdrome: " + i.ToString() + " turn to " + armyOwner); GamePlay.gpPostMissionLoad(CreateNewFrontLineMission(i, j)); } } AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName)); if (action != null) action.Do(); } } Last edited by Ataros; 05-06-2011 at 07:51 AM. |
#6
|
|||
|
|||
![]()
Okay. I think I've got a handle on how to create and manipulate "MissionMarkers" aka Front Markers in a script. I've attached a simple, commented example. Shoot down the bomber in front of you and the southwest airfield's front marker changes to blue.
Quote:
Do you have a link to a tutorial on how to create multiplayer missions? |
#7
|
|||
|
|||
![]() Quote:
When new submission is loaded it can contain a new moved frontline and a new birthplace (e.g. red one) in the location where the blue one used to be. The problem is the old birthplace is not removed by loading a new submission and blue aircraft still can be created in the newly captured red airfield. That is why you need to destroy an old blue birthplace with a script I guess: Code:
foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces()) { if (bp != null) bp.destroy(); } Ideally I would like to move the frontline and change side of these 2 birthplaces based on results of a recent submission. Say if reds loose more aircrafts or tanks (or more then say 70%) in recent mission reds loose an airfield in D3. If they win next mission they take it back, etc. and repeat it forever. In the future I believe this script can be used to move frontline across the whole map to create an ongoing war. Please find a recent version of my mission attached. Last edited by Ataros; 05-16-2011 at 11:50 AM. |
#8
|
|||
|
|||
![]()
Could some C# experts check this part of script for errors. Trying to randomize submission loading here. Thanks to Groundhog for idea.
Intended to run in cycle forever. Does not work for me ( Need help please. Code:
using System; using maddox.game; using maddox.game.world; using System.Collections.Generic; public class Mission : AMission { // loading sub-missions public override void OnTickGame() { if (Time.tickCounter() % 54000 == 12600) // 54000=30 min repeat. 12600=7 min delay. { // randomly selects 1 of several submissions Random RandomIncident = new Random(); switch (RandomIncident.Next(1, 3)) { case 1: GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/BoF1/BoF1_air01.mis"); // GamePlay.gpHUDLogCenter("mis1 loaded!"); double initTime = 0.0; Timeout(initTime += 600, () => { GamePlay.gpHUDLogCenter("Attention! Enemy activity is expected at E3!"); }); Timeout(initTime += 600, () => { GamePlay.gpHUDLogCenter("Attention! Help is needed at E3/D4!"); }); break; case 2: GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/BoF1/BoF1_sea01.mis"); // GamePlay.gpHUDLogCenter("mis2 loaded"); double initTime = 0.0; Timeout(initTime += 500, () => { GamePlay.gpHUDLogCenter("Attention! Cover your shipping at C4!"); }); Timeout(initTime += 300, () => { GamePlay.gpHUDLogCenter("Attention! Ships are under attack at C4!"); }); break; case 3: GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/BoF1/BoF1_air02.mis"); // GamePlay.gpHUDLogCenter("mis3 loaded!"); double initTime = 0.0; Timeout(initTime += 600, () => { GamePlay.gpHUDLogCenter("Attention! Enemy activity is expected at E2!"); }); Timeout(initTime += 300, () => { GamePlay.gpHUDLogCenter("Attention! All airgroups please proceed to E2/D3!"); }); break; } } /////////////////////// //loads small submissions w/o messages if (Time.tickCounter() % 216000 == 108000) // 216000=120 min repeat. 108000=60 min delay. { GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/BoF1/BoF1_small01.mis"); } if (Time.tickCounter() % 216000 == 215999) // 216000=120 min repeat. 215999=120 min delay. { GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/BoF1/BoF1_small02.mis"); } } } Last edited by Ataros; 05-16-2011 at 07:56 PM. |
#9
|
|||
|
|||
![]()
Thanks for the help Ataros, I'll start experimenting with that right away.
As for your code, what exactly isn't working? I can tell you right now that case 3 will never run because the Next(int, int) method returns an integer greater than or equal to the smaller number, but only less than the larger number. In other words, it will never return three, just one or two. It should look like this: switch (RandomIncident.Next(1, 4)) See here: http://msdn.microsoft.com/en-us/library/2dx6wyd4.aspx |
#10
|
||||
|
||||
![]() Quote:
I'm slowly getting to grips with this ![]() I have a script for generating sub-missions, messages etc., and want to start a later flight in the same mission to make a second later attack on a convoy in the same mission but I can't seem to set a later start time in FMB Object Viewer. There's no way to change it from the main mission start time of 12:00 (which seems a bit daft). Can I script a start time for a planned mission or perhaps a spawn, aircraft. waypoints etc? I tried to follow your moving front line and army changes but I can't see how to make it work for a new flight.
__________________
klem 56 Squadron RAF "Firebirds" http://firebirds.2ndtaf.org.uk/ ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders |
![]() |
Thread Tools | |
Display Modes | |
|
|