/// <summary>
        /// Change guild of guard (emblem on equipment) when keep is claimed
        /// </summary>
        public void ChangeGuild()
        {
            ClothingMgr.EquipGuard(this);

            Guild  guild     = Component.AbstractKeep.Guild;
            string guildname = string.Empty;

            if (guild != null)
            {
                guildname = guild.Name;
            }

            GuildName = guildname;

            if (Inventory == null)
            {
                return;
            }

            int emblem = 0;

            if (guild != null)
            {
                emblem = guild.Emblem;
            }

            InventoryItem lefthand = Inventory.GetItem(eInventorySlot.LeftHandWeapon);

            if (lefthand != null)
            {
                lefthand.Emblem = emblem;
            }

            InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);

            if (cloak != null)
            {
                cloak.Emblem = emblem;

                if (cloak.Emblem != 0)
                {
                    cloak.Model = 558; // change to a model that looks ok with an emblem
                }
            }

            if (IsAlive)
            {
                BroadcastLivingEquipmentUpdate();
            }
        }
 public static void RefreshTemplate(GameKeepGuard guard)
 {
     SetGuardRealm(guard);
     SetGuardGuild(guard);
     SetGuardRespawn(guard);
     SetGuardGender(guard);
     SetGuardModel(guard);
     SetGuardName(guard);
     SetBlockEvadeParryChance(guard);
     SetGuardBrain(guard);
     SetGuardSpeed(guard);
     SetGuardLevel(guard);
     SetGuardResists(guard);
     SetGuardStats(guard);
     SetGuardAggression(guard);
     ClothingMgr.EquipGuard(guard);
     ClothingMgr.SetEmblem(guard);
 }
Beispiel #3
0
 public void RefreshTemplate()
 {
     SetRealm();
     SetGuild();
     SetRespawnTime();
     SetGender();
     SetModel();
     SetName();
     SetBlockEvadeParryChance();
     SetBrain();
     SetSpeed();
     SetLevel();
     SetResists();
     SetStats();
     SetAggression();
     ClothingMgr.EquipGuard(this);
     ClothingMgr.SetEmblem(this);
 }
