1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Public Moongate with destination for a new player only on siege ruleset server

Discussion in 'Script Support' started by LordFenris, Nov 13, 2017.

  1. LordFenris

    LordFenris Member

    Jul 21, 2014
    Likes Received:
    I need advice on extending the functionality of public moongate.
    My server work with active siege ruleset, but we have launched the New Haven startup area - only for new players (with less than 40 hours of gameplay). Now we would like to change the public moongate script - still with active siege - to allow players with less than 40 hours of gaming only (or account with less than 40 hours) - to travel from and to Haven via public moongate . I mean New Haven as a destination - it was displayed (in gump) only for characters with less than 40 hours of gameplay (or accounts with that game time).
    Normally this is achieved under the young system, but on siege young system does not work, so a new players do not see the Trammel destinations in the public moongate gump.
    We try to push ourselves forward, but we came across some trouble. What have we done

    First - we already commited a list of destinations on Trammel (line 250+) for New Haven only.

    Code (C#):
    1. public static readonly PMList Trammel =
    2.             new PMList(1012000, 1012012, Map.Trammel, new PMEntry[]
    3.             {
    4.                 //new PMEntry(new Point3D(4467, 1283, 5), 1012003), // Moonglow
    5.                 //new PMEntry(new Point3D(1336, 1997, 5), 1012004), // Britain
    6.                 //new PMEntry(new Point3D(1499, 3771, 5), 1012005), // Jhelom
    7.                 //new PMEntry(new Point3D(771, 752, 5), 1012006), // Yew
    8.                 //new PMEntry(new Point3D(2701, 692, 5), 1012007), // Minoc
    9.                 //new PMEntry(new Point3D(1828, 2948,-20), 1012008), // Trinsic
    10.                 //new PMEntry(new Point3D(643, 2067, 5), 1012009), // Skara Brae
    11.                 /* Dynamic Z for Magincia to support both old and new maps. */
    12.                 //new PMEntry(new Point3D(3563, 2139, Map.Trammel.GetAverageZ(3563, 2139)), 1012010), // (New) Magincia
    13.                 new PMEntry(new Point3D(3450, 2677, 25), 1078098)// New Haven
    14.             });

    Next, to achieve the intended goal we partly comment line 58-60 to disable Trammel display locking - as a destinaton point in gump (for servers with active siege ruleset):

    Code (C#):
    2. //if (!Siege.SiegeShard)
    3. //{
    4. count + = MoonGen (PMList.Trammel);
    5. //}
    Next we have added another part of code in PM Checklist section (line 420+) -

    Code (C#):
    1.  else if (mobile.GameTime >= TimeSpan.FromHours(40.0))
    2.   {
    3.    checkLists = PMList.SALists;
    4.   }
    and allso we modified gump checklist section (line 490)+

    Code (C#):
    2.                 //if (Siege.SiegeShard && checkLists[i].Number == 1012000) // Trammel
    3.                 //   continue;
    4.                 if (Siege.SiegeShard && mobile.GameTime >= TimeSpan.FromHours(40.0) && checkLists[i].Number == 1012000) // Trammel
    5.                 continue;
    This should result in a full list of continents (with Trammel/New Haven destination ) but only for characters with less than 40 hours of gameplay

    At last, we wrote a new lines in ListEntries sector (line 550+)

    Code (C#):
    1. else if (m_Mobile.Player && m_Mobile.GameTime >= TimeSpan.FromHours(40.0) && list.Map == Map.Trammel)
    2. {
    3. m_Mobile.SendLocalizedMessage(1019004); // You are not allowed to travel there.
    4. return;
    5. }
    what should cause older characters to receive a message about being unable to move to Trammel (New Haven area)

    Unfortunately - after modifications - our test server stop during startup with these error:
    Error indicates that the public moongate script does not properly describe the GameTime parameter.
    Could I ask for your help in this regard please?

    I attach our modified file.

    Attached Files:

    #1 LordFenris, Nov 13, 2017
    Last edited: Nov 13, 2017
  2. zerodowned

    Moderator ServUO Developer

    Jun 28, 2014
    Likes Received:
    The error is saying that Server/Mobile doesn't have a GameTime property, which is true.
    What you need to do is this

    PlayerMobile pm = (PlayerMobile)from; // "from" referring to Mobile, this is called Casting - Mobile to PlayerMobile

    or, I believe you could do this which sometimes makes things a little cleaner if you need the Casting for a few lines without messing up any other lines

    • Like Like x 1
  3. Ravenwolfe

    Moderator ServUO Developer

    Sep 7, 2013
    Likes Received:
    Direct casting is handy, but you better make sure it can never return null. Indirect casting is often needed so you can follow up with a null check:

    PlayerMobile pm = from as PlayerMobile;

    If (pm != null)
    Do something()

    With a direct cast, you need to make sure the condition will always exist.

    ((PlayerMobile)from).GameTime // direct cast, no null check. You will get a null crash if this code runs against something that is not a PlayerMobile.
    • Informative Informative x 1
  4. zerodowned

    Moderator ServUO Developer

    Jun 28, 2014
    Likes Received:
    Hadn't considered that, Ty.
Similar Threads: Public Moongate
Forum Title Date
Script Support PublicMoongates Jan 4, 2018
Archived Bug Reports Public moongate with siege ruleset bug Nov 13, 2017
ServUO Discussion Publicmoongate.cs Sep 7, 2017
Script Support XML Att Requirement for Public Moongate Dec 27, 2016
Custom Releases Publicmoongate.cs with valley of eodon location Nov 28, 2016
Script Support Public moongate using Html instead of HtmlLocalized Oct 7, 2016
Tutorials How to remove a facet from the public moongate Jan 14, 2015