From b366492f0e4dd7b3b1c412fdc7f4ff23d3661021 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 14:42:02 +0800 Subject: [PATCH] 1 --- server/gameserver/boxdrop.cc | 26 ++++++++++++++++++++++++++ server/gameserver/boxdrop.h | 2 ++ server/gameserver/human.cc | 2 ++ server/gameserver/trigger.cc | 3 +++ 4 files changed, 33 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 63649c05..97f993e1 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -16,10 +16,13 @@ #include "jsondatamgr.h" #include "player.h" #include "mapinstance.h" +#include "human.h" +#include "stats.h" #include "mt/MapMode.h" #include "mt/Hero.h" #include "mt/MapThing.h" +#include "mt/Param.h" const int BOX_ID = 150001; @@ -53,6 +56,29 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) } } +void BoxDrop::OnHumanDeadDrop(Human* hum) +{ + if (hum->box_num <= 0) { + return; + } + if (room_->IsGameOver()) { + return; + } + if (room_->GetVictoryTeam()) { + return; + } + int rnd = a8::RandEx(0, 100); + if (hum->stats->abandon_battle) { + if (rnd <= mt::Param::s().battle_event_end_loss_rate_quit * 100) { + Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + } + } else { + if (rnd <= mt::Param::s().battle_event_end_loss_rate_dead * 100) { + Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + } + } +} + void BoxDrop::Drop(int num, const glm::vec3& center) { for (int i = 0; i < num; ++i) { diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 5d0477a6..2ce4d118 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -3,6 +3,7 @@ class Room; class Hero; class Obstacle; +class Human; class BoxDrop : public std::enable_shared_from_this { @@ -14,6 +15,7 @@ class BoxDrop : public std::enable_shared_from_this void OnBattleStart(); void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); + void OnHumanDeadDrop(Human* hum); void RequestReturnBoxNum(); bool GetNextBoxPos(glm::vec3& pos); void DropByUuid(int obj_uniid, const glm::vec3& center); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 07231b03..dc1bcbe2 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -44,6 +44,7 @@ #include "hero.h" #include "bornpoint.h" #include "ingamevoice.h" +#include "boxdrop.h" #include "buff/sprint.h" @@ -3252,6 +3253,7 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we } room->GetInGameVoice()->OnHumanBeKill(real_killer_id, this); } + room->GetBoxDrop()->OnHumanDeadDrop(this); SendViewerUiMemberUpdate({GetUniId(), killer_id, real_killer_id}); room->NotifyUiUpdate(); } diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index 7f0b5e8c..5c456048 100644 --- a/server/gameserver/trigger.cc +++ b/server/gameserver/trigger.cc @@ -520,6 +520,9 @@ void Trigger::RemoveEventHandlers(std::vector> handl } } +/* + !!! + */ void Trigger::DispatchEvent(int event_id, const std::vector& param) { auto itr = listeners_hash_.find(event_id);