/// <summary>
        /// Sends a message to all players to notify them of the raize
        /// </summary>
        /// <param name="keep">The keep object</param>
        /// <param name="realm">The raizing realm</param>
        public static void BroadcastRaize(AbstractGameKeep keep, eRealm realm)
        {
            string message = string.Format(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "PlayerManager.BroadcastRaize.Razed", keep.Name, GlobalConstants.RealmToName(realm)));

            BroadcastMessage(message, eRealm.None);
            NewsMgr.CreateNews(message, keep.Realm, eNewsType.RvRGlobal, false);
        }
Beispiel #2
0
 /// <summary>
 /// This Function is called when keep is taken to repair door
 /// </summary>
 /// <param name="realm">new realm of keep taken</param>
 public void Reset(eRealm realm)
 {
     Realm              = realm;
     Health             = MaxHealth;
     m_oldHealthPercent = HealthPercent;
     CloseDoor();
 }
Beispiel #3
0
        /// <summary>
        /// Get's a random NPC based on a con level
        /// </summary>
        /// <param name="realm"></param>
        /// <param name="compareLevel"></param>
        /// <param name="conLevel">-3 grey, -2 green, -1 blue, 0 yellow, 1 - orange, 2 red, 3 purple</param>
        /// <returns></returns>
        public GameNPC GetRandomNPCByCon(eRealm realm, int compareLevel, int conLevel)
        {
            List <GameNPC> npcs      = GetNPCsOfZone(new eRealm[] { realm }, 0, 0, compareLevel, conLevel, true);
            GameNPC        randomNPC = (npcs.Count == 0 ? null : npcs[0]);

            return(randomNPC);
        }
        /// <summary>
        /// Add a new teleport destination in memory and save to database, if
        /// successful.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="teleportID"></param>
        /// <param name="type"></param>
        private void AddTeleport(GameClient client, String teleportID, String type)
        {
            GamePlayer player = client.Player;
            eRealm     realm  = player.Realm;

            if (WorldMgr.GetTeleportLocation(realm, String.Format("{0}:{1}", type, teleportID)) != null)
            {
                client.Out.SendMessage(String.Format("Teleport ID [{0}] already exists!", teleportID),
                                       eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            Teleport teleport = new Teleport();

            teleport.TeleportID = teleportID;
            teleport.Realm      = (int)realm;
            teleport.RegionID   = player.CurrentRegion.ID;
            teleport.X          = player.X;
            teleport.Y          = player.Y;
            teleport.Z          = player.Z;
            teleport.Heading    = player.Heading;
            teleport.Type       = type;

            if (!WorldMgr.AddTeleportLocation(teleport))
            {
                client.Out.SendMessage(String.Format("Failed to add teleport ID [{0}] in memory!", teleportID),
                                       eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            GameServer.Database.AddObject(teleport);
            client.Out.SendMessage(String.Format("Teleport ID [{0}] successfully added.", teleportID),
                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
        }
Beispiel #5
0
		public static void CreateNews(string message, eRealm realm, eNewsType type, bool sendMessage)
		{
			if (sendMessage)
			{
				foreach (GameClient client in WorldMgr.GetAllClients())
				{
					if (client.Player == null)
						continue;
					if ((client.Account.PrivLevel != 1 || realm == eRealm.None) || client.Player.Realm == realm)
					{
						client.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_SystemWindow);
					}
				}
			}

			if (ServerProperties.Properties.RECORD_NEWS)
			{
				DBNews news = new DBNews();
				news.Type = (byte)type;
				news.Realm = (byte)realm;
				news.Text = message;
				GameServer.Database.AddObject(news);
				GameEventMgr.Notify(DatabaseEvent.NewsCreated, new NewsEventArgs(news));
			}
		}
Beispiel #6
0
        /// <summary>
        /// Reset the keep with special server rules handling
        /// </summary>
        /// <param name="lord">The lord that was killed</param>
        /// <param name="killer">The lord's killer</param>
        public override void ResetKeep(GuardLord lord, GameObject killer)
        {
            base.ResetKeep(lord, killer);
            eRealm realm = eRealm.None;

            // pvp servers, the realm changes to the group leaders realm
            if (killer is GamePlayer gamePlayer)
            {
                Group group = gamePlayer.Group;
                realm = group?.Leader.Realm ?? killer.Realm;
            }
            else if ((killer as GameNPC)?.Brain is IControlledBrain)
            {
                GamePlayer player = (((GameNPC)killer).Brain as IControlledBrain)?.GetPlayerOwner();
                Group      group  = null;
                if (player != null)
                {
                    group = player.Group;
                }

                realm = group?.Leader.Realm ?? killer.Realm;
            }

            lord.Component.AbstractKeep.Reset(realm);
        }
        /// <summary>
        /// Display teleport destinations for passed realm
        /// </summary>
        /// <param name="destRealm">Realm to display destinations for</param>
        public String DisplayTeleportDestinations(eRealm destRealm)
        {
            StringBuilder sRet = new StringBuilder("");

            switch (destRealm)
            {
            case eRealm.Albion:
                sRet.Append("Would you like to teleport to?\n[Camelot]\n[Albion Frontiers] or [Battlegrounds]\n[Albion Darkness Falls]\n");
                sRet.Append("[Albion Mainland]\n[Albion Dungeons]\n[Albion Shrouded Isles]\n[Albion Oceanus]\n");
                sRet.Append("[Housing]\n[Hibernia] or [Midgard]");
                break;

            case eRealm.Midgard:
                sRet.Append("Would you like to teleport to?\n[Jordheim]\n[Midgard Frontiers] or [Battlegrounds]\n[Midgard Darkness Falls]\n");
                sRet.Append("[Midgard Mainland]\n[Midgard Dungeons]\n[Midgard Shrouded Isles]\n[Midgard Oceanus]\n");
                sRet.Append("[Housing]\n[Albion] or [Hibernia]");
                break;

            case eRealm.Hibernia:
                sRet.Append("Would you like to teleport to?\n[Tir na Nog]\n[Hibernia Frontiers] or [Battlegrounds]\n[Hibernia Darkness Falls]\n");
                sRet.Append("[Hibernia Mainland]\n[Hibernia Dungeons]\n[Hibernia Shrouded Isles]\n[Hibernia Oceanus]\n");
                sRet.Append("[Housing]\n[Albion] or [Midgard]");
                break;

            default:
                log.Warn(String.Format("DisplayTeleportDestinations does not handle player realm [{0}]", destRealm.ToString()));
                break;
            }

            return(sRet.ToString());
        }
Beispiel #8
0
        /// <summary>
        /// Gets the bonus modifier for a realm/relictype.
        /// </summary>
        /// <param name="realm"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static double GetRelicBonusModifier(eRealm realm, eRelicType type)
        {
            double bonus      = 0.0;
            bool   owningSelf = false;

            //only playerrealms can get bonus
            foreach (GameRelic rel in getRelics(realm, type))
            {
                if (rel.Realm == rel.OriginalRealm)
                {
                    owningSelf = true;
                }
                else
                {
                    bonus += ServerProperties.Properties.RELIC_OWNING_BONUS * 0.01;
                }
            }

            // Bonus apply only if owning original relic
            if (owningSelf)
            {
                return(bonus);
            }

            return(0.0);
        }
Beispiel #9
0
        public static void CreateNews(string message, eRealm realm, eNewsType type, bool sendMessage)
        {
            if (sendMessage)
            {
                foreach (GameClient client in WorldMgr.GetAllClients())
                {
                    if (client.Player == null)
                    {
                        continue;
                    }
                    if ((client.Account.PrivLevel != 1 || realm == eRealm.None) || client.Player.Realm == realm)
                    {
                        client.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
            }

            if (ServerProperties.Properties.RECORD_NEWS)
            {
                DBNews news = new DBNews();
                news.Type  = (byte)type;
                news.Realm = (byte)realm;
                news.Text  = message;
                GameServer.Database.AddObject(news);
                GameEventMgr.Notify(DatabaseEvent.NewsCreated, new NewsEventArgs(news));
            }
        }
Beispiel #10
0
        /// <summary>
        /// searches for a npc guild script
        /// </summary>
        /// <param name="guild"></param>
        /// <param name="realm"></param>
        /// <returns>type of class for searched npc guild or null</returns>
        public static Type FindNPCGuildScriptClass(string guild, eRealm realm)
        {
            if (string.IsNullOrEmpty(guild))
            {
                return(null);
            }

            Type type = null;

            if (m_script_guilds[(int)realm] == null)
            {
                Hashtable allScriptGuilds = new Hashtable();
                ArrayList asms            = new ArrayList(Scripts);
                asms.Add(typeof(GameServer).Assembly);
                foreach (Assembly asm in asms)
                {
                    Hashtable scriptGuilds = FindAllNPCGuildScriptClasses(realm, asm);
                    if (scriptGuilds == null)
                    {
                        continue;
                    }
                    foreach (DictionaryEntry entry in scriptGuilds)
                    {
                        if (allScriptGuilds.ContainsKey(entry.Key))
                        {
                            continue;                                                                 // guild is already found
                        }
                        allScriptGuilds.Add(entry.Key, entry.Value);
                    }
                }
                m_script_guilds[(int)realm] = allScriptGuilds;
            }

            //SmallHorse: First test if no realm-guild hashmap is null, then test further
            //Also ... you can not use "nullobject as anytype" ... this crashes!
            //You have to test against NULL result before casting it... read msdn doku
            if (m_script_guilds[(int)realm] != null && m_script_guilds[(int)realm][guild] != null)
            {
                type = m_script_guilds[(int)realm][guild] as Type;
            }

            if (type == null)
            {
                if (m_gs_guilds[(int)realm] == null)
                {
                    Assembly gasm = Assembly.GetAssembly(typeof(GameServer));
                    m_gs_guilds[(int)realm] = FindAllNPCGuildScriptClasses(realm, gasm);
                }
            }

            //SmallHorse: First test if no realm-guild hashmap is null, then test further
            //Also ... you can not use "nullobject as anytype" ... this crashes!
            //You have to test against NULL result before casting it... read msdn doku
            if (m_gs_guilds[(int)realm] != null && m_gs_guilds[(int)realm][guild] != null)
            {
                type = m_gs_guilds[(int)realm][guild] as Type;
            }

            return(type);
        }
Beispiel #11
0
        /// <summary>
        /// does a realm have the amount of keeps required for a certain bonus
        /// </summary>
        /// <param name="type">the type of bonus</param>
        /// <param name="realm">the realm</param>
        /// <returns>true if the realm has the required amount of keeps</returns>
        public static bool RealmHasBonus(eKeepBonusType type, eRealm realm)
        {
            if (!ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
            {
                return(false);
            }

            if (realm == eRealm.None)
            {
                return(false);
            }

            int count = 0;

            switch (realm)
            {
            case eRealm.Albion: count = albCount; break;

            case eRealm.Midgard: count = midCount; break;

            case eRealm.Hibernia: count = hibCount; break;
            }

            return(count >= (int)type);
        }
        /// <summary>
        /// Player receives this item (added to players inventory)
        /// </summary>
        /// <param name="player"></param>
        public override void OnReceive(GamePlayer player)
        {
            // for guild banners we don't actually add it to inventory but instead register
            // if it is rescued by a friendly player or taken by the enemy

            player.Inventory.RemoveItem(this);

            int    trophyModel = 0;
            eRealm realm       = eRealm.None;

            switch (Model)
            {
            case 3223:
                trophyModel = 3359;
                realm       = eRealm.Albion;
                break;

            case 3224:
                trophyModel = 3361;
                realm       = eRealm.Midgard;
                break;

            case 3225:
                trophyModel = 3360;
                realm       = eRealm.Hibernia;
                break;
            }

            // if picked up by an enemy then turn this into a trophy
            if (realm != player.Realm)
            {
                ItemUnique template = new ItemUnique(Template);
                template.ClassType        = "";
                template.Model            = trophyModel;
                template.IsDropable       = true;
                template.IsIndestructible = false;

                GameServer.Database.AddObject(template);
                GameInventoryItem trophy = new GameInventoryItem(template);
                player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, trophy);
                OwnerGuild.SendMessageToGuildMembers(player.Name + " of " + GlobalConstants.RealmToName(player.Realm) + " has captured your guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow);
                OwnerGuild.GuildBannerLostTime = DateTime.Now;
            }
            else
            {
                m_status = eStatus.Recovered;

                // A friendly player has picked up the banner.
                if (OwnerGuild != null)
                {
                    OwnerGuild.SendMessageToGuildMembers(player.Name + " has recovered your guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow);
                }

                if (SummonPlayer != null)
                {
                    SummonPlayer.GuildBanner = null;
                }
            }
        }
Beispiel #13
0
 private PlayerRace(eRace race, eRealm realm, eDAoCExpansion expansion, eLivingModel maleModel, eLivingModel femaleModel)
 {
     ID          = race;
     Realm       = realm;
     Expansion   = expansion;
     MaleModel   = maleModel;
     FemaleModel = femaleModel;
 }
Beispiel #14
0
 /// <summary>
 /// 1125 sendrealm
 /// </summary>
 public override void SendRealm(eRealm realm)
 {
     using (var pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.Realm)))
     {
         pak.WriteByte((byte)realm);
         pak.Fill(0, 12);
         SendTCP(pak);
     }
 }
Beispiel #15
0
        public static MiniTemp GetRelicTemplate(eRealm Realm, eRelicType RelicType)
        {
            MiniTemp m_template = new MiniTemp();

            switch (Realm)
            {
            case eRealm.Albion:
                if (RelicType == eRelicType.Magic)
                {
                    m_template.Name  = "Merlins Staff";
                    m_template.Model = 630;
                }
                else
                {
                    m_template.Name  = "Scabbard of Excalibur";
                    m_template.Model = 631;
                }

                break;

            case eRealm.Midgard:
                if (RelicType == eRelicType.Magic)
                {
                    m_template.Name  = "Horn of Valhalla";
                    m_template.Model = 635;
                }
                else
                {
                    m_template.Name  = "Thors Hammer";
                    m_template.Model = 634;
                }

                break;

            case eRealm.Hibernia:
                if (RelicType == eRelicType.Magic)
                {
                    m_template.Name  = "Cauldron of Dagda";
                    m_template.Model = 632;
                }
                else
                {
                    m_template.Name  = " Lughs Spear of Lightning";
                    m_template.Model = 633;
                }

                break;

            default:
                m_template.Name  = "Unkown Relic";
                m_template.Model = 633;
                break;
            }

            return(m_template);
        }
Beispiel #16
0
 public string getRealmString(eRealm Realm)
 {
     switch (Realm)
     {
         case eRealm.Albion: return " ALB";
         case eRealm.Midgard: return " MID";
         case eRealm.Hibernia: return " HIB";
         default: return " NONE";
     }
 }
Beispiel #17
0
        public override bool AddToWorld()
        {
            if (base.AddToWorld())
            {
                m_lastRealm = Realm;
                return(true);
            }

            return(false);
        }
Beispiel #18
0
		/// <summary>
		/// This method checks if a guild exists
		/// if not, the guild is created with default values
		/// </summary>
		/// <param name="guildName">The guild name that is being checked</param>
		private static void CheckGuild(eRealm currentRealm, string guildName)
		{
			if (!GuildMgr.DoesGuildExist(guildName))
			{
				Guild newguild = GuildMgr.CreateGuild(currentRealm, guildName);
				newguild.Ranks[8].OcHear = true;
				newguild.Motd = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE,"Guild.StartupGuild.Motd");
				newguild.Omotd = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE,"Guild.StartupGuild.Omotd");
				newguild.Ranks[8].Title =  LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE,"Guild.StartupGuild.Title");
			}
		}
Beispiel #19
0
 /// <summary>
 /// This method checks if a guild exists
 /// if not, the guild is created with default values
 /// </summary>
 /// <param name="currentRealm">Current Realm being checked</param>
 /// <param name="guildName">The guild name that is being checked</param>
 private static void CheckGuild(eRealm currentRealm, string guildName)
 {
     if (!GuildMgr.DoesGuildExist(guildName))
     {
         Guild newguild = GuildMgr.CreateGuild(currentRealm, guildName);
         newguild.Ranks[8].OcHear = true;
         newguild.Motd            = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Guild.StartupGuild.Motd");
         newguild.Omotd           = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Guild.StartupGuild.Omotd");
         newguild.Ranks[8].Title  = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Guild.StartupGuild.Title");
     }
 }
Beispiel #20
0
 /// <summary>
 /// when  keep is taken it check if the realm which take gain the control of DF
 /// </summary>
 /// <param name="e"></param>
 /// <param name="sender"></param>
 /// <param name="arguments"></param>
 public static void OnKeepTaken(DOLEvent e, object sender, EventArgs arguments)
 {
     KeepEventArgs args = arguments as KeepEventArgs;
     eRealm realm = (eRealm) args.Keep.Realm ;
     if (realm != DarknessFallOwner )
     {
         int currentDFOwnerTowerCount = GameServer.KeepManager.GetTowerCountByRealm(DarknessFallOwner);
         int challengerOwnerTowerCount = GameServer.KeepManager.GetTowerCountByRealm(realm);
         if (currentDFOwnerTowerCount < challengerOwnerTowerCount)
             DarknessFallOwner = realm;
     }
 }
Beispiel #21
0
        public ScoutMission(object owner)
            : base(owner)
        {
            eRealm realm = 0;

            if (owner is Group group)
            {
                realm = group.Leader.Realm;
            }
            else if (owner is GamePlayer player)
            {
                realm = player.Realm;
            }

            ArrayList list = new ArrayList();

            ICollection <AbstractGameKeep> keeps;

            if (owner is Group group1)
            {
                keeps = GameServer.KeepManager.GetKeepsOfRegion(group1.Leader.CurrentRegionID);
            }
            else if (owner is GamePlayer gOwner)
            {
                keeps = GameServer.KeepManager.GetKeepsOfRegion(gOwner.CurrentRegionID);
            }
            else
            {
                keeps = new List <AbstractGameKeep>();
            }

            foreach (AbstractGameKeep keep in keeps)
            {
                if (keep.IsPortalKeep)
                {
                    continue;
                }

                if (keep.Realm != realm)
                {
                    list.Add(keep);
                }
            }

            if (list.Count > 0)
            {
                _keep = list[Util.Random(list.Count - 1)] as AbstractGameKeep;
            }

            GameEventMgr.AddHandler(AreaEvent.PlayerEnter, new DOLEventHandler(Notify));
            GameEventMgr.AddHandler(KeepEvent.KeepTaken, new DOLEventHandler(Notify));
        }
Beispiel #22
0
        /// <summary>
        /// Returns an enumeration with all mounted Relics of an realm by a specified RelicType
        /// </summary>
        /// <param name="Realm"></param>
        /// <param name="RelicType"></param>
        /// <returns></returns>
        public static IEnumerable getRelics(eRealm Realm, eRelicType RelicType)
        {
            ArrayList realmTypeRelics = new ArrayList();

            foreach (GameRelic relic in getRelics(Realm))
            {
                if (relic.RelicType == RelicType)
                {
                    realmTypeRelics.Add(relic);
                }
            }
            return(realmTypeRelics);
        }
Beispiel #23
0
        public string getRealmString(eRealm Realm)
        {
            switch (Realm)
            {
            case eRealm.Albion: return(" ALB");

            case eRealm.Midgard: return(" MID");

            case eRealm.Hibernia: return(" HIB");

            default: return(" NONE");
            }
        }
Beispiel #24
0
 /// <summary>
 /// Method to broadcast messages, if eRealm.None all can see,
 /// else only the right realm can see
 /// </summary>
 /// <param name="message">The message</param>
 /// <param name="realm">The realm</param>
 public static void BroadcastMessage(string message, eRealm realm)
 {
     foreach (GameClient client in WorldMgr.GetAllClients())
     {
         if (client.Player == null)
         {
             continue;
         }
         if ((client.Account.PrivLevel != 1 || realm == eRealm.None) || client.Player.Realm == realm)
         {
             client.Out.SendMessage(message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
         }
     }
 }
        public RaizeMission(object owner)
            : base(owner)
        {
            eRealm realm = 0;

            if (owner is Group)
            {
                realm = (owner as Group).Leader.Realm;
            }
            else if (owner is GamePlayer)
            {
                realm = (owner as GamePlayer).Realm;
            }

            ArrayList list = new ArrayList();

            ICollection <AbstractGameKeep> keeps;

            if (owner is Group)
            {
                keeps = GameServer.KeepManager.GetKeepsOfRegion((owner as Group).Leader.CurrentRegionID);
            }
            else if (owner is GamePlayer)
            {
                keeps = GameServer.KeepManager.GetKeepsOfRegion((owner as GamePlayer).CurrentRegionID);
            }
            else
            {
                keeps = new List <AbstractGameKeep>();
            }

            foreach (AbstractGameKeep keep in keeps)
            {
                if (keep.IsPortalKeep)
                {
                    continue;
                }
                if (keep is GameKeepTower && keep.Realm != realm)
                {
                    list.Add(keep);
                }
            }

            if (list.Count > 0)
            {
                m_keep = list[Util.Random(list.Count - 1)] as AbstractGameKeep;
            }

            GameEventMgr.AddHandler(KeepEvent.TowerRaized, new DOLEventHandler(Notify));
        }
        /// <summary>
        /// Display teleport destinations for passed realm
        /// </summary>
        /// <param name="PlayerRealm">Realm to display destinations for</param>
        public String DisplayTeleportDestinations(eRealm DestinationRealm)
        {
            String sRet = null;

            switch (DestinationRealm)
            {
            case eRealm.Albion:
                sRet = String.Format("Greetings. I can channel the energies of this place to send you {0} {1} {2} {3} {4} {5} {6} {7}",
                                     "to far away lands. If you wish to fight in the Frontiers I can send you to [Forest Sauvage] or to the",
                                     "border keeps [Castle Sauvage] and [Snowdonia Fortress]. Maybe you wish to undertake the Trials of",
                                     "Atlantis in [Albion Oceanus] haven or wish to visit the harbor of [Gothwaite] and the [Albion Shrouded Isles]?",
                                     "You could explore the [Avalon Marsh] or perhaps you would prefer the comforts of the [housing] regions.",
                                     "Perhaps the fierce [Battlegrounds] are more to your liking or do you wish to meet the citizens inside",
                                     "the great city of [Camelot] or the [Inconnu Crypt]?",
                                     "Or perhaps you are interested in porting to our training camp [Holtham]?",
                                     "Or would you prefer to teleport to [Hibernia] or [Midgard]?");
                break;

            case eRealm.Midgard:
                sRet = String.Format("Greetings. I can channel the energies of this place to send you {0} {1} {2} {3} {4} {5} {6} {7}",
                                     "to far away lands. If you wish to fight in the Frontiers I can send you to [Uppland] or to the",
                                     "border keeps [Svasud Faste] and [Vindsaul Faste]. Maybe you wish to undertake the Trials of",
                                     "Atlantis in [Midgard Oceanus] haven or wish to visit the [City of Aegirhamn] and the [Midgard Shrouded Isles]?",
                                     "You could explore the [Gotar] or perhaps you would prefer the comforts of the [housing] regions.",
                                     "Perhaps the fierce [Battlegrounds] are more to your liking or do you wish to meet the citizens inside",
                                     "the great city of [Jordheim] or the [Kobold Undercity]?",
                                     "Or perhaps you are interested in porting to our training camp [Hafheim]?",
                                     "Or would you prefer to teleport to [Albion] or [Hibernia]?");
                break;

            case eRealm.Hibernia:
                sRet = String.Format("Greetings. I can channel the energies of this place to send you {0} {1} {2} {3} {4} {5} {6} {7}",
                                     "to far away lands. If you wish to fight in the Frontiers I can send you to [Cruachan Gorge] or to the",
                                     "border keeps [Druim Ligen] and [Druim Cain]. Maybe you wish to undertake the Trials of",
                                     "Atlantis in [Hibernia Oceanus] haven or wish to visit the mysterious Grove of [Domnann] and the [Hibernia Shrouded Isles]?",
                                     "You could explore the [Shannon Estuary] or perhaps you would prefer the comforts of the [housing] regions.",
                                     "Perhaps the fierce [Battlegrounds] are more to your liking or do you wish to meet the citizens inside",
                                     "the great city of [Tir na Nog] or the [Shar Labyrinth]?",
                                     "Or perhaps you are interested in porting to our training camp [Fintain]?",
                                     "Or would you prefer to teleport to [Albion] or [Midgard]?");
                break;

            default:
                log.Warn(String.Format("DisplayTeleportDestinations does not handle player realm [{0}]", DestinationRealm.ToString()));
                break;
            }

            return(sRet);
        }
Beispiel #27
0
        public static Guild CreateGuild(eRealm realm, string guildName, GamePlayer creator = null)
        {
            if (DoesGuildExist(guildName))
            {
                if (creator != null)
                {
                    creator.Out.SendMessage(guildName + " already exists!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }

                return(null);
            }

            try
            {
                DBGuild dbGuild = new DBGuild();
                dbGuild.GuildName = guildName;
                dbGuild.GuildID   = System.Guid.NewGuid().ToString();
                dbGuild.Realm     = (byte)realm;
                Guild newguild = new Guild(dbGuild);
                if (newguild.AddToDatabase() == false)
                {
                    if (creator != null)
                    {
                        creator.Out.SendMessage("Database error, unable to add a new guild!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }

                    return(null);
                }

                AddGuild(newguild);
                CreateRanks(newguild);

                if (log.IsDebugEnabled)
                {
                    log.Debug("Create guild; guild name=\"" + guildName + "\" Realm=" + GlobalConstants.RealmToName(newguild.Realm));
                }

                return(newguild);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("CreateGuild", e);
                }

                return(null);
            }
        }
        /// <summary>
        /// when  keep is taken it check if the realm which take gain the control of DF
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        public static void OnKeepTaken(DOLEvent e, object sender, EventArgs arguments)
        {
            KeepEventArgs args  = arguments as KeepEventArgs;
            eRealm        realm = (eRealm)args.Keep.Realm;

            if (realm != DarknessFallOwner)
            {
                int currentDFOwnerTowerCount  = GameServer.KeepManager.GetTowerCountByRealm(DarknessFallOwner);
                int challengerOwnerTowerCount = GameServer.KeepManager.GetTowerCountByRealm(realm);
                if (currentDFOwnerTowerCount < challengerOwnerTowerCount)
                {
                    DarknessFallOwner = realm;
                }
            }
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            if (Util.Chance(10))
            {
                ItemTemplate[] itemTemplates = null;

                eRealm realm = mob.CurrentZone.Realm;

                if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
                {
                    realm = (eRealm)Util.Random((int)eRealm._FirstPlayerRealm, (int)eRealm._LastPlayerRealm);
                }

                switch (realm)
                {
                case eRealm.Albion:
                {
                    int index = Math.Min(m_itemTemplatesAlb.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesAlb[index];
                }
                break;

                case eRealm.Hibernia:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesHib[index];
                    break;
                }

                case eRealm.Midgard:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesMid[index];
                    break;
                }
                }

                if (itemTemplates != null && itemTemplates.Length > 0)
                {
                    ItemTemplate itemTemplate = itemTemplates[Util.Random(itemTemplates.Length - 1)];
                    loot.AddFixed(itemTemplate, 1);
                }
            }

            return(loot);
        }
Beispiel #30
0
        public static Spell GetGuardHealSmallSpell(eRealm realm)
        {
            switch (realm)
            {
            case eRealm.None:
            case eRealm.Albion:
                return(AlbGuardHealSmallSpell);

            case eRealm.Midgard:
                return(MidGuardHealSmallSpell);

            case eRealm.Hibernia:
                return(HibGuardHealSmallSpell);
            }
            return(null);
        }
Beispiel #31
0
        /// <summary>
        /// Returns an enumeration with all mounted Relics of an realm
        /// </summary>
        /// <param name="Realm"></param>
        /// <returns></returns>
        public static IEnumerable getRelics(eRealm Realm)
        {
            ArrayList realmRelics = new ArrayList();

            lock (m_relics)
            {
                foreach (GameRelic relic in m_relics.Values)
                {
                    if (relic.Realm == Realm && relic.IsMounted)
                    {
                        realmRelics.Add(relic);
                    }
                }
            }
            return(realmRelics);
        }
Beispiel #32
0
        /// <summary>
        /// get relic count by realm and relictype
        /// </summary>
        /// <param name="realm"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetRelicCount(eRealm realm, eRelicType type)
        {
            int index = 0;

            lock (m_relics.SyncRoot)
            {
                foreach (GameRelic relic in m_relics.Values)
                {
                    if ((relic.Realm == realm) && (relic.RelicType == type) && (relic is GameRelic))
                    {
                        index++;
                    }
                }
            }
            return(index);
        }
Beispiel #33
0
        private Spell GetGuardHealSmallSpell(eRealm realm)
        {
            switch (realm)
            {
            case eRealm.None:
            case eRealm.Albion:
                return(GuardSpellDB.AlbGuardHealSmallSpell);

            case eRealm.Midgard:
                return(GuardSpellDB.MidGuardHealSmallSpell);

            case eRealm.Hibernia:
                return(GuardSpellDB.HibGuardHealSmallSpell);
            }
            return(null);
        }
Beispiel #34
0
        /// <summary>
        /// Loads the GameRelic from Database
        /// </summary>
        /// <param name="obj">The DBRelic-object for this relic</param>
        public override void LoadFromDatabase(DataObject obj)
        {
            InternalID      = obj.ObjectId;
            m_dbRelic       = obj as DBRelic;
            CurrentRegionID = (ushort)m_dbRelic.Region;
            X               = m_dbRelic.X;
            Y               = m_dbRelic.Y;
            Z               = m_dbRelic.Z;
            Heading         = (ushort)m_dbRelic.Heading;
            m_relicType     = (eRelicType)m_dbRelic.relicType;
            Realm           = (eRealm)m_dbRelic.Realm;
            m_originalRealm = (eRealm)m_dbRelic.OriginalRealm;
            m_lastRealm     = (eRealm)m_dbRelic.LastRealm;


            //get constant values
            MiniTemp template = GetRelicTemplate(m_originalRealm, m_relicType);

            m_name   = template.Name;
            m_model  = template.Model;
            template = null;

            //set still empty fields
            Emblem = 0;
            Level  = 99;

            //generate itemtemplate for inventoryitem
            ItemTemplate m_itemTemp;

            m_itemTemp             = new ItemTemplate();
            m_itemTemp.Name        = Name;
            m_itemTemp.Object_Type = (int)eObjectType.Magical;
            m_itemTemp.Model       = Model;
            m_itemTemp.IsDropable  = true;
            m_itemTemp.IsPickable  = false;
            m_itemTemp.Level       = 99;
            m_itemTemp.Quality     = 100;
            m_itemTemp.Price       = 0;
            m_itemTemp.PackSize    = 1;
            m_itemTemp.AllowAdd    = false;
            m_itemTemp.Weight      = 1000;
            m_itemTemp.Id_nb       = "GameRelic";
            m_itemTemp.IsTradable  = false;
            m_itemTemp.ClassType   = "DOL.GS.GameInventoryRelic";
            m_item = GameInventoryItem.Create <ItemTemplate>(m_itemTemp);
        }
        /// <summary>
        /// does a realm have the amount of keeps required for a certain bonus
        /// </summary>
        /// <param name="type">the type of bonus</param>
        /// <param name="realm">the realm</param>
        /// <returns>true if the realm has the required amount of keeps</returns>
        public static bool RealmHasBonus(eKeepBonusType type, eRealm realm)
        {
            if (!ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
                return false;

            if (realm == eRealm.None)
                return false;

            int count = 0;
            switch (realm)
            {
                case eRealm.Albion: count = albCount; break;
                case eRealm.Midgard: count = midCount; break;
                case eRealm.Hibernia: count = hibCount; break;
            }

            return count >= (int)type;
        }
        /// <summary>
        /// check if a realm have more keep at start
        /// to know the DF owner
        /// </summary>

        private static void CheckDFOwner()
        {
            int albcount = GameServer.KeepManager.GetTowerCountByRealm(eRealm.Albion);
            int midcount = GameServer.KeepManager.GetTowerCountByRealm(eRealm.Midgard);
            int hibcount = GameServer.KeepManager.GetTowerCountByRealm(eRealm.Hibernia);

            if (albcount > midcount && albcount > hibcount)
            {
                DarknessFallOwner = eRealm.Albion;
            }
            if (midcount > albcount && midcount > hibcount)
            {
                DarknessFallOwner = eRealm.Midgard;
            }
            if (hibcount > midcount && hibcount > albcount)
            {
                DarknessFallOwner = eRealm.Hibernia;
            }
        }
Beispiel #37
0
		/// <summary>
		/// Get a list of all versions for this artifact.
		/// </summary>
		/// <param name="artifactID"></param>
		/// <param name="realm"></param>
		/// <returns></returns>
		private static List<ArtifactXItem> GetArtifactVersions(String artifactID, eRealm realm)
		{
			List<ArtifactXItem> versions = new List<ArtifactXItem>();
			if (artifactID != null)
			{
				lock (m_artifactVersions)
				{
					if (m_artifactVersions.ContainsKey(artifactID))
					{
						List<ArtifactXItem> allVersions = m_artifactVersions[artifactID];
						foreach (ArtifactXItem version in allVersions)
							if (version.Realm == 0 || version.Realm == (int)realm)
								versions.Add(version);
					}
				}
			}

			return versions;
		}
Beispiel #38
0
		/// <summary>
		/// Method to broadcast messages, if eRealm.None all can see,
		/// else only the right realm can see
		/// </summary>
		/// <param name="message">The message</param>
		/// <param name="realm">The realm</param>
		public static void BroadcastMessage(string message, eRealm realm)
		{
			foreach (GameClient client in WorldMgr.GetAllClients())
			{
				if (client.Player == null)
					continue;
				if ((client.Account.PrivLevel != 1 || realm == eRealm.None) || client.Player.Realm == realm)
				{
					client.Out.SendMessage(message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
				}
			}
		}
Beispiel #39
0
		/// <summary>
		/// Sends a message to all players to notify them of the raize
		/// </summary>
		/// <param name="keep">The keep object</param>
		/// <param name="realm">The raizing realm</param>
		public static void BroadcastRaize(AbstractGameKeep keep, eRealm realm)
		{
			string message = string.Format(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "PlayerManager.BroadcastRaize.Razed", keep.Name, GlobalConstants.RealmToName(realm)));
			BroadcastMessage(message, eRealm.None);
			NewsMgr.CreateNews(message, keep.Realm, eNewsType.RvRGlobal, false);
		}
Beispiel #40
0
		public override void SendCharacterOverview(eRealm realm)
		{
			if (realm < eRealm.Albion || realm > eRealm.Hibernia)
			{
				throw new Exception("CharacterOverview requested for unknown realm " + realm);
			}

			int firstSlot = (byte)realm * 100;

			GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview));
			pak.FillString(m_gameClient.Account.Name, 28); //extra 4 in 1.104

			if (m_gameClient.Account.Characters == null)
			{
				pak.Fill(0x0, 1880);
			}
			else
			{
				Dictionary<int, DOLCharacters> charsBySlot = new Dictionary<int, DOLCharacters>();
				string itemQuery = "(";
				foreach (DOLCharacters c in m_gameClient.Account.Characters)
				{
					try
					{
						charsBySlot.Add(c.AccountSlot, c);
						itemQuery += "OwnerID = '" + c.ObjectId + "' OR ";
					}
					catch (Exception ex)
					{
						log.Error("SendCharacterOverview - Duplicate char in slot? Slot: " + c.AccountSlot + ", Account: " + c.AccountName, ex);
					}
				}
				itemQuery = itemQuery.Substring(0, itemQuery.Length - 4); //remove last OR
				itemQuery += ") AND SlotPosition >= " + ((int)eInventorySlot.MinEquipable) + " AND SlotPosition <= " + ((int)eInventorySlot.MaxEquipable);

				var itemsByOwnerID = new Dictionary<string, Dictionary<eInventorySlot, InventoryItem>>();
				var allItems = (InventoryItem[])GameServer.Database.SelectObjects<InventoryItem>(itemQuery);
				foreach (InventoryItem item in allItems)
				{
                    try
                    {
                        if (!itemsByOwnerID.ContainsKey(item.OwnerID))
                            itemsByOwnerID.Add(item.OwnerID, new Dictionary<eInventorySlot, InventoryItem>());

                        itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item);
                    }
                    catch (Exception ex)
                    {
                        log.Error("SendCharacterOverview - Duplicate item on character? OwnerID: " + item.OwnerID + ", SlotPosition: " + item.SlotPosition + ", Account: " + m_gameClient.Account.Name, ex);
                    }
				}

				for (int i = firstSlot; i < (firstSlot + 10); i++)
				{
					DOLCharacters c = null;
					if (!charsBySlot.TryGetValue(i, out c))
					{
						pak.Fill(0x0, 188);
					}
					else
					{
						Dictionary<eInventorySlot, InventoryItem> charItems = null;

						if (!itemsByOwnerID.TryGetValue(c.ObjectId, out charItems))
							charItems = new Dictionary<eInventorySlot, InventoryItem>();

						byte extensionTorso = 0;
						byte extensionGloves = 0;
						byte extensionBoots = 0;

						InventoryItem item = null;

						if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out item))
							extensionTorso = item.Extension;

						if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item))
							extensionGloves = item.Extension;

						if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item))
							extensionBoots = item.Extension;

						pak.FillString(c.Name, 24);
						pak.WriteByte(0x01);
						pak.WriteByte((byte)c.EyeSize);
						pak.WriteByte((byte)c.LipSize);
						pak.WriteByte((byte)c.EyeColor);
						pak.WriteByte((byte)c.HairColor);
						pak.WriteByte((byte)c.FaceType);
						pak.WriteByte((byte)c.HairStyle);
						pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves));
						pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0)));
						pak.WriteByte((byte)c.CustomisationStep); //1 = auto generate config, 2= config ended by player, 3= enable config to player
						pak.WriteByte((byte)c.MoodType);
						pak.Fill(0x0, 13); //0 String

						string locationDescription = "";
						Region region = WorldMgr.GetRegion((ushort)c.Region);
						if (region != null)
						{
							Zone zone = null;
							if ((zone = region.GetZone(c.Xpos, c.Ypos)) != null)
							{
								IList areas = zone.GetAreasOfSpot(c.Xpos, c.Ypos, c.Zpos);

								foreach (AbstractArea area in areas)
								{
									if (!area.DisplayMessage)
										continue;

									locationDescription = area.Description;
									break;
								}

								if (locationDescription == "")
								{
									locationDescription = zone.Description;
								}
							}
						}
						pak.FillString(locationDescription, 24);

						string classname = "";
						if (c.Class != 0)
							classname = ((eCharacterClass)c.Class).ToString();
						pak.FillString(classname, 24);

						string racename = GamePlayer.RACENAMES(m_gameClient, c.Race, c.Gender);
						pak.FillString(racename, 24);

						pak.WriteByte((byte)c.Level);
						pak.WriteByte((byte)c.Class);
						pak.WriteByte((byte)c.Realm);
						pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4))); // race max value can be 0x1F
						pak.WriteShortLowEndian((ushort)c.CurrentModel);
						pak.WriteByte((byte)c.Region);
						if (region == null || (int)m_gameClient.ClientType > region.Expansion)
							pak.WriteByte(0x00);
						else
							pak.WriteByte((byte)(region.Expansion + 1)); //0x04-Cata zone, 0x05 - DR zone
						pak.WriteInt(0x0); // Internal database ID
						pak.WriteByte((byte)c.Strength);
						pak.WriteByte((byte)c.Dexterity);
						pak.WriteByte((byte)c.Constitution);
						pak.WriteByte((byte)c.Quickness);
						pak.WriteByte((byte)c.Intelligence);
						pak.WriteByte((byte)c.Piety);
						pak.WriteByte((byte)c.Empathy);
						pak.WriteByte((byte)c.Charisma);

						InventoryItem rightHandWeapon = null;
						charItems.TryGetValue(eInventorySlot.RightHandWeapon, out rightHandWeapon);
						InventoryItem leftHandWeapon = null;
						charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out leftHandWeapon);
						InventoryItem twoHandWeapon = null;
						charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out twoHandWeapon);
						InventoryItem distanceWeapon = null;
						charItems.TryGetValue(eInventorySlot.DistanceWeapon, out distanceWeapon);

						InventoryItem helmet = null;
						charItems.TryGetValue(eInventorySlot.HeadArmor, out helmet);
						InventoryItem gloves = null;
						charItems.TryGetValue(eInventorySlot.HandsArmor, out gloves);
						InventoryItem boots = null;
						charItems.TryGetValue(eInventorySlot.FeetArmor, out boots);
						InventoryItem torso = null;
						charItems.TryGetValue(eInventorySlot.TorsoArmor, out torso);
						InventoryItem cloak = null;
						charItems.TryGetValue(eInventorySlot.Cloak, out cloak);
						InventoryItem legs = null;
						charItems.TryGetValue(eInventorySlot.LegsArmor, out legs);
						InventoryItem arms = null;
						charItems.TryGetValue(eInventorySlot.ArmsArmor, out arms);

						pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0));
						pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0));
						pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0));

						ushort rightHandColor = 0;
						if (rightHandWeapon != null)
						{
							rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color);
						}
						pak.WriteShortLowEndian(rightHandColor);

						pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0));
						pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0));
						pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0));
						pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0));

						ushort helmetColor = 0;
						if (helmet != null)
						{
							helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color);
						}
						pak.WriteShortLowEndian(helmetColor);

						ushort glovesColor = 0;
						if (gloves != null)
						{
							glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color);
						}
						pak.WriteShortLowEndian(glovesColor);

						ushort bootsColor = 0;
						if (boots != null)
						{
							bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color);
						}
						pak.WriteShortLowEndian(bootsColor);

						ushort leftHandWeaponColor = 0;
						if (leftHandWeapon != null)
						{
							leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color);
						}
						pak.WriteShortLowEndian(leftHandWeaponColor);

						ushort torsoColor = 0;
						if (torso != null)
						{
							torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color);
						}
						pak.WriteShortLowEndian(torsoColor);

						ushort cloakColor = 0;
						if (cloak != null)
						{
							cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color);
						}
						pak.WriteShortLowEndian(cloakColor);

						ushort legsColor = 0;
						if (legs != null)
						{
							legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color);
						}
						pak.WriteShortLowEndian(legsColor);

						ushort armsColor = 0;
						if (arms != null)
						{
							armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color);
						}
						pak.WriteShortLowEndian(armsColor);

						//weapon models

						pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0));
						pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0));
						pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0));
						pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0));

						if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.TwoHanded)
						{
							pak.WriteByte(0x02);
							pak.WriteByte(0x02);
						}
						else if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.Distance)
						{
							pak.WriteByte(0x03);
							pak.WriteByte(0x03);
						}
						else
						{
							byte righthand = 0xFF;
							byte lefthand = 0xFF;

							if (rightHandWeapon != null)
								righthand = 0x00;

							if (leftHandWeapon != null)
								lefthand = 0x01;

							pak.WriteByte(righthand);
							pak.WriteByte(lefthand);
						}

						if (region == null || region.Expansion != 1)
							pak.WriteByte(0x00);
						else
							pak.WriteByte(0x01); //0x01=char in SI zone, classic client can't "play"

						pak.WriteByte((byte)c.Constitution);
						pak.Fill(0x00, 4);//new trailing bytes in 1.99
					}

				}
			}
			pak.Fill(0x0, 90);
			SendTCP(pak);
		}
