Esempio n. 1
0
 public static void DumpSpell(TextWriter writer, Spell spell)
 {
     spell.Dump(writer, "\t");
     writer.WriteLine();
     writer.WriteLine("#################################################################");
     writer.WriteLine();
 }
Esempio n. 2
0
		public static void InitSneedSpells()
		{
			disarm = SpellHandler.Get(SpellId.Disarm_2);  //disarm
			disarm.AISettings.SetCooldown(10000);
			disarm.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);


			SpellHandler.Apply(spell => spell.CooldownTime = 20000, SpellId.MoltenMetal);
			SpellHandler.Apply(spell => spell.CooldownTime = 25000, SpellId.MeltOre);


			// Rhakzor's slam has a cooldown of about 12s
			SpellHandler.Apply(spell => { spell.AISettings.SetCooldown(10000, 14000); }, SpellId.RhahkZorSlam);


			SpellHandler.Apply(spell => spell.CooldownTime = 10000, SpellId.SmiteSlam);

			// remember the Spells for later use
			terrify = SpellHandler.Get(SpellId.Terrify);
			terrify.AISettings.SetCooldown(21000);
			terrify.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);

			distractingPain = SpellHandler.Get(SpellId.DistractingPain);
			distractingPain.AISettings.SetCooldown(12000);
			distractingPain.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);

			ejectSneed = SpellHandler.Get(SpellId.EjectSneed);
		}
Esempio n. 3
0
 public static void InitMarrowgar()
 {
     BoneSlice = SpellHandler.Get(SpellId.BoneSlice);
     BoneStorm = SpellHandler.Get(SpellId.BoneStorm);
     ColdFlame = SpellHandler.Get(SpellId.Coldflame_3);
     ColdFlameBone = SpellHandler.Get(SpellId.Coldflame_13);
     boneLength = Utility.Random(20, 30);
 }
Esempio n. 4
0
 static void InitMarrowgar()
 {
     BoneSlice = SpellHandler.Get(SpellId.BoneSlice);
     BoneStorm = SpellHandler.Get(SpellId.BoneStorm);
     ColdFlame = SpellHandler.Get(SpellId.Coldflame_3);
     ColdFlameBone = SpellHandler.Get(SpellId.Coldflame_13);
     boneLength = urand.Next(20, 30);
 }
Esempio n. 5
0
		internal void AddSpell(Spell spell)
		{
			if (spell == null)
			{
				throw new ArgumentNullException("spell");
			}
			Spells.Add(spell);
			spell.Line = this;
		}
Esempio n. 6
0
		/// <summary>
		/// Checks whether the given target resisted the debuff, represented through the given spell
		/// </summary>
		public static CastMissReason CheckDebuffResist(Unit target, Spell spell, int casterLevel, bool hostile)
		{
			var missReason = CastMissReason.None;
			if (hostile && target.CheckDebuffResist(casterLevel, target.GetLeastResistantSchool(spell)))
			{
				missReason = CastMissReason.Resist;
			}
			return missReason;
		}
Esempio n. 7
0
        public AISpellCastAction(Unit owner, Spell spell)
            : base(owner)
        {
            m_spell = spell;

            //if (m_target != null)
            //{
            //    m_range = new SimpleRange(m_spell.Range.Min, m_spell.Range.Max);
            //}
        }
Esempio n. 8
0
		public static void Init(TestContext testContext)
		{
			chr = Setup.AllianceCharacterPool.Create();
			client = chr.FakeClient;
			disenchantSpell = SpellHandler.Get(SpellId.DisenchantPT);
			disenchantSpell.CastDelay = 0;	// we don't want to wait

			ItemMgr.LoadAll();
			//LootMgr.LoadAll();
			ContentMgr.Load<ItemLootItemEntry>();
		}
Esempio n. 9
0
		public SpellCastAction(IBrain owner, Unit target, Spell spell) : base(owner)
		{
			m_ownerBrain = owner;
			m_target = target;
			m_spell = spell;

			if (m_target != null)
				m_range = new AIRange(m_spell.Range.Min, m_spell.Range.Max);

			IsPrimary = true;
		}
Esempio n. 10
0
		//internal static readonly ObjectPool<List<AuraApplicationInfo>> AuraAppListPool = ObjectPoolMgr.CreatePool(() => new List<AuraApplicationInfo>());

		public static void Trigger(WorldObject caster, SpellEffect triggerEffect, Spell spell)
		{
			var cast = SpellCastPool.Obtain();
			cast.Caster = caster;
			cast.m_triggerEffect = triggerEffect;

			caster.ExecuteInContext(() =>
			{
				cast.Start(spell, true);
				cast.Dispose();
			});
		}
