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-20-2012, 06:35 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default Actor keys help

I'm trying to cycle through the battle actors to see if a particular actor type exists, however, the actors don't seem to be registering their keys correctly. The code below constantly return zero in chat irrespective of how many actors are in the battle. Any ideas?

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 09:27 AM.
Reply With Quote
  #2  
Old 03-20-2012, 06:44 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Aha you add the keys of a empty dictonary to a list and wondering why no members is in there?

Code:
    private Dictionary<String, AiActor> allActors = new Dictionary<String, AiActor>();

    public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorCreated(missionNumber, shortName, actor);

        allActors.Add(shortName, actor); //<=== Added to feed the dictionary

        #region actor keys testing
        List<string> keys = new List<string>(allActors.Keys);
        sendChatMessageTo(-1, "Keys count=" + keys.Count.ToString(), null);
        #endregion
    }

Last edited by FG28_Kodiak; 03-20-2012 at 06:50 AM.
Reply With Quote
  #3  
Old 03-20-2012, 08:30 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Thankyou again Kodiak. Sometimes you can look & look & can't see the wood for the trees.
__________________
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 03-20-2012, 11:51 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

@salmo, If you inspecting the actors to try and test for if they exist in the mission, using this I think we may bypass the null points I keep striking in other thread about testing actors for null.

In the add to list, you may need missionnumber aswell for repeats of the same mission where you will get the same actor shortname repeated. Then look for all 3 parameters.

btw I've just been working on list handling and found a simple way to find the index number of a line listing, with that you can ask for the item contents or delete the line etc.

int indexnm; // declare an int for the index number

Then search for bob as actor name in the example following, I havent done it yet, but im sure you could also look for mission,shortname and actor in one line since that is specific in one case only where as you might find several "bob" references.

indexnm = list.FindIndex(r => r.shortName.Equals("bob"));

Once you have the indexnumber you can report/manupulate the info and any other entry on that line by refering to the indexnumber

sendChatMessageTo(-1, "shortName: " + list[indexnm].shortName);
Reply With Quote
  #5  
Old 03-21-2012, 04:35 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Quote:
Originally Posted by Smokeynz View Post
indexnm = list.FindIndex(r => r.shortName.Equals("bob"));
You will get nothing:
Equals compares the complete string, you should use Contains(..).
Reply With Quote
  #6  
Old 03-21-2012, 09:28 AM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

Oddly, it works

this is an example, but I am pulling and passing a number of things now

some declarations
Code:
bool timeIO;// = true; //time indicator switch on/off
double timevalue;
double timeindicator;
after I grab data from external text file configlists
i then find the data, and parse to game
Code:
idxIO = ConfigList.FindIndex(r => r.ConfigName.Equals("timeIO"));
idxTV = ConfigList.FindIndex(s => s.ConfigName.Equals("timevalue"));
double.TryParse(ConfigList[idxTV].ConfigValue, out timevalue);
timeIO is set as "ON" or "OFF" in config.
Im trying to set as realtime update, the only bit not working. at the moment it loads on start and stop of mission.

Code:
 timeIO = (ConfigList[idxIO].ConfigValue == "ON" ? true : false);        
        if (timeIO == true)
        {
            if (Time.current() >= timeindicator)
            {
                ScreenMsg(-1, "Elapsed Time:Min:" + timeindicator / 60 + " Secs:" + timeindicator + " Ticks:" + timeindicator * 30);
            }                
        }
        if (Time.current() >= timeindicator)
        {            
            timeindicator = timeindicator + timevalue;
        }

Last edited by Smokeynz; 03-21-2012 at 09:32 AM.
Reply With Quote
Reply


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 07:25 PM.


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