![]() |
|
#1
|
|||
|
|||
![]()
Thanks FG28_Kodiak,
As I am in the steep learning curve in how to do 'scripting', I would like a complete script. I appreciate your help and it will help me to learn more about scripting in my next campaigns. If you need to see the complete campaign, contact me privately through the forum. DFLion |
#2
|
|||
|
|||
![]()
I have just finished scripting my 'Battle of France' campaign and it seems to be working very well. The only thing that doesn't work is that if you are successful in a mission, then have to leave the game (for some reason), when you come back to the (game) campaign it doesn't start where you left it????
My KG1.111_Ju88 campaign is still not working properly? Need some help 'boys and girls'? DFLion |
#3
|
|||
|
|||
![]()
At the moment i about to finish a checkAirfield Routine:
Code:
using System; using System.Text; using System.Collections; using System.Collections.Generic; using maddox.game; using maddox.game.world; using maddox.GP; public class Mission : AMission { AiAirport PlayerStartAirport; AiAirport PlayerEndAirport; AiAircraft PlayerAircraft; internal AiAirport getNearestAirfield(Player player) { AiAirport NearestAirfield = null; AiAirport[] airports = GamePlay.gpAirports(); Point3d PlayerStartPos = player.Place().Pos(); if (airports != null) { foreach (AiAirport airport in airports) { if (NearestAirfield != null) { if (NearestAirfield != null) if (NearestAirfield.Pos().distance(ref PlayerStartPos) > airport.Pos().distance(ref PlayerStartPos)) NearestAirfield = airport; } else NearestAirfield = airport; } } return NearestAirfield; } internal AiAirport getNearestAirfield(AiWayPoint waypoint) { AiAirport NearestAirfield = null; AiAirport[] airports = GamePlay.gpAirports(); Point3d WaypointPos = waypoint.P; if (airports != null) { foreach (AiAirport airport in airports) { if (NearestAirfield != null) { if (NearestAirfield != null) if (NearestAirfield.Pos().distance(ref WaypointPos) > airport.Pos().distance(ref WaypointPos)) NearestAirfield = airport; } else NearestAirfield = airport; } } return NearestAirfield; } internal bool checkAirfield(Player player, AiAirport airport, double maxdistance) { Point3d PlayerPos = player.Place().Pos(); GamePlay.gpLogServer(null, "Distanz zum Flugplatz {0}", new object[] {airport.Pos().distance(ref PlayerPos)}); //test if (airport.Pos().distance(ref PlayerPos) < maxdistance) return true; else return false; } public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; } private void checkLanded(AiAircraft aircraft) { if (GamePlay.gpPlayer().Place() != aircraft) return; } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { if (aircraft.Player(0) != null) { if (checkAirfield(aircraft.Player(0) , PlayerStartAirport, 2000.0)) GamePlay.gpHUDLogCenter("Mission Successfull"); } } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { if (aircraft.Player(0) != null) { if (checkAirfield(aircraft.Player(0), PlayerStartAirport, 2000.0)) GamePlay.gpHUDLogCenter("Mission Successfull"); } } public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) { base.OnPlaceEnter(player, actor, placeIndex); if (PlayerStartAirport== null) PlayerStartAirport = getNearestAirfield(player); AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay(); int i = Wp.Length; if (i > 0) { AiWayPoint EndPoint = Wp[i - 1]; if (PlayerEndAirport == null) PlayerEndAirport = getNearestAirfield(EndPoint); } else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() }); } } This Code:
AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay(); int i = Wp.Length; if (i > 0) { AiWayPoint EndPoint = Wp[i - 1]; if (PlayerEndAirport == null) PlayerEndAirport = getNearestAirfield(EndPoint); } else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() }); Last edited by FG28_Kodiak; 10-06-2011 at 08:25 AM. |
#4
|
|||
|
|||
![]()
These two script routines look very promising Kodiak. I will wait until you test them further. Thankyou again.
DFLion |
![]() |
Thread Tools | |
Display Modes | |
|
|