Beispiel #41
0
		/// <summary>
		/// reset the realm when the lord have been killed
		/// </summary>
		/// <param name="realm"></param>
		public virtual void Reset(eRealm realm)
		{
			LastAttackedByEnemyTick = 0;
			StartCombatTick = 0;

			Realm = realm;

			PlayerMgr.BroadcastCapture(this);

            Level = (byte)ServerProperties.Properties.STARTING_KEEP_LEVEL;

			//if a guild holds the keep, we release it
			if (Guild != null)
			{
				Release();
			}
			//we repair all keep components, but not if it is a tower and is raised
			foreach (GameKeepComponent component in this.KeepComponents)
			{
				if (!component.IsRaized)
					component.Repair(component.MaxHealth - component.Health);
				foreach (GameKeepHookPoint hp in component.KeepHookPoints.Values)
				{
					if (hp.Object != null)
						hp.Object.Die(null);
				}
			}
			//change realm
			foreach (GameClient client in WorldMgr.GetClientsOfRegion(this.CurrentRegion.ID))
			{
				client.Out.SendKeepComponentUpdate(this, false);
			}
			//we reset all doors
			foreach(GameKeepDoor door in Doors.Values)
			{
				door.Reset(realm);
			}

			//we make sure all players are not in the air
			ResetPlayersOfKeep();

			//we reset the guards
			foreach (GameKeepGuard guard in Guards.Values)
			{
				if (guard is GuardLord && guard.IsAlive )
				{
					this.TemplateManager.GetMethod("RefreshTemplate").Invoke(null, new object[] { guard });
				}
				else if (guard is GuardLord == false)
				{
					guard.Die(guard);
				}
			}

			//we reset the banners
			foreach (GameKeepBanner banner in Banners.Values)
			{
				banner.ChangeRealm();
			}

			//update guard level for every keep
			if (!IsPortalKeep && ServerProperties.Properties.USE_KEEP_BALANCING)
				GameServer.KeepManager.UpdateBaseLevels();

			//update the counts of keeps for the bonuses
			if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES)
				KeepBonusMgr.UpdateCounts();

			SaveIntoDatabase();

			GameEventMgr.Notify(KeepEvent.KeepTaken, new KeepEventArgs(this));

		}
