Ejemplo n.º 1
0
		/// <summary>
		/// Returns if a player is allowed to pick up a mounted relic (depends if they own their own relic of the same type)
		/// </summary>
		/// <param name="player"></param>
		/// <param name="relic"></param>
		/// <returns></returns>
		public static bool CanPickupRelicFromShrine(GamePlayer player, GameRelic relic)
		{
			//debug: if (player == null || relic == null) return false;
			//their own relics can always be picked up.
			if (player.Realm == relic.OriginalRealm)
				return true;
			IEnumerable list = getRelics(player.Realm, relic.RelicType);
			foreach (GameRelic curRelic in list)
			{
				if (curRelic.Realm == curRelic.OriginalRealm)
					return true;
			}

			return false;
		}
Ejemplo n.º 2
0
		/// <summary>
		/// load all relics from DB
		/// </summary>
		/// <returns></returns>
		public static bool Init()
		{
			lock (m_relics.SyncRoot)
			{
				//at first remove all relics
				foreach (GameRelic rel in m_relics.Values)
				{
					rel.SaveIntoDatabase();
					rel.RemoveFromWorld();
				}

				//then clear the hashtable
				m_relics.Clear();

				//then we remove all relics from the pads
				foreach (GameRelicPad pad in m_relicPads)
				{
					pad.RemoveRelic();
				}

				// if relics are on the ground during init we will return them to their owners
				List<GameRelic> lostRelics = new List<GameRelic>();

				var relics = GameServer.Database.SelectAllObjects<DBRelic>();
				foreach (DBRelic datarelic in relics)
				{
					if (datarelic.relicType < 0 || datarelic.relicType > 1
						|| datarelic.OriginalRealm < 1 || datarelic.OriginalRealm > 3)
					{
						log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Realm or Type missmatch.");
						continue;
					}

					if (WorldMgr.GetRegion((ushort)datarelic.Region) == null)
					{
						log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Region missmatch.");
						continue;
					}
					GameRelic relic = new GameRelic(datarelic);
					m_relics.Add(datarelic.RelicID, relic);

					relic.AddToWorld();
					GameRelicPad pad = GetPadAtRelicLocation(relic);
					if (pad != null)
					{
						if (relic.RelicType == pad.PadType)
						{
							relic.RelicPadTakesOver(pad, true);
							log.Debug("DBRelic: " + relic.Name + " has been loaded and added to pad " + pad.Name + ".");
						}
					}
					else
					{
						lostRelics.Add(relic);
					}
				}

				foreach (GameRelic lostRelic in lostRelics)
				{
					eRealm returnRealm = (eRealm)lostRelic.LastRealm;

					if (returnRealm == eRealm.None)
					{
						returnRealm = lostRelic.OriginalRealm;
					}

					// ok, now we have a realm to return the relic too, lets find a pad

					foreach (GameRelicPad pad in m_relicPads)
					{
						if (pad.MountedRelic == null && pad.Realm == returnRealm && pad.PadType == lostRelic.RelicType)
						{
							lostRelic.RelicPadTakesOver(pad, true);
							log.Debug("Lost Relic: " + lostRelic.Name + " has returned to last pad: " + pad.Name + ".");
						}
					}
				}

				// Final cleanup.  If any relic is still unmounted then mount the damn thing to any empty pad

				foreach (GameRelic lostRelic in lostRelics)
				{
					if (lostRelic.CurrentRelicPad == null)
					{
						foreach (GameRelicPad pad in m_relicPads)
						{
							if (pad.MountedRelic == null && pad.PadType == lostRelic.RelicType)
							{
								lostRelic.RelicPadTakesOver(pad, true);
								log.Debug("Lost Relic: " + lostRelic.Name + " auto assigned to pad: " + pad.Name + ".");
							}
						}
					}
				}
			}

			log.Debug(m_relicPads.Count + " relicpads" + ((m_relicPads.Count > 1) ? "s were" : " was") + " loaded.");
			log.Debug(m_relics.Count + " relic" + ((m_relics.Count > 1) ? "s were" : " was") + " loaded.");
			return true;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new KeepEventArgs
 /// </summary>
 public RelicPadEventArgs(GamePlayer player, GameRelic relic)
 {
     this.m_player = player;
     this.m_relic = relic;
 }
Ejemplo n.º 4
0
		/// <summary>
		/// This is called on during the loading. It looks for relicpads and where it could be stored.
		/// </summary>
		/// <returns>null if no GameRelicPad was found at the relic's position.</returns>
		private static GameRelicPad GetPadAtRelicLocation(GameRelic relic)
		{

			lock (m_relicPads.SyncRoot)
			{
				foreach (GameRelicPad pad in m_relicPads)
				{
					if (relic.IsWithinRadius(pad, 200))
						//if (pad.X == relic.X && pad.Y == relic.Y && pad.Z == relic.Z && pad.CurrentRegionID == relic.CurrentRegionID)
						return pad;
				}
				return null;
			}

		}
Ejemplo n.º 5
0
        /// <summary>
        /// load all relics from DB
        /// </summary>
        /// <returns></returns>
        public static bool Init()
        {
            lock (m_relics.SyncRoot)
            {
                //at first remove all relics
                foreach (GameRelic rel in m_relics.Values)
                {
                    rel.SaveIntoDatabase();
                    rel.RemoveFromWorld();
                }

                //then clear the hashtable
                m_relics.Clear();

                //then we remove all relics from the pads
                foreach (GameRelicPad pad in m_relicPads)
                {
                    pad.RemoveRelic();
                }

                var relics = GameServer.Database.SelectAllObjects<DBRelic>();
                foreach (DBRelic datarelic in relics)
                {
                    if (datarelic.relicType < 0 || datarelic.relicType > 1
                        || datarelic.OriginalRealm < 1 || datarelic.OriginalRealm > 3)
                    {
                        log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Realm or Type missmatch.");
                        continue;
                    }

                    if (WorldMgr.GetRegion((ushort)datarelic.Region) == null)
                    {
                        log.Warn("DBRelic: Could not load " + datarelic.RelicID + ": Region missmatch.");
                        continue;
                    }
                    GameRelic relic = new GameRelic(datarelic);
                    m_relics.Add(datarelic.RelicID, relic);

                    relic.AddToWorld();
                    GameRelicPad pad = GetPadAtRelicLocation(relic);
                    if (pad != null && relic.RelicType == pad.PadType)
                    {
                        relic.RelicPadTakesOver(pad, true);
                        log.Debug("DBRelic: " + relic.Name + " has been loaded and added to pad " + pad.Name + ".");
                    }
                }
            }
            log.Debug(m_relicPads.Count + " relicpads" + ((m_relicPads.Count > 1) ? "s were" : " was") + " loaded.");
            log.Debug(m_relics.Count + " relic" + ((m_relics.Count > 1) ? "s were" : " was") + " loaded.");
            return true;
        }
Ejemplo n.º 6
0
 public void RemoveRelic()
 {
     m_mountedRelic = null;
 }
Ejemplo n.º 7
0
        public void RemoveRelic(GameRelic relic)
        {
            m_mountedRelic = null;

            if (relic.CurrentCarrier != null)
            {
                string message = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameRelicPad.RemoveRelic.Removed", relic.CurrentCarrier.Name, GlobalConstants.RealmToName((eRealm)relic.CurrentCarrier.Realm), relic.Name, Name);
                foreach (GameClient cl in WorldMgr.GetAllPlayingClients())
                {
                    if (cl.Player.ObjectState != eObjectState.Active) continue;
                    cl.Out.SendMessage(message + "\n" + message + "\n" + message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
                NewsMgr.CreateNews(message, relic.CurrentCarrier.Realm, eNewsType.RvRGlobal, false);

                Notify(RelicPadEvent.RelicStolen, this, new RelicPadEventArgs(relic.CurrentCarrier, relic));
            }
        }
Ejemplo n.º 8
0
        public void MountRelic(GameRelic relic, bool returning)
        {
            m_mountedRelic = relic;

            if (relic.CurrentCarrier != null && returning == false)
            {
                /* Sending broadcast */
                string message = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameRelicPad.MountRelic.Stored", relic.CurrentCarrier.Name, GlobalConstants.RealmToName((eRealm)relic.CurrentCarrier.Realm), relic.Name, Name);
                foreach (GameClient cl in WorldMgr.GetAllPlayingClients())
                {
                    if (cl.Player.ObjectState != eObjectState.Active) continue;
                    cl.Out.SendMessage(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GameRelicPad.MountRelic.Captured", GlobalConstants.RealmToName((eRealm)relic.CurrentCarrier.Realm), relic.Name), eChatType.CT_ScreenCenterSmaller, eChatLoc.CL_SystemWindow);
                    cl.Out.SendMessage(message + "\n" + message + "\n" + message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
                NewsMgr.CreateNews(message, relic.CurrentCarrier.Realm, eNewsType.RvRGlobal, false);

                /* Increasing of CapturedRelics */
                //select targets to increase CapturedRelics
                //TODO increase stats

                List<GamePlayer> targets = new List<GamePlayer>();
                if (relic.CurrentCarrier.Group != null)
                {
                    foreach (GamePlayer p in relic.CurrentCarrier.Group.GetPlayersInTheGroup())
                    {
                        targets.Add(p);
                    }
                }
                else
                {
                    targets.Add(relic.CurrentCarrier);
                }

                foreach (GamePlayer target in targets)
                {
                    target.CapturedRelics++;
                }

                Notify(RelicPadEvent.RelicMounted, this, new RelicPadEventArgs(relic.CurrentCarrier, relic));
            }
            else
            {
                // relic returned to pad, probably because it was dropped on ground and timer expired.
                string message = string.Format("The {0} has been returned to {1}.", relic.Name, Name);
                foreach (GameClient cl in WorldMgr.GetAllPlayingClients())
                {
                    if (cl.Player.ObjectState != eObjectState.Active) continue;
                    cl.Out.SendMessage(message + "\n" + message + "\n" + message, eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Checks if a GameRelic is mounted at this GameRelicPad
 /// </summary>
 /// <param name="relic"></param>
 /// <returns></returns>
 public bool IsMountedHere(GameRelic relic)
 {
     return m_mountedRelic == relic;
 }