public void PetTestClassInitialize() { Setup.EnsureNPCsLoaded(); Setup.EnsureItemsLoaded(); EnsureChar(ref Master, Setup.AllianceCharacterPool); EnsurePet(ref Cat, Setup.NPCPool); Cat.Name = "Cletus"; Cat.Entry.Family = new CreatureFamily() { Id = CreatureFamilyId.Cat, PetTalentType = PetTalentType.Ferocity }; EnsurePet(ref Bear, Setup.NPCPool); Bear.Name = "BillyRay"; Bear.Entry.Family = new CreatureFamily() { Id = CreatureFamilyId.Bear, PetTalentType = PetTalentType.Tenacity }; // Add the FeedPet spell to the Master Master.Class = ClassId.Hunter; var spell = SpellHandler.Get(SpellId.ClassSkillFeedPet); Master.Spells.AddSpell(spell); }
public override void Apply() { var chr = m_cast.CasterObject as Character; int spellCost = 0; if (chr != null) { if (chr.Totems != null) { foreach (var totem in chr.Totems) { if (totem == null) { continue; } var spell = SpellHandler.Get(totem.CreationSpellId); if (spell != null) { spellCost += ((chr.BasePower * spell.PowerCostPercentage) / 100) / 4; totem.Delete(); } } chr.Energize(spellCost, chr, Effect); } } }
public static void FixEyeOfAcherusSpells() { var eyeSpell = SpellHandler.Get(SpellId.EffectTheEyeOfAcherus); eyeSpell.AuraRemoved += EffectTheEyeOfAcherusRemoved; var ghoulSpell = SpellHandler.Get(SpellId.SummonGhoulsOnScarletCrusade); ghoulSpell.GetEffect(SpellEffectType.ScriptEffect).SpellEffectHandlerCreator = (cast, effect) => new SummonGhoulsSpellEffectHandler(cast, effect); var returnEyeSpell = SpellHandler.Get(SpellId.RecallEyeOfAcherus); returnEyeSpell.GetEffect(SpellEffectType.ScriptEffect).SpellEffectHandlerCreator = (cast, effect) => new ReturnEyeOfAcherusSpellEffectHandler(cast, effect); //Siphon spell should target self and then the effect channels to the target //Pretty stupid limiting it to one npc anyway when there are //five it needs to work with! //SpellHandler.Apply(spell => // { // spell.RequiredTargetId = 0; // }, SpellId.SiphonOfAcherus); var siphonSpell = SpellHandler.Get(SpellId.SiphonOfAcherus); siphonSpell.RequiredTargetId = 0; siphonSpell.OverrideCustomTargetDefinitions( DefaultTargetAdders.AddAreaSource, IsSiphonTriggerNPC); }
public override void OnHit(DamageAction action) { var chr = action.Attacker as Character; if (chr != null) { if (chr.Group != null) { List <Character> origGroup = new List <Character>(chr.Group.GetAllCharacters()); List <Character> scrambledGroup = new List <Character>(); Random randNum = new Random(); int i = -1; foreach (Character groupMember in origGroup) { i++; if (groupMember == chr) { continue; } if (randNum.NextDouble() < (3 - scrambledGroup.Count / origGroup.Count - i)) { scrambledGroup.Add(groupMember); } } var effect = SpellHandler.Get(SpellId.DivineStorm_2).GetEffect(SpellEffectType.Heal); foreach (Character target in scrambledGroup) { target.Heal(action.GetDamagePercent(25), chr, effect); } } } base.OnHit(action); }
public override void Apply() { var target = Cast.CasterObject as Character; if (target == null) { return; } var buttonId = Effect.MiscValue + 132; for (var actionButtonCount = Effect.MiscValueB; actionButtonCount != 0; actionButtonCount--, buttonId++) { //type 0 is spell if (target.GetTypeFromActionButton(buttonId) != 0) { continue; } var spellId = target.GetActionFromActionButton(buttonId); var spell = SpellHandler.Get(spellId); if (spell == null) { continue; } var cast = target.SpellCast; if (cast == null) { continue; } cast.Trigger(spell); } }
public static void InitLadySpells() { var forkedLightning = SpellHandler.Get(SpellId.ForkedLightningRank1); forkedLightning.AISettings.SetCooldownRange(8000); // is this correct? shouldn't it be AoE? that spell only does 5 damage // in that case it should not have a custom target definition, but stick with the default one forkedLightning.MaxTargets = 1; forkedLightning.OverrideAITargetDefinitions( DefaultTargetAdders.AddAreaSource, // Adder DefaultTargetEvaluators.RandomEvaluator, // Evaluator DefaultTargetFilters.IsHostile, DefaultTargetFilters.IsPlayer); // Filters var slow = SpellHandler.Get(SpellId.SlowRank1); slow.AISettings.SetCooldownRange(13000); slow.MaxTargets = 1; slow.OverrideAITargetDefinitions( DefaultTargetAdders.AddAreaSource, // Adder DefaultTargetEvaluators.RandomEvaluator, // Evaluator DefaultTargetFilters.IsHostile, DefaultTargetFilters.IsPlayer); // Filters var frostNova = SpellHandler.Get(SpellId.ClassSkillFrostNovaRank2); frostNova.AISettings.SetCooldown(20000); frostNova.AddTextAndSoundEvent(NPCAiTextMgr.GetFirstTextByEnglishPrefix("You should not be here! Slay them!")); }
public void FinalizeDataHolder() { if ((Spell = SpellHandler.Get(SpellId)) == null) { ContentMgr.OnInvalidDBData("SpellId is invalid in " + this); } else if (RequiredSpellId != SpellId.None && SpellHandler.Get(RequiredSpellId) == null) { ContentMgr.OnInvalidDBData("RequiredSpellId is invalid in " + this); } else if (RequiredSkillId != SkillId.None && SkillHandler.Get(RequiredSkillId) == null) { ContentMgr.OnInvalidDBData("RequiredSkillId is invalid in " + this); } else { NPCEntry entry = NPCMgr.GetEntry(TrainerId); if (entry == null) { ContentMgr.OnInvalidDBData("TrainerId is invalid in " + this); } else { if (RequiredLevel == 0) { RequiredLevel = Spell.Level; } if (entry.TrainerEntry == null) { entry.TrainerEntry = new TrainerEntry(); } entry.TrainerEntry.AddSpell(this); } } }
public static void HandlePetCastSpell(IRealmClient client, RealmPacketIn packet) { var petId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var pet = chr.Map.GetObject(petId) as NPC; if (pet != null) { //TODO: Add (pet as Vehicle).GetDriver() == chr; if (pet == chr.ActivePet || chr.Vehicle == pet || chr.Charm == pet || chr.GodMode) { var castCount = packet.ReadByte(); var spellId = packet.ReadUInt32(); var unkFlags = packet.ReadByte(); //TODO: Fix this //var spell = pet.Spells[spellId]; var spell = SpellHandler.Get(spellId); if (spell != null) { var cast = pet.SpellCast; cast.Start(spell, packet, castCount, unkFlags); } } } #if DEBUG else { chr.SendSystemMessage("You sent CMSG_PET_CAST_SPELL for a pet that does not exist in the same Map."); } #endif }
public static void Init() { // Make some deprecated spell (with an area target) an instant teleport spell: SpellHandler.Get(TeleSpellId).SpecialCast = delegate(Spell spell, WorldObject caster, WorldObject target, ref Vector3 targetPos) { if (caster is Unit) { var unitCaster = caster as Unit; unitCaster.TeleportTo(unitCaster.Map, ref targetPos); } }; // add the spell to any newly created staff-Character Character.Created += chr => { if (chr.Account.Role.IsStaff) { chr.Spells.AddSpell(TeleSpellId); } }; // let staff members join the staff channel Character.LoggedIn += (chr, firstConnect) => { if (firstConnect) { if (chr.Account.Role.IsStaff && ChatChannel.Staff != null) { chr.AddMessage(() => ChatChannel.Staff.TryJoin(chr)); } } }; }
public override void Apply() { Character casterObject = this.Cast.CasterObject as Character; if (casterObject == null) { return; } int buttonIndex = this.Effect.MiscValue + 132; int miscValueB = this.Effect.MiscValueB; while (miscValueB != 0) { if (casterObject.GetTypeFromActionButton(buttonIndex) == (byte)0) { Spell spell = SpellHandler.Get(casterObject.GetActionFromActionButton(buttonIndex)); if (spell != null) { SpellCast spellCast = casterObject.SpellCast; if (spellCast != null) { spellCast.Trigger(spell, new WorldObject[0]); } } } --miscValueB; ++buttonIndex; } }
public override bool Use(Character user) { var entry = (GOMeetingStoneEntry)m_go.Entry; if (!(user is Character)) { return(false); } var chr = (Character)user; var target = chr.Target; if (target == null || target == chr || !chr.IsAlliedWith(target)) { return(false); } var level = chr.Level; if (level < entry.MinLevel || level > entry.MaxLevel) { // try this: //SpellHandler.SendCastFailed(chr, 0, SpellId.MeetingStoneSummon, SpellFailedReason.LevelRequirement); return(false); } chr.SpellCast.Start(SpellHandler.Get(SpellId.MeetingStoneSummon), false, new[] { target }); return(true); }
public void FinalizeDataHolder() { Spell spell = SpellHandler.Get(this.SpellId); if (spell == null) { ContentMgr.OnInvalidDBData(this.GetType().Name + " for \"{0} {1}\" refers to invalid Spell: {2}.", (object)this.Race, (object)this.Class, (object)this); } else { List <Archetype> archetypes = ArchetypeMgr.GetArchetypes(this.Race, this.Class); if (archetypes == null) { ContentMgr.OnInvalidDBData(this.GetType().Name + " \"{0}\" refers to invalid Archetype: {1} {2}.", (object)this, (object)this.Race, (object)this.Class); } else { foreach (Archetype archetype in archetypes) { archetype.Spells.Add(spell); } } } }
public override SkillAbility ConvertTo(byte[] rawData, ref int id) { SkillAbility ability = new SkillAbility(); int field = 0; id = (int)(ability.AbilityId = GetUInt32(rawData, field++)); ability.Skill = ById[GetUInt32(rawData, field++)]; SpellId spellId = (SpellId)GetUInt32(rawData, field++); if (spellId > SpellId.None) { Spell spell = SpellHandler.Get(spellId); if (spell != null) { ability.Spell = spell; } } ability.RaceMask = (RaceMask)GetUInt32(rawData, field++); ability.ClassMask = (ClassMask)GetUInt32(rawData, field++); GetUInt32(rawData, field++); GetUInt32(rawData, field++); GetInt32(rawData, field++); ability.NextSpellId = (SpellId)GetUInt32(rawData, field++); ability.AcquireMethod = (SkillAcquireMethod)GetInt32(rawData, field++); ability.GreyValue = GetUInt32(rawData, field++); ability.YellowValue = GetUInt32(rawData, field); uint num2 = ability.GreyValue - ability.YellowValue; int num3 = (int)(ability.YellowValue - (num2 / 2)); ability.RedValue = (num3 < 0) ? 0 : ((uint)num3); ability.GreenValue = ability.YellowValue + (num2 / 2); ability.CanGainSkill = ability.GreenValue > 0; return(ability); }
public override void OnEnterCombat() { m_owner.Yell(DefaultAddonLocalizer.Instance.GetTranslations(AddonMsgKey.HerodAggro)); m_owner.PlaySound(5830); m_owner.SpellCast.Start(SpellHandler.Get(SpellId.RushingChargeRank1_2)); base.OnEnterCombat(); }
public override void OnDamageDealt(RealmServer.Misc.IDamageAction action) { if (action.Spell == SpellHandler.Get(SpellId.WhirlwindRank1)) { base.OnDamageDealt(action); } }
private static void FixAcherusDKTeleporters() { var dKPortalHeartToHall = NPCMgr.GetEntry(NPCId.TeleportHeartHall); if (dKPortalHeartToHall != null) { var hallPortSpell = SpellHandler.Get(SpellId.EffectTeleportToHallOfCommand); hallPortSpell.OverrideAITargetDefinitions( DefaultTargetAdders.AddAreaSource, DefaultTargetEvaluators.NearestEvaluator, DefaultTargetFilters.IsPlayer); hallPortSpell.AISettings.SetCooldown(0); dKPortalHeartToHall.AddSpell(hallPortSpell); dKPortalHeartToHall.AggroBaseRange = 10; dKPortalHeartToHall.Activated += DKPortalActivated; } var dKPortalHallToHeart = NPCMgr.GetEntry(NPCId.TeleportHallHeart); if (dKPortalHallToHeart == null) { return; } var heartPortSpell = SpellHandler.Get(SpellId.EffectTeleportToHeartOfAcherus); heartPortSpell.OverrideAITargetDefinitions( DefaultTargetAdders.AddAreaSource, DefaultTargetEvaluators.NearestEvaluator, DefaultTargetFilters.IsPlayer); heartPortSpell.AISettings.SetCooldown(0); dKPortalHallToHeart.AddSpell(heartPortSpell); dKPortalHallToHeart.AggroBaseRange = 10; dKPortalHallToHeart.Activated += DKPortalActivated; }
protected override void Apply() { base.Apply(); var chr = m_aura.Owner as Character; if (chr != null) { //Overkill if (chr.Spells.Contains(SpellId.RogueAssassinationOverkill)) { var ovk = chr.Auras[SpellId.ClassSkillOverkill]; if (ovk != null) { ovk.Duration = -1; //no duration/last forever AuraHandler.SendAuraUpdate(m_aura.Owner, ovk); } else { chr.Auras.CreateAndStartAura(m_aura.CasterReference, SpellHandler.Get(SpellId.ClassSkillOverkill), true); } } //Master of Subtlety if (chr.Auras[SpellLineId.RogueSubtletyMasterOfSubtlety] != null) { chr.Auras.Remove(SpellId.MasterOfSubtlety_2); //remove periodic dummy so dmg buff doesn't get removed if casting stealth again var masterofsub = chr.Auras[SpellLineId.RogueSubtletyMasterOfSubtlety, true]; var customspell = SpellHandler.Get(SpellId.MasterOfSubtlety); customspell.Effects[0].BasePoints = masterofsub.Spell.Effects[0].BasePoints; chr.Auras.CreateAndStartAura(m_aura.CasterReference, customspell, true); } } }
/// <summary> /// Defines a set of Auras that are mutually exclusive /// </summary> public static uint AddAuraGroup(SpellLineId auraLine, SpellLineId auraLine2, params SpellId[] auras) { var uid = GetNextAuraUID(); var line = auraLine.GetLine(); line.AuraUID = uid; foreach (var spell in line) { spell.AuraUID = uid; } line = auraLine2.GetLine(); line.AuraUID = uid; foreach (var spell in line) { spell.AuraUID = uid; } foreach (var id in auras) { var spell = SpellHandler.Get(id); if (spell == null) { throw new ArgumentException("Invalid SpellId: " + id); } spell.AuraUID = uid; } return(uid); }
public new void FinalizeDataHolder() { if ((Spell = SpellHandler.Get(SpellId)) == null) { ContentMgr.OnInvalidDBData("SpellId is invalid in " + this); } else if (RequiredSpellId != SpellId.None && SpellHandler.Get(RequiredSpellId) == null) { ContentMgr.OnInvalidDBData("RequiredSpellId is invalid in " + this); } else if (RequiredSkillId != SkillId.None && SkillHandler.Get(RequiredSkillId) == null) { ContentMgr.OnInvalidDBData("RequiredSkillId is invalid in " + this); } else { if (RequiredLevel == 0) { RequiredLevel = Spell.Level; } if (!NPCMgr.TrainerSpellTemplates.ContainsKey(TrainerTemplateId)) { NPCMgr.TrainerSpellTemplates.Add(TrainerTemplateId, new List <TrainerSpellEntry>()); } NPCMgr.TrainerSpellTemplates[TrainerTemplateId].Add(this); } }
public void TestInstantDamageSpell() { var spell = SpellHandler.Get(SpellId.ClassSkillFireBlastRank1); Assert.AreEqual(0, spell.ProjectileSpeed); // not delayed chr.EnsureInWorld(); var enemy = chr.Enemies.Create(); enemy.Regenerates = false; var oldHealth = enemy.Health; Asser.GreaterThan(enemy.Health, 0); // make sure we are in range and facing the enemy enemy.EnsureXDistance(chr, spell.Range.MinDist + 0.5f, true); chr.EnsureFacing(enemy); // triggered spells are instant and cannot miss chr.Map.AddMessageAndWait(() => { var failReason = chr.SpellCast.Start(spell, true, enemy); Assert.AreEqual(SpellFailedReason.Ok, failReason); Assert.IsFalse(chr.SpellCast.IsCasting); Asser.GreaterThan(oldHealth, enemy.Health); }); }
public void TestPushback() { Setup.EnsureMinimalSetup(); SpellHandler.LoadSpells(); var npc = Setup.NPCPool.CreateDummy(); npc.EnsureInWorldAndLiving(); var spell = SpellHandler.Get(SpellId.ClassSkillPrayerOfHealingRank1); Assert.IsNotNull(spell); Asser.GreaterThan(spell.CastDelay, 0u); npc.Map.AddMessageAndWait(new Message(() => { var cast = npc.SpellCast; var err = cast.Start(spell, false, npc); Assert.AreEqual(err, SpellFailedReason.Ok); Assert.IsTrue(npc.IsUsingSpell); var timeleft = cast.RemainingCastTime; cast.RemainingCastTime -= 2000; Asser.Approx(timeleft - 2000, 40, cast.RemainingCastTime); timeleft = cast.RemainingCastTime; cast.Pushback(); Asser.Approx(timeleft + 1000, 40, cast.RemainingCastTime); timeleft = cast.RemainingCastTime; cast.Pushback(); Asser.Approx(timeleft + 800, 40, cast.RemainingCastTime); })); }
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); }
/// <summary>Defines a set of Auras that are mutually exclusive</summary> public static uint AddAuraGroup(SpellLineId auraLine, SpellLineId auraLine2, params SpellId[] auras) { uint nextAuraUid = GetNextAuraUID(); SpellLine line1 = auraLine.GetLine(); line1.AuraUID = nextAuraUid; foreach (Spell spell in line1) { spell.AuraUID = nextAuraUid; } SpellLine line2 = auraLine2.GetLine(); line2.AuraUID = nextAuraUid; foreach (Spell spell in line2) { spell.AuraUID = nextAuraUid; } foreach (SpellId aura in auras) { Spell spell = SpellHandler.Get(aura); if (spell == null) { throw new ArgumentException("Invalid SpellId: " + aura); } spell.AuraUID = nextAuraUid; } return(nextAuraUid); }
protected internal override void InitEntry() { if (Radius < 1) { Radius = 5; } Spell = SpellHandler.Get(SpellId); }
static void FixTameSpell(SpellId id, SpellId triggerId) { // add a spell-trigger var spell = SpellHandler.Get(id); var effect = spell.AddTriggerSpellEffect(triggerId, ImplicitSpellTargetType.SingleEnemy); effect.Amplitude = spell.Durations.Min; }
protected internal override void InitEntry() { if (this.Radius < 1) { this.Radius = 5; } this.Spell = SpellHandler.Get(this.SpellId); }
public override void OnDamageDealt(RealmServer.Misc.IDamageAction action) { if (action.Spell == SpellHandler.Get(SpellId.VoidBlast)) { m_owner.Say(m_owner.Target.Name + " shifts into the void..."); base.OnDamageDealt(action); } }
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); }
protected override void Apply() { IList <WorldObject> objectsInRadius = this.Owner.GetObjectsInRadius <Unit>(3f, ObjectTypes.Unit, false, int.MaxValue); bool flag = false; foreach (WorldObject worldObject in (IEnumerable <WorldObject>)objectsInRadius) { Unit unit = worldObject as Unit; if (unit != null && unit.IsHostileWith((IFactionMember)this.Owner)) { flag = true; break; } } if (!flag) { return; } foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>) this.Owner.GetObjectsInRadius <Unit>(12f, ObjectTypes.Unit, false, int.MaxValue)) { Unit pos = objectsInRadiu as Unit; if (pos != null && pos.IsHostileWith((IFactionMember)this.Owner)) { if (this.SpellEffect.MiscValueB == 1) { Spell spell = SpellHandler.Get(775U); pos.Auras.CreateAndStartAura(this.Owner.SharedReference, spell, false, (Item)null); } else if (this.SpellEffect.MiscValueB == 0) { float dist = pos.GetDist((IHasPosition)this.Owner); float num = 1f; if ((double)dist >= 3.0) { num /= (float)Math.Pow((double)dist, 0.600000023841858); } DamageAction damageAction = pos.DealSpellDamage(this.Owner, this.SpellEffect, (int)((double)this.Owner.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0 * (double)num), true, true, false, false); if (damageAction != null) { if (this.m_aura != null) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse( this.m_aura.CasterUnit as Character, objectsInRadiu as Character, objectsInRadiu as NPC, damageAction.ActualDamage); } damageAction.OnFinished(); } } } } this.Aura.Cancel(); }
protected internal override void InitEntry() { Lock = LockEntry.Entries.Get((uint)LockId); Spell = SpellHandler.Get(SpellId); IsConsumable = Fields[5] > 0; LinkedTrapId = (uint)Fields[12]; LosOk = Fields[16] > 0; AllowMounted = Fields[17] > 0; }