mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[9212] Implement pet speed synchronization with owner only for follow mode.
* This allow pet use own speed (and all speed affects appiedto pet itself) in combat. * Apply this speed synhronization to minipets/guardians also. * Also rename Unit::SetSpeed to SetSpeedRate as more close to real functionality.
This commit is contained in:
parent
a6a5935406
commit
eaecc467d5
8 changed files with 73 additions and 22 deletions
|
|
@ -8400,7 +8400,7 @@ void Unit::SetPet(Pet* pet)
|
|||
// FIXME: hack, speed must be set only at follow
|
||||
if(pet && GetTypeId()==TYPEID_PLAYER)
|
||||
for(int i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||
pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
|
||||
pet->SetSpeedRate(UnitMoveType(i), m_speed_rate[i], true);
|
||||
}
|
||||
|
||||
void Unit::SetCharm(Unit* pet)
|
||||
|
|
@ -10428,6 +10428,23 @@ void Unit::UpdateWalkMode(Unit* source, bool self)
|
|||
|
||||
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
{
|
||||
// not in combat pet have same speed as owner
|
||||
switch(mtype)
|
||||
{
|
||||
case MOVE_RUN:
|
||||
case MOVE_WALK:
|
||||
case MOVE_SWIM:
|
||||
if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
||||
{
|
||||
if(Unit* owner = GetOwner())
|
||||
{
|
||||
SetSpeedRate(mtype,owner->GetSpeedRate(mtype),forced);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int32 main_speed_mod = 0;
|
||||
float stack_bonus = 1.0f;
|
||||
float non_stack_bonus = 1.0f;
|
||||
|
|
@ -10519,7 +10536,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
|||
if (speed < min_speed)
|
||||
speed = min_speed;
|
||||
}
|
||||
SetSpeed(mtype, speed, forced);
|
||||
SetSpeedRate(mtype, speed, forced);
|
||||
}
|
||||
|
||||
float Unit::GetSpeed( UnitMoveType mtype ) const
|
||||
|
|
@ -10527,7 +10544,15 @@ float Unit::GetSpeed( UnitMoveType mtype ) const
|
|||
return m_speed_rate[mtype]*baseMoveSpeed[mtype];
|
||||
}
|
||||
|
||||
void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
|
||||
struct SetSpeedRateHelper
|
||||
{
|
||||
explicit SetSpeedRateHelper(UnitMoveType _mtype, bool _forced) : mtype(_mtype), forced(_forced) {}
|
||||
void operator()(Unit* unit) const { unit->UpdateSpeed(mtype,forced); }
|
||||
UnitMoveType mtype;
|
||||
bool forced;
|
||||
};
|
||||
|
||||
void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced)
|
||||
{
|
||||
if (rate < 0)
|
||||
rate = 0.0f;
|
||||
|
|
@ -10573,7 +10598,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
|
|||
data.Initialize(MSG_MOVE_SET_PITCH_RATE, 8+4+2+4+4+4+4+4+4+4);
|
||||
break;
|
||||
default:
|
||||
sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype);
|
||||
sLog.outError("Unit::SetSpeedRate: Unsupported move type (%d), data not sent to client.",mtype);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -10628,7 +10653,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
|
|||
data.Initialize(SMSG_FORCE_PITCH_RATE_CHANGE, 16);
|
||||
break;
|
||||
default:
|
||||
sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype);
|
||||
sLog.outError("Unit::SetSpeedRate: Unsupported move type (%d), data not sent to client.",mtype);
|
||||
return;
|
||||
}
|
||||
data.append(GetPackGUID());
|
||||
|
|
@ -10638,8 +10663,11 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
|
|||
data << float(GetSpeed(mtype));
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
if(Pet* pet = GetPet())
|
||||
pet->SetSpeed(MOVE_RUN, m_speed_rate[mtype],forced);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER) // need include minpet
|
||||
((Player*)this)->CallForAllControlledUnits(SetSpeedRateHelper(mtype,forced),false,true,true,true);
|
||||
else
|
||||
CallForAllControlledUnits(SetSpeedRateHelper(mtype,forced),false,true,true);
|
||||
}
|
||||
|
||||
void Unit::SetHover(bool on)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue