diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index ed493d5..db851f9 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -747,6 +747,20 @@ void Human::DoSkill() { recover_hp_frameno_ = room->frame_no; a8::SetBitFlag(status, HS_RecoverHP); + room->xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE, + a8::XParams() + .SetSender(this) + .SetParam1(skill_meta->i->value1()), + [] (const a8::XParams& param) + { + Human* hum = (Human*)param.sender.GetUserData(); + if (a8::HasBitFlag(hum->status, HS_RecoverHP)) { + hum->RecoverHp(param.param1); + hum->need_sync_active_player = true; + } + }, + &skill_xtimer_attacher_.timer_list_ + ); room->xtimer.AddDeadLineTimerAndAttach(skill_meta->i->last_time() * SERVER_FRAME_RATE, a8::XParams() .SetSender(this), @@ -1091,3 +1105,11 @@ int Human::GetVolume(int slot_id) } return volume_[slot_id]; } + +void Human::RecoverHp(int inc_hp) +{ + if (!dead) { + health += inc_hp; + health = std::max(health, GetMaxHP()); + } +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index f2fa5ce..8d02adc 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -148,6 +148,7 @@ class Human : public Entity void AddInventory(int slot_id, int num); void DecInventory(int slot_id, int num); int GetVolume(int slot_id); + void RecoverHp(int inc_hp); protected: long long last_shot_frameno_ = 0; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 6d86807..c5ca1d3 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -637,6 +637,12 @@ void Player::LootInteraction(Loot* entity) room->DropItem(pos, skin, 1); } skin = entity->item_id; + skin_meta = MetaMgr::Instance()->GetDress(skin); + if (skin_meta) { + skill_meta = MetaMgr::Instance()->GetSkill(skin_meta->i->skill_id()); + } else { + skill_meta = nullptr; + } SyncAroundPlayers(); } break;