Beispiel #42
0
		/// <summary>
		/// get keep count by realm
		/// </summary>
		/// <param name="realm"></param>
		/// <returns></returns>
		public static int GetKeepCountByRealm(eRealm realm)
		{
			int index = 0;
			lock (m_keeps.SyncRoot)
			{
				foreach (AbstractGameKeep keep in m_keeps.Values)
				{
					if (keep.Region != NEW_FRONTIERS) continue;
					if (((eRealm)keep.Realm == realm) && (keep is GameKeep))
						index++;
				}
			}
			return index;
		}
Beispiel #43
0
		/// <summary>
		/// Gets the bonus modifier for a realm/relictype.
		/// </summary>
		/// <param name="realm"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		public static double GetRelicBonusModifier(eRealm realm, eRelicType type)
		{
			double value = 0.0;
			//only playerrealms can get bonus
			foreach (GameRelic rel in getRelics(realm, type))
			{
				if (rel.Realm != rel.OriginalRealm)
					value += 0.1;
			}
			return value;
		}
Beispiel #44
0
 /// <summary>
 /// Get's a random NPC based on a con level
 /// </summary>
 /// <param name="realm"></param>
 /// <param name="compareLevel"></param>
 /// <param name="conLevel">-3 grey, -2 green, -1 blue, 0 yellow, 1 - orange, 2 red, 3 purple</param>
 /// <returns></returns>
 public GameNPC GetRandomNPCByCon(eRealm realm, int compareLevel, int conLevel)
 {
     List<GameNPC> npcs = GetNPCsOfZone(new eRealm[] { realm }, 0, 0, compareLevel, conLevel, true);
     GameNPC randomNPC = (npcs.Count == 0 ? null : npcs[0]);
     return randomNPC;
 }
Beispiel #45
0
		/// <summary>
		/// Returns an enumeration with all mounted Relics of an realm
		/// </summary>
		/// <param name="Realm"></param>
		/// <returns></returns>
		public static IEnumerable getRelics(eRealm Realm)
		{
			ArrayList realmRelics = new ArrayList();
			lock (m_relics)
			{
				foreach (GameRelic relic in m_relics.Values)
				{
					if (relic.Realm == Realm && relic.IsMounted)
						realmRelics.Add(relic);
				}
			}
			return realmRelics;
		}
Beispiel #46
0
		/// <summary>
		/// Searches for NPC guild scripts
		/// </summary>
		/// <param name="realm">Realm for searching handlers</param>
		/// <param name="asm">The assembly to search through</param>
		/// <returns>
		/// all handlers that were found, guildname(string) => classtype(Type)
		/// </returns>
		protected static Hashtable FindAllNPCGuildScriptClasses(eRealm realm, Assembly asm)
		{
			Hashtable ht = new Hashtable();
			if (asm != null)
			{
				foreach (Type type in asm.GetTypes())
				{
					// Pick up a class
					if (type.IsClass != true) continue;
					if (!type.IsSubclassOf(typeof(GameNPC))) continue;

					try
					{
						object[] objs = type.GetCustomAttributes(typeof(NPCGuildScriptAttribute), false);
						if (objs.Length == 0) continue;

						foreach (NPCGuildScriptAttribute attrib in objs)
						{
							if (attrib.Realm == eRealm.None || attrib.Realm == realm)
							{
								ht[attrib.GuildName] = type;
							}

						}
					}
					catch (Exception e)
					{
						if (log.IsErrorEnabled)
							log.Error("FindAllNPCGuildScriptClasses", e);
					}
				}
			}
			return ht;
		}
Beispiel #47
0
		/// <summary>
        /// get relic count by realm and relictype
		/// </summary>
		/// <param name="realm"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		public static int GetRelicCount(eRealm realm, eRelicType type)
		{
			int index = 0;
			lock (m_relics.SyncRoot)
			{
				foreach (GameRelic relic in m_relics.Values)
				{
					if ((relic.Realm == realm) && (relic.RelicType == type) && (relic is GameRelic))
						index++;
				}
			}
			return index;

		}
Beispiel #48
0
		/// <summary>
		/// searches for a npc guild script
		/// </summary>
		/// <param name="guild"></param>
		/// <param name="realm"></param>
		/// <returns>type of class for searched npc guild or null</returns>
		public static Type FindNPCGuildScriptClass(string guild, eRealm realm)
		{
			if (string.IsNullOrEmpty(guild)) return null;

			Type type = null;
			if (m_script_guilds[(int)realm] == null)
			{
				Hashtable allScriptGuilds = new Hashtable();
				ArrayList asms = new ArrayList(Scripts);
				asms.Add(typeof(GameServer).Assembly);
				foreach (Assembly asm in asms)
				{
					Hashtable scriptGuilds = FindAllNPCGuildScriptClasses(realm, asm);
					if (scriptGuilds == null) continue;
					foreach (DictionaryEntry entry in scriptGuilds)
					{
						if (allScriptGuilds.ContainsKey(entry.Key)) continue; // guild is already found
						allScriptGuilds.Add(entry.Key, entry.Value);
					}
				}
				m_script_guilds[(int)realm] = allScriptGuilds;
			}

			//SmallHorse: First test if no realm-guild hashmap is null, then test further
			//Also ... you can not use "nullobject as anytype" ... this crashes!
			//You have to test against NULL result before casting it... read msdn doku
			if (m_script_guilds[(int)realm] != null && m_script_guilds[(int)realm][guild] != null)
				type = m_script_guilds[(int)realm][guild] as Type;

			if (type == null)
			{
				if (m_gs_guilds[(int)realm] == null)
				{
					Assembly gasm = Assembly.GetAssembly(typeof(GameServer));
					m_gs_guilds[(int)realm] = FindAllNPCGuildScriptClasses(realm, gasm);
				}
			}

			//SmallHorse: First test if no realm-guild hashmap is null, then test further
			//Also ... you can not use "nullobject as anytype" ... this crashes!
			//You have to test against NULL result before casting it... read msdn doku
			if (m_gs_guilds[(int)realm] != null && m_gs_guilds[(int)realm][guild] != null)
				type = m_gs_guilds[(int)realm][guild] as Type;

			return type;
		}
