PDA

View Full Version : ATAG Great But... Improvement idea.


hc_wolf
02-07-2012, 12:31 AM
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?

KDN
02-07-2012, 12:07 PM
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.

FG28_Kodiak
02-07-2012, 12:38 PM
This is a script i made may be its usefull for you:

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(air craft.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(act or, 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(pla yer, 2000.0))
GamePlay.gpLogServer(null, "Player is on Destination Airfield", null);
}

}

salmo
02-07-2012, 12:43 PM
Stop landing at enemy airfields ....


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);
}

hc_wolf
02-07-2012, 05:50 PM
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?

FG28_Kodiak
02-08-2012, 05:40 AM
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 ;).


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_Alt itudeAGL, -1) <= 2.0
|| (actor as AiAircraft).getParameter(part.ParameterTypes.Z_Vel ocityTAS, -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;
}
}

SNAFU
02-08-2012, 08:44 AM
Kodiak, you put him right back into the cockpit if he leaves the plane via ESC until the plane is destroyed?

FG28_Kodiak
02-08-2012, 08:56 AM
No, only bad statistic. ;)
But its also possible to force him back into Cockpit, with few modifications :rolleyes: