OnActorDead - was it the player?
I'm trying to determine if when an aricraft/actor is shot down if the player was involved.
My thought is that the onActorDead provides the actor that died, but also a list of damage initiators and the score and time for each of these? I seem to be able to count these from the 'list' but am stuck trying to loop through the list with a 'foreach'. I have never used a C# list before so might be totally wrong on what I'm attempting.
So count works, I think:
Code:
public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
{
Console.WriteLine("" + shortName + " is dead actor");
Console.WriteLine("Count " + damages.Count);
}
But if I try this to hopefully go through each score value (I actually intend to check the initiators if one is the player but am trying to just start with the score values as practice on getting something from the list):
Code:
public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
{
Console.WriteLine("" + shortName + " is dead actor");
//Console.WriteLine("Count " + damages.Count);
foreach (double s in damages)
Console.WriteLine(s);
}
I get an errror in the script compiler saying: Cannot convert type 'maddox.game.world.DamagerScore' to 'double'
but if I see correctly in my object browser the DamagerScore method is like this: public DamagerScore(maddox.game.world.AiDamageInitiator i, double s, double t)
Am I even close? Is there an easy way to check if a dead/killed/destroyed aircraft(actor) was damaged by the player?
Re: OnActorDead - was it the player?
Try this:
Code:
foreach(maddox.game.world.DamagerScore damage in damages)
{
Now do something with "damage.whatever"
...
}
Re: OnActorDead - was it the player?
Quote:
Originally Posted by
Yo-Yo
But if I try this to hopefully go through each score value (I actually intend to check the initiators if one is the player but am trying to just start with the score values as practice on getting something from the list):
Code:
public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
{
Console.WriteLine("" + shortName + " is dead actor");
//Console.WriteLine("Count " + damages.Count);
foreach (double s in damages)
Console.WriteLine(s);
}
maddox.game.world.DamagerScore objects expose those properties :
initiator : as AiDamageInitiator
score : as double
time : as double
So, your code could be like :
Code:
public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
{
Console.WriteLine("" + shortName + " is dead actor");
//Console.WriteLine("Count " + damages.Count);
foreach ((maddox.game.world.DamagerScore)objDamage in damages)
Console.WriteLine(objDamage.score);
}
This is lunch time so I have no time to test yet.
Re: OnActorDead - was it the player?
BTW, I use this tool :
https://www.jetbrains.com/decompiler/
Very useful to discover interfaces of classes, inheritances, subtypes and more.
Re: OnActorDead - was it the player?
Thanks both, that should be enough for me to go on for now. Appreciated.
Re: OnActorDead - was it the player?
Quote:
Originally Posted by
Sleepy_Fly
Oh that seems very usefiul indeed. Will take me a while to get my head around it but I think that allows me to see much of the stuff I was generally banging my head over repeatedly.
Re: OnActorDead - was it the player?
Quote:
Originally Posted by
Yo-Yo
Oh that seems very usefiul indeed. Will take me a while to get my head around it but I think that allows me to see much of the stuff I was generally banging my head over repeatedly.
(un)fortunately, the core code is obfuscated ;-)
Re: OnActorDead - was it the player?
Code:
foreach (DamagerScore ds in damages)
{
if (ds.initiator.Player != null) {
// check Player name
}
}
Re: OnActorDead - was it the player?
Quote:
Originally Posted by
ATAG_Oskar
Code:
foreach (DamagerScore ds in damages)
{
if (ds.initiator.Player != null) {
// check Player name
}
}
Ooo nice! Thanks.
Re: OnActorDead - was it the player?
Re: OnActorDead - was it the player?