![]() |
#1
|
|||
|
|||
![]()
Can someone help me with building a test script for this?
ATAG is great but we could add a little move incentive to players to complete there missions by landing by adding a score in to either their Kill score or to a Mission complete tally. And stop people ejecting over channel or landing at enemy air bases to do a quick re-spawn. This could also add to the Refuel/ Re-arm / Repair (RRR) scenario. Can someone help me with this script. 1) If player has Landed 2) If RRR vehicles are not present then Spawn vehicles xyz (Refuel truck, Repair & Ammo trucks) at a standard point near Hangar or on airbase. Have them drive to a designated area on airfield assigned to RRR. (feel of airport is alive). 3) If the player is landed and engines off in this area for 5 seconds points are awarded as they have landed safely, refuelled, rearmed and repaired. 4) Ontick time or if player not present the RRR vehicles destroyed Possibility to introduce minus score to people who do not land plane in designated (RRR) area. Maybe Bliss could you send me the current ATAG mission for me to Test with off line?
__________________
__________________ Win7, 64bit Ultra Asus P8P67Pro MB Intel i7-2600K Coursair 16GB (4x 4GB), DDR3-1600MHz Gainward Nvidia 580GTX 3GB DDR5 850-Watt Modular Power Supply WIN7 and COD on Gskill SSD 240GB 40" Panasonic LCD TrackIR5 + Thrustmaster Warthog stick, throttle & pedals |
#2
|
|||
|
|||
![]()
I was not aware that there is a Refuel/Rearm/Repair active scenario? I am all for it for special scoring for taking care of your plane.
|
#3
|
|||
|
|||
![]()
This is a script i made may be its usefull for you:
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 { internal class PilotInfo { public Player player { get; set; } public AiAirport StartAirport { get; set; } public AiAirport DestinationAirport { get; set; } public AiActor CurrActor { get; set; } } internal class PilotList { internal AiAirport[] AirportsMap; internal List<PilotInfo> PilotsInMission = new List<PilotInfo>(); public void AddAirports(AiAirport[] airports) { AirportsMap = airports; } public void AddPilot(Player player, AiActor actor) { foreach (PilotInfo pi in PilotsInMission) { if (pi.player == player) { if (pi.CurrActor != actor) { pi.CurrActor = actor; pi.StartAirport = getNearestAirfield(player); if (getEndAirfield(player) != null) pi.DestinationAirport = getEndAirfield(player); else //if no Destinationairport (no Waypoints) set Destinationairport = Startairport pi.DestinationAirport = getNearestAirfield(player); } return; } } PilotInfo NewPilot = new PilotInfo(); NewPilot.player = player; NewPilot.CurrActor = actor; NewPilot.StartAirport = getNearestAirfield(player); if (getEndAirfield(player) != null) NewPilot.DestinationAirport = getEndAirfield(player); else //if no Destinationairport (no Waypoints) set Destinationairport = Startairport NewPilot.DestinationAirport = getNearestAirfield(player); PilotsInMission.Add(NewPilot); } private AiAirport getNearestAirfield(Player player) { AiAirport NearestAirfield = null; AiAirport[] airports = AirportsMap; 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 = AirportsMap; 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; } public bool checkIsStartAirfield(Player player, double maxdistance) { Point3d PlayerPos = player.Place().Pos(); bool tmpIsStartAirfield = false; foreach (PilotInfo pi in PilotsInMission) { if (pi.player == player) { if (pi.StartAirport.Pos().distance(ref PlayerPos) < maxdistance) tmpIsStartAirfield = true; else tmpIsStartAirfield = false; break; } } return tmpIsStartAirfield; } public bool checkIsDestinationAirfield(Player player, double maxdistance) { Point3d PlayerPos = player.Place().Pos(); bool tmpAirfield = false; foreach (PilotInfo pi in PilotsInMission) { if (pi.player == player) { if (pi.DestinationAirport.Pos().distance(ref PlayerPos) < maxdistance) tmpAirfield = true; else tmpAirfield = false; break; } } return tmpAirfield; } public bool checkIsStartAirfield(AiActor actor, double maxdistance) { Point3d ActorPos = actor.Pos(); bool tmpIsStartAirfield = false; foreach (PilotInfo pi in PilotsInMission) { if (pi.CurrActor == actor) { if (pi.StartAirport.Pos().distance(ref ActorPos) < maxdistance) tmpIsStartAirfield = true; else tmpIsStartAirfield = false; break; } } return tmpIsStartAirfield; } public bool checkIsDestinationAirfield(AiActor actor, double maxdistance) { Point3d ActorPos = actor.Pos(); bool tmpAirfield = false; foreach (PilotInfo pi in PilotsInMission) { if (pi.CurrActor == actor) { if (pi.DestinationAirport.Pos().distance(ref ActorPos) < maxdistance) tmpAirfield = true; else tmpAirfield = false; break; } } return tmpAirfield; } public AiAirport getEndAirfield(Player player) { AiAirport tmpAirport = null; AiWayPoint[] Wp = player.Place().Group().GetWay(); int i = Wp.Length; if (i > 0) { AiWayPoint EndPoint = Wp[i - 1]; if ((EndPoint as AiAirWayPoint).Action == AiAirWayPointType.LANDING) tmpAirport = getNearestAirfield(EndPoint); } return tmpAirport; } public AiAirport returnDestinationAirport(Player player) { AiAirport tmpAirport = null; foreach (PilotInfo pi in PilotsInMission) { if (pi.player == player) { tmpAirport = pi.DestinationAirport; } } return tmpAirport; } } PilotList AllPilotsInMission = new PilotList(); public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); GamePlay.gpLogServer(null, "--->gelandet<---", null); if (aircraft.Player(0) != null) if (AllPilotsInMission.checkIsStartAirfield(aircraft.Player(0), 2000.0)) GamePlay.gpLogServer(null, "Player ist auf Ausgangsflugplatz gelandet", null); else GamePlay.gpLogServer(null, "Player ist NICHT auf Ausgangsflugplatz gelandet", null); if (aircraft.Player(0) != null) if (AllPilotsInMission.checkIsDestinationAirfield(aircraft.Player(0), 2000.0)) GamePlay.gpLogServer(null, "Player ist auf Zielflugplatz gelandet", null); else GamePlay.gpLogServer(null, "Player ist NICHT auf Zielflugplatz gelandet", null); } public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex) { base.OnPlaceLeave(player, actor, placeIndex); // tests if (actor != null) if (AllPilotsInMission.checkIsStartAirfield(actor, 2000.0)) GamePlay.gpLogServer(null, "Plane is on Destination Airfield", null); else GamePlay.gpLogServer(null, "Plane is NOT on Destination Airfield", null); if (actor != null) if (AllPilotsInMission.checkIsDestinationAirfield(actor, 2000.0)) GamePlay.gpLogServer(null, "Plane is on Destination Airfield", null); else GamePlay.gpLogServer(null, "Plane is NOT on Destination Airfield", null); } public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) { base.OnPlaceEnter(player, actor, placeIndex); AllPilotsInMission.AddAirports(GamePlay.gpAirports()); AllPilotsInMission.AddPilot(player, actor); //tests if (AllPilotsInMission.checkIsStartAirfield(player, 2000.0)) GamePlay.gpLogServer(null, "Player is on Start Airfield", null); if (AllPilotsInMission.checkIsDestinationAirfield(player, 2000.0)) GamePlay.gpLogServer(null, "Player is on Destination Airfield", null); } } |
#4
|
|||
|
|||
![]()
Stop landing at enemy airfields ....
Code:
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces()) { double CircleRadius = 1000.00; if (Math.Sqrt(Math.Pow((bp.Pos().x - aircraft.Pos().x), 2) + (Math.Pow((bp.Pos().y - aircraft.Pos().y), 2))) <= CircleRadius) { // landed within 1km of an airbase if(bp.Army() != aircraft.Army()) { // landed at enemy base so penalise the player sendScreenMessageToPilot(aircraft, "Not allowed to land at enemy base " + bp.Name().ToString(), null); // add any penalties here } } } } private void sendScreenMessageToPilot(AiAircraft aircraft, string msg, object[] parms) { // send a screen message to the pilot of specified aircraft ONLY GamePlay.gpHUDLogCenter(new Player[] { aircraft.Player(0) }, msg, null); }
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash. Get the latest COD Team Fusion patch info HERE Last edited by salmo; 02-07-2012 at 02:10 PM. |
#5
|
|||
|
|||
![]()
Thanks FG28 and Salmo, this is a great start. I will begin compiling and testing. Once I build the basic structure I will post again to see what's missing and needs to be added.
Anyone else think they have code that can assist?
__________________
__________________ Win7, 64bit Ultra Asus P8P67Pro MB Intel i7-2600K Coursair 16GB (4x 4GB), DDR3-1600MHz Gainward Nvidia 580GTX 3GB DDR5 850-Watt Modular Power Supply WIN7 and COD on Gskill SSD 240GB 40" Panasonic LCD TrackIR5 + Thrustmaster Warthog stick, throttle & pedals |
#6
|
|||
|
|||
![]()
This is part of my Debriefing Script (work in progress)
![]() I store the playernames of the players which use a plane with timestamps and position for entering and leaving. So i can decide to evaluate the usage of an actor. If a player leaves the plane short before it is Killed, i can get the players using this plane anyway ![]() Code:
public class ActorUsage { public class CrewMember { public string CrewmanName { get; set; } public int CrewmanPlace { get; set; } internal DateTime EnterTime { get; set; } internal DateTime LeaveTime { get; set; } internal Point3d EnterPlanePos { get; set; } internal Point3d LeavePlanePos { get; set; } public CrewMember(Player player, int placeIndex, Point3d enterPos) { this.CrewmanName = player.Name(); this.CrewmanPlace = placeIndex; this.EnterPlanePos = enterPos; this.EnterTime = DateTime.Now; } } public class ActorDetails { public AiActor actor { get; set; } public AiAirport StartAirport { get; set; } public bool AircraftUsed = false; public bool AircraftDamaged = false; public List<CrewMember> CrewHistory = new List<CrewMember>(); public bool IsActorAirborne(AiActor actor) { if (actor == null || !actor.IsAlive() || !(actor as AiAircraft).IsAirborne() || (actor as AiAircraft).getParameter(part.ParameterTypes.Z_AltitudeAGL, -1) <= 2.0 || (actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0 ) { return false; } else return true; } } public List<ActorDetails> ActorHistory = new List<ActorDetails>(); public void PlaceEnter(Player player, AiActor actor, int placeIndex) { if (actor != null && !ActorHistory.Exists(item => item.actor == actor)) { ActorDetails NewActor = new ActorDetails(); NewActor.actor = actor; NewActor.CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos())); ActorHistory.Add(NewActor); } else if (actor != null) { int i = ActorHistory.FindIndex(item => item.actor == actor); if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name()))) { int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name())); ActorHistory[i].CrewHistory[j].CrewmanPlace = placeIndex; } else { ActorHistory[i].CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos())); } } } public void PlaceLeave(Player player, AiActor actor, int placeIndex) { if (actor != null && ActorHistory.Exists(item => item.actor == actor)) { int i = ActorHistory.FindIndex(item => item.actor == actor); if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name()))) { int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name())); Point3d tmpPoint = ActorHistory[i].CrewHistory[j].EnterPlanePos; if ((actor as AiAircraft).Pos().distance(ref tmpPoint) < 1) { ActorHistory[i].CrewHistory.RemoveAt(j); // no position changes of plane so delete the crewman entry } else { ActorHistory[i].CrewHistory[j].LeavePlanePos = (actor as AiAircraft).Pos(); ActorHistory[i].CrewHistory[j].LeaveTime = DateTime.Now; ActorHistory[i].AircraftUsed = true; } } } } public List<KeyValuePair<string, int>> ActorDead(AiActor actor) { List<KeyValuePair<string, int>> tmpActorPlace = new List<KeyValuePair<string, int>>(); if (ActorHistory.Exists(item => item.actor == actor)) { int i = ActorHistory.FindIndex(item => item.actor == actor); ActorHistory[i].CrewHistory.ForEach(item => { tmpActorPlace.Add(new KeyValuePair<string, int>(item.CrewmanName, item.CrewmanPlace)); }); return tmpActorPlace; } else return null; } public List<AiActor> GetActors() { List<AiActor> tmpActors = new List<AiActor>(); foreach (ActorDetails ad in ActorHistory) { tmpActors.Add(ad.actor); } return tmpActors; } public List<string> GetActorPlayer() { List<string> tmpStrings = new List<string>(); foreach (ActorDetails ad in ActorHistory) { foreach (CrewMember cm in ad.CrewHistory) { tmpStrings.Add(ad.actor.Name().ToString() + "::" + ad.AircraftUsed + "::" + cm.CrewmanName + "::" + cm.CrewmanPlace.ToString() + "::" + cm.EnterTime.ToShortTimeString() + "::" + cm.LeaveTime.ToShortTimeString()); } } return tmpStrings; } } |
#7
|
|||
|
|||
![]()
Kodiak, you put him right back into the cockpit if he leaves the plane via ESC until the plane is destroyed?
|
#8
|
|||
|
|||
![]()
No, only bad statistic.
![]() But its also possible to force him back into Cockpit, with few modifications ![]() |
![]() |
|
|