diff --git a/server/gameserver/hero.cc b/server/gameserver/hero.cc index d1654422..3ea030b3 100644 --- a/server/gameserver/hero.cc +++ b/server/gameserver/hero.cc @@ -29,6 +29,7 @@ #include "mt/MapThing.h" #include "mt/BattleBasicAttribute.h" #include "mt/Map.h" +#include "mt/MobaRoom.h" Hero::Hero():Creature() { @@ -368,6 +369,27 @@ void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id) } AllocDeadExp(killer_id); GetTrigger()->Die(killer_id, weapon_id); + if (room->IsMobaModeRoom() && !room->IsGameOver()) { + int revive_time = room->GetMapMeta()->GetMobaRoomMeta()->GetMonsterReviveTime(GetHeroMeta()->id()); + if (revive_time >= 0) { + room->xtimer.SetTimeoutEx + (revive_time * SERVER_FRAME_RATE, + [room = room, hero_meta = GetHeroMeta(), pos = src_pos] (int event, const a8::Args* args) + { + glm::vec3 pos; + if (a8::TIMER_EXEC_EVENT == event) { + Hero* hero = room->CreateHero + (nullptr, + hero_meta, + pos, + GlmHelper::UP, + 666, + 0); + } + }, + &room->xtimer_attacher_); + } + } } void Hero::OnAddToTargetPartObject(Entity* target) diff --git a/server/gameserver/hero.h b/server/gameserver/hero.h index 3b97c888..c5a7bbbe 100644 --- a/server/gameserver/hero.h +++ b/server/gameserver/hero.h @@ -15,6 +15,7 @@ public: const mt::Hero* meta = nullptr; bool is_pve_boss = false; list_head entry; + glm::vec3 src_pos = glm::vec3(0.0f, 0.0f, 0.0f); Hero(); virtual ~Hero() override; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index b0c6caba..2ce6e0e0 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -868,6 +868,7 @@ Hero* Room::CreateHero(Creature* master, hero->master.Attach(master); } hero->room = this; + hero->src_pos = pos; hero->GetMutablePos().FromGlmVec3(pos); hero->SetMoveDir(dir); hero->SetAttackDir(dir);