[9581] Fixed apply damage reduction to melee/ranged damage.
[getmangos.git] / src / game / DynamicObject.h
blobfffdbec20fa93789b6a3dd021674047f9b907d26
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_DYNAMICOBJECT_H
20 #define MANGOSSERVER_DYNAMICOBJECT_H
22 #include "Object.h"
23 #include "DBCEnums.h"
25 class Unit;
26 struct SpellEntry;
28 class DynamicObject : public WorldObject
30 public:
31 typedef std::set<Unit*> AffectedSet;
32 explicit DynamicObject();
34 void AddToWorld();
35 void RemoveFromWorld();
37 bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius);
38 void Update(uint32 p_time);
39 void Delete();
40 uint32 GetSpellId() const { return m_spellId; }
41 SpellEffectIndex GetEffIndex() const { return m_effIndex; }
42 uint32 GetDuration() const { return m_aliveDuration; }
43 uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
44 Unit* GetCaster() const;
45 float GetRadius() const { return m_radius; }
46 bool IsAffecting(Unit *unit) const { return m_affected.find(unit) != m_affected.end(); }
47 void AddAffected(Unit *unit) { m_affected.insert(unit); }
48 void RemoveAffected(Unit *unit) { m_affected.erase(unit); }
49 void Delay(int32 delaytime);
51 bool IsHostileTo(Unit const* unit) const;
52 bool IsFriendlyTo(Unit const* unit) const;
54 bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
56 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
57 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
58 void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
59 void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId,receiver); }
60 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
62 GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
64 bool isActiveObject() const { return m_isActiveObject; }
65 protected:
66 uint32 m_spellId;
67 SpellEffectIndex m_effIndex;
68 int32 m_aliveDuration;
69 float m_radius; // radius apply persistent effect, 0 = no persistent effect
70 AffectedSet m_affected;
71 private:
72 GridReference<DynamicObject> m_gridRef;
73 bool m_isActiveObject;
75 #endif