[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:
megamage
2008-11-02 00:59:44 -05:00
parent 1dad2c855c
commit 972e2d56e2
8 changed files with 38 additions and 25 deletions

View File

@@ -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());
}