Beispiel #49
0
		/// <summary>
		/// Returns an enumeration with all mounted Relics of an realm by a specified RelicType
		/// </summary>
		/// <param name="Realm"></param>
		/// <param name="RelicType"></param>
		/// <returns></returns>
		public static IEnumerable getRelics(eRealm Realm, eRelicType RelicType)
		{
			ArrayList realmTypeRelics = new ArrayList();
			foreach (GameRelic relic in getRelics(Realm))
			{
				if (relic.RelicType == RelicType)
					realmTypeRelics.Add(relic);
			}
			return realmTypeRelics;
		}
Beispiel #50
0
		public static string RealmToName(eRealm realm)
		{
			switch (realm)
			{
					case eRealm.None: return "None";
					case eRealm.Albion: return "Albion";
					case eRealm.Midgard: return "Midgard";
					case eRealm.Hibernia: return "Hibernia";
					case eRealm.Door: return "Door";
					default: return "";
			}
		}
Beispiel #51
0
		/// <summary>
		/// Gets the bonus modifier for a realm/relictype.
		/// </summary>
		/// <param name="realm"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		public static double GetRelicBonusModifier(eRealm realm, eRelicType type)
		{
			double bonus = 0.0;
			bool owningSelf = false;
			//only playerrealms can get bonus
			foreach (GameRelic rel in getRelics(realm, type))
			{
				if (rel.Realm == rel.OriginalRealm)
				{
					owningSelf = true;
				}
				else
				{
					bonus += ServerProperties.Properties.RELIC_OWNING_BONUS*0.01;
				}
			}
			
			// Bonus apply only if owning original relic
			if (owningSelf)
				return bonus;
			
			return 0.0;
		}