Esempio n. 11
0
		/// <summary>
		/// Returns whether the spell can be casted (true) or if immunity of the target prevents it (false)
		/// </summary>
		public static bool CheckImmune(Unit target, Spell spell, bool hostile)
		{
			if (spell.Mechanic != SpellMechanic.None &&
						hostile == spell.Mechanic.IsNegative() &&
						((spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
						!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
						(target.IsImmune(SpellMechanic.Invulnerable_2) || target.IsImmune(SpellMechanic.Invulnerable))) ||
						(target.IsImmune(spell.Mechanic) || target.IsImmune(spell.DispelType)))
			{
				return false;
			}
			return true;
		}
Esempio n. 12
0
		public static void Trigger(WorldObject caster, Spell spell, ref Vector3 targetLoc, WorldObject selected, Item casterItem)
		{
			var cast = ObtainPooledCast(caster);
			cast.TargetLoc = targetLoc;
			cast.Selected = selected;
			cast.CasterItem = casterItem;

			cast.ExecuteInContext(() =>
			{
				cast.Start(spell, true);
				//cast.Dispose();
			});
		}
Esempio n. 13
0
		private static void DisplayPath(Spell spell, WorldObject caster, WorldObject target, ref Vector3 to)
		{
			if (!(caster is Character)) return;
			if (!NPCMgr.Loaded)
			{
				NPCMgr.LoadAllLater();
				caster.Say("Loading NPCs...");
				return;
			}


			var from = caster.Position;
			from.Z += 5;
			to.Z += 5;
			caster.Map.Terrain.FindPath(new PathQuery(from, ref to, caster, OnFoundPath));
		}
Esempio n. 14
0
		public SpellLine(SpellLineId id, params Spell[] spells)
		{
			LineId = id;
			AuraUID =  (uint)id;
			Spells = new List<Spell>();
			if (spells.Length > 0)
			{
				m_firstSpell = spells[0];

				for (var i = 0; i < spells.Length; i++)
				{
					var spell = spells[i];
					AddSpell(spell);
				}
			}
		}
Esempio n. 15
0
#pragma warning restore 0649

		#endregion

		protected WSGFaction(WarsongGulch instance,
			SpellId flagSpell,
			SpellId flagDropSpell,
			SpellId flagDropDebuff,
			SpellId flagCarrierDebuffSpellId,
			GOEntryId flagStand,
			GOEntryId flagDropId)
		{
			Instance = instance;
			_flagSpell = SpellHandler.Get(flagSpell);
			_flagDropSpell = SpellHandler.Get(flagDropSpell);
			_flagDropDebuff = SpellHandler.Get(flagDropDebuff);
			_flagCarrierDebuffSpell = SpellHandler.Get(flagCarrierDebuffSpellId);
			FlagStandEntry = GOMgr.GetEntry(flagStand);
			DroppedFlagEntry = GOMgr.GetEntry(flagDropId);

			_flagRespawn = WarsongGulch.FlagRespawnTime;
			Score = 0;
		}
Esempio n. 16
0
		/// <summary>
		/// Returns whether the given target is immune to the given spell
		/// </summary>
		public static bool IsImmune(Unit target, Spell spell, bool hostile)
		{
			if (
						hostile &&
						spell.Mechanic.IsNegative() &&
						!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
						(spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
						(
							// immune against spell
							target.IsInvulnerable ||
							target.IsImmune(SpellMechanic.Invulnerable_2) ||
							target.IsImmune(SpellMechanic.Invulnerable) ||
							target.IsImmune(spell.Mechanic) ||
							target.IsImmune(spell.DispelType)
						)
				)
			{
				return true;
			}
			return false;
		}
Esempio n. 17
0
        public static void ApplyAura(TestCharacter chr, Spell spell)
        {
            Assert.IsTrue(spell.IsAura || spell.IsAreaAura, "Spell {0} is not an Aura", spell);

            chr.EnsureInWorld();

            chr.ShapeshiftForm = ShapeshiftForm.Normal;
            chr.Auras.Clear();

            Assert.AreEqual(0, chr.Auras.Count);

            // important: Execute this in the Map's thread
            chr.Map.AddMessageAndWait(new Message(() => {
                chr.SpellCast.TriggerSelf(spell);

                var failure =
                    chr.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_SPELL_FAILURE);

                Assert.IsNull(failure,
                              failure != null
                                ? "Spell failed: " + failure["FailReason"].Value
                                : "");

                Assert.AreEqual(1, chr.Auras.Count, "Aura was not added.");
                var aura = chr.Auras[spell, !spell.HasHarmfulEffects];

                Assert.IsNotNull(aura);

                Assert.AreEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.Duration);
                Assert.AreNotEqual(0, spell.GetDuration(chr.SharedReference, chr));
                Asser.GreaterOrEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.TimeLeft);

                aura.Cancel();

                Assert.IsNull(chr.Auras[spell, !spell.HasHarmfulEffects]);
                Assert.AreEqual(0, chr.Auras.Count);
            }));
        }
Esempio n. 18
0
        public static bool SendTotemCreated(IPacketReceiver client, Spell totemSpell, EntityId totemEntityId)
        {
            var chr = client as Character;
            if (chr == null)
                return false;

            var effect = totemSpell.GetEffect(SpellEffectType.Summon);
            if (effect == null)
                return false;

            var slot = effect.SummonEntry.Slot - 1;

            using(var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TOTEM_CREATED))
            {
                packet.Write(slot);
                packet.Write(totemEntityId);
                packet.Write(totemSpell.GetDuration(chr.SharedReference));
                packet.Write(totemSpell.Id);

                client.Send(packet);
            }
            return true;
        }
Esempio n. 19
0
		private static void AddSpell(Spell spell)
		{
			var clss = spell.ClassId;
			if (clss == ClassId.PetTalents && spell.Talent != null)
			{
				clss = ClassId.Hunter;
			}

			var map = Maps[(int)clss];
			if (map == null)
			{
				Maps[(int)clss] = map = new Dictionary<string, HashSet<Spell>>(100);
			}

			var name = spell.Name;
			if (!string.IsNullOrEmpty(spell.RankDesc) && !spell.RankDesc.Contains("Rank"))
			{
				name += " " + spell.RankDesc;
			}
			var line = map.GetOrCreate(name);
			line.Add(spell);
		}
Esempio n. 20
0
		public override void AddSpell(Spell spell)
		{
		    if (m_byId.ContainsKey(spell.SpellId)) return;
		    //NPCOwner.Brain.ActionCollection.AddFactory
		    base.AddSpell(spell);

		    OnNewSpell(spell);
		}
Esempio n. 21
0
			public CooldownRemoveTimer(int millis, Spell spell) : base(millis, null)
			{
				Spell = spell;
				Callback = DoRemoveCooldown;
			}
Esempio n. 22
0
	    /// <summary>
		/// Returns the delay until the given spell has cooled down in milliseconds
		/// </summary>
		public int GetRemainingCooldownMillis(Spell spell)
		{
			if (m_cooldowns == null) return 0;

		    var cooldown = m_cooldowns.Find(cd => cd.Spell.Id == spell.Id);
            return cooldown == null ? 0 : cooldown.GetDelayUntilNextExecution(Owner);
		}
Esempio n. 23
0
		public override void ClearCooldown(Spell spell, bool alsoCategory = true)
		{
		    if (m_cooldowns == null) return;
		    for (var i = 0; i < m_cooldowns.Count; i++)
		    {
		        var cd = m_cooldowns[i];
		        if (cd.Spell.Id != spell.Id) continue;

		        m_cooldowns.Remove(cd);
		        AddReadySpell(cd.Spell);
		        break;
		    }
		}
Esempio n. 24
0
		private void AddCooldown(Spell spell, int millis)
		{
			if (millis <= 0) return;
			m_readySpells.Remove(spell);

			var action = new CooldownRemoveTimer(millis, spell);
			Owner.AddUpdateAction(action);
			if (m_cooldowns == null)
			{
				m_cooldowns = new List<CooldownRemoveTimer>();
			}
			m_cooldowns.Add(action);
		}
Esempio n. 25
0
		public void AddCooldown(Spell spell, DateTime cdTime)
		{
			var millis = (cdTime - DateTime.Now).ToMilliSecondsInt();
			AddCooldown(spell, millis);
		}
