Exemplo n.º 1
0
		/// <summary>
		/// Checks requirements for trading between two characters
		/// </summary>
		/// <param name="initChr">possible initiator of trading</param>
		/// <param name="targetChr">possible target of trading</param>
		public static bool MayProposeTrade(Character initChr, Character targetChr)
		{
			TradeStatus tradeStatus;

			if (targetChr == null || !targetChr.IsInContext)
			{
				tradeStatus = TradeStatus.PlayerNotFound;
				return false;
			}
			else if (initChr.IsLoggingOut || targetChr.IsLoggingOut)
			{
				tradeStatus = TradeStatus.LoggingOut;
			}
			else if (!initChr.IsAlive)
			{
				tradeStatus = TradeStatus.PlayerDead;
			}
			else if (!targetChr.IsInRadius(initChr, MaxTradeRadius))
			{
				tradeStatus = TradeStatus.TooFarAway;
			}
			else if (!targetChr.IsAlive)
			{
				tradeStatus = TradeStatus.TargetDead;
			}
			else if (targetChr.IsStunned)
			{
				tradeStatus = TradeStatus.TargetStunned;
			}
			else if (targetChr.IsIgnoring(initChr))
			{
				tradeStatus = TradeStatus.PlayerIgnored;
			}
			else if (targetChr.TradeWindow != null)
			{
				tradeStatus = TradeStatus.AlreadyTrading;
			}
			else if (targetChr.Faction.Group != initChr.Faction.Group && !initChr.Role.IsStaff)
			{
				tradeStatus = TradeStatus.WrongFaction;
			}
			else if (targetChr.IsLoggingOut)
			{
				tradeStatus = TradeStatus.TargetLoggingOut;
			}
			else
			{
				tradeStatus = TradeStatus.Proposed;
				return true;
			}

			TradeHandler.SendTradeStatus(initChr, tradeStatus);
			return false;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Move to the killer and pleed
		/// </summary>
		/// <param name="ambusher"></param>
		/// <param name="killer"></param>
		private static void SeekForgiveness(NPC ambusher, Character killer)
		{
			if (killer.IsInWorld &&
						killer.IsAlive &&
						killer.Map == ambusher.Map &&
						killer.IsInRadius(ambusher, MaxForgivenessDistance))
			{
				// make sure we are using the right means of transportation
				if (killer.IsFlying)
				{
					ambusher.Mount(MountId.FlyingBroom);			// probably won't display correctly
					ambusher.Movement.MoveType = AIMoveType.Fly;
				}
				else
				{
					ambusher.Dismount();
					ambusher.Movement.MoveType = AIMoveType.Walk;
				}

				// go to killer
				ambusher.MoveInFrontThenExecute(killer, mover => {
					mover.StandState = StandState.Kneeling;
					mover.Say("I beg thee for forgiveness!");
				});
			}
			else
			{
				// killer is not in reach anymore
				ambusher.Say("Sigh!");
				ambusher.Delete();
			}
		}
Exemplo n.º 3
0
		/// <summary>
		/// Checks requirements for trading between two characters
		/// </summary>
		/// <param name="initChr">possible initiator of trading</param>
		/// <param name="targetChr">possible target of trading</param>
		/// <returns></returns>
		public static bool CheckRequirements(Character initChr, Character targetChr)
		{
			var tradeStatus = TradeStatus.Proposed;

			if (initChr.IsLoggingOut)
			{
				tradeStatus = TradeStatus.LoggingOut;
			}
			else if (!initChr.IsAlive)
			{
				tradeStatus = TradeStatus.PlayerDead;
			}

			if (tradeStatus != TradeStatus.Proposed)
			{
				TradeHandler.SendTradeStatus(initChr, tradeStatus);
				return false;
			}

			if (targetChr == null)
			{
				TradeHandler.SendTradeStatus(initChr, TradeStatus.PlayerNotFound);
				return false;
			}

			if (!targetChr.IsInRadius(initChr, 10.0f))
			{
				tradeStatus = TradeStatus.TooFarAway;
			}
			else if (!targetChr.IsAlive)
			{
				tradeStatus = TradeStatus.TargetDead;
			}
			else if (targetChr.IsStunned)
			{
				tradeStatus = TradeStatus.TargetStunned;
			}
			else if (Singleton<RelationMgr>.Instance.HasRelation(
				targetChr.EntityId.Low, initChr.EntityId.Low, CharacterRelationType.Ignored))
			{
				tradeStatus = TradeStatus.PlayerIgnored;
			}
			else if (targetChr.TradeInfo != null)
			{
				tradeStatus = TradeStatus.AlreadyTrading;
			}
			else if (targetChr.Faction.Group != initChr.Faction.Group && !initChr.Role.IsStaff)
			{
				tradeStatus = TradeStatus.WrongFaction;
			}
			else if (targetChr.IsLoggingOut)
			{
				tradeStatus = TradeStatus.TargetLoggingOut;
			}

			if (tradeStatus != TradeStatus.Proposed)
			{
				TradeHandler.SendTradeStatus(initChr.Client, tradeStatus);
				return false;
			}

			return true;
		}