修复宝石掉落问题

This commit is contained in:
aozhiwei 2023-04-11 15:01:34 +08:00
parent 54662c4ec2
commit 693c707bb3
3 changed files with 37 additions and 7 deletions

View File

@ -376,6 +376,7 @@ private:
protected: protected:
bool need_sync_active_player_ = false; bool need_sync_active_player_ = false;
std::list<std::any> on_dead_remove_objects_;
ActionType_e action_type = AT_None; ActionType_e action_type = AT_None;
int action_duration = 0; int action_duration = 0;

View File

@ -1239,7 +1239,7 @@ void Human::DeadDrop()
} }
} }
{ {
if (GetInventory(IS_GEMSTONE) > 0) { if (GetInventory(IS_GEMSTONE) > 0 && gemstone > 0) {
room->frame_event.AddPropChg room->frame_event.AddPropChg
( (
GetWeakPtrRef(), GetWeakPtrRef(),
@ -1248,15 +1248,21 @@ void Human::DeadDrop()
0, 0,
false); false);
#if 0 const mt::Equip* gem_stone_meta = mt::Equip::GetGemStone();
SetMaxHP(GetMaxHP() + dto.item_meta->_max_hp * GetBattleContext()->GetMaxHP()); if (gem_stone_meta) {
#endif Position drop_pos = GetPos();
room->DropItem(drop_pos.ToGlmVec3(), gem_stone_meta->id(), gemstone, 1);
}
SetMaxHP(GetBattleContext()->GetMaxHP());
gemstone = 0; gemstone = 0;
DecInventory(IS_GEMSTONE, GetInventory(IS_GEMSTONE)); DecInventory(IS_GEMSTONE, GetInventory(IS_GEMSTONE));
SyncVolume(IS_GEMSTONE); SyncVolume(IS_GEMSTONE);
} }
} }
{
on_dead_remove_objects_.clear();
}
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
@ -3218,7 +3224,26 @@ void Human::ProcGemStoneItem(AddItemDTO& dto)
0, 0,
gemstone, gemstone,
false); false);
GetAbility()->AddAttrRate(kHAT_Atk, dto.item_meta->_atk);
auto context = A8_MAKE_SMART_ANON_STRUCT_SHARED
(
CreatureWeakPtr owner;
AttrRateHandle handle;
);
context->owner = GetWeakPtrRef();
context->_destory_cb =
[context = context.get()] ()
{
if (context->owner.Get() &&
context->owner.Get()->room->IsDestorying() &&
!context->handle.expired()
) {
context->owner.Get()->GetAbility()->RemoveAttrRate(context->handle);
}
};
context->handle = GetAbility()->AddAttrRate(kHAT_Atk, dto.item_meta->_atk);
on_dead_remove_objects_.push_back(context);
SetMaxHP(GetMaxHP() + dto.item_meta->_max_hp * GetBattleContext()->GetMaxHP()); SetMaxHP(GetMaxHP() + dto.item_meta->_max_hp * GetBattleContext()->GetMaxHP());
SetHP(GetHP() + dto.item_meta->_max_hp * GetBattleContext()->GetMaxHP()); SetHP(GetHP() + dto.item_meta->_max_hp * GetBattleContext()->GetMaxHP());
room->frame_event.AddPropChg room->frame_event.AddPropChg

View File

@ -510,7 +510,11 @@ void Room::DropItem(const glm::vec3& pos, int item_id, int item_count, int item_
void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_id, int item_count, int item_lv, bool show_anim) void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_id, int item_count, int item_lv, bool show_anim)
{ {
const mt::Equip* equip_meta = mt::Equip::GetById(item_id); const mt::Equip* equip_meta = mt::Equip::GetById(item_id);
if (equip_meta && equip_meta->group_num() > 0 && item_count > 0) { int group_num = equip_meta->group_num();
if (item_id == mt::Equip::GEMSTONE_ID && group_num <= 0) {
group_num = 1;
}
if (equip_meta && group_num > 0 && item_count > 0) {
#if 1 #if 1
if (equip_meta->equip_type() == EQUIP_TYPE_BULLET) { if (equip_meta->equip_type() == EQUIP_TYPE_BULLET) {
return; return;
@ -518,7 +522,7 @@ void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_
#endif #endif
int total_count = item_count; int total_count = item_count;
while (total_count > 0) { while (total_count > 0) {
int drop_num = std::min(total_count, equip_meta->group_num()); int drop_num = std::min(total_count, group_num);
if (drop_num < 1) { if (drop_num < 1) {
drop_num = 1; drop_num = 1;
} }