1C Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official 1C Company forum > 1C Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2011, 10:49 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default Getting the actor type?

This is probably very obvious, but I just can't seem to crack it. I'm trying to get the actor type when the actor is destroyed ie ship, car, plane etc. here's what I tried

code removed by author
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE

Last edited by salmo; 10-18-2012 at 10:24 AM.
Reply With Quote
  #2  
Old 12-22-2011, 11:07 AM
41Sqn_Banks 41Sqn_Banks is offline
Approved Member
 
Join Date: Oct 2007
Posts: 644
Default

If you want to observer the individual ground actors use this:
Code:
public override void OnActorDestroyed(int missionNumber, string shortName, maddox.game.world.AiActor actor)
{
    if (actor is AiGroundActor)
    {
        AiGroundActor groundActor = actor as AiGroundActor;
        if (groundActor.Type() == AiGroundActorType.ShipTransport /* || groundActor.Type() == AiGroundActorType.ShipDestroyer || ... */)
        {
            GamePlay.gpHUDLogCenter("Ship destroyed");
        }
    }
}
If you are interested in the complete ground group (e.g. a column or tank group) use this:
Code:
public override void OnActorDestroyed(int missionNumber, string shortName, maddox.game.world.AiActor actor)
{
    if (actor is AiGroundGroup)
    {
        AiGroundGroup groundGroup = actor as AiGroundGroup;
        if (groundGroup.GroupType() == AiGroundGroupType.Ship)
        {
            GamePlay.gpHUDLogCenter("Ship destroyed");
        }
    }
}
Reply With Quote
  #3  
Old 12-22-2011, 11:07 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Thanks Banks
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
Reply With Quote
  #4  
Old 12-22-2011, 12:25 PM
Octocat Octocat is offline
Junior Member
 
Join Date: Dec 2011
Posts: 22
Default

Something like this:

Code:
if (actor != null)
{
  if (actor is AiAirGroup)
  {
    var airgrp = (AiAirGroup)actor;
    // processing air group
  }
  else if (actor is AiAircraft)
  {
    var aircft = (AiAircaft)actor;
    // processing aircraft
  }
  else
  {
     LogMessage("Destroyed unknown actor type: {0}", actor.GetType().Name);
  }
}

Real problem for me, is in ActorDead handler, to separate between actor killed / disapeared events. Has someone solution?
Reply With Quote
  #5  
Old 05-27-2012, 11:36 AM
pupo162 pupo162 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 1,183
Default

here comes pupo ressutecting the dead again.

As anyoen foudn a solution for what Octocat was asking?

i need to creat an exception for the actor destroyd, so that planes who are reflown dont count as destroyed.
Reply With Quote
  #6  
Old 05-27-2012, 02:14 PM
FG28_Kodiak FG28_Kodiak is offline
Senior Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

All disapearing Actors are registered in
OnActorDestroyed(..)

If this was the Question.
Reply With Quote
  #7  
Old 05-27-2012, 03:03 PM
pupo162 pupo162 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 1,183
Default

No kodiak.

in my code i give points to teams on a plane his destroyed. yet the game also uses destroy to get rid of planes. so if i refly, the plane i refly gets caught by onactordestryed, and a kill is given to the enemy.

is there a way to avoid this?
Reply With Quote
  #8  
Old 05-27-2012, 03:37 PM
FG28_Kodiak FG28_Kodiak is offline
Senior Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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.

Last edited by FG28_Kodiak; 05-27-2012 at 03:44 PM.
Reply With Quote
  #9  
Old 05-27-2012, 04: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
  #10  
Old 05-27-2012, 05:44 PM
FG28_Kodiak FG28_Kodiak is offline
Senior Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

You would like to destoy a plane only if a player is present in that plane?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:52 AM.

Based on a design by: Miner Skinz.com

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2007 1C Company. All rights reserved.