public static void DumpSpell(TextWriter writer, Spell spell) { spell.Dump(writer, "\t"); writer.WriteLine(); writer.WriteLine("#################################################################"); writer.WriteLine(); }
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); }
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); }
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); }
internal void AddSpell(Spell spell) { if (spell == null) { throw new ArgumentNullException("spell"); } Spells.Add(spell); spell.Line = this; }
/// <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; }
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); //} }
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>(); }
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; }
//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(); }); }
/// <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; }
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(); }); }
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)); }
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); } } }
#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; }
/// <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; }
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); })); }
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; }
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); }
public override void AddSpell(Spell spell) { if (m_byId.ContainsKey(spell.SpellId)) return; //NPCOwner.Brain.ActionCollection.AddFactory base.AddSpell(spell); OnNewSpell(spell); }
public CooldownRemoveTimer(int millis, Spell spell) : base(millis, null) { Spell = spell; Callback = DoRemoveCooldown; }
/// <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); }
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; } }
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); }
public void AddCooldown(Spell spell, DateTime cdTime) { var millis = (cdTime - DateTime.Now).ToMilliSecondsInt(); AddCooldown(spell, millis); }
int GetSpecIndex(Spell spell) { var chr = OwnerChar; return(spell.IsTalent ? chr.Talents.CurrentSpecIndex : SpellRecord.NoSpecIndex); }
/// <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; * } * } * } * }*/ }
public override void AddSpell(Spell spell) { AddSpell(spell, true); }
/// <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; }
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]); }
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; }
public override bool IsReady(Spell spell) { return m_readySpells.Contains(spell); }
/// <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; }
public void AddNew(Spell spell) { AddSpell(spell, false); }