Results 1 to 10 of 10

Thread: FrontMarkers not accessible from submission script?

  1. #1
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    FrontMarkers not accessible from submission script?

    I touched on this in another thread, but it remains a mystery.

    Paste this into the main mission script:

    bool frontExist = false;
    if(GamePlay.gpFrontExist())
    frontExist = true;

    ...returns true (as long as the mission designer has specified the frontline)

    Put the same thing in a submission script and it returns false. Returns true if you paste the main mission frontline markers into the submission.mis file

    Oskar has confirmed that frontline markers are loaded when the main mission is loaded, so I don't understand why a submission cannot access them at runtime.

    Thanks

  2. #2
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: FrontMarkers not accessible from submission script?

    If the sub-mission code needs to know this you can add a line to the OnBattleStarted method in the main mission.

    Code:
    DataDictionary.Add("FrontExist", true);
    or

    Code:
    DataDictionary.Add("FrontExist", GamePlay.gpFrontExist());

    Then in your sub-mission code you can check.

    Code:
    bool frontExist = false;
        if (DataDictionary.ContainsKey("FrontExist")) {
            frontExist = (bool)DataDictionary["FrontExist"];
        }

  3. Likes Marcost liked this post
  4. #3
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    Re: FrontMarkers not accessible from submission script?

    Thanks that would resolve the 'exists' part but how can I pass the x,y location of the front markers to the submission?

    Regards

    M

  5. #4
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: FrontMarkers not accessible from submission script?

    Quote Originally Posted by Marcost View Post
    Thanks that would resolve the 'exists' part but how can I pass the x,y location of the front markers to the submission?

    Regards

    M
    Just pass the base mission.

    Code:
    DataDictionary.Add("BaseMission", this);
    Then use it like this.

    Code:
          AMission baseMission = (AMission)DataDictionary["BaseMission"];
          int army = baseMission.GamePlay.gpFrontArmy(x, y);

  6. Likes ATAG_Snapper, Marcost liked this post
  7. #5
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    Re: FrontMarkers not accessible from submission script?

    Ahah, that sounds good! I will hopefully try it tonight.

    Thanks again

  8. Likes ATAG_Snapper liked this post
  9. #6
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    Re: FrontMarkers not accessible from submission script?

    Ok I'm struggling. Simple example attached, for use with the default single mission 'Aerial Crusade'. Submission returns false for frontExists. Maybe you can see something simple I am not doing, in the code?

    https://www.mediafire.com/file/msw0n...rusade.7z/file

    Also, if I restart the mission (without quitting to desktop inbetween) I get this error:

    [17:02:37] =================================================
    [17:02:37] System.ArgumentException: An item with the same key has already been added.
    [17:02:37] at System.ThrowHelper.ThrowArgumentException(Exceptio nResource resource)
    [17:02:37] at System.Collections.Generic.Dictionary`2.Insert(TKe y key, TValue value, Boolean add)
    [17:02:37] at Mission.OnBattleStarted()
    [17:02:37] at maddox.game.ABattle.OnBattleStarted()
    [17:02:37] at maddox.game.world.Strategy.OnBattleStarted()
    [17:02:37] at maddox.game.ABattle.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at maddox.game.world.Strategy.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at maddox.game.GameDef.eventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at y45c1v2ebB$KGoVuDLAOgPveOWCjmls4YNlJvUerFjtA.s$bfu 6e1CXdvl0HcORTAHEE(GameEventId , Object , Object , Int32 )
    [17:02:37] =================================================

    Thanks!

    ps wouldn't let me attach file to post: 'invalid type'

  10. #7
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: FrontMarkers not accessible from submission script?

    Quote Originally Posted by Marcost View Post
    Also, if I restart the mission (without quitting to desktop inbetween) I get this error:
    [17:02:37] =================================================
    [17:02:37] System.ArgumentException: An item with the same key has already been added.
    [17:02:37] at System.ThrowHelper.ThrowArgumentException(Exceptio nResource resource)
    [17:02:37] at System.Collections.Generic.Dictionary`2.Insert(TKe y key, TValue value, Boolean add)
    [17:02:37] at Mission.OnBattleStarted()
    [17:02:37] at maddox.game.ABattle.OnBattleStarted()
    [17:02:37] at maddox.game.world.Strategy.OnBattleStarted()
    [17:02:37] at maddox.game.ABattle.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at maddox.game.world.Strategy.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at maddox.game.GameDef.eventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt)
    [17:02:37] at y45c1v2ebB$KGoVuDLAOgPveOWCjmls4YNlJvUerFjtA.s$bfu 6e1CXdvl0HcORTAHEE(GameEventId , Object , Object , Int32 )
    [17:02:37] =================================================
    This is a know bug: Loading a new mission (or the same mission again) without quitting the game first loads that mission on top of the previous. That's why the key already exists: It's still there frome before. No other way but to restart the game (until I've found a fix for this).

  11. Likes Marcost liked this post
  12. #8
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: FrontMarkers not accessible from submission script?

    Quote Originally Posted by Marcost View Post
    [17:02:37] System.ArgumentException: An item with the same key has already been added.
    [17:02:37] at System.ThrowHelper.ThrowArgumentException(Exceptio nResource resource)
    I checked your code and you are including that line to put the base mission in the Dictionary in both the base mission OBS method and the sub-mission OBS. It should be in the base mission OnBattleStarted only.

    Also, Artist reminds me that the better way to grab a reference to the base mission is with the 'new' (since v7) built in function. This can be called from anywhere and you don't have to use the Dictionary.
    Code:
    Battle.GetBaseMission();
    
    Battle.GetBaseMission().GamePlay.gpFrontArmy(x, y);

  13. Likes Marcost liked this post
  14. #9
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    Re: FrontMarkers not accessible from submission script?

    Thanks both for the replies. I now have in the sub-mission:

    Battle.GetBaseMission().GamePlay.gpFrontExist();

    and I still get a false

    Is there a particular reference I need in the script maybe? The script does run.

    @Oskar, I named them differently - MyBaseMission in the master and baseMission in ths sub. Must be the bug Artist referred to.

    Cheers

    M
    Last edited by Marcost; Aug-21-2021 at 13:12.

  15. #10
    Supporting Member
    Join Date
    Sep 2019
    Location
    Yorkshire
    Posts
    138
    Post Thanks / Like
    Total Downloaded
    1.39 GB

    Re: FrontMarkers not accessible from submission script?

    Well I got it working:


    //submission:

    public override void Inited()
    {
    base.Inited();
    AMission BaseMission = Battle.GetBaseMission();
    bool frontExist = BaseMission.GamePlay.gpFrontExist();
    }


    Thanks for your help!

    M

  16. Likes ATAG_Snapper, Bonditaria liked this post

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •