Did you manage to recognize static units with OnActorDead, that would be interesting. So far we only accounted for AI units with OnActorDead.
I also had problems with OnCrashLanded-Events but maybe you try landing in water, this is the only way I could reproduce a crash landing.
Code:
Dictionary<string, int> LWAvailableAirplanes = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.Bf-109E-3",60},
{"bob:Aircraft.Bf-109E-3B",24},
{"bob:Aircraft.Bf-109E-1",40},
{"bob:Aircraft.Bf-109E-4",50},
{"bob:Aircraft.Bf-109E-4B",24},
{"bob:Aircraft.Bf-110C-4",24},
{"bob:Aircraft.Bf-110C-7",24},
{"bob:Aircraft.Ju-87B-2",60},
{"bob:Aircraft.Ju-88A-1",40},
{"bob:Aircraft.He-111H-2",60},
{"bob:Aircraft.He-111P-2",20},
};
Dictionary<string, int> RAFAvailableAirplanes = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.SpitfireMkIa",30},
{"bob:Aircraft.SpitfireMkI",60},
{"bob:Aircraft.HurricaneMkI",50},
{"bob:Aircraft.HurricaneMkI_dH5-20",50},
{"bob:Aircraft.BlenheimMkIV",40},
{"bob:Aircraft.SpitfireMkIIa",0},
};
Dictionary<AiGroundActorType,int> PointsforGroundTargets = new Dictionary<AiGroundActorType,int>()
{
{AiGroundActorType.AAGun, 2},
{AiGroundActorType.AmmoComposition, 2},
{AiGroundActorType.Amphibian, 2},
{AiGroundActorType.ArmoredCar, 2},
{AiGroundActorType.Artillery, 2},
{AiGroundActorType.Balloon, 2},
{AiGroundActorType.Bridge, 2},
{AiGroundActorType.Bus, 2},
{AiGroundActorType.Car, 2},
{AiGroundActorType.ContainerLong, 2},
{AiGroundActorType.ContainerShort, 2},
{AiGroundActorType.EngineWagon, 2},
{AiGroundActorType.FreightWagon, 2},
{AiGroundActorType.Generator, 2},
{AiGroundActorType.House, 2},
{AiGroundActorType.LightTruck, 2},
{AiGroundActorType.Listener, 2},
{AiGroundActorType.Medic, 2},
{AiGroundActorType.Motorcycle, 2},
{AiGroundActorType.PassengerWagon, 2},
{AiGroundActorType.Plane, 2},
{AiGroundActorType.Predictor, 2},
{AiGroundActorType.Radar, 2},
{AiGroundActorType.RadioBeacon, 2},
{AiGroundActorType.RadioBeamProjector, 2},
{AiGroundActorType.SPG, 2},
{AiGroundActorType.Tank, 2},
{AiGroundActorType.Tractor, 2},
{AiGroundActorType.Trailer, 2},
{AiGroundActorType.Truck, 2},
//Schiffe
//{AiGroundActorType.ShipBattleship, 1},
//{AiGroundActorType.ShipCarrier, 1},
//{AiGroundActorType.ShipCruiser, 1},
//{AiGroundActorType.ShipSubmarine, 1},
{AiGroundActorType.ShipTransport, 25},
{AiGroundActorType.ShipMisc,2},
{AiGroundActorType.ShipDestroyer,50},
{AiGroundActorType.ShipSmallWarship, 50},
{AiGroundActorType.Unknown, 2}
};
Dictionary<string, int> PointsforAirTargets = new Dictionary<string, int>()
{
{"DiveBomber", 3},
{"Bomber", 3},
{"Bomber, DiveBomber",3},
{"AmphibiousPlane", 3},
{"TorpedoBomber", 3},
{"Transport", 3},
{"BNZFighter",1},
{"Fighter",1},
{"Glider",1},
{"HeavyFighter",2},
{"JaBo",1},
{"SailPlane",1},
{"Scout",1},
{"Sturmovik",1},
{"TNBFighter",1},
{"UNKNOWN",1}
};
public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);
if ((actor as AiGroundActor) != null && damages[0].initiator.Player != null)
GamePlay.gpLogServer(null, "{0} was destroyed by {1}", new object[] { (actor as AiCart).InternalTypeName().Substring(4), (damages[0].initiator.Player.Name()) });
foreach (DamagerScore ds in damages)
{
int Addpoints = 0;
int value;
bool willReportDead = false;
string TargetName = "";
if (ds.initiator != null)
{
if (ds.initiator.Actor != null)
{
if (actor.Army() != ds.initiator.Actor.Army())
{
if (actor is AiPerson) break; // At moment Pilotkills are not counted ;)
if (actor is AiAircraft)
{
if (PointsforAirTargets.TryGetValue((actor as AiAircraft).Type().ToString(), out value)) // Erstetzt wegen Stukaproblem
Addpoints = PointsforAirTargets[(actor as AiAircraft).Type().ToString()];
TargetName = SplitName((actor as AiAircraft).InternalTypeName());
value = 0;
if (actor.Army() == ArmyRed)
{
BlueAirKills++;
if (RAFAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
{
RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
TargetName += " (" + RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)"; // Shows Counter for Planetype
}
}
else if (actor.Army() == ArmyBlue)
{
RedAirKills++;
if (LWAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
{
LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
TargetName += " (" + LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)"; // Shows Counter for Planetype
}
}
}
if (actor is AiGroundActor)
{
if (PointsforGroundTargets.TryGetValue((actor as AiGroundActor).Type(), out value))
Addpoints = PointsforGroundTargets[(actor as AiGroundActor).Type()];
TargetName = SplitName((actor as AiGroundActor).InternalTypeName());
}
willReportDead = true;
if (ds.initiator.Actor.Army() == ArmyBlue)
{
BlueGrdKills++;
ScoreBlue += Addpoints;
if (Addpoints <=0)
{ScoreBlue += 3;}
GamePlay.gpLogServer(null, "Britisch {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
break;
}
else if (ds.initiator.Actor.Army() == ArmyRed)
{
RedGrdKills++;
ScoreRed += Addpoints;
if (Addpoints <=0)
{ScoreRed += 3;}
GamePlay.gpLogServer(null, "German {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
break;
}
}
}
}
}
}