aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/CreatureAIRegistry.cpp2
-rw-r--r--src/game/GameObject.cpp18
-rw-r--r--src/game/GameObject.h2
-rw-r--r--src/game/Object.cpp4
-rw-r--r--src/game/Spell.cpp27
-rw-r--r--src/game/Spell.h6
-rw-r--r--src/game/SpellEffects.cpp3
7 files changed, 37 insertions, 25 deletions
diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp
index 0416d2951bd..6a0c5637893 100644
--- a/src/game/CreatureAIRegistry.cpp
+++ b/src/game/CreatureAIRegistry.cpp
@@ -37,7 +37,7 @@ namespace AIRegistry
{
void Initialize()
{
- (new CreatureAIFactory<NullCreatureAI>("NullAI"))->RegisterSelf();
+ (new CreatureAIFactory<NullCreatureAI>("NullCreatureAI"))->RegisterSelf();
(new CreatureAIFactory<AggressorAI>("AggressorAI"))->RegisterSelf();
(new CreatureAIFactory<ReactorAI>("ReactorAI"))->RegisterSelf();
(new CreatureAIFactory<GuardAI>("GuardAI"))->RegisterSelf();
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 2a5b9fb1867..57d206fa1aa 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -341,9 +341,10 @@ void GameObject::Update(uint32 /*p_time*/)
if (ok)
{
- Unit *caster = owner ? owner : ok;
+ //Unit *caster = owner ? owner : ok;
- caster->CastSpell(ok, goInfo->trap.spellId, true);
+ //caster->CastSpell(ok, goInfo->trap.spellId, true);
+ CastSpell(ok, goInfo->trap.spellId);
m_cooldownTime = time(NULL) + 4; // 4 seconds
if(NeedDespawn)
@@ -1263,3 +1264,16 @@ void GameObject::Use(Unit* user)
spell->prepare(&targets);
}
+
+void GameObject::CastSpell(Unit* target, uint32 spell)
+{
+ //summon world trigger
+ Creature *trigger = SummonCreature(12999, GetPositionX(), GetPositionY(), GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 1);
+ if(!trigger) return;
+
+ Unit *owner = GetOwner();
+ if(owner) trigger->setFaction(owner->getFaction());
+ else trigger->setFaction(14);
+ trigger->SetVisibility(VISIBILITY_OFF); //should this be true?
+ trigger->CastSpell(target, spell, true, 0, 0, owner->GetGUID());
+} \ No newline at end of file
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 58f1ee53e48..5ed3cfd1e6e 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -572,6 +572,8 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
GameObject* LookupFishingHoleAround(float range);
GridReference<GameObject> &GetGridRef() { return m_gridRef; }
+
+ void CastSpell(Unit *target, uint32 spell);
protected:
uint32 m_charges; // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22)
uint32 m_spellId;
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index d7ec1c110cc..506acb6b7d8 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1483,7 +1483,11 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
((Creature*)this)->AI()->JustSummoned(pCreature);
if(pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && pCreature->m_spells[0])
+ {
+ if(GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER)
+ pCreature->setFaction(((Unit*)this)->getFaction());
pCreature->CastSpell(pCreature, pCreature->m_spells[0], true, 0, 0, GetGUID());
+ }
//return the creature therewith the summoner has access to it
return pCreature;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index a200ef88467..1bc7783d053 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -94,7 +94,7 @@ void SpellCastTargets::setUnitTarget(Unit *target)
m_targetMask |= TARGET_FLAG_UNIT;
}
-void SpellCastTargets::setDestination(float x, float y, float z, bool send, uint32 mapId)
+void SpellCastTargets::setDestination(float x, float y, float z, bool send, int32 mapId)
{
m_destX = x;
m_destY = y;
@@ -102,7 +102,7 @@ void SpellCastTargets::setDestination(float x, float y, float z, bool send, uint
m_hasDest = true;
if(send)
m_targetMask |= TARGET_FLAG_DEST_LOCATION;
- if(mapId)
+ if(mapId >= 0)
m_mapId = mapId;
}
@@ -415,20 +415,8 @@ void Spell::FillTargetMap()
std::list<Unit*> tmpUnitMap;
- // Note: this hack with search required until GO casting not implemented
- // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support
- // currently each enemy selected explicitly and self cast damage
- if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_AROUND_CASTER
- && m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA
- && m_spellInfo->Effect[i]==SPELL_EFFECT_ENVIRONMENTAL_DAMAGE)
- {
- tmpUnitMap.push_back(m_targets.getUnitTarget());
- }
- else
- {
- SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap);
- SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap);
- }
+ SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap);
+ SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap);
if(m_targets.HasDest())
{
@@ -716,7 +704,10 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex)
target.processed = false; // Effects not apply on target
// Calculate hit result
- target.missCondition = m_caster->SpellHitResult(pVictim, m_spellInfo, m_canReflect);
+ if(m_originalCaster)
+ target.missCondition = m_originalCaster->SpellHitResult(pVictim, m_spellInfo, m_canReflect);
+ else
+ target.missCondition = SPELL_MISS_NONE;
if (target.missCondition == SPELL_MISS_NONE)
++m_countOfHit;
else
@@ -1454,7 +1445,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap)
if(m_spellInfo->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS
|| m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS
|| m_spellInfo->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS)
- m_targets.setDestination(st->target_X, st->target_Y, st->target_Z, true, st->target_mapId);
+ m_targets.setDestination(st->target_X, st->target_Y, st->target_Z, true, (int32)st->target_mapId);
else if(st->target_mapId == m_caster->GetMapId())
m_targets.setDestination(st->target_X, st->target_Y, st->target_Z);
}
diff --git a/src/game/Spell.h b/src/game/Spell.h
index f6fa5103578..8ec4a1d64d4 100644
--- a/src/game/Spell.h
+++ b/src/game/Spell.h
@@ -111,7 +111,7 @@ class SpellCastTargets
//m_srcY = target.m_srcY;
//m_srcZ = target.m_srcZ;
- m_mapId = 0;
+ m_mapId = -1;
m_destX = target.m_destX;
m_destY = target.m_destY;
m_destZ = target.m_destZ;
@@ -127,7 +127,7 @@ class SpellCastTargets
uint64 getUnitTargetGUID() const { return m_unitTargetGUID; }
Unit *getUnitTarget() const { return m_unitTarget; }
void setUnitTarget(Unit *target);
- void setDestination(float x, float y, float z, bool send = true, uint32 mapId = 0);
+ void setDestination(float x, float y, float z, bool send = true, int32 mapId = -1);
void setDestination(Unit *target, bool send = true);
uint64 getGOTargetGUID() const { return m_GOTargetGUID; }
@@ -155,7 +155,7 @@ class SpellCastTargets
void Update(Unit* caster);
float m_srcX, m_srcY, m_srcZ;
- uint32 m_mapId;
+ int32 m_mapId;
float m_destX, m_destY, m_destZ;
bool m_hasDest;
std::string m_strTarget;
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 58ece04a267..bfa14d9cebb 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1978,7 +1978,8 @@ void Spell::EffectTeleportUnits(uint32 i)
return;
}
// Init dest coordinates
- uint32 mapid = m_targets.m_mapId;
+ int32 mapid = m_targets.m_mapId;
+ if(mapid < 0) mapid = (int32)unitTarget->GetMapId();
float x = m_targets.m_destX;
float y = m_targets.m_destY;
float z = m_targets.m_destZ;