*Some update of spell target selection.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-09 10:48:14 -05:00
parent 3b4e4b8215
commit 6592e99f4a
4 changed files with 31 additions and 20 deletions

View File

@@ -198,7 +198,7 @@ void GameObject::Update(uint32 /*p_time*/)
{
// Arming Time for GAMEOBJECT_TYPE_TRAP (6)
Unit* owner = GetOwner();
if (owner && ((Player*)owner)->isInCombat())
if (owner && owner->isInCombat())
m_cooldownTime = time(NULL) + GetGOInfo()->trap.startDelay;
m_lootState = GO_READY;
break;

View File

@@ -1597,6 +1597,8 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargets TargetType)
break;
}
case SPELL_TARGET_TYPE_CREATURE:
if(m_targets.getUnitTarget() && m_targets.getUnitTarget()->GetEntry() == i_spellST->second.targetEntry)
return m_targets.getUnitTarget();
case SPELL_TARGET_TYPE_DEAD:
default:
{
@@ -1925,7 +1927,13 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
m_targets.setDestination(st->target_X, st->target_Y, st->target_Z);
}
else
sLog.outError( "SPELL: unknown target coordinates for spell ID %u\n", m_spellInfo->Id );
{
sLog.outError( "SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id );
Unit *target = NULL;
if(uint64 guid = m_caster->GetUInt64Value(UNIT_FIELD_TARGET))
target = ObjectAccessor::GetUnit(*m_caster, guid);
m_targets.setDestination(target ? target : m_caster);
}
break;
case TARGET_DST_HOME:
if(m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -2045,7 +2053,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
else if(pushType)
{
// Dummy, just for client
if(spellmgr.EffectTargetType[m_spellInfo->Effect[i]] == SPELL_REQUIRE_DEST)
if(spellmgr.EffectTargetType[m_spellInfo->Effect[i]] != SPELL_REQUIRE_UNIT)
return;
float radius;
@@ -3971,13 +3979,16 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_IN_ARENA;
// zone check
uint32 zone, area;
m_caster->GetZoneAndAreaId(zone,area);
if(m_caster->GetTypeId() == TYPEID_UNIT || !((Player*)m_caster)->isGameMaster())
{
uint32 zone, area;
m_caster->GetZoneAndAreaId(zone,area);
SpellCastResult locRes= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area,
m_caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)m_caster) : NULL);
if(locRes != SPELL_CAST_OK)
return locRes;
SpellCastResult locRes= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area,
m_caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)m_caster) : NULL);
if(locRes != SPELL_CAST_OK)
return locRes;
}
// not let players cast spells at mount (and let do it to creatures)
if( m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&

View File

@@ -1000,7 +1000,7 @@ void Aura::_AddAura()
for(std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr)
{
if(*itr < 0)
m_target->ApplySpellImmune(id, IMMUNITY_ID, -(*itr), m_target);
m_target->ApplySpellImmune(id, IMMUNITY_ID, -(*itr), true);
else if(Unit* caster = GetCaster())
caster->AddAura(*itr, m_target);
}

View File

@@ -4775,17 +4775,17 @@ void Spell::EffectScriptEffect(uint32 effIndex)
unitTarget->CastSpell(unitTarget, 44870, true);
break;
}
// spell of Brutallus - Stomp
case 45185:
{
if(!unitTarget)
return;
if(unitTarget->HasAura(46394)) // spell of Brutallus - Burn
unitTarget->RemoveAurasDueToSpell(46394);
// spell of Brutallus - Stomp
case 45185:
{
if(!unitTarget)
return;
break;
}
if(unitTarget->HasAura(46394)) // spell of Brutallus - Burn
unitTarget->RemoveAurasDueToSpell(46394);
break;
}
// Negative Energy
case 46289:
{