Index: src/ascent-world/Object.cpp =================================================================== --- src/ascent-world/Object.cpp (revision 4541) +++ src/ascent-world/Object.cpp (working copy) @@ -46,6 +46,8 @@ m_flySpeed = 7.0f; m_backFlySpeed = 4.5f; + m_mountSpeed = 7.0f; + m_backWalkSpeed = 4.5f; // this should really be named m_backRunSpeed m_swimSpeed = 4.722222f; m_backSwimSpeed = 2.5f; Index: src/ascent-world/Object.h =================================================================== --- src/ascent-world/Object.h (revision 4541) +++ src/ascent-world/Object.h (working copy) @@ -454,6 +454,8 @@ float m_backSwimSpeed; float m_turnRate; float m_flySpeed; + float m_mountSpeed; + float m_lastMountSpeed; float m_backFlySpeed; float m_base_runSpeed; Index: src/ascent-world/Player.cpp =================================================================== --- src/ascent-world/Player.cpp (revision 4541) +++ src/ascent-world/Player.cpp (working copy) @@ -3776,43 +3776,39 @@ SendMessageToSet(&data, true); } -void Player::SetPlayerSpeed(uint8 SpeedType, float value) +void Player::AddPlayerSpeed(uint8 SpeedType, float value) { - /*WorldPacket data(18); - data << GetNewGUID(); - data << m_speedChangeCounter++; - - if(SpeedType == RUN) // nfi what this is.. :/ - data << uint8(1); + //sLog.outString("AddPlayerSpeed(%u,%f)", SpeedType, value); + if(SpeedType == RUN) + SetPlayerSpeed(SpeedType, m_runSpeed + value); - data << value;*/ - WorldPacket data(50); - /*if(SpeedType==FLY) - { - data << GetNewGUID(); - data << m_speedChangeCounter++; + if(SpeedType == SWIM) + SetPlayerSpeed(SpeedType, m_swimSpeed + value); - if(SpeedType == RUN) // nfi what this is.. :/ - data << uint8(1); + if(SpeedType == FLY) + SetPlayerSpeed(SpeedType, m_flySpeed + value); - data << value; + if(SpeedType == MOUNT) + SetPlayerSpeed(SpeedType, m_mountSpeed + value); + + if(SpeedType == ALL) + { + AddPlayerSpeed(RUN, value); + AddPlayerSpeed(SWIM, value); + AddPlayerSpeed(FLY, value); + AddPlayerSpeed(MOUNT, value); } - else - { - data << GetNewGUID(); - data << uint32(0); - data << uint8(0); - data << uint32(getMSTime()); - data << GetPosition(); - data << m_position.o; - data << uint32(0); - data << value; - }*/ +} + +void Player::SetPlayerSpeed(uint8 SpeedType, float value) +{ + //sLog.outString("SetPlayerSpeed(%u,%f)", SpeedType, value); + WorldPacket data(50); if( SpeedType != SWIMBACK ) { data << GetNewGUID(); data << m_speedChangeCounter++; - if( SpeedType == RUN ) + if( SpeedType == RUN || SpeedType == MOUNT ) data << uint8(1); data << value; @@ -3840,6 +3836,13 @@ m_runSpeed = value; m_lastRunSpeed = value; }break; + case MOUNT: + { + if(value == m_lastMountSpeed) return; + data.SetOpcode(SMSG_FORCE_RUN_SPEED_CHANGE); + m_mountSpeed = value; + m_lastMountSpeed = value; + }break; case RUNBACK: { if(value == m_lastRunBackSpeed) @@ -10285,7 +10288,13 @@ }*/ // simplified; just take the fastest speed. less chance of fuckups too - float speed = ( flying_aura ) ? m_flySpeed : ( m_swimSpeed > m_runSpeed ) ? m_swimSpeed : m_runSpeed; + float speed = (m_swimSpeed > m_runSpeed) ? m_swimSpeed : m_runSpeed; + if(flying_aura && m_flySpeed > speed) + speed = m_flySpeed; + + if(IsMounted() && m_mountSpeed > speed) + speed = m_mountSpeed; + if( speed != _lastHeartbeatV ) { if( m_isMoving ) Index: src/ascent-world/Player.h =================================================================== --- src/ascent-world/Player.h (revision 4541) +++ src/ascent-world/Player.h (working copy) @@ -138,6 +138,9 @@ SWIMBACK = 4, WALK = 5, FLY = 6, + MOUNT = 7, + NUM_SPEEDS = 8, + ALL = 0xFF, }; enum Standing @@ -1105,6 +1108,7 @@ /* Movement system */ /************************************************************************/ void SetMovement(uint8 pType, uint32 flag); + void AddPlayerSpeed(uint8 SpeedType, float value); void SetPlayerSpeed(uint8 SpeedType, float value); float GetPlayerSpeed(){return m_runSpeed;} uint8 m_currentMovement; Index: src/ascent-world/SpellAuras.cpp =================================================================== --- src/ascent-world/SpellAuras.cpp (revision 4541) +++ src/ascent-world/SpellAuras.cpp (working copy) @@ -308,7 +308,40 @@ } } }*/ +#define QUICKCALC \ + (mod->m_amount / 100.0f) +void Aura::CalcSpeedMod(uint32 type) +{ + switch(type) + { + case RUN: + m_speedMod[RUN] = m_target->m_runSpeed * QUICKCALC; + //sLog.outString("Spell Mod RUN calculated to be: %f", m_speedMod[RUN]); + break; + case SWIM: + m_speedMod[SWIM] = m_target->m_swimSpeed * QUICKCALC; + break; + + case MOUNT: + m_speedMod[MOUNT] = m_target->m_mountSpeed * QUICKCALC; + //sLog.outString("Spell Mod MOUNT calculated to be: %f", m_speedMod[MOUNT]); + break; + + case FLY: + m_speedMod[FLY] = m_target->m_flySpeed * QUICKCALC; + break; + } + + if(type == ALL) // Mehhhh + { + CalcSpeedMod(RUN); + CalcSpeedMod(FLY); + CalcSpeedMod(MOUNT); + CalcSpeedMod(SWIM); + } +} + Unit* Aura::GetUnitCaster() { if( !m_target ) @@ -467,7 +500,7 @@ m_target->m_auras[m_auraSlot] = NULL; - if( GetSpellProto()->SpellGroupType && m_target->GetTypeId() == TYPEID_PLAYER ) + /*if( GetSpellProto()->SpellGroupType && m_target->GetTypeId() == TYPEID_PLAYER ) { int32 speedmod = 0; SM_FIValue( m_target->SM_FSpeedMod, &speedmod, m_spellProto->SpellGroupType ); @@ -476,7 +509,7 @@ m_target->m_speedModifier -= speedmod; m_target->UpdateSpeed(); } - } + }*/ // remove attacker Unit* caster = GetUnitCaster(); @@ -3369,11 +3402,14 @@ void Aura::SpellAuraModIncreaseSpeed(bool apply) { if(apply) - m_target->m_speedModifier += mod->m_amount; + { + CalcSpeedMod(RUN); + m_target->UpdateSpeedFromAura(this, RUN, true); + } else - m_target->m_speedModifier -= mod->m_amount; - - m_target->UpdateSpeed(); + { + m_target->UpdateSpeedFromAura(this, RUN, false); + } } void Aura::SpellAuraModIncreaseMountedSpeed(bool apply) @@ -3381,11 +3417,12 @@ if(apply) { SetPositive(); - m_target->m_mountedspeedModifier += mod->m_amount; + CalcSpeedMod(MOUNT); + m_target->UpdateSpeedFromAura(this, MOUNT, true); } else - m_target->m_mountedspeedModifier -= mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, MOUNT, false); + } void Aura::SpellAuraModCreatureRangedAttackPower(bool apply) @@ -3415,48 +3452,21 @@ void Aura::SpellAuraModDecreaseSpeed(bool apply) { - //there can not be 2 slow downs only most powerfull is applied if(apply) { - switch(m_spellProto->NameHash) - { - case 0x1931b37a: // Stealth - SetPositive(); - break; - - case 0x25dab9ca: // Dazed - SetNegative(); - break; - - default: - /* burlex: this would be better as a if(caster is hostile to target) then effect = negative) */ - if(m_casterGuid != m_target->GetGUID()) - SetNegative(); - break; - } - - //let's check Mage talents if we proc anythig - if(m_spellProto->School==SCHOOL_FROST) - { - Unit *caster=GetUnitCaster(); - //yes we are freezing the bastard, so can we proc anything on this ? - if(caster && caster->IsPlayer() && m_target) - static_cast< Player* >(caster)->EventStunOrImmobilize(m_target); - } - m_target->speedReductionMap.insert(make_pair(m_spellProto->Id, mod->m_amount)); - //m_target->m_slowdown=this; - //m_target->m_speedModifier += mod->m_amount; + CalcSpeedMod(RUN); + CalcSpeedMod(FLY); + CalcSpeedMod(MOUNT); + m_target->UpdateSpeedFromAura(this, RUN, true); + m_target->UpdateSpeedFromAura(this, FLY, true); + m_target->UpdateSpeedFromAura(this, MOUNT, true); } else { - map< uint32, int32 >::iterator itr = m_target->speedReductionMap.find(m_spellProto->Id); - if(itr != m_target->speedReductionMap.end()) - m_target->speedReductionMap.erase(itr); - //m_target->m_speedModifier -= mod->m_amount; - //m_target->m_slowdown=NULL; + m_target->UpdateSpeedFromAura(this, RUN, false); + m_target->UpdateSpeedFromAura(this, FLY, false); + m_target->UpdateSpeedFromAura(this, MOUNT, false); } - if(m_target->GetSpeedDecrease()) - m_target->UpdateSpeed(); } @@ -4534,19 +4544,12 @@ { if(apply) { + CalcSpeedMod(SWIM); if(m_target->isAlive()) SetPositive(); - m_target->m_swimSpeed = 0.04722222f*(100+mod->m_amount); + m_target->UpdateSpeedFromAura(this, SWIM, true); } else - m_target->m_swimSpeed = PLAYER_NORMAL_SWIM_SPEED; - if(m_target->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(SMSG_FORCE_SWIM_SPEED_CHANGE, 17); - data << m_target->GetNewGUID(); - data << (uint32)2; - data << m_target->m_swimSpeed; - static_cast< Player* >( m_target )->GetSession()->SendPacket(&data); - } + m_target->UpdateSpeedFromAura(this, SWIM, false); } void Aura::SpellAuraModCratureDmgDone(bool apply) @@ -6297,13 +6300,12 @@ { if(apply) { + CalcSpeedMod(RUN); SetPositive(); - m_target->m_speedModifier += mod->m_amount; + m_target->UpdateSpeedFromAura(this, RUN, true); } else - m_target->m_speedModifier -= mod->m_amount; - - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, RUN, false); } void Aura::SpellAuraModIncreaseEnergyPerc( bool apply ) @@ -6895,13 +6897,13 @@ { if(apply) { - m_target->m_speedModifier += mod->m_amount; + CalcSpeedMod(RUN); + m_target->UpdateSpeedFromAura(this, RUN, true); } else { - m_target->m_speedModifier -= mod->m_amount; + m_target->UpdateSpeedFromAura(this, RUN, false); } - m_target->UpdateSpeed(); } } @@ -7514,9 +7516,9 @@ { if(apply) { + CalcSpeedMod(FLY); m_target->EnableFlight(); - m_target->m_flyspeedModifier += mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, FLY, true); if(m_target->IsPlayer()) { static_cast< Player* >( m_target )->flying_aura = m_spellProto->Id; @@ -7525,8 +7527,7 @@ else { m_target->DisableFlight(); - m_target->m_flyspeedModifier -= mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, FLY, false); if(m_target->IsPlayer()) { static_cast< Player* >( m_target )->flying_aura = 0; @@ -7539,9 +7540,9 @@ // Used in flight form (only so far) if(apply) { + CalcSpeedMod(FLY); m_target->EnableFlight(); - m_target->m_flyspeedModifier += mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, FLY, true); if(m_target->IsPlayer()) { static_cast< Player* >( m_target )->flying_aura = m_spellProto->Id; @@ -7550,8 +7551,7 @@ else { m_target->DisableFlight(); - m_target->m_flyspeedModifier -= mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, FLY, false); if(m_target->IsPlayer()) { static_cast< Player* >( m_target )->flying_aura = 0; @@ -7562,19 +7562,28 @@ void Aura::SpellAuraIncreaseMovementAndMountedSpeed( bool apply ) { if( apply ) - m_target->m_mountedspeedModifier += mod->m_amount; + { + CalcSpeedMod(FLY); + CalcSpeedMod(MOUNT); + m_target->UpdateSpeedFromAura(this, RUN, true); + m_target->UpdateSpeedFromAura(this, MOUNT, true); + } else - m_target->m_mountedspeedModifier -= mod->m_amount; - m_target->UpdateSpeed(); + { + m_target->UpdateSpeedFromAura(this, RUN, false); + m_target->UpdateSpeedFromAura(this, MOUNT, false); + } } void Aura::SpellAuraIncreaseFlightSpeed( bool apply ) { if( apply ) - m_target->m_flyspeedModifier += mod->m_amount; + { + CalcSpeedMod(FLY); + m_target->UpdateSpeedFromAura(this, FLY, true); + } else - m_target->m_flyspeedModifier -= mod->m_amount; - m_target->UpdateSpeed(); + m_target->UpdateSpeedFromAura(this, FLY, false); } Index: src/ascent-world/SpellAuras.h =================================================================== --- src/ascent-world/SpellAuras.h (revision 4541) +++ src/ascent-world/SpellAuras.h (working copy) @@ -651,6 +651,9 @@ uint8 m_visualSlot; uint32 pSpellId; //this represents the triggering spell id + float m_speedMod[NUM_SPEEDS]; + void CalcSpeedMod(uint32 type); + // this stuff can be cached in spellproto. ASCENT_INLINE bool IsCombatStateAffecting() { Index: src/ascent-world/Unit.cpp =================================================================== --- src/ascent-world/Unit.cpp (revision 4541) +++ src/ascent-world/Unit.cpp (working copy) @@ -4566,33 +4566,37 @@ } } -void Unit::UpdateSpeed() +void Unit::UpdateSpeedFromAura(Aura * pAura, uint32 speedType, bool apply) { - if(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID) == 0) + float mod = pAura->m_speedMod[speedType]; + if(!apply) + mod = -mod; + + //sLog.outString("UpdateSpeedFromAura(Aura, %u, %s) mod = %f", speedType, (apply) ? "true" : "false", mod); + if(IsPlayer()) { - if(IsPlayer()) - m_runSpeed = m_base_runSpeed*(1.0f + ((float)m_speedModifier)/100.0f); - else - m_runSpeed = m_base_runSpeed*(1.0f + ((float)m_speedModifier)/100.0f); + static_cast(this)->AddPlayerSpeed(speedType, mod); + return; } - else + + switch(speedType) { - if(IsPlayer()) - { - m_runSpeed = m_base_runSpeed*(1.0f + ((float)m_mountedspeedModifier)/100.0f); - m_runSpeed += (m_speedModifier<0) ? (m_base_runSpeed*((float)m_speedModifier)/100.0f) : 0; - } - else - { - m_runSpeed = m_base_runSpeed*(1.0f + ((float)m_mountedspeedModifier)/100.0f); - m_runSpeed += (m_speedModifier<0) ? (m_base_runSpeed*((float)m_speedModifier)/100.0f) : 0; - } + case RUN: + m_runSpeed += mod; + break; + case SWIM: + m_swimSpeed += mod; + break; + case FLY: + m_flySpeed += mod; + break; + case MOUNT: + m_mountSpeed += mod; } +} - - - m_flySpeed = PLAYER_NORMAL_FLIGHT_SPEED*(1.0f + ((float)m_flyspeedModifier)/100.0f); - +void Unit::UpdateSpeed() +{ // Limit speed due to effects such as http://www.wowhead.com/?spell=31896 [Judgement of Justice] if( m_maxSpeed && m_runSpeed > m_maxSpeed ) { Index: src/ascent-world/Unit.h =================================================================== --- src/ascent-world/Unit.h (revision 4541) +++ src/ascent-world/Unit.h (working copy) @@ -1020,6 +1020,7 @@ bool GetSpeedDecrease(); int32 m_mountedspeedModifier; int32 m_flyspeedModifier; + void UpdateSpeedFromAura(Aura * pAura, uint32 speedType, bool apply); void UpdateSpeed(); void EnableFlight(); void DisableFlight();