/// <summary> /// Lets this Pet cast the given spell /// </summary> public void CastPetSpell(SpellId spellId, WorldObject target) { var spell = NPCSpells.GetReadySpell(spellId); SpellFailedReason err; if (spell != null) { if (spell.HasTargets) { Target = m_master.Target; } err = spell.CheckCasterConstraints(this); if (err == SpellFailedReason.Ok) { err = SpellCast.Start(spell, false, target != null ? new[] { target } : null); } } else { err = SpellFailedReason.NotReady; } if (err != SpellFailedReason.Ok && m_master is IPacketReceiver) { PetHandler.SendCastFailed((IPacketReceiver)m_master, spellId, err); } }
private static void BuildSpells() { for (var i = 0; i < spells.Count; i++) { Table[i] = new SpellId[NumLevels]; } for (var i = 0; i < spells.Count; i++) { var spell = spells[i]; var spellLevels = SpellLevelProgression.GetSpellLevels(spell); if (spellLevels == null) { log.Error($"ArmorCantrips - couldn't find {spell}"); continue; } if (spellLevels.Count != NumLevels) { log.Error($"ArmorCantrips - expected {NumLevels} levels for {spell}, found {spellLevels.Count}"); continue; } for (var j = 0; j < NumLevels; j++) { Table[i][j] = spellLevels[j]; } } }
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); }
private static SpellId AdjustForWeaponMastery(WorldObject wo, SpellId spell) { // handle two-handed weapons if (wo.WeaponSkill == Skill.TwoHandedCombat) { return(SpellId.CANTRIPTWOHANDEDAPTITUDE1); } // 10% chance to adjust to dual wielding var rng = ThreadSafeRandom.Next(0.0f, 1.0f); if (rng < 0.1f) { return(SpellId.CantripDualWieldAptitude1); } // heavy/light/finesse weapons switch (wo.WeaponSkill) { case Skill.HeavyWeapons: return(SpellId.CANTRIPHEAVYWEAPONSAPTITUDE1); case Skill.LightWeapons: return(SpellId.CANTRIPLIGHTWEAPONSAPTITUDE1); case Skill.FinesseWeapons: return(SpellId.CANTRIPFINESSEWEAPONSAPTITUDE1); } return(spell); }
/// <summary> /// Adds the spell without doing any further checks nor adding any spell-related skills or showing animations (after load) /// </summary> internal void OnlyAdd(SpellRecord record) { SpellId spellId = record.SpellId; Spell spell = SpellHandler.Get(spellId); this.m_byId[spellId] = spell; }
public static void SendMagicDamage(WorldObject victim, IEntity attacker, SpellId spell, uint damage, uint overkill, DamageSchoolMask schools, uint absorbed, uint resisted, uint blocked, bool unkBool, SpellLogFlags flags) { using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { victim.EntityId.WritePacked((BinaryWriter)packet); if (attacker != null) { attacker.EntityId.WritePacked((BinaryWriter)packet); } else { packet.Write((byte)0); } packet.Write((uint)spell); packet.Write(damage); packet.Write(overkill); packet.Write((byte)schools); packet.Write(absorbed); packet.Write(resisted); packet.Write(0); packet.Write(unkBool); packet.Write(blocked); packet.Write((uint)flags); packet.Write((byte)0); victim.SendPacketToArea(packet, true, false, Locale.Any, new float?()); } }
public static void BuySpell(this NPC trainer, Character chr, SpellId spellEntryId) { if (!trainer.CheckTrainerCanTrain(chr)) { return; } TrainerSpellEntry spellEntry = trainer.TrainerEntry.GetSpellEntry(spellEntryId); if (spellEntry == null || !trainer.CheckBuySpellConditions(chr, spellEntry)) { return; } chr.SubtractMoney(spellEntry.GetDiscountedCost(chr, trainer)); WCell.RealmServer.Handlers.NPCHandler.SendTrainerBuySucceeded((IPacketReceiver)chr.Client, trainer, spellEntry); SpellHandler.SendVisual((WorldObject)trainer, 179U); if (spellEntry.Spell.IsTeachSpell) { trainer.SpellCast.Trigger(spellEntry.Spell, new WorldObject[1] { (WorldObject)chr }); } else if (chr.PowerType == PowerType.Mana || spellEntry.Spell.PreviousRank == null) { chr.Spells.AddSpell(spellEntry.Spell); trainer.TalkToTrainer(chr); } else { chr.Spells.Replace(spellEntry.Spell.PreviousRank, spellEntry.Spell); } }
/// <summary> /// Adds the spell without doing any further checks or adding any spell-related skills or showing animations /// </summary> public void OnlyAdd(SpellId id) { var spell = SpellHandler.ById.Get((uint)id); m_byId.Add(id, spell); m_byRealId.Add(spell.RealId, spell); }
/// <summary> /// Returns the TrainerSpellEntry from SpellsForSale with the given spellId, else null. /// </summary> public TrainerSpellEntry GetSpellEntry(SpellId spellId) { TrainerSpellEntry trainerSpellEntry; Spells.TryGetValue(spellId, out trainerSpellEntry); return(trainerSpellEntry); }
/// <summary> /// Adds the spell without doing any further checks or adding any spell-related skills or showing animations /// </summary> public void OnlyAdd(SpellId id) { Spell spell = SpellHandler.ById.Get <Spell>((uint)id); this.m_byId.Add(id, spell); this.m_byRealId.Add(spell.RealId, spell); }
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; }
public override int GetHashCode() { int hash = 1; if (PlayerLevel != 0) { hash ^= PlayerLevel.GetHashCode(); } if (EncounterId.Length != 0) { hash ^= EncounterId.GetHashCode(); } if (SpellId.Length != 0) { hash ^= SpellId.GetHashCode(); } if (Outcome != 0) { hash ^= Outcome.GetHashCode(); } if (CheckpointFailRound != 0) { hash ^= CheckpointFailRound.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private static void BuildSpells(List <SpellId> spells, SpellId[][] matrix) { for (var i = 0; i < NumTiers; i++) { matrix[i] = new SpellId[spells.Count]; } for (var i = 0; i < spells.Count; i++) { var spell = spells[i]; var spellLevels = SpellLevelProgression.GetSpellLevels(spell); if (spellLevels == null) { log.Error($"GemSpells - couldn't find {spell}"); continue; } if (spellLevels.Count != NumTiers) { log.Error($"GemSpells - expected {NumTiers} levels for {spell}, found {spellLevels.Count}"); continue; } for (var j = 0; j < NumTiers; j++) { matrix[j][i] = spellLevels[j]; } } }
public static void SendMagicDamage(WorldObject victim, IEntity attacker, SpellId spell, uint damage, uint overkill, DamageSchoolMask schools, uint absorbed, uint resisted, uint blocked, bool unkBool, SpellLogFlags flags) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { victim.EntityId.WritePacked(packet); if (attacker != null) { attacker.EntityId.WritePacked(packet); } else { packet.Write((byte)0); } packet.Write((uint)spell); packet.Write(damage); packet.Write(overkill); packet.Write((byte)schools); packet.Write(absorbed); packet.Write(resisted); packet.Write(0); // apparently always 0 packet.Write(unkBool); // 0 or 1 packet.Write(blocked); // also flags 0x8, 0x10, packet.Write((uint)flags); packet.Write((byte)0); // unused by client victim.SendPacketToArea(packet, true, false); } }
static void AddProcTrigger(SpellId id, SpellId triggerId) { SpellHandler.Apply(spell => { var effect = spell.AddAuraEffect(AuraType.ProcTriggerSpell, ImplicitSpellTargetType.Self); effect.TriggerSpellId = triggerId; },id); }
public SpellRecord(SpellId id, uint ownerId, int specIndex) { this.SpellId = id; this.OwnerId = ownerId; this.SpecIndex = specIndex; this.RecordId = SpellRecord.NextId(); this.State = RecordState.New; }
public static void SendPetLearnedSpell(IPacketReceiver receiver, SpellId spellId) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_LEARNED_SPELL, 4)) { packet.Write((uint)spellId); receiver.Send(packet, false); } }
public SpellRecord(SpellId id, uint ownerId, int specIndex) { SpellId = id; OwnerId = ownerId; SpecIndex = specIndex; RecordId = NextId(); State = RecordState.New; }
public MountSpellHandler(SpellCast cast, SpellEffect effect, SpellId apprenticeRidingSkill, SpellId journeymanRidingSkill, SpellId expertRidingSkill, SpellId artisanRidingSkill) : base(cast, effect) { _apprenticeRidingSpell = apprenticeRidingSkill; _journeymanRidingSpell = journeymanRidingSkill; _expertRidingSpell = expertRidingSkill; _artisanRidingSpell = artisanRidingSkill; }
/// <summary> /// Returns the spell with the given spellId or null if it doesn't exist /// </summary> public static Spell Get(SpellId spellId) { if ((uint)spellId >= ById.Length) { return(null); } return(ById[(uint)spellId]); }
static void AddProcTrigger(SpellId id, SpellId triggerId) { SpellHandler.Apply(spell => { var effect = spell.AddAuraEffect(AuraType.ProcTriggerSpell, ImplicitSpellTargetType.Self); effect.TriggerSpellId = triggerId; }, id); }
/// <summary> /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable. /// </summary> public void AddSpell(SpellId spellId) { if (this.Contains(spellId)) { return; } this.AddSpell(SpellHandler.Get(spellId)); }
public Spell this[SpellId id] { get { Spell spell; this.m_byId.TryGetValue(id, out spell); return(spell); } }
/// <summary> /// Only works if you have 2 valid spell ids and oldSpellId already exists. /// </summary> public void Replace(SpellId oldSpellId, SpellId newSpellId) { Spell oldSpell, newSpell = SpellHandler.Get(newSpellId); if (m_byId.TryGetValue(oldSpellId, out oldSpell)) { Replace(oldSpell, newSpell); } }
/// <summary> /// Adds a Spell that will be used by all NPCs of this Entry /// </summary> public void AddSpell(SpellId spellId) { var spell = SpellHandler.Get(spellId); if (spell != null) { AddSpell(spell); } }
public bool Remove(SpellId id) { Spell spell = SpellHandler.Get(id); if (spell != null) { return(this.Remove(spell)); } return(false); }
/// <summary> /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable. /// </summary> public void AddSpell(SpellId spellId) { if (Contains(spellId)) { return; } var spell = SpellHandler.Get(spellId); AddSpell(spell); }
/// <summary> /// Adds a Spell that will be used by all NPCs of this Entry /// </summary> public void AddSpell(SpellId spellId) { Spell spell = SpellHandler.Get(spellId); if (spell == null) { return; } this.AddSpell(spell); }
/// <summary> /// Forces the client to start or update a cooldown timer on the given single spell /// (mostly important for certain talents and item spells that don't automatically start cooling down) /// </summary> public static void SendCooldownUpdate(Character chr, SpellId spellId) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_COOLDOWN_EVENT, 12)) { packet.WriteUInt((uint)spellId); chr.EntityId.WritePacked(packet); chr.Send(packet, addEnd: false); } }
public static void SendCastFailed(IPacketReceiver receiver, SpellId spellId, SpellFailedReason reason) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_CAST_FAILED, 8)) { packet.Write(0); packet.Write((uint)spellId); packet.Write((byte)reason); receiver.Send(packet, false); } }
public Spell GetReadySpell(SpellId spellId) { foreach (var spell in m_readySpells) { if (spell.SpellId == spellId) { return spell; } } return null; }
public Spell GetReadySpell(SpellId spellId) { foreach (var spell in m_readySpells) { if (spell.SpellId == spellId) { return(spell); } } return(null); }
public Spell GetReadySpell(SpellId spellId) { for (int i = 0; i < m_readySpells.Count; i++) { var spell = m_readySpells[i]; if (spell.SpellId == spellId) { return spell; } } return null; }
static void FixTameSpell(SpellId id, SpellId triggerId) { // convert the Dummy aura into a spell-trigger var spell = SpellHandler.Get(id); var effect = spell.GetEffect(SpellEffectType.ApplyAura); effect.AuraType = AuraType.None; effect.EffectType = SpellEffectType.TriggerSpell; //spell.Durations.Min = 200; //spell.Durations.Max = 200; effect.Amplitude = spell.Durations.Min; effect.TriggerSpellId = triggerId; }
public void AddAura(SpellId spellId) { var spell = SpellHandler.Get(spellId); if (spell == null) { LogManager.GetCurrentClassLogger().Warn("Tried to add invalid Aura-Spell \"{0}\" to NPCEntry: {1}", spellId, this); } else { Auras.Add(spell); } }
/// <summary> /// Correct 3.0.9 /// </summary> public static void SendSpellMiss(SpellId spell, WorldObject caster, bool doIt, ICollection<CastMiss> missedTargets) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLLOGMISS, 34)) { packet.Write((uint)spell); packet.Write(caster.EntityId); packet.Write(doIt);// TODO: test this value. Its a bool that seems to determine whether to display this packet in the combat log packet.Write(missedTargets.Count); foreach (var miss in missedTargets) { packet.Write(miss.Target.EntityId); packet.Write((byte)miss.Reason); } caster.SendPacketToArea(packet); } }
public DynamicObject(Unit creator, SpellId spellId, float radius, Region region, Vector3 pos) { if (creator == null) throw new ArgumentNullException("creator", "creator must not be null"); Master = m_creator = creator; EntityId = EntityId.GetDynamicObjectId(++lastId); Type |= ObjectTypes.DynamicObject; SetEntityId(DynamicObjectFields.CASTER, Caster.EntityId); SpellId = spellId; Radius = radius; Bytes = 0x01EEEEEE; ScaleX = 1; m_position = pos; region.AddObjectLater(this); }
#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; }
static void HandleTrainerList(PacketParser parser) { var spells = parser.ParsedPacket["Spells"].List; foreach (var spellSegment in spells) { var id = (SpellId)spellSegment["Spell"].UIntValue; var moneyCost = spellSegment["MoneyCost"].IntValue; var talentCost = spellSegment["TalentCost"].IntValue; var profCost = spellSegment["ProfessionPointCost"].IntValue; int reqLevel = spellSegment["RequiredLevel"].ByteValue; var reqSkill = (SkillId)spellSegment["RequiredSkill"].UIntValue; var reqSkillValue = spellSegment["RequiredSkillLevel"].IntValue; var reqSpells = new SpellId[3]; reqSpells[0] = (SpellId)spellSegment["RequiredSpellId1"].UIntValue; reqSpells[1] = (SpellId)spellSegment["RequiredSpellId2"].UIntValue; reqSpells[2] = (SpellId)spellSegment["RequiredSpellId3"].UIntValue; // TODO: Calc exact money cost, depending on the faction } }
private static void FixFeralSwiftness(SpellId origSpell, SpellId triggerSpell) { // Feral Swiftness should only be applied in Cat Form SpellHandler.Apply(spell => { // only as cat // triggers the dodge effect spell spell.AllowedShapeshiftMask = ShapeshiftMask.Cat; spell.AddTriggerSpellEffect(triggerSpell); }, origSpell); SpellHandler.Apply(spell => { // this spell applies the dodge bonus for Feral Swiftness // "increases your chance to dodge while in Cat Form, Bear Form and Dire Bear Form" // must be passive spell.Attributes |= SpellAttributes.Passive; spell.AllowedShapeshiftMask = ShapeshiftMask.Cat | ShapeshiftMask.Bear | ShapeshiftMask.DireBear; }, triggerSpell); }
/// <summary> /// Adds a SpellEffect that will trigger the given Spell on the given type of target /// </summary> public SpellEffect AddPeriodicTriggerSpellEffect(SpellId triggerSpell, ImplicitTargetType targetType) { var effect = AddAuraEffect(AuraType.PeriodicTriggerSpell); effect.TriggerSpellId = triggerSpell; effect.ImplicitTargetA = targetType; return effect; }
/// <summary> /// Adds a SpellEffect that will trigger the given Spell on oneself /// </summary> public SpellEffect AddPeriodicTriggerSpellEffect(SpellId triggerSpell) { return AddPeriodicTriggerSpellEffect(triggerSpell, ImplicitTargetType.Self); }
/// <summary> /// Adds a SpellEffect that will trigger the given Spell on the given type of target /// </summary> public SpellEffect AddTriggerSpellEffect(SpellId triggerSpell, ImplicitTargetType targetType) { var effect = AddEffect(SpellEffectType.TriggerSpell); effect.TriggerSpellId = triggerSpell; effect.ImplicitTargetA = targetType; return effect; }
/// <summary> /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable. /// </summary> public void AddSpell(SpellId spellId) { var spell = SpellHandler.Get(spellId); AddSpell(spell); }
/// <summary> /// Only works if you have 2 valid spell ids and oldSpellId already exists. /// </summary> public void Replace(SpellId oldSpellId, SpellId newSpellId) { Spell oldSpell, newSpell = SpellHandler.Get(newSpellId); if (m_byId.TryGetValue((uint)oldSpellId, out oldSpell)) { Replace(oldSpell, newSpell); } }
public void Remove(SpellId spellId) { Replace(SpellHandler.Get(spellId), null); }
public Spell this[SpellId id] { get { Spell spell; m_byId.TryGetValue((uint)id, out spell); return spell; } }
public bool Contains(SpellId id) { return m_byId.ContainsKey((uint)id); }
/// <summary> /// Clears a single spell's cooldown /// </summary> public static void SendClearCoolDown(Character chr, SpellId spellId) { IRealmClient client = chr.Client; if (client != null) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CLEAR_COOLDOWN, 12)) { packet.WriteUInt((uint)spellId); chr.EntityId.WritePacked(packet); client.Send(packet); } } }
public ToggleAuraHandler(SpellId auraId) { ToggleAuraSpell = SpellHandler.Get(auraId); }
public static void SendImpact(WorldObject target, SpellId id) { var spell = Get(id); SendImpact(target, spell.Visual); }
public static void SendPetLearnedSpell(IPacketReceiver receiver, SpellId spellId) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_LEARNED_SPELL, 4)) { packet.Write((uint)spellId); receiver.Send(packet); } }
public static void SendCastFailed(IPacketReceiver receiver, SpellId spellId, SpellFailedReason reason) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_CAST_FAILED, 8)) { packet.Write(0); // unkown packet.Write((uint)spellId); packet.Write((byte)reason); receiver.Send(packet); } }
/// <summary> /// Returns the TrainerSpellEntry from SpellsForSale with the given spellId, else null. /// </summary> public TrainerSpellEntry GetSpellEntry(SpellId spellId) { TrainerSpellEntry entry; Spells.TryGetValue(spellId, out entry); return entry; }
/// <summary> /// Adds a SpellEffect that will trigger the given Spell on oneself /// </summary> public SpellEffect AddTriggerSpellEffect(SpellId triggerSpell) { return AddTriggerSpellEffect(triggerSpell, ImplicitSpellTargetType.Self); }
/// <summary> /// Adds the spell without doing any further checks or adding any spell-related skills or showing animations /// </summary> public void OnlyAdd(SpellId id) { m_byId.Add((uint)id, SpellHandler.ById.Get((uint)id)); }
public void RemoveProcHandler(SpellId procId) { if (m_procHandlers != null) { foreach (var handler in m_procHandlers) { if (handler.ProcSpell != null && handler.ProcSpell.SpellId == procId) { m_procHandlers.Remove(handler); break; } } } }
/// <summary> /// Forces the client to start or update a cooldown timer on the given single spell /// (mostly important for certain talents and item spells that don't automatically start cooling down) /// </summary> public static void SendCooldownUpdate(Character chr, SpellId spellId) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_COOLDOWN_EVENT, 12)) { packet.WriteUInt((uint)spellId); chr.EntityId.WritePacked(packet); chr.Send(packet); } }