View Single Post
  #9  
Old 05-27-2012, 03:57 PM
pupo162 pupo162 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 1,183
Default

Quote:
Originally Posted by FG28_Kodiak View Post
You can use two events:

Code:
 public override void OnAircraftKilled(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftKilled(missionNumber, shortName, aircraft);
    }
and
Code:
    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
    {
        base.OnActorDead(missionNumber, shortName, actor, damages);
    }
On OnAircraftKilled is called when a plane is not longer flyable, for example if the pilot get killed or its too heavy damaged, but you get not the damager.

OnActorDead is called later after a plane is hitting the ground or a GroundActor or AiPerson or AiGroup (a Ships is an AiGroup) is killed. And you can check the damagers.

OnActorDestroyed is called every time a Actor is removed from the game, so its also called if a script removed a empty plane. So you should use OnAircraftKilled or OnActorDead.
thanks! that puts some light on waht each one does. i started by using onactordead, but its giving some issues with exception errors, so im tryign on aircraft killed, still not workin.... yet.

Also, since you are here ( ), im havign were a damaged plane, when landed is not destroyed.

code here

Quote:
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);

Player player = null;



int value = 0;


if (aircraft.Player(0) != null)
{
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
// TODO: Account for more than one player in an aircraft
player = aircraft.Player(i);
break;
}
}

if (player != null)


switch (player.Army())
{
case 1:
if (rafa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
rafa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
bluescore = bluescore - rafv[(aircraft as AiAircraft).InternalTypeName()];
GamePlay.gpHUDLogCenter(new Player[] { player }, "Welcome Home, {0} : saved!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) }); // THIS MESSAGE IS STILL DISPLAYED!
Timeout(5, () =>
{ destroyPlane(aircraft); });

}

break;

case 2:
if (lwa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
lwa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
redscore = redscore - lwv[(aircraft as AiAircraft).InternalTypeName()];
GamePlay.gpHUDLogCenter(new Player[] { player }, "Welcome Home, {0} : saved!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) }); // THIS MESSAGE IS STILL DISPLAYED!
Timeout(5, () =>
{ destroyPlane(aircraft); });

}
break;

}
}
}
Reply With Quote