mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
[svn] Add function GameObject::CastSpell. Used for hunter's trap and so.
Use original caster instead caster to check spell hit result. Let spell triggers have the same faction as the summoner. Fix the bug that trigger creatures attack enemy. (no need use civilian extra flag in the future, 128 is enough) Fix shadow step. --HG-- branch : trunk
This commit is contained in:
1
sql/updates/153_world.sql
Normal file
1
sql/updates/153_world.sql
Normal file
@@ -0,0 +1 @@
|
||||
update creature_template set flags_extra = 128 where entry = 12999;
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user