This commit is contained in:
aozhiwei 2023-03-27 17:56:30 +08:00
parent 9b3fd2f6c3
commit c442a0e563
6 changed files with 75 additions and 74 deletions

View File

@ -3062,5 +3062,76 @@ float Creature::GetSpeed()
const float min_speed = 30.0f;
const float base_speed = GetHeroMeta()->move_speed();
float finaly_speed = base_speed;
const float ONE_LIMIT = 0.99999f;
/*
kBET_HoldShield
kBET_BePull
{
Buff* buff = GetBuffByEffectId(kBET_BePull);
if (buff) {
return buff->meta->_buff_param2;
}
}
if (GetAbility()->GetFixedSpeedTimes() > 0) {
return GetAbility()->GetFixedSped();
}
*/
if (HasBuffEffect(kBET_Jump)) {
finaly_speed = GetHeroMeta()->jump_speed();
} else if (HasBuffEffect(kBET_Down)) {
finaly_speed = GetHeroMeta()->fall_speed();
} else {
float addition = 0.0f;
float ruduce = 0.0f;
if (aiming) {
if (GetHeroMeta()->fall_speed() > ONE_LIMIT) {
addition += GetHeroMeta()->fall_speed();
} else {
ruduce += GetHeroMeta()->fall_speed();
}
} else if (action_type == AT_Reload) {
if (GetHeroMeta()->reload_speed() > ONE_LIMIT) {
addition += GetHeroMeta()->reload_speed();
} else {
ruduce += GetHeroMeta()->reload_speed();
}
} else if (action_type == AT_UseItem) {
if (GetHeroMeta()->medicine_speed() > ONE_LIMIT) {
addition += GetHeroMeta()->medicine_speed();
} else {
ruduce += GetHeroMeta()->medicine_speed();
}
} else if (HasBuffEffect(kBET_InWater)) {
if (GetHeroMeta()->medicine_speed() > ONE_LIMIT) {
addition += GetHeroMeta()->medicine_speed();
} else {
ruduce += GetHeroMeta()->medicine_speed();
}
} else if (shot_hold &&
(
GetCurrWeapon()->weapon_idx == GUN_SLOT1 ||
GetCurrWeapon()->weapon_idx == GUN_SLOT2
)) {
if (GetHeroMeta()->shoot_speed() > ONE_LIMIT) {
addition += GetHeroMeta()->shoot_speed();
} else {
ruduce += GetHeroMeta()->shoot_speed();
}
}
if (addition > ONE_LIMIT) {
addition = addition - ONE_LIMIT;
}
if (ruduce > 0.00001f) {
ruduce = 1.0f - ruduce;
}
addition += GetAbility()->GetAttrAddition(kHAT_Speed);
ruduce = std::max(ruduce, GetAbility()->GetAttrRuduce(kHAT_Speed));
float rate = addition - ruduce;
finaly_speed *= 1.0f + rate;
}
return std::max(min_speed, finaly_speed) / SERVER_FRAME_RATE;
}

View File

@ -113,6 +113,8 @@ class Creature : public MoveableEntity
int shield_max_hp_ = 0;
int gemstone = 0;
bool shot_start = false;
bool shot_hold = false;
Creature();
virtual ~Creature() override;

View File

@ -14,7 +14,6 @@ class Hero : public Creature
public:
CreatureWeakPtr master;
const mt::Hero* meta = nullptr;
bool shot_hold = false;
bool is_pve_boss = false;
Hero();

View File

@ -106,77 +106,6 @@ void Human::Initialize()
float Human::GetSpeed()
{
return Creature::GetSpeed();
#if 0
{
Buff* buff = GetBuffByEffectId(kBET_HoldShield);
if (buff) {
return buff->meta->_buff_param6 / SERVER_FRAME_RATE;
}
}
{
Buff* buff = GetBuffByEffectId(kBET_Jump);
if (buff) {
return meta->jump_speed();
}
}
{
Buff* buff = GetBuffByEffectId(kBET_BePull);
if (buff) {
return buff->meta->_buff_param2;
}
}
if (GetAbility()->GetFixedSpeedTimes() > 0) {
return GetAbility()->GetFixedSped();
}
float speed = 1.0;
if (downed) {
speed = meta->move_speed3();
} else {
if (shot_hold) {
if (GetCurrWeapon()->weapon_idx == GUN_SLOT1 ||
GetCurrWeapon()->weapon_idx == GUN_SLOT2) {
if (action_type != AT_Reload) {
speed = meta->shot_speed() * (1 + GetAbility()->GetAttrRate(kHAT_ShotSpeed));
if (HasBuffEffect(kBET_InWater)) {
speed *= mt::Param::s().water_move_coefficient;
}
return speed;
}
}
} else if (aiming) {
speed = std::max(1, meta->aiming_speed());
if (HasBuffEffect(kBET_InWater)) {
speed *= mt::Param::s().water_move_coefficient;
}
return speed;
} else if (action_type == AT_Reload) {
speed = std::max(1, meta->reload_speed());
if (HasBuffEffect(kBET_InWater)) {
speed *= mt::Param::s().water_move_coefficient;
}
return speed;
} else if (action_type == AT_UseItem) {
speed = std::max(1, meta->useitem_speed());
if (HasBuffEffect(kBET_InWater)) {
speed *= mt::Param::s().water_move_coefficient;
}
return speed;
}
speed = meta->move_speed();
}
float old_speed = speed;
#if 1
speed = (speed * SERVER_FRAME_RATE *
(1 + GetAbility()->GetSpeedAddition() - GetAbility()->GetSpeedRuduce())) / SERVER_FRAME_RATE;
#else
speed = (speed + GetAbility()->GetAttrAbs(kHAT_Speed)) *
(1 + GetAbility()->GetAttrRate(kHAT_Speed));
#endif
if (HasBuffEffect(kBET_InWater)) {
speed *= mt::Param::s().water_move_coefficient;
}
return std::max(speed, 1.0f);
#endif
}
bool Human::IsDead(Room * room)

View File

@ -114,8 +114,6 @@ class Human : public Creature
std::set<Human*> kill_humans;
std::shared_ptr<BornPoint> born_point = nullptr;
bool shot_start = false;
bool shot_hold = false;
a8::XTimerWp shot_hold_timer;
int series_shot_frames = 0;
float fly_distance = 0.0f;

View File

@ -87,12 +87,14 @@ namespace mt
}
}
{
#if 0
if (jump_speed() < 0.0001f) {
jump_speed_ = 1.0f;
}
if (fall_speed() < 0.0001f) {
fall_speed_ = 1.0f;
}
#endif
if (aim_speed() < 0.0001f) {
aim_speed_ = 1.0f;
}