OregonCore  revision be9e804-git
Your Favourite TBC server
Spell.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __SPELL_H
19 #define __SPELL_H
20 
21 #include "GridDefines.h"
22 #include "SpellMgr.h"
23 #include "SharedDefines.h"
24 
25 static const uint32 MAX_SPELL_ID = 53085;
26 
27 class Unit;
28 class Player;
29 class GameObject;
30 class Aura;
31 
33 {
34  CAST_FLAG_PENDING = 0x00000001, // Pending == 1
35  CAST_FLAG_UNKNOWN1 = 0x00000002,
36  CAST_FLAG_UNKNOWN2 = 0x00000010,
37  CAST_FLAG_AMMO = 0x00000020,
38  CAST_FLAG_UNKNOWN3 = 0x00000100
39 };
40 
42 {
44  SPELL_RANGE_MELEE = 1, //melee
45  SPELL_RANGE_RANGED = 2, //hunter range and ranged weapon
46 };
47 
49 {
50  PUSH_NONE = 0,
56  PUSH_CASTER_CENTER, //this is never used in grid search
58 };
59 
60 bool IsQuestTameSpell(uint32 spellId);
61 
62 namespace Oregon
63 {
64 struct SpellNotifierCreatureAndPlayer;
65 }
66 
67 class SpellCastTargets;
68 
70 {
71  explicit SpellCastTargetsReader(SpellCastTargets& _targets, Unit* _caster) : targets(_targets), caster(_caster) {}
72 
75 };
76 
78 {
79  public:
82 
83  void read(ByteBuffer& data, Unit* caster);
84  void write(ByteBuffer& data) const;
85 
87  {
88  return SpellCastTargetsReader(*this, caster);
89  }
90 
92  {
93  m_unitTarget = target.m_unitTarget;
94  m_itemTarget = target.m_itemTarget;
95  m_GOTarget = target.m_GOTarget;
96 
97  m_unitTargetGUID = target.m_unitTargetGUID;
98  m_GOTargetGUID = target.m_GOTargetGUID;
99  m_CorpseTargetGUID = target.m_CorpseTargetGUID;
100  m_itemTargetGUID = target.m_itemTargetGUID;
101 
102  m_itemTargetEntry = target.m_itemTargetEntry;
103 
104  m_srcPos = target.m_srcPos;
105  m_dstPos.Relocate(target.m_dstPos);
106 
107  m_strTarget = target.m_strTarget;
108 
109  m_targetMask = target.m_targetMask;
110 
111  return *this;
112  }
113 
115  {
116  return m_unitTargetGUID.GetRawValue();
117  }
119  {
120  return m_unitTarget;
121  }
122  void setUnitTarget(Unit* target);
123  void setSrc(float x, float y, float z);
124  void setSrc(Position* pos);
125  void setDst(float x, float y, float z, float orientation, uint32 mapId = MAPID_INVALID);
126  void setDst(Position* pos);
127 
129  {
130  return m_GOTargetGUID.GetRawValue();
131  }
133  {
134  return m_GOTarget;
135  }
136  void setGOTarget(GameObject* target);
137 
139  {
140  return m_CorpseTargetGUID.GetRawValue();
141  }
142  void setCorpseTarget(Corpse* corpse);
144  {
145  return m_itemTargetGUID.GetRawValue();
146  }
148  {
149  return m_itemTarget;
150  }
152  {
153  return m_itemTargetEntry;
154  }
155  void setItemTarget(Item* item);
157  {
158  if (m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM))
159  {
160  m_itemTargetGUID = m_itemTarget->GetGUID();
161  m_itemTargetEntry = m_itemTarget->GetEntry();
162  }
163  }
164 
165  bool IsEmpty() const
166  {
167  return m_GOTargetGUID.IsEmpty() && m_unitTargetGUID.IsEmpty() && m_itemTarget == NULL && m_CorpseTargetGUID.IsEmpty();
168  }
169 
170  bool HasSrc() const { return (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) != 0; }
171  bool HasDst() const { return (m_targetMask & TARGET_FLAG_DEST_LOCATION) != 0; }
172 
173  void Update(Unit* caster);
174 
177  std::string m_strTarget;
178 
180  private:
181  // objects (can be used at spell creating and after Update at casting
185 
186  // object GUID/etc, can be used always
192 };
193 
194 inline ByteBuffer& operator<< (ByteBuffer& buf, SpellCastTargets const& targets)
195 {
196  targets.write(buf);
197  return buf;
198 }
199 
201 {
202  targets.targets.read(buf, targets.caster);
203  return buf;
204 }
205 
206 
208 {
209  explicit SpellValue(SpellEntry const* proto)
210  {
211  for (uint32 i = 0; i < 3; ++i)
212  EffectBasePoints[i] = proto->EffectBasePoints[i];
213  MaxAffectedTargets = proto->MaxAffectedTargets;
214  Duration = GetSpellDuration(proto);
215  CustomDuration = false;
216  }
217  int32 EffectBasePoints[3];
221 };
222 
224 {
231 };
232 
234 {
239 };
240 
242 {
247 };
248 
249 class Spell
250 {
252  friend void Unit::SetCurrentCastedSpell(Spell* pSpell);
253  public:
254 
255  void EffectNULL(SpellEffIndex effIndex);
256  void EffectUnused(SpellEffIndex effIndex);
257  void EffectDistract(SpellEffIndex effIndex);
258  void EffectPull(SpellEffIndex effIndex);
259  void EffectSchoolDMG(SpellEffIndex effIndex);
260  void EffectEnvironmentalDMG(SpellEffIndex effIndex);
261  void EffectInstaKill(SpellEffIndex effIndex);
262  void EffectDummy(SpellEffIndex effIndex);
263  void EffectTeleportUnits(SpellEffIndex effIndex);
264  void EffectApplyAura(SpellEffIndex effIndex);
265  void EffectSendEvent(SpellEffIndex effIndex);
266  void EffectPowerBurn(SpellEffIndex effIndex);
267  void EffectPowerDrain(SpellEffIndex effIndex);
268  void EffectHeal(SpellEffIndex effIndex);
269  void EffectBind(SpellEffIndex effIndex);
270  void EffectHealthLeech(SpellEffIndex effIndex);
271  void EffectQuestComplete(SpellEffIndex effIndex);
272  void EffectCreateItem(SpellEffIndex effIndex);
273  void EffectPersistentAA(SpellEffIndex effIndex);
274  void EffectEnergize(SpellEffIndex effIndex);
275  void EffectOpenLock(SpellEffIndex effIndex);
276  void EffectSummonChangeItem(SpellEffIndex effIndex);
277  void EffectOpenSecretSafe(SpellEffIndex effIndex);
278  void EffectProficiency(SpellEffIndex effIndex);
279  void EffectSummonType(SpellEffIndex effIndex);
280  void EffectLearnSpell(SpellEffIndex effIndex);
281  void EffectDispel(SpellEffIndex effIndex);
282  void EffectDualWield(SpellEffIndex effIndex);
283  void EffectPickPocket(SpellEffIndex effIndex);
284  void EffectAddFarsight(SpellEffIndex effIndex);
285  void EffectHealMechanical(SpellEffIndex effIndex);
286  void EffectTeleUnitsFaceCaster(SpellEffIndex effIndex);
287  void EffectLearnSkill(SpellEffIndex effIndex);
288  void EffectAddHonor(SpellEffIndex effIndex);
289  void EffectTradeSkill(SpellEffIndex effIndex);
290  void EffectEnchantItemPerm(SpellEffIndex effIndex);
291  void EffectEnchantItemTmp(SpellEffIndex effIndex);
292  void EffectTameCreature(SpellEffIndex effIndex);
293  void EffectSummonPet(SpellEffIndex effIndex);
294  void SummonClassPet(SpellEffIndex effIndex);
295  void EffectLearnPetSpell(SpellEffIndex effIndex);
296  void EffectWeaponDmg(SpellEffIndex effIndex);
297  void EffectForceCast(SpellEffIndex effIndex);
298  void EffectTriggerSpell(SpellEffIndex effIndex);
299  void EffectTriggerMissileSpell(SpellEffIndex effIndex);
300  void EffectThreat(SpellEffIndex effIndex);
301  void EffectHealMaxHealth(SpellEffIndex effIndex);
302  void EffectInterruptCast(SpellEffIndex effIndex);
303  void EffectSummonObjectWild(SpellEffIndex effIndex);
304  void EffectScriptEffect(SpellEffIndex effIndex);
305  void EffectSanctuary(SpellEffIndex effIndex);
306  void EffectAddComboPoints(SpellEffIndex effIndex);
307  void EffectDuel(SpellEffIndex effIndex);
308  void EffectStuck(SpellEffIndex effIndex);
309  void EffectSummonPlayer(SpellEffIndex effIndex);
310  void EffectActivateObject(SpellEffIndex effIndex);
311  void EffectEnchantHeldItem(SpellEffIndex effIndex);
312  void EffectSummonObject(SpellEffIndex effIndex);
313  void EffectResurrect(SpellEffIndex effIndex);
314  void EffectParry(SpellEffIndex effIndex);
315  void EffectBlock(SpellEffIndex effIndex);
316  void EffectMomentMove(SpellEffIndex effIndex);
317  void EffectTransmitted(SpellEffIndex effIndex);
318  void EffectDisEnchant(SpellEffIndex effIndex);
319  void EffectInebriate(SpellEffIndex effIndex);
320  void EffectFeedPet(SpellEffIndex effIndex);
321  void EffectDismissPet(SpellEffIndex effIndex);
322  void EffectReputation(SpellEffIndex effIndex);
323  void EffectSelfResurrect(SpellEffIndex effIndex);
324  void EffectSkinning(SpellEffIndex effIndex);
325  void EffectCharge(SpellEffIndex effIndex);
326  void EffectProspecting(SpellEffIndex effIndex);
327  void EffectSendTaxi(SpellEffIndex effIndex);
328  void EffectSummonCritter(SpellEffIndex effIndex);
329  void EffectKnockBack(SpellEffIndex effIndex);
330  void EffectPlayerPull(SpellEffIndex effIndex);
331  void EffectDispelMechanic(SpellEffIndex effIndex);
332  void EffectSummonDeadPet(SpellEffIndex effIndex);
333  void EffectDestroyAllTotems(SpellEffIndex effIndex);
334  void EffectDurabilityDamage(SpellEffIndex effIndex);
335  void EffectSkill(SpellEffIndex effIndex);
336  void EffectTaunt(SpellEffIndex effIndex);
337  void EffectDurabilityDamagePCT(SpellEffIndex effIndex);
338  void EffectModifyThreatPercent(SpellEffIndex effIndex);
339  void EffectResurrectNew(SpellEffIndex effIndex);
340  void EffectAddExtraAttacks(SpellEffIndex effIndex);
341  void EffectSpiritHeal(SpellEffIndex effIndex);
342  void EffectSkinPlayerCorpse(SpellEffIndex effIndex);
343  void EffectStealBeneficialBuff(SpellEffIndex effIndex);
344  void EffectUnlearnSpecialization(SpellEffIndex effIndex);
345  void EffectHealPct(SpellEffIndex effIndex);
346  void EffectEnergizePct(SpellEffIndex effIndex);
347  void EffectTriggerSpellWithValue(SpellEffIndex effIndex);
348  void EffectTriggerRitualOfSummoning(SpellEffIndex effIndex);
349  void EffectKillCredit(SpellEffIndex effIndex);
350  void EffectQuestFail(SpellEffIndex effIndex);
351  void EffectRedirectThreat(SpellEffIndex effIndex);
352  void EffectSummonFriend(SpellEffIndex effIndex);
353 
354  Spell(Unit* Caster, SpellEntry const* info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL, bool skipCheck = false);
355  ~Spell();
356 
357  void prepare(SpellCastTargets* targets, Aura* triggeredByAura = NULL);
358  void cancel(bool sendInterrupt = true);
359  void update(uint32 difftime);
360  void cast(bool skipCheck = false);
361  void finish(bool ok = true);
362  void TakePower();
363  void TakeReagents();
364  void TakeCastItem();
365  void TriggerSpell();
366  SpellCastResult CheckCast(bool strict);
367  SpellCastResult CheckPetCast(Unit* target);
368  SpellCastResult CheckDummyCast(uint32 effIndex);
369  bool CanAutoCast(Unit* target);
370 
371  // handlers
372  void handle_immediate();
373  uint64 handle_delayed(uint64 t_offset);
374  // handler helpers
375  void _handle_immediate_phase();
376  void _handle_finish_phase();
377 
378  SpellCastResult CheckItems();
379  SpellCastResult CheckRange(bool strict);
380  SpellCastResult CheckPower();
381  SpellCastResult CheckCasterAuras() const;
382 
384  {
385  if (m_originalCaster)
386  return m_originalCaster->CalculateSpellDamage(m_spellInfo, i, m_currentBasePoints[i], target);
387  return m_caster->CalculateSpellDamage(m_spellInfo, i, m_currentBasePoints[i], target);
388  }
389 
390  bool HaveTargetsForEffect(uint8 effect) const;
391  void Delayed();
392  void DelayedChannel();
393  uint32 getState() const
394  {
395  return m_spellState;
396  }
397  void setState(uint32 state)
398  {
399  m_spellState = state;
400  }
401 
402  void DoCreateItem(uint32 i, uint32 itemtype);
403 
404  void WriteSpellGoTargets(WorldPacket* data);
405  void WriteAmmoToPacket(WorldPacket* data);
406  void FillTargetMap();
407 
408  void SetTargetMap(uint32 i, uint32 cur);
409 
410  Unit* SelectMagnetTarget();
411  void HandleHitTriggerAura();
412  bool CheckTarget(Unit* target, uint32 eff);
413 
414  void CheckSrc()
415  {
416  if (!m_targets.HasSrc()) m_targets.setSrc(m_caster);
417  }
418  void CheckDst()
419  {
420  if (!m_targets.HasDst()) m_targets.setDst(m_caster);
421  }
422 
423  void SendCastResult(SpellCastResult result);
424  void SendSpellStart();
425  void SendSpellGo();
426  void SendSpellCooldown();
427  void SendLogExecute();
428  void SendInterrupted(uint8 result);
429  void SendChannelUpdate(uint32 time);
430  void SendChannelStart(uint32 duration);
431  void SendResurrectRequest(Player* target);
432  void SendPlaySpellVisual(uint32 SpellID);
433 
434  void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, float DamageMultiplier = 1.0);
435  void HandleThreatSpells();
436  //void HandleAddAura(Unit* Target);
437 
438  const SpellEntry* const m_spellInfo;
439  int32 m_currentBasePoints[3]; // cache SpellEntry::EffectBasePoints and use for set custom base points
444 
446  {
447  return m_casttime;
448  }
449  bool IsAutoRepeat() const
450  {
451  return m_autoRepeat;
452  }
453  void SetAutoRepeat(bool rep)
454  {
455  m_autoRepeat = rep;
456  }
457  void ReSetTimer()
458  {
459  m_timer = m_casttime > 0 ? m_casttime : 0;
460  }
462  {
464  }
465  bool IsRangedSpell() const
466  {
467  return m_spellInfo->Attributes & SPELL_ATTR0_RANGED;
468  }
469  bool IsChannelActive() const
470  {
471  return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0;
472  }
474  {
475  return !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK);
476  }
477 
478  bool IsDeletable() const
479  {
480  return !m_referencedFromCurrentSpell && !m_executedCurrently;
481  }
483  {
484  m_referencedFromCurrentSpell = yes;
485  }
486  bool IsInterruptable() const
487  {
488  return !m_executedCurrently;
489  }
490  void SetExecutedCurrently(bool yes)
491  {
492  m_executedCurrently = yes;
493  }
495  {
496  return m_delayStart;
497  }
498  void SetDelayStart(uint64 m_time)
499  {
500  m_delayStart = m_time;
501  }
503  {
504  return m_delayMoment;
505  }
506 
507  CurrentSpellTypes GetCurrentContainer();
508 
509  Unit* GetCaster() const
510  {
511  return m_caster;
512  }
514  {
515  return m_originalCaster;
516  }
518  {
519  return m_powerCost;
520  }
521 
522  void UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
523  void CalculateHitResults();
524 
525  bool IsAffectedBy(SpellEntry const* spellInfo, uint32 effectId);
526 
527  bool CheckTargetCreatureType(Unit* target) const;
528 
529  void AddTriggeredSpell(SpellEntry const* spell)
530  {
531  m_TriggerSpells.push_back(spell);
532  }
533 
534  void CleanupTargetList();
535 
536  void SetSpellValue(SpellValueMod mod, int32 value);
537  protected:
538 
539  void SendLoot(uint64 guid, LootType loottype);
540 
541  Unit* const m_caster;
542 
544 
545  uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection
546  // e.g. damage around area spell trigered by victim aura and damage enemies of aura caster
547  Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers()
548 
549  Spell** m_selfContainer; // pointer to our spell container (if applicable)
550  Spell** m_triggeringContainer; // pointer to container with spell that has triggered us
551 
552  //Spell data
553  SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example)
554  WeaponAttackType m_attackType; // For weapon based attack
555  int32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare
556  int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare
557  bool m_canReflect; // can reflect this spell?
561 
562 
565  {
566  return m_delayAtDamageCount < 5 ? IN_MILLISECONDS - (m_delayAtDamageCount++) * 200 : 200;
567  }
568 
569  // Delayed spells system
570  uint64 m_delayStart; // time of spell delay start, filled by event handler, zero = just started
571  uint64 m_delayMoment; // moment of next delay call, used internally
572  bool m_immediateHandled; // were immediate actions handled? (used by delayed spells only)
573 
574  // These vars are used in both delayed spell system and modified immediate spell system
575  bool m_referencedFromCurrentSpell; // mark as references to prevent deleted and access by dead pointers
576  bool m_executedCurrently; // mark as executed to prevent deleted and access by dead pointers
577  bool m_needSpellLog; // need to send spell log?
578  bool m_needComboPoints; // Need combo points?
579  uint8 m_applyMultiplierMask; // by effect: damage multiplier needed?
580  float m_damageMultipliers[3]; // by effect: damage multiplier
581 
582  // Current targets, to be used in SpellEffects (MUST BE USED ONLY IN SPELL EFFECTS)
587 
588  // this is set in Spell Hit, but used in Apply Aura handler
591 
592  // -------------------------------------------
594 
595  // Damage and healing in effects need just calculate
596  int32 m_damage; // Damge in effects count here
597  int32 m_healing; // Healing in effects count here
598  int32 m_healthLeech; // Health leech in effects for all targets count here
599 
600  //******************************************
601  // Spell trigger system
602  //******************************************
603  bool m_canTrigger; // Can start trigger (m_IsTriggeredSpell can`t use for this)
604  uint32 m_procAttacker; // Attacker trigger flags
605  uint32 m_procVictim; // Victim trigger flags
606  void prepareDataForTriggerSystem();
607 
608  //*****************************************
609  // Spell target subsystem
610  //*****************************************
611  // Targets store structures and data
614  struct TargetInfo
615  {
618  SpellMissInfo missCondition: 8;
619  SpellMissInfo reflectResult: 8;
620  uint8 effectMask: 8;
621  bool processed: 1;
622  bool deleted: 1;
624  bool crit;
625  };
626  std::list<TargetInfo> m_UniqueTargetInfo;
627  uint8 m_needAliveTargetMask; // Mask req. alive targets
629 
631  {
634  uint8 effectMask: 8;
635  bool processed: 1;
636  bool deleted: 1;
637  };
638  std::list<GOTargetInfo> m_UniqueGOTargetInfo;
639 
641  {
644  };
645  std::list<ItemTargetInfo> m_UniqueItemInfo;
646 
647  void AddUnitTarget(Unit* target, uint32 effIndex);
648  void AddUnitTarget(uint64 unitGUID, uint32 effIndex);
649  void AddGOTarget(GameObject* target, uint32 effIndex);
650  void AddGOTarget(uint64 goGUID, uint32 effIndex);
651  void AddItemTarget(Item* target, uint32 effIndex);
652  void DoAllEffectOnTarget(TargetInfo* target);
653  void DoSpellHitOnUnit(Unit* unit, uint32 effectMask);
654  void DoAllEffectOnTarget(GOTargetInfo* target);
655  void DoAllEffectOnTarget(ItemTargetInfo* target);
656  bool IsAliveUnitPresentInTargetList();
657  void SearchAreaTarget(std::list<Unit*>& unitList, float radius, const uint32 type, SpellTargets TargetType, uint32 entry = 0);
658  void SearchChainTarget(std::list<Unit*>& unitList, float radius, uint32 unMaxTargets, SpellTargets TargetType);
659  WorldObject* SearchNearbyTarget(float range, SpellTargets TargetType);
660  bool IsValidSingleTargetEffect(Unit const* target, Targets type) const;
661  bool IsValidSingleTargetSpell(Unit const* target) const;
662  void CalculateDamageDoneForAllTargets();
663  int32 CalculateDamageDone(Unit* unit, const uint32 effectMask, float* multiplier);
664  void SpellDamageSchoolDmg(SpellEffIndex effIndex);
665  void SpellDamageWeaponDmg(SpellEffIndex effIndex);
666  void SpellDamageHeal(SpellEffIndex effIndex);
667 
668  void GetSummonPosition(uint32 i, Position& pos, float radius = 0.0f);
669  void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties);
670 
671  SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
672  // -------------------------------------------
673 
674  //List For Triggered Spells
675  typedef std::vector<SpellEntry const*> TriggerSpells;
676  TriggerSpells m_TriggerSpells;
677  typedef std::vector< std::pair<SpellEntry const*, int32> > ChanceTriggerSpells;
678  ChanceTriggerSpells m_ChanceTriggerSpells;
679 
682 
688 
689  // if need this can be replaced by Aura copy
690  // we can't store original aura link to prevent access to deleted auras
691  // and in same time need aura data and after aura deleting.
693 
696 };
697 
698 namespace Oregon
699 {
701 {
702  std::list<Unit*>* i_data;
705  float i_radius, i_radiusSq;
709  const Position* const i_pos;
711 
712  SpellNotifierCreatureAndPlayer(Spell& spell, std::list<Unit*>& data, float radius, const uint32& type,
713  SpellTargets TargetType = SPELL_TARGETS_ENEMY, const Position* pos = NULL, uint32 entry = 0, SpellEntry const* spellProto = NULL)
714  : i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_radiusSq(radius* radius),
715  i_TargetType(TargetType), i_caster(spell.GetCaster()), i_entry(entry), i_pos(pos), i_spellProto(spellProto)
716  {
717  }
718 
719  template<class T> inline void Visit(GridRefManager<T>& m)
720  {
721  assert(i_data);
722 
723  if (!i_caster)
724  return;
725 
726  for (typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr)
727  {
728  if (!itr->GetSource()->IsAlive() || (itr->GetSource()->GetTypeId() == TYPEID_PLAYER && ((Player*)itr->GetSource())->IsInFlight()))
729  continue;
730 
731  switch (i_TargetType)
732  {
733  case SPELL_TARGETS_ALLY:
734  if (!i_caster->_IsValidAssistTarget(itr->GetSource(), i_spellProto))
735  continue;
736  if (itr->GetSource()->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
737  continue;
738  if (itr->GetSource()->GetTypeId() == TYPEID_PLAYER && itr->GetSource()->ToPlayer()->IsGameMaster())
739  continue;
740  break;
741  case SPELL_TARGETS_ENEMY:
742  {
743  if (itr->GetSource()->GetTypeId() == TYPEID_UNIT && ((Creature*)itr->GetSource())->IsTotem())
744  continue;
745 
746  if (i_caster->GetCreatureType() == CREATURE_TYPE_TOTEM)
747  {
748  if (!itr->GetSource()->isAttackableByAOE(i_pos->GetPositionX(), i_pos->GetPositionY(), i_pos->GetPositionZ(), true))
749  continue;
750  }
751  else
752  {
753  if (!itr->GetSource()->isAttackableByAOE())
754  continue;
755  }
756 
757  if (!i_caster->_IsValidAttackTarget(itr->GetSource(), i_spellProto))
758  continue;
759 
760  }
761  break;
762  case SPELL_TARGETS_ENTRY:
763  {
764  if (itr->GetSource()->GetEntry() != i_entry)
765  continue;
766  }
767  break;
768  default:
769  continue;
770  }
771 
772  switch (i_push_type)
773  {
774  case PUSH_IN_FRONT:
775  if (i_caster->isInFrontInMap((Unit*)(itr->GetSource()), i_radius, float(M_PI) / 3))
776  i_data->push_back(itr->GetSource());
777  break;
778  case PUSH_IN_BACK:
779  if (i_caster->isInBackInMap((Unit*)(itr->GetSource()), i_radius, float(M_PI) / 3))
780  i_data->push_back(itr->GetSource());
781  break;
782  case PUSH_IN_LINE:
783  if (i_caster->HasInLine((Unit*)(itr->GetSource()), i_caster->GetObjectSize()))
784  i_data->push_back(itr->GetSource());
785  break;
786  default:
787  if (i_TargetType != SPELL_TARGETS_ENTRY && i_push_type == PUSH_SRC_CENTER && i_caster) // if caster then check distance from caster to target (because of model collision)
788  {
789  if (i_caster->IsWithinDistInMap(itr->GetSource(), i_radius))
790  i_data->push_back(itr->GetSource());
791  }
792  else
793  {
794  if ((itr->GetSource()->GetExactDistSq(i_pos) < i_radiusSq))
795  i_data->push_back(itr->GetSource());
796  }
797  break;
798  }
799  }
800  }
801 
802  #ifdef WIN32
803  template<> inline void Visit(CorpseMapType&) {}
804  template<> inline void Visit(GameObjectMapType&) {}
805  template<> inline void Visit(DynamicObjectMapType&) {}
806  #endif
807 };
808 
809 #ifndef WIN32
813 #endif
814 }
815 
816 typedef void(Spell::*pEffect)(SpellEffIndex effIndex);
817 
818 class SpellEvent : public BasicEvent
819 {
820  public:
821  SpellEvent(Spell* spell);
822  virtual ~SpellEvent();
823 
824  virtual bool Execute(uint64 e_time, uint32 p_time);
825  virtual void Abort(uint64 e_time);
826  virtual bool IsDeletable() const;
827  protected:
829 };
830 #endif
831 
GameObject * focusObject
Definition: Spell.h:593
Targets
SpellNotifyPushType
Definition: Spell.h:48
uint32 m_itemTargetEntry
Definition: Spell.h:191
GameObject * gameObjTarget
Definition: Spell.h:585
bool m_destroyed
Definition: Spell.h:628
Unit *const m_caster
Definition: Spell.h:541
uint32 m_spellState
Definition: Spell.h:680
bool m_isNeedSendToClient
Definition: Spell.h:559
std::list< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:645
SpellCastTargetsReader ReadForCaster(Unit *caster)
Definition: Spell.h:86
Definition: Corpse.h:48
uint64 timeDelay
Definition: Spell.h:617
uint64 m_castItemGUID
Definition: Spell.h:441
int32 CalculateDamage(uint8 i, Unit *target)
Definition: Spell.h:383
bool IsRangedSpell() const
Definition: Spell.h:465
uint32 MaxAffectedTargets
Definition: DBCStructure.h:762
#define MAPID_INVALID
Definition: Object.h:547
SpellCastFlags
Definition: Spell.h:32
int32 m_casttime
Definition: Spell.h:556
float m_castPositionZ
Definition: Spell.h:685
DiminishingLevels m_diminishLevel
Definition: Spell.h:589
void write(ByteBuffer &data) const
Definition: Spell.cpp:213
bool m_canReflect
Definition: Spell.h:557
bool IsQuestTameSpell(uint32 spellId)
Definition: Spell.cpp:53
CurrentSpellTypes
Definition: Unit.h:735
GameObject * getGOTarget() const
Definition: Spell.h:132
SpellSchoolMask
Unit * GetCaster() const
Definition: Spell.h:509
uint32 getState() const
Definition: Spell.h:393
SpellTargets
Definition: Spell.h:241
uint64 m_delayStart
Definition: Spell.h:570
bool HasInLine(Position const *pos, float width) const
Definition: Position.cpp:151
SpellCastTargets m_targets
Definition: Spell.h:443
WeaponAttackType
Definition: Unit.h:498
int32 GetPowerCost() const
Definition: Spell.h:517
SpellNotifierCreatureAndPlayer(Spell &spell, std::list< Unit * > &data, float radius, const uint32 &type, SpellTargets TargetType=SPELL_TARGETS_ENEMY, const Position *pos=NULL, uint32 entry=0, SpellEntry const *spellProto=NULL)
Definition: Spell.h:712
uint32 Duration
Definition: Spell.h:219
uint32 MaxAffectedTargets
Definition: Spell.h:218
SpellValueMod
Definition: Unit.h:133
uint32 InterruptFlags
Definition: DBCStructure.h:699
bool IsAutoRepeat() const
Definition: Spell.h:449
DiminishingGroup
bool m_skipCheck
Definition: Spell.h:695
bool IsInterruptable() const
Definition: Spell.h:486
void setState(uint32 state)
Definition: Spell.h:397
bool _IsValidAssistTarget(Unit const *target, SpellEntry const *bySpell) const
Definition: Unit.cpp:9672
Unit * getUnitTarget() const
Definition: Spell.h:118
ACE_INT32 int32
Definition: Define.h:67
void SetCurrentCastedSpell(Spell *pSpell)
Definition: Unit.cpp:3462
int32 m_timer
Definition: Spell.h:681
bool m_immediateHandled
Definition: Spell.h:572
uint64 getItemTargetGUID() const
Definition: Spell.h:143
Item * m_CastItem
Definition: Spell.h:440
bool IsChannelActive() const
Definition: Spell.h:469
SpellValue *const m_spellValue
Definition: Spell.h:543
float m_castPositionX
Definition: Spell.h:683
uint32 GetCreatureType() const
Definition: Unit.cpp:10721
std::vector< std::pair< SpellEntry const *, int32 > > ChanceTriggerSpells
Definition: Spell.h:677
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:729
Position m_srcPos
Definition: Spell.h:175
ReplenishType
Definition: Spell.h:233
float m_castPositionY
Definition: Spell.h:684
bool HasSrc() const
Definition: Spell.h:170
bool IsNextMeleeSwingSpell() const
Definition: Spell.h:461
void CheckSrc()
Definition: Spell.h:414
uint64 GetDelayMoment() const
Definition: Spell.h:502
void SetExecutedCurrently(bool yes)
Definition: Spell.h:490
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:750
uint32 m_procVictim
Definition: Spell.h:605
bool m_autoRepeat
Definition: Spell.h:558
uint8 m_needAliveTargetMask
Definition: Spell.h:627
uint32 Attributes
Definition: DBCStructure.h:679
const SpellEntry *const m_spellInfo
Definition: Spell.h:438
ACE_UINT8 uint8
Definition: Define.h:73
void Relocate(float x, float y)
Definition: Position.h:65
Unit * unitTarget
Definition: Spell.h:583
Unit * m_originalCaster
Definition: Spell.h:547
int32 damage
Definition: Spell.h:586
SpellEntry const * m_triggeredByAuraSpell
Definition: Spell.h:692
int finish(const char *message, int returnValue)
Definition: generator.cpp:242
Item * m_itemTarget
Definition: Spell.h:184
TriggerSpells m_TriggerSpells
Definition: Spell.h:676
bool HasDst() const
Definition: Spell.h:171
std::vector< SpellEntry const * > TriggerSpells
Definition: Spell.h:675
DiminishingLevels
Definition: Unit.h:643
int32 m_healthLeech
Definition: Spell.h:598
LootType
Definition: LootMgr.h:54
float GetPositionY() const
Definition: Position.h:98
ChanceTriggerSpells m_ChanceTriggerSpells
Definition: Spell.h:678
const Position *const i_pos
Definition: Spell.h:709
ObjectGuid m_unitTargetGUID
Definition: Spell.h:187
Definition: Item.h:196
Unit * GetOriginalCaster() const
Definition: Spell.h:513
uint64 m_delayMoment
Definition: Spell.h:571
SpellEffIndex
Definition: SharedDefines.h:24
int32 GetNextDelayAtDamageMsTime()
Definition: Spell.h:564
etc mysql my cnf *Then change max_allowed_packet to a bigger value
float GetPositionZ() const
Definition: Position.h:99
std::list< Unit * > * i_data
Definition: Spell.h:702
uint32 m_targetMask
Definition: Spell.h:179
ByteBuffer & operator>>(ByteBuffer &buf, SpellCastTargetsReader const &targets)
Definition: Spell.h:200
uint32 m_procAttacker
Definition: Spell.h:604
Unit * m_unitTarget
Definition: Spell.h:182
uint64 GetDelayStart() const
Definition: Spell.h:494
Item * itemTarget
Definition: Spell.h:584
SpellMissInfo
int32 damage
Definition: Spell.h:623
Spell ** m_triggeringContainer
Definition: Spell.h:550
int32 m_damage
Definition: Spell.h:596
std::list< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:626
uint64 m_originalCasterGUID
Definition: Spell.h:545
Item * getItemTarget() const
Definition: Spell.h:147
uint32 m_countOfHit
Definition: Spell.h:612
SpellCastTargetsReader(SpellCastTargets &_targets, Unit *_caster)
Definition: Spell.h:71
uint64 targetGUID
Definition: Spell.h:632
iterator end()
GameObject * m_GOTarget
Definition: Spell.h:183
bool m_isCastTimeHidden
Definition: Spell.h:560
bool isInBackInMap(Unit const *target, float distance, float arc=M_PI) const
Definition: Unit.cpp:3651
bool IsAutoActionResetSpell() const
Definition: Spell.h:473
WeaponAttackType m_attackType
Definition: Spell.h:554
ByteBuffer & operator<<(ByteBuffer &buf, SpellCastTargets const &targets)
Definition: Spell.h:194
void ReSetTimer()
Definition: Spell.h:457
bool m_needSpellLog
Definition: Spell.h:577
uint64 getCorpseTargetGUID() const
Definition: Spell.h:138
ACE_UINT64 uint64
Definition: Define.h:70
bool m_IsTriggeredSpell
Definition: Spell.h:687
bool IsEmpty() const
Definition: Spell.h:165
ObjectGuid m_CorpseTargetGUID
Definition: Spell.h:189
void SetDelayStart(uint64 m_time)
Definition: Spell.h:498
bool IsDeletable() const
Definition: Spell.h:478
bool m_executedCurrently
Definition: Spell.h:576
void(Spell::* pEffect)(SpellEffIndex effIndex)
Definition: Spell.h:816
uint32 m_customAttr
Definition: Spell.h:694
void CheckDst()
Definition: Spell.h:418
uint32 m_countOfMiss
Definition: Spell.h:613
bool _IsValidAttackTarget(Unit const *target, SpellEntry const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:9559
SpellRangeFlag
Definition: Spell.h:41
uint8 m_applyMultiplierMask
Definition: Spell.h:579
iterator begin()
ObjectGuid m_itemTargetGUID
Definition: Spell.h:190
SpellEntry const * i_spellProto
Definition: Spell.h:710
uint64 targetGUID
Definition: Spell.h:616
uint64 timeDelay
Definition: Spell.h:633
uint8 m_delayAtDamageCount
Definition: Spell.h:563
ObjectGuid m_GOTargetGUID
Definition: Spell.h:188
uint64 getGOTargetGUID() const
Definition: Spell.h:128
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:553
Spell * m_Spell
Definition: Spell.h:828
SpellCastResult
bool m_canTrigger
Definition: Spell.h:603
SkillType
DiminishingGroup m_diminishGroup
Definition: Spell.h:590
void Visit(GridRefManager< T > &m)
Definition: Spell.h:719
bool CustomDuration
Definition: Spell.h:220
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:482
SpellValue(SpellEntry const *proto)
Definition: Spell.h:209
uint32 getItemTargetEntry() const
Definition: Spell.h:151
SpellState
Definition: Spell.h:223
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
uint8 m_cast_count
Definition: Spell.h:442
Spell ** m_selfContainer
Definition: Spell.h:549
bool isInFrontInMap(Unit const *target, float distance, float arc=M_PI) const
Definition: Unit.cpp:3646
int32 GetCastTime() const
Definition: Spell.h:445
Definition: Unit.h:908
float GetObjectSize() const
Definition: Object.h:645
Definition: Player.h:923
int32 m_healing
Definition: Spell.h:597
void SetAutoRepeat(bool rep)
Definition: Spell.h:453
bool m_referencedFromCurrentSpell
Definition: Spell.h:575
SpellCastTargets & operator=(const SpellCastTargets &target)
Definition: Spell.h:91
bool m_needComboPoints
Definition: Spell.h:578
int32 GetSpellDuration(SpellEntry const *spellInfo)
Definition: SpellMgr.cpp:228
void AddTriggeredSpell(SpellEntry const *spell)
Definition: Spell.h:529
int32 m_powerCost
Definition: Spell.h:555
uint64 getUnitTargetGUID() const
Definition: Spell.h:114
WorldLocation m_dstPos
Definition: Spell.h:176
std::string m_strTarget
Definition: Spell.h:177
SpellCastTargets & targets
Definition: Spell.h:73
void updateTradeSlotItem()
Definition: Spell.h:156
std::list< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:638
void read(ByteBuffer &data, Unit *caster)
Definition: Spell.cpp:172
float m_castOrientation
Definition: Spell.h:686
Definition: Spell.h:249