Beispiel #52
0
		public virtual int GetRealmKeepBonusLevel(eRealm realm)
		{
			int keep = 7 - GetKeepCountByRealm(realm);
			return (int)(keep * ServerProperties.Properties.KEEP_BALANCE_MULTIPLIER);
		}
Beispiel #53
0
		/// <summary>
		/// get keep count by realm
		/// </summary>
		/// <param name="realm"></param>
		/// <returns></returns>
		public virtual int GetKeepCountByRealm(eRealm realm)
		{
			int index = 0;
			lock (m_keepList.SyncRoot)
			{
				foreach (AbstractGameKeep keep in m_keepList.Values)
				{
					if (m_frontierRegionsList.Contains(keep.Region) == false) continue;
					if (((eRealm)keep.Realm == realm) && (keep is GameKeep))
						index++;
				}
			}
			return index;
		}
Beispiel #54
0
		public virtual int GetRealmTowerBonusLevel(eRealm realm)
		{
			int tower = 28 - GetTowerCountByRealm(realm);
			return (int)(tower * ServerProperties.Properties.TOWER_BALANCE_MULTIPLIER);
		}
Beispiel #55
0
		/// <summary>
		/// Create a hashtable containing all item templates that are valid for
		/// this class.
		/// </summary>
		/// <param name="artifactID"></param>
		/// <param name="charClass"></param>
		/// <param name="realm"></param>
		/// <returns></returns>
		public static Dictionary<String, ItemTemplate> GetArtifactVersions(String artifactID, eCharacterClass charClass, eRealm realm)
		{
			if (artifactID == null)
				return null;

			List<ArtifactXItem> allVersions = GetArtifactVersions(artifactID, realm);
			Dictionary<String, ItemTemplate> classVersions = new Dictionary<String, ItemTemplate>();

			lock (allVersions)
			{
				ItemTemplate itemTemplate;
				foreach (ArtifactXItem version in allVersions)
				{
					itemTemplate = GameServer.Database.FindObjectByKey<ItemTemplate>(version.ItemID);

					if (itemTemplate == null)
					{
						log.Warn(String.Format("Artifact item template '{0}' is missing", version.ItemID));
					}
					else
					{
						foreach (String classID in  itemTemplate.AllowedClasses.SplitCSV(true))
						{
							try
							{
								if (Int32.Parse(classID) == (int)charClass)
								{
									classVersions.Add(version.Version, itemTemplate);
									break;
								}
							}
							catch (Exception ex)
							{
								log.Error(String.Format("Invalid class ID '{0}' for item template '{1}', checked by class '{2}'", classID, itemTemplate.Id_nb, (int)charClass));
								log.Error(ex.Message);
							}
						}
					}
				}
			}

			return classVersions;
		}
