This commit is contained in:
aozhiwei 2024-04-01 20:35:57 +08:00
parent a838ac6408
commit 7ed5aa8fa7

View File

@ -332,13 +332,14 @@ void Hero::DecHP(float dec_hp, int killer_id, const std::string killer_name, int
void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id) void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
{ {
std::vector<int> items;
dead = true; dead = true;
if (meta->HasDrop() && !room->IsPveRoom()) { if (meta->HasDrop() && !room->IsPveRoom()) {
room->ScatterDrop(GetPos().ToGlmVec3(), meta->RandDrop()); room->ScatterDrop(GetPos().ToGlmVec3(), meta->RandDrop(), false, &items);
} }
if (!room->IsPveRoom()) { if (!room->IsPveRoom()) {
for (int id : meta->_drop_list) { for (int id : meta->_drop_list) {
room->ScatterDrop(GetPos().ToGlmVec3(), id); room->ScatterDrop(GetPos().ToGlmVec3(), id, false, &items);
} }
} }
room->frame_event.AddDead(GetWeakPtrRef(), 0); room->frame_event.AddDead(GetWeakPtrRef(), 0);
@ -370,23 +371,38 @@ void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
AllocDeadExp(killer_id); AllocDeadExp(killer_id);
GetTrigger()->Die(killer_id, weapon_id); GetTrigger()->Die(killer_id, weapon_id);
if (room->IsMobaModeRoom() && !room->IsGameOver()) { if (room->IsMobaModeRoom() && !room->IsGameOver()) {
int revive_time = room->GetMapMeta()->GetMobaRoomMeta()->GetMonsterReviveTime(GetHeroMeta()->id()); {
if (revive_time >= 0) { int revive_time = room->GetMapMeta()->GetMobaRoomMeta()->GetMonsterReviveTime(GetHeroMeta()->id());
room->xtimer.SetTimeoutEx if (revive_time >= 0) {
(revive_time * SERVER_FRAME_RATE, room->xtimer.SetTimeoutEx
[room = room, hero_meta = GetHeroMeta(), pos = src_pos] (int event, const a8::Args* args) (revive_time * SERVER_FRAME_RATE,
{ [room = room, hero_meta = GetHeroMeta(), pos = src_pos] (int event, const a8::Args* args)
if (a8::TIMER_EXEC_EVENT == event) { {
Hero* hero = room->CreateHero if (a8::TIMER_EXEC_EVENT == event) {
(nullptr, Hero* hero = room->CreateHero
hero_meta, (nullptr,
pos, hero_meta,
GlmHelper::UP, pos,
666, GlmHelper::UP,
0); 666,
} 0);
}, }
&room->xtimer_attacher_); },
&room->xtimer_attacher_);
}
}
{
int life_time = room->GetMapMeta()->GetMobaRoomMeta()->GetMonsterLootLifeTime(GetHeroMeta()->id());
if (life_time >= 0) {
room->xtimer.SetTimeoutEx
(life_time * SERVER_FRAME_RATE,
[room = room, items] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
}
},
&room->xtimer_attacher_);
}
} }
} }
} }