Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2012, 05:19 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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)
Reply With Quote
  #2  
Old 03-14-2012, 07:49 AM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

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.
Reply With Quote
  #3  
Old 03-14-2012, 08:30 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Why so complicated

Code:
 private void damageAiControlledPlane(AiActor actorMain)
    {
        if (actorMain != null && actorMain is AiAircraft)
            if (isAiControlledPlane(actorMain as AiAircraft))
                    (actorMain as AiAircraft).Destroy();
    }
Reply With Quote
  #4  
Old 03-18-2012, 09:23 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

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?
Reply With Quote
  #5  
Old 03-18-2012, 11:13 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

Think this explains what I am seeing, 3. Don’t kill objects too soon.

http://codebetter.com/raymondlewalle...ses-in-vb-net/

But the problem for CLOD, the Onactorcreated creates an array of objects, actors which are part of play.
If you test those objects later, and they have been destroyed by play or despawning routines, they don't exist, so either the reference of "null" or the actor reference will throw an exception. For null there has to be an array member to state "are you null" .

So with that, incounting exceptions of objects with no reference, it may require double listing arrays. The game creates an internal onactorcreated, you might have to create a second array to test the actors condition upon.

Kinda a test of "are you alive" by comparing existance of that actor in both arrays. In play that actor meets its fate, is despawned or hangs around. In 2 of these you may incounter an object reference error if trying to clear the decks of clutter. With a second array "null" is not important, because you test against the array with array, not the "object actor" which may be automatically cleared from the onactorcreated array.

confused, i am.

if I am on the right track in this, we need a method to avoid object exception when dealing with object/actor tracking over the mission period. Considering that the base mission has potential to be 24/7

in summary

objects/actors can lose references to themselves so that even the "null" test has no reference. this thows an exception object without a reference.
Reply With Quote
  #6  
Old 03-19-2012, 05:27 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

SmokyNZ, I concur with you that there is something screwy with the actors that gives rise to null exceptions. I'm unsure what the cause is, but here's a code snippet from a script I'm working on. The CheckActors routine was working & keys.Count was returning the number of actor keys, then all of a sudden, it failed & now persistently returns zero even though there are actors in the mission.

Code:
public class Mission : AMission
{
private Dictionary<String, AiActor> allActors = new Dictionary<String, AiActor>();

    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
CheckActors();
}

public void CheckActors()
{
        List<string> keys = new List<string>(allActors.Keys);
        sendChatMessageTo(-1, "Keys count=" + keys.Count.ToString(), null);
       // .......
    }

    private void sendChatMessageTo(int army, string msg, object[] parms)
    {   // send a chat message to all players in specified army (1=red; 2=blue)
        List<Player> Players = new List<Player>();
        // on Dedi the server:
        if (GamePlay.gpPlayer() != null)
        {
            if (GamePlay.gpPlayer().Army() == army || army == -1)
                Players.Add(GamePlay.gpPlayer());
        } //rest of the crowd
        if (GamePlay.gpRemotePlayers() != null || GamePlay.gpRemotePlayers().Length > 0)
        {
            foreach (Player p in GamePlay.gpRemotePlayers())
            {
                if (p.Army() == army || army == -1)
                    Players.Add(p);
            }
        }
        if (Players != null && Players.Count > 0)
            GamePlay.gpLogServer(Players.ToArray(), msg, parms);
    }
}
__________________
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; 03-19-2012 at 05:31 AM.
Reply With Quote
  #7  
Old 03-19-2012, 05:38 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

@Smokeynz
Could i see the complete Errormessage, please?
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 09:48 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.