Beispiel #4
0
        /// <summary>
        /// load all keeps from the DB
        /// </summary>
        /// <returns></returns>
        public virtual bool Load()
        {
            // first check the regions we manage
            foreach (Region r in WorldMgr.Regions.Values)
            {
                if (r.IsFrontier)
                {
                    m_frontierRegionsList.Add(r.ID);
                }
            }

            // default to NF if no frontier regions found
            if (m_frontierRegionsList.Count == 0)
            {
                m_frontierRegionsList.Add(DEFAULT_FRONTIERS_REGION);
            }

            ClothingMgr.LoadTemplates();

            //Dinberg - moved this here, battlegrounds must be loaded before keepcomponents are.
            LoadBattlegroundCaps();

            if (!ServerProperties.Properties.LOAD_KEEPS)
            {
                return(true);
            }

            lock (m_keepList.SyncRoot)
            {
                m_keepList.Clear();

                var keeps = GameServer.Database.SelectAllObjects <DBKeep>();
                foreach (DBKeep datakeep in keeps)
                {
                    Region keepRegion = WorldMgr.GetRegion(datakeep.Region);
                    if (keepRegion == null)
                    {
                        continue;
                    }

                    AbstractGameKeep keep;
                    if ((datakeep.KeepID >> 8) != 0 || ((datakeep.KeepID & 0xFF) > 150))
                    {
                        keep = keepRegion.CreateGameKeepTower();
                    }
                    else
                    {
                        keep = keepRegion.CreateGameKeep();
                    }

                    keep.Load(datakeep);
                    RegisterKeep(datakeep.KeepID, keep);
                }

                // This adds owner keeps to towers / portal keeps
                foreach (AbstractGameKeep keep in m_keepList.Values)
                {
                    GameKeepTower tower = keep as GameKeepTower;
                    if (tower != null)
                    {
                        int      index     = tower.KeepID & 0xFF;
                        GameKeep ownerKeep = GetKeepByID(index) as GameKeep;
                        if (ownerKeep != null)
                        {
                            ownerKeep.AddTower(tower);
                        }
                        tower.Keep        = ownerKeep;
                        tower.OwnerKeepID = index;

                        if (tower.OwnerKeepID < 10)
                        {
                            log.WarnFormat("Tower.OwnerKeepID < 10 for KeepID {0}. Doors on this tower will not be targetable! ({0} & 0xFF < 10). Choose a different KeepID to correct this issue.", tower.KeepID);
                        }
                    }
                }
                if (ServerProperties.Properties.USE_NEW_KEEPS == 2)
                {
                    log.ErrorFormat("ServerProperty USE_NEW_KEEPS is actually set to 2 but it is no longer used. Loading as if he were 0 but please set to 0 or 1 !");
                }

                // var keepcomponents = default(IList<DBKeepComponent>); Why was this done this way rather than being strictly typed?
                IList <DBKeepComponent> keepcomponents = null;

                if (ServerProperties.Properties.USE_NEW_KEEPS == 0 || ServerProperties.Properties.USE_NEW_KEEPS == 2)
                {
                    keepcomponents = DOLDB <DBKeepComponent> .SelectObjects(DB.Column(nameof(DBKeepComponent.Skin)).IsLessThan(20));
                }
                else if (ServerProperties.Properties.USE_NEW_KEEPS == 1)
                {
                    keepcomponents = DOLDB <DBKeepComponent> .SelectObjects(DB.Column(nameof(DBKeepComponent.Skin)).IsGreatherThan(20));
                }

                if (keepcomponents != null)
                {
                    keepcomponents
                    .GroupBy(x => x.KeepID)
                    .AsParallel()
                    .ForAll(components =>
                    {
                        foreach (DBKeepComponent component in components)
                        {
                            AbstractGameKeep keep = GetKeepByID(component.KeepID);
                            if (keep == null)
                            {
                                //missingKeeps = true;
                                continue;
                            }

                            GameKeepComponent gamecomponent = keep.CurrentRegion.CreateGameKeepComponent();
                            gamecomponent.LoadFromDatabase(component, keep);
                            keep.KeepComponents.Add(gamecomponent);
                        }
                    });
                }

                /*if (missingKeeps && log.IsWarnEnabled)
                 * {
                 *      log.WarnFormat("Some keeps not found while loading components, possibly old/new keeptypes.");
                 * }*/

                if (m_keepList.Count != 0)
                {
                    foreach (AbstractGameKeep keep in m_keepList.Values)
                    {
                        if (keep.KeepComponents.Count != 0)
                        {
                            keep.KeepComponents.Sort();
                        }
                    }
                }
                LoadHookPoints();

                log.Info("Loaded " + m_keepList.Count + " keeps successfully");
            }

            if (ServerProperties.Properties.USE_KEEP_BALANCING)
            {
                UpdateBaseLevels();
            }

            if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                KeepBonusMgr.UpdateCounts();
            }

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// load all keeps from the DB
        /// </summary>
        /// <returns></returns>
        public virtual bool Load()
        {
            // first check the regions we manage
            foreach (Region r in WorldMgr.Regions.Values)
            {
                if (r.IsFrontier)
                {
                    m_frontierRegionsList.Add(r.ID);
                }
            }

            // default to NF if no frontier regions found
            if (m_frontierRegionsList.Count == 0)
            {
                m_frontierRegionsList.Add(DEFAULT_FRONTIERS_REGION);
            }

            ClothingMgr.LoadTemplates();

            //Dinberg - moved this here, battlegrounds must be loaded before keepcomponents are.
            LoadBattlegroundCaps();

            if (!ServerProperties.Properties.LOAD_KEEPS)
            {
                return(true);
            }

            lock (m_keepList.SyncRoot)
            {
                m_keepList.Clear();

                var keeps = GameServer.Database.SelectAllObjects <DBKeep>();
                foreach (DBKeep datakeep in keeps)
                {
                    Region keepRegion = WorldMgr.GetRegion(datakeep.Region);
                    if (keepRegion == null)
                    {
                        continue;
                    }

                    //Dinberg - checking whether the keep is old or new.
                    //The only way to do this is to examine the database entries for hookpoints and thus determine
                    //in this manner whether the keep is old, new or 'both'. A keep will be 'both' if it is found to
                    //have components of both sets, which is possible.

                    bool hasOldComponents = false;
                    bool hasNewComponents = false;

                    //I don't want to touch the loading order of hookpoints, as i think they may depend on the
                    //assumption keeps and towers are linked before population. So we will settle for a second
                    //query. It's on server start, so it wont impact running performance.

                    var currentKeepComponents = GameServer.Database.SelectObjects <DBKeepComponent>("`KeepID` = '" + datakeep.KeepID + "'");

                    //Pass through, and depending on the outcome of the components, determine the 'age' of the keep.
                    foreach (DBKeepComponent comp in currentKeepComponents)
                    {
                        if (comp.Skin >= 0 && comp.Skin <= 20) //these are the min/max ids for old keeps.
                        {
                            hasOldComponents = true;
                        }
                        if (comp.Skin > 20) //any skinID greater than this are ids for new keeps.
                        {
                            hasNewComponents = true;
                        }
                    }


                    if (datakeep.KeepSkinType != eKeepSkinType.Any)
                    {
                        if (datakeep.KeepSkinType == eKeepSkinType.New && hasNewComponents == false)
                        {
                            continue;
                        }
                        else if (datakeep.KeepSkinType == eKeepSkinType.Old && hasOldComponents == false)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // Use server properties to determine correct keep to load
                        //"use_new_keeps", "Keeps to load. 0 for Old Keeps, 1 for new keeps, 2 for both.", 2

                        if (ServerProperties.Properties.USE_NEW_KEEPS == 0 && !hasOldComponents)
                        {
                            continue;
                        }

                        if (ServerProperties.Properties.USE_NEW_KEEPS == 1 && !hasNewComponents)
                        {
                            continue;
                        }
                    }

                    //If we've got this far, we are permitted to load as per normal!

                    AbstractGameKeep keep;
                    if ((datakeep.KeepID >> 8) != 0 || ((datakeep.KeepID & 0xFF) > 150))
                    {
                        keep = keepRegion.CreateGameKeepTower();
                    }
                    else
                    {
                        keep = keepRegion.CreateGameKeep();
                    }

                    keep.Load(datakeep);
                    RegisterKeep(datakeep.KeepID, keep);
                }

                // This adds owner keeps to towers / portal keeps
                foreach (AbstractGameKeep keep in m_keepList.Values)
                {
                    GameKeepTower tower = keep as GameKeepTower;
                    if (tower != null)
                    {
                        int      index     = tower.KeepID & 0xFF;
                        GameKeep ownerKeep = GetKeepByID(index) as GameKeep;
                        if (ownerKeep != null)
                        {
                            ownerKeep.AddTower(tower);
                        }
                        tower.Keep        = ownerKeep;
                        tower.OwnerKeepID = index;

                        if (tower.OwnerKeepID < 10)
                        {
                            log.WarnFormat("Tower.OwnerKeepID < 10 for KeepID {0}.  Doors on this tower will not be targetable! ({0} & 0xFF < 10).  Choose a different KeepID to correct this issue.", tower.KeepID);
                        }
                    }
                }

                bool missingKeeps = false;

                var keepcomponents = GameServer.Database.SelectAllObjects <DBKeepComponent>();
                foreach (DBKeepComponent component in keepcomponents)
                {
                    AbstractGameKeep keep = GetKeepByID(component.KeepID);
                    if (keep == null)
                    {
                        missingKeeps = true;
                        continue;
                    }

                    if (keep.DBKeep.KeepSkinType != eKeepSkinType.Any)
                    {
                        if (keep.DBKeep.KeepSkinType == eKeepSkinType.New && IsNewKeepComponent(component.Skin) == false)
                        {
                            continue;
                        }
                        else if (keep.DBKeep.KeepSkinType == eKeepSkinType.Old && IsNewKeepComponent(component.Skin))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // if use old keeps don't try to load new components
                        if (ServerProperties.Properties.USE_NEW_KEEPS == 0 && IsNewKeepComponent(component.Skin))
                        {
                            continue;
                        }

                        // if use new keeps don't try and load old components
                        if (ServerProperties.Properties.USE_NEW_KEEPS == 1 && !IsNewKeepComponent(component.Skin))
                        {
                            continue;
                        }
                    }

                    GameKeepComponent gamecomponent = keep.CurrentRegion.CreateGameKeepComponent();
                    gamecomponent.LoadFromDatabase(component, keep);
                    keep.KeepComponents.Add(gamecomponent);
                }

                if (missingKeeps && log.IsWarnEnabled)
                {
                    log.WarnFormat("Some keeps not found while loading components, possibly old/new keeptypes.");
                }

                if (m_keepList.Count != 0)
                {
                    foreach (AbstractGameKeep keep in m_keepList.Values)
                    {
                        if (keep.KeepComponents.Count != 0)
                        {
                            keep.KeepComponents.Sort();
                        }
                    }
                }
                LoadHookPoints();

                log.Info("Loaded " + m_keepList.Count + " keeps successfully");
            }

            if (ServerProperties.Properties.USE_KEEP_BALANCING)
            {
                UpdateBaseLevels();
            }

            if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                KeepBonusMgr.UpdateCounts();
            }

            return(true);
        }