Beispiel #56
0
 /// <summary>
 /// Get a random NPC belonging to a realm between levels minlevel and maxlevel
 /// </summary>
 /// <param name="realm">The realm the NPC belong to</param>
 /// <param name="minLevel">The minimal level of the NPC</param>
 /// <param name="maxLevel">The maximal level NPC</param>
 /// <returns>A npc</returns>
 public GameNPC GetRandomNPC(eRealm realm, int minLevel, int maxLevel)
 {
     return GetRandomNPC(new eRealm[] { realm }, minLevel, maxLevel);
 }
Beispiel #57
0
		public static string ArmorLevelToName(int armorLevel, eRealm realm)
		{
			switch (realm)
			{
				case eRealm.Albion:
					{
						switch (armorLevel)
						{
								case ArmorLevel.Cloth: return "cloth";
								case ArmorLevel.Chain: return "chain";
								case ArmorLevel.Leather: return "leather";
								case ArmorLevel.Plate: return "plate";
								case ArmorLevel.Studded: return "studded";
								default: return "undefined";
						}
					}
				case eRealm.Midgard:
					{
						switch (armorLevel)
						{
								case ArmorLevel.Cloth: return "cloth";
								case ArmorLevel.Chain: return "chain";
								case ArmorLevel.Leather: return "leather";
								case ArmorLevel.Studded: return "studded";
								default: return "undefined";
						}
					}
				case eRealm.Hibernia:
					{
						switch (armorLevel)
						{
								case ArmorLevel.Cloth: return "cloth";
								case ArmorLevel.Scale: return "scale";
								case ArmorLevel.Leather: return "leather";
								case ArmorLevel.Reinforced: return "reinforced";
								default: return "undefined";
						}
					}
					default: return "undefined";
			}
		}
Beispiel #58
0
 /// <summary>
 /// Get a random npc from zone with given realms
 /// </summary>
 /// <param name="realms">The realms to get the NPC from</param>
 /// <returns>The NPC</returns>
 public GameNPC GetRandomNPC(eRealm[] realms)
 {
     return GetRandomNPC(realms, -1, -1);
 }
Beispiel #59
0
		public static int EmblemOfRealm(eRealm realm)
		{
			switch (realm)
			{
					case eRealm.None: return 0;
					case eRealm.Albion: return 464;
					case eRealm.Midgard: return 465;
					case eRealm.Hibernia: return 466;
					default: return 0;
			}
		}
Beispiel #60
0
 /// <summary>
 /// Get a random npc from zone with given realms
 /// </summary>
 /// <param name="realms">The realms to get the NPC from</param>
 /// <param name="maxLevel">The minimal level of the NPC</param>
 /// <param name="minLevel">The maximum level of the NPC</param>
 /// <returns>The NPC</returns>
 public GameNPC GetRandomNPC(eRealm[] realms, int minLevel, int maxLevel)
 {
     List<GameNPC> npcs = GetNPCsOfZone(realms, minLevel, maxLevel, 0, 0, true);
     GameNPC randomNPC = (npcs.Count == 0 ? null : npcs[0]);
     return randomNPC;
 }