修复rpg问题

This commit is contained in:
aozhiwei 2021-05-17 19:54:11 +08:00
parent e250768911
commit b97746dd84
3 changed files with 21 additions and 2 deletions

View File

@ -259,7 +259,7 @@ void Bullet::Check(float distance)
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
}
if (!objects.empty() || distance > bullet_range ||
(IsBomb() && distance >= fly_distance)
(IsBomb() && meta->i->_inventory_slot() != IS_RPG && distance >= fly_distance)
) {
if (IsBomb()) {
ProcBomb();

View File

@ -275,5 +275,23 @@ void Hero::DetachFromMaster()
void Hero::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
{
if (dec_hp < 0.001f) {
return;
}
float old_health = GetHP();
float new_health = std::max(0.0f, GetHP() - dec_hp);
ability.hp = std::max(0.0f, new_health);
if (GetHP() <= 0.0001f && !IsDead(room)) {
BeKill(killer_id, killer_name, weapon_id);
}
room->frame_event.AddHpChg(GetWeakPtrRef());
}
void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
{
dead = true;
BroadcastDeleteState(room);
RemoveFromAroundPlayers(room);
room->grid_service->RemoveCreature(this);
room->RemoveObjectLater(this);
}

View File

@ -43,6 +43,7 @@ protected:
void InternalUpdateMove(float speed);
bool IsCollisionInMapService();
virtual void RecalcSelfCollider() override;
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
private:
bool later_removed_ = false;