Пример #1
0
		private static bool OnBeforeAmbusherDeath(NPC ambusher)
		{
			if (ambusher.FirstAttacker is Character)
			{
				var killer = (Character)ambusher.FirstAttacker;
				if (!killer.QuestLog.HasActiveQuest(AmbusherQuest))
				{
					// quest isn't active
					return true;
				}

				// say something
				ambusher.Say("Oh kind sir, please don't kill me!");

				// discarded the idea of the backstabber:
				//ambusher.MoveBehindThenExecute(killer,
				//    attacker => attacker.SpellCast.Start(SpellId.ClassSkillBackstabRank1, false, killer));

				// cast some AoE spell (ignoring all restrictions)
				ambusher.SpellCast.Trigger(SpellId.ClassSkillFrostNovaRank6);

				// Is now friendly with everyone
				ambusher.FactionId = FactionId.Friendly;

				// more health than ever before (not necessary here)
				ambusher.BaseHealth = ambusher.Health = 100000;

				// won't do anything stupid anymore
				ambusher.Brain.DefaultState = BrainState.Idle;
				ambusher.Brain.EnterDefaultState();

				// never leave the killer alone: Approach again and again...
				ambusher.CallPeriodically(2000,
					obj => SeekForgiveness(ambusher, killer));

				return false; 		// return false to indicate that the guy didn't die
			}
			return true;			// die
		}
Пример #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();
			}
		}