Esempio n. 26
0
        int GetSpecIndex(Spell spell)
        {
            var chr = OwnerChar;

            return(spell.IsTalent ? chr.Talents.CurrentSpecIndex : SpellRecord.NoSpecIndex);
        }
Esempio n. 27
0
 /// <summary>
 /// Add everything to the caster that this spell requires
 /// </summary>
 public void AddSpellRequirements(Spell spell)
 {
     /*var chr = OwnerChar;
      * // add reagents
      * foreach (var reagent in spell.Reagents)
      * {
      *      var templ = reagent.Template;
      *      if (templ != null)
      *      {
      *              var amt = reagent.Amount * 10;
      *              chr.Inventory.Ensure(templ, amt);
      *      }
      * }
      *
      * // add tools
      * if (spell.RequiredTools != null)
      * {
      *      foreach (var tool in spell.RequiredTools)
      *      {
      *              chr.Inventory.Ensure(tool.Template, 1);
      *      }
      * }
      * if (spell.RequiredToolCategories != null)
      * {
      *      foreach (var cat in spell.RequiredToolCategories)
      *      {
      *              var tool = ItemMgr.GetFirstItemOfToolCategory(cat);
      *              if (tool != null)
      *              {
      *                      chr.Inventory.Ensure(tool, 1);
      *              }
      *      }
      * }
      *
      * // Profession
      * if (spell.Ability != null && spell.Ability.Skill != null)
      * {
      *      chr.Skills.TryLearn(spell.Ability.Skill.Id);
      * }
      *
      *
      * // add spellfocus object (if not present)
      * if (spell.RequiredSpellFocus != 0)
      * {
      *      var range = Owner.GetSpellMaxRange(spell);
      *      var go = chr.Map.GetGOWithSpellFocus(chr.Position, spell.RequiredSpellFocus,
      *              range > 0 ? (range) : 5f, chr.Phase);
      *
      *      if (go == null)
      *      {
      *              foreach (var entry in GOMgr.Entries.Values)
      *              {
      *                      if (entry is GOSpellFocusEntry &&
      *                              ((GOSpellFocusEntry)entry).SpellFocus == spell.RequiredSpellFocus)
      *                      {
      *                              entry.Spawn(chr, chr);
      *                              break;
      *                      }
      *              }
      *      }
      * }*/
 }
Esempio n. 28
0
 public override void AddSpell(Spell spell)
 {
     AddSpell(spell, true);
 }
Esempio n. 29
0
		/// <summary>
		/// Returns the modified power-cost needed to cast a Spell of the given DamageSchool 
		/// and the given base amount of power required
		/// </summary>
		public virtual int GetPowerCost(DamageSchool school, Spell spell, int cost)
		{
			int modifier = PowerCostModifier;
			if (m_schoolPowerCostMods != null)
			{
				modifier += m_schoolPowerCostMods[(int)school];
			}

			cost += modifier;

			cost = (int)(Math.Round(PowerCostMultiplier) * cost);
			return cost;
		}
Esempio n. 30
0
		public bool HasEnoughPowerToCast(Spell spell, WorldObject selected)
		{
			if (!spell.CostsMana)
			{
				return true;
			}
			if (selected is Unit)
			{
				return Power >= spell.CalcPowerCost(this, ((Unit)selected).GetLeastResistant(spell));
			}
			return Power >= spell.CalcPowerCost(this, spell.Schools[0]);
		}
Esempio n. 31
0
		public DamageSchool GetLeastResistant(Spell spell)
		{
			if (spell.Schools.Length == 1)
			{
				return spell.Schools[0];
			}

			var least = int.MaxValue;
			var leastSchool = DamageSchool.Physical;
			foreach (var school in spell.Schools)
			{
				var res = GetResistance(school);
				if (res < least)
				{
					least = res;
					leastSchool = school;
				}
			}
			return leastSchool;
		}
Esempio n. 32
0
		public override bool IsReady(Spell spell)
		{
			return m_readySpells.Contains(spell);
		}
Esempio n. 33
0
		/// <summary>
		/// Tries to consume the given amount of Power, also considers modifiers to Power-cost.
		/// </summary>
		public bool ConsumePower(DamageSchool type, Spell spell, int neededPower)
		{
			neededPower = GetPowerCost(type, spell, neededPower);

			if (Power >= neededPower)
			{
				Power -= neededPower;
				return true;
			}

			return false;
		}
Esempio n. 34
0
 public void AddNew(Spell spell)
 {
     AddSpell(spell, false);
 }