*Fix charge spells: do stun effect when caster arrive target.

*Some other fix about delayed spell calculation.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-30 19:00:09 -06:00
parent 8fee06f041
commit 9b927d1742
6 changed files with 35 additions and 9 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove)
float speed;
if(traveller.GetTraveller().hasUnitState(UNIT_STAT_CHARGING))
speed = 0.025f; // assume it is 25 yard per second
speed = SPEED_CHARGE * 0.001f;
else
speed = traveller.Speed() * 0.001f; // speed is in seconds so convert from second to millisecond
i_totalTravelTime = static_cast<uint32>(dist/speed);
+18 -4
View File
@@ -425,7 +425,7 @@ void Spell::FillTargetMap()
{
if(effectTargetType == SPELL_REQUIRE_CASTER)
AddUnitTarget(m_caster, i);
if(effectTargetType == SPELL_REQUIRE_DEST)
/*else if(effectTargetType == SPELL_REQUIRE_DEST)
{
if(m_targets.HasDest() && m_spellInfo->speed > 0.0f)
{
@@ -433,7 +433,7 @@ void Spell::FillTargetMap()
if (dist < 5.0f) dist = 5.0f;
m_delayMoment = (uint64) floor(dist / m_spellInfo->speed * 1000.0f);
}
}
}*/
else if(effectTargetType == SPELL_REQUIRE_ITEM)
{
if(m_targets.getItemTarget())
@@ -613,6 +613,16 @@ void Spell::FillTargetMap()
for(std::list<Unit*>::iterator iunit= tmpUnitMap.begin();iunit != tmpUnitMap.end();++iunit)
AddUnitTarget((*iunit), i);
}
if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
if(m_spellInfo->speed > 0.0f && m_targets.HasDest())
{
float dist = m_caster->GetDistance(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ);
if (dist < 5.0f) dist = 5.0f;
m_delayMoment = (uint64) floor(dist / m_spellInfo->speed * 1000.0f);
}
}
}
void Spell::prepareDataForTriggerSystem()
@@ -2209,6 +2219,8 @@ void Spell::cast(bool skipCheck)
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if (m_spellInfo->speed > 0.0f && !IsChanneledSpell(m_spellInfo))
{
if(m_customAttr & SPELL_ATTR_CU_CHARGE)
EffectCharge(0);
// Remove used for cast item if need (it can be already NULL after TakeReagents call
// in case delayed spell remove item at cast delay start
@@ -2284,12 +2296,14 @@ uint64 Spell::handle_delayed(uint64 t_offset)
m_immediateHandled = true;
}
bool single_missile = (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION);
// now recheck units targeting correctness (need before any effects apply to prevent adding immunity at first effect not allow apply second spell effect and similar cases)
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();++ihit)
{
if (ihit->processed == false)
{
if ( ihit->timeDelay <= t_offset )
if ( single_missile || ihit->timeDelay <= t_offset )
DoAllEffectOnTarget(&(*ihit));
else if( next_time == 0 || ihit->timeDelay < next_time )
next_time = ihit->timeDelay;
@@ -2301,7 +2315,7 @@ uint64 Spell::handle_delayed(uint64 t_offset)
{
if (ighit->processed == false)
{
if ( ighit->timeDelay <= t_offset )
if ( single_missile || ighit->timeDelay <= t_offset )
DoAllEffectOnTarget(&(*ighit));
else if( next_time == 0 || ighit->timeDelay < next_time )
next_time = ighit->timeDelay;
+8 -4
View File
@@ -159,7 +159,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectUnused, // 93 SPELL_EFFECT_SUMMON_PHANTASM
&Spell::EffectSelfResurrect, // 94 SPELL_EFFECT_SELF_RESURRECT
&Spell::EffectSkinning, // 95 SPELL_EFFECT_SKINNING
&Spell::EffectCharge, // 96 SPELL_EFFECT_CHARGE
&Spell::EffectUnused, // 96 SPELL_EFFECT_CHARGE
&Spell::EffectSummonCritter, // 97 SPELL_EFFECT_SUMMON_CRITTER
&Spell::EffectKnockBack, // 98 SPELL_EFFECT_KNOCK_BACK
&Spell::EffectDisEnchant, // 99 SPELL_EFFECT_DISENCHANT
@@ -5734,16 +5734,20 @@ void Spell::EffectSkinning(uint32 /*i*/)
void Spell::EffectCharge(uint32 /*i*/)
{
if(!unitTarget || !m_caster)
if(!m_caster)
return;
Unit *target = m_targets.getUnitTarget();
if(!target)
return;
float x, y, z;
unitTarget->GetContactPoint(m_caster, x, y, z);
target->GetContactPoint(m_caster, x, y, z);
m_caster->GetMotionMaster()->MoveCharge(x, y, z);
// not all charge effects used in negative spells
if ( !IsPositiveSpell(m_spellInfo->Id) && m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->Attack(unitTarget,true);
m_caster->Attack(target, true);
}
void Spell::EffectSummonCritter(uint32 i)
+5
View File
@@ -2148,6 +2148,11 @@ void SpellMgr::LoadSpellCustomAttr()
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
case SPELL_EFFECT_HEAL:
mSpellCustomAttr[i] |= SPELL_ATTR_CU_DIRECT_DAMAGE;
break;
case SPELL_EFFECT_CHARGE:
spellInfo->speed = SPEED_CHARGE;
mSpellCustomAttr[i] |= SPELL_ATTR_CU_CHARGE;
break;
}
}
+1
View File
@@ -702,6 +702,7 @@ inline bool IsProfessionSkill(uint32 skill)
#define SPELL_ATTR_CU_AURA_CC 0x00000040
#define SPELL_ATTR_CU_AURA_SPELL 0x00000080
#define SPELL_ATTR_CU_DIRECT_DAMAGE 0x00000100
#define SPELL_ATTR_CU_CHARGE 0x00000200
typedef std::vector<uint32> SpellCustomAttribute;
+2
View File
@@ -390,6 +390,8 @@ enum UnitMoveType
#define MAX_MOVE_TYPE 8
extern float baseMoveSpeed[MAX_MOVE_TYPE];
// assume it is 25 yard per 0.6 second
#define SPEED_CHARGE 42.0f
enum WeaponAttackType
{