![]() |
|
|
|
#1
|
|||
|
|||
|
hmmm that bit is straight from collection, despawner, unmodified.
Thought it was trying to handle group of planes, works without me applying several attemps to run this, as single routine ok, with double up it seems cause error. |
|
#2
|
|||
|
|||
|
IIRC group must be used in case a player creates e.g. 6 bombers, then leaves his aircraft to create another group of 5 bombers, etc., etc. If each aircraft in a group is not removed this would lead to AI spamming. Groups and foreach cycle is the solution to this IIRC.
|
|
#3
|
|||
|
|||
|
cheers Ataros, Yep thats how I understood it
For the moment I decided to run just one Triggered despawn timer from the On created. Actually I wonder if the despawning routine justs needs a catch for null, timers completing looking for aircraft to despawn that have been destroyed already, or despawned already. Im sure in the case of aircraft destroyed we see the same nullpoint exception looking for the aircraftat a later time. Also be nice to purge references of aircraft from the oncreated that dont exist anymore(this happens with despawner, but maybe not by ingame shot down destroyed) Last edited by Smokeynz; 03-13-2012 at 06:45 PM. |
|
#4
|
|||
|
|||
|
No the group is not nessesary, every Actor you created calls OnActorCreated(..) so every Actor is destroyed after the amount of time.
It's doppelt gemoppelt as we germans says And there is no test if the group exists. if(actorMain.Group() != null) |
|
#5
|
|||
|
|||
|
So I presume this trimmed version is all that is needed
NOTE this edit cause another error...sigh Code:
private void damageAiControlledPlane(AiActor actorMain)
{
if (actor == null || !(actor is AiAircraft))
return;
AiAircraft aircraft = (actor as AiAircraft);
if (!isAiControlledPlane(aircraft))
return;
if (aircraft == null)
return;
(actor as AiAircraft).Destroy();
}
Last edited by Smokeynz; 03-14-2012 at 08:27 AM. |
|
#6
|
|||
|
|||
|
Why so complicated
Code:
private void damageAiControlledPlane(AiActor actorMain)
{
if (actorMain != null && actorMain is AiAircraft)
if (isAiControlledPlane(actorMain as AiAircraft))
(actorMain as AiAircraft).Destroy();
}
|
|
#7
|
|||
|
|||
|
ok tried the last alteration, but still seeing exceptions when the timer comes to run despawner.
if (actor is AiAircraft) Timeout(despawntime, () => { damageAiControlledPlane(actor); }); i added a null check after the timeout but still problem exists if (actor is AiAircraft) Timeout(despawntime, () => { if(actor != null) damageAiControlledPlane(actor); }); basically I think the problem is the existance/ state of the object is different after aperiod than from when the timeout is called, ie the plane is just created. When the destroy actually runs, the aircraft has already been detroyed by activivity or something else. despite anull check it throws an exception. So the null is not the right check, in the wrong place or other problem is causing issue. However, I have noticed that the "on actor task completed" can have 1 ai interfere with another ai if the last path length crosses another ai path. Which makes me wonder if there is some cross over in other areas. any ideas anyone? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|