예제 #1
0
        /// <summary>
        /// Change location on character creation
        /// </summary>
        public static void CharacterCreation(DOLEvent ev, object sender, EventArgs args)
        {
            // Check Args
            var chArgs = args as CharacterEventArgs;

            if (chArgs == null)
            {
                return;
            }

            DOLCharacters ch = chArgs.Character;

            try
            {
                var availableLocation = GetAllStartupLocationForCharacter(ch, chArgs.GameClient.Version);

                StartupLocation dbStartupLocation = null;

                // get the first entry according to Tutorial Enabling.
                foreach (var location in availableLocation)
                {
                    if (ServerProperties.Properties.DISABLE_TUTORIAL && location.ClientRegionID == TUTORIAL_REGIONID)
                    {
                        continue;
                    }

                    dbStartupLocation = location;
                    break;
                }

                if (dbStartupLocation == null)
                {
                    log.WarnFormat(
                        "startup location not found: account={0}; char name={1}; region={2}; realm={3}; class={4} ({5}); race={6} ({7}); version={8}",
                        ch.AccountName, ch.Name, ch.Region, ch.Realm, ch.Class, (eCharacterClass)ch.Class, ch.Race, (eRace)ch.Race, chArgs.GameClient.Version);
                }
                else
                {
                    ch.Xpos      = dbStartupLocation.XPos;
                    ch.Ypos      = dbStartupLocation.YPos;
                    ch.Zpos      = dbStartupLocation.ZPos;
                    ch.Region    = dbStartupLocation.Region;
                    ch.Direction = dbStartupLocation.Heading;
                    BindCharacter(ch);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(
                        "StartupLocations script: error changing location. account={0}; char name={1}; region={2}; realm={3}; class={4} ({5}); race={6} ({7}); version={8}; {9}",
                        ch.AccountName, ch.Name, ch.Region, ch.Realm, ch.Class, (eCharacterClass)ch.Class, ch.Race, (eRace)ch.Race, chArgs.GameClient.Version, e);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Decides whether player can jump to the target point.
        /// All messages with reasons must be sent here.
        /// Can change destination too.
        /// </summary>
        /// <param name="targetPoint">The jump destination</param>
        /// <param name="player">The jumping player</param>
        /// <returns>True if allowed</returns>
        public bool IsAllowedToJump(ZonePoint targetPoint, GamePlayer player)
        {
            StartupLocation loc = StartupLocations.GetNonTutorialLocation(player);

            if (loc != null)
            {
                targetPoint.TargetX       = loc.XPos;
                targetPoint.TargetY       = loc.YPos;
                targetPoint.TargetZ       = loc.ZPos;
                targetPoint.TargetHeading = (ushort)loc.Heading;
                targetPoint.TargetRegion  = (ushort)loc.Region;
                return(true);
            }

            return(false);
        }
예제 #3
0
        /// <summary>
        /// Change location on character creation
        /// </summary>
        public static void CharacterCreation(DOLEvent ev, object sender, EventArgs args)
        {
            CharacterEventArgs chArgs = args as CharacterEventArgs;

            if (chArgs == null)
            {
                return;
            }
            DOLCharacters ch = chArgs.Character;

            try
            {
                StartLocation   startLocation     = null;
                GameClient      client            = chArgs.GameClient;
                StartupLocation dbStartupLocation = null;

                // do we have custom locations in the DB ?
                if (ServerProperties.Properties.USE_CUSTOM_START_LOCATIONS)
                {
                    // First try to find an ALL entry
                    var startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs = 'ALL'");
                    if (startupLocations.Count > 0)
                    {
                        dbStartupLocation = startupLocations[0];
                    }
                    else
                    {
                        // find realm-based SL
                        startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs LIKE '%" + GlobalConstants.RealmToName((eRealm)ch.Realm).Substring(0, 3) + "%'");
                        if (startupLocations.Count > 0)
                        {
                            dbStartupLocation = startupLocations[0];
                        }
                        else
                        {
                            // find class-based SL
                            startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs LIKE '%" + ch.Class + "%'");
                            foreach (var curSL in startupLocations)
                            {
                                foreach (var classID in curSL.ClassIDs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                                {
                                    int charClass = 0;
                                    int.TryParse(classID, out charClass);
                                    if (charClass == ch.Class)
                                    {
                                        dbStartupLocation = curSL;
                                        break;
                                    }
                                }
                                if (dbStartupLocation != null)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    // fill loc with our found SL
                    if (dbStartupLocation != null)
                    {
                        startLocation = new StartLocation(dbStartupLocation.XPos, dbStartupLocation.YPos, dbStartupLocation.ZPos, dbStartupLocation.Heading);
                        ch.Region     = dbStartupLocation.Region;
                    }
                }

                // no custom SL or custom SL not found
                if (dbStartupLocation == null)
                {
                    // tutorial all realms use the same region
                    // except if disabled in SP, v1.93+ start is in tutorial zone
                    if ((ch.Region == 27 || (int)client.Version >= (int)GameClient.eClientVersion.Version193) && !ServerProperties.Properties.DISABLE_TUTORIAL)
                    {
                        switch (ch.Realm)
                        {
                        case 1:                                 // alb
                            startLocation = new StartLocation(95638, 101322, 5340, 998);
                            break;

                        case 2:                                 // mid
                            startLocation = new StartLocation(226716, 232385, 5340, 1024);
                            break;

                        case 3:                                 // hib
                            startLocation = new StartLocation(357788, 363457, 5340, 1024);
                            break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version193)
                    {
                        // no base classes, so we choose a common startuplocation per realm
                        switch (ch.Realm)
                        {
                        case 1:                                 // alb
                            startLocation = new StartLocation(562418, 512268, 2500, 2980);
                            break;

                        case 2:                                 // mid
                            startLocation = new StartLocation(802869, 726016, 4699, 1399);
                            break;

                        case 3:                                 // hib
                            startLocation = new StartLocation(347279, 489681, 5200, 2332);
                            break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version180)
                    {
                        startLocation = (StartLocation)MainTownStartingLocations[ch.Class];
                    }
                    else if (ch.Region == 1 || ch.Region == 100 || ch.Region == 200)                     // all classic regions
                    {
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                    else if (ch.Region == 51 || ch.Region == 151 || ch.Region == 181)                     // all ShroudedIsles regions
                    {
                        startLocation = (StartLocation)ShroudedIslesLocations[ch.Race][ch.Class];
                    }
                    else
                    {
                        log.DebugFormat("tried to create char in unknown region {0}", ch.Region);
                        switch (ch.Realm)
                        {
                        default: ch.Region = 1; break;

                        case 2: ch.Region = 100; break;

                        case 3: ch.Region = 200; break;
                        }
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                }

                if (startLocation == null)
                {
                    log.Warn("startup location not found: account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")");
                }
                else
                {
                    ch.Xpos      = startLocation.X;
                    ch.Ypos      = startLocation.Y;
                    ch.Zpos      = startLocation.Z;
                    ch.Direction = startLocation.Heading;
                }

                BindCharacter(ch);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("StartupLocations script: error changing location. account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")", e);
                }
            }
        }