PDA

View Full Version : OnActorDead ??



_1SMV_Poppy_64
May-03-2014, 15:21
Hi all, as you can imagine, I'm tryng to using a script to write an eventlog with all useful events for a stat...

I'm close to finish but I can't intercept the name of the object (aircraft AI or Human or other) that destroy an actor.
Imagine a mission with a vehicle moving on a road and a player that destroy it.
With the class OnActorDead I have not the initiator:



public override void OnActorDestroyed(int missionNumber, string shortName, AiActor actor)
{
base.OnActorDestroyed(missionNumber, shortName, actor);
double posizionex = actor.Pos().x;
double posizioney = actor.Pos().y;

GamePlay.gpHUDLogCenter("DEBUG -> OnActorDestroyed " + shortName + " ARMY " + actor.Army() + " totally destroyed" + " at " + posizionex.ToString("0") + " " + posizioney.ToString("0") + " MIS N° " + missionNumber.ToString("0"));
}


as you can see there is not the INITIATOR.

MOD - T.F. 4.312
Someone has a suggestion?
Thank you!

Salmo
May-03-2014, 17:30
I'm well aware of this problem & have solutions. The issue is not quite as straight forward as you might think.

There can be many damage INITIATORS for one dead actor. You could have one damage initiator kill the actor outright. Or you could have several initiators severely damage another actor, then just a very tiny amount of further damage from one last initiator will 'kill' the actor.

So what do you want? Only the initiator that did the most damage? The first initiator than did the damage? The last initiator that did damage? All the initiators that did damage to the dead actor? All the initiators that did damge to the dead actor and how much damage they did? Then you've got the instance where an actor dies but there are NO damage INITIATORS. How do you want that circumstance treated?

_1SMV_Poppy_64
May-03-2014, 18:54
Thank you Salmo for your support as first.

I think that is sufficient to have the last player initiator that did damage.

Thank you again...

Salmo
May-03-2014, 19:54
Thank you Salmo for your support as first. I think that is sufficient to have the last player initiator that did damage. Thank you again...

Solution published HERE http://theairtacticalassaultgroup.com/forum/showthread.php?t=10653&p=117008#post117008 (needs testing)

_1SMV_Poppy_64
May-04-2014, 15:30
Solution published HERE http://theairtacticalassaultgroup.com/forum/showthread.php?t=10653&p=117008#post117008 (needs testing)


Thank you again!

Salmo
May-05-2014, 09:05
Poppy, since you only want the initiators, here's a little function that will give you a string with all the damage initiators. Hint: There IS a damage initiator contained in the damages list of the OnActor Dear method.



public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);
string damageinitiators = GetDamageInitiators(damages);
// Your code here to show the damagers string or whatever ....
}

public string GetDamageInitiators(List<DamagerScore> damages)
{ // returns a string of damage initiators
string damageinitiators = string.Empty;
for (int i = 0; i < damages.Count; i++)
{
if (damages[i].initiator.Player != null)
{ // damage initiator is a player
damageinitiators = string.Concat(damageinitiators, ", ", damages[i].initiator.Player.Name());
}
else
{ // damage initiator is some sort of Ai (or nothing)
AiActor AiDamager = damages[i].initiator.Actor;
if (AiDamager is AiAircraft)
{
damageinitiators = string.Concat(damageinitiators, ", ", (AiDamager as AiAircraft).TypedName());
}
else if (AiDamager is AiGroundActor)
{
AiGroundActor ga = AiDamager as AiGroundActor;
damageinitiators = string.Concat(damageinitiators, ", ", ga.Type());
}
else
{
damageinitiators = string.Concat(damageinitiators, " Unknown");
}
}
}
return damageinitiators;
}

_1SMV_Poppy_64
May-06-2014, 16:56
Thank you Salmo!

here the line wrote by the script


OnActorDead 0:1_Chief0 ARMY 2 totally destroyed by , 1SMV_Poppy_64 at 66627 69594 MIS N° 0

The comma is a separator for the iniziators I think...

Thank you again!!!