This commit is contained in:
aozhiwei 2024-08-23 14:42:02 +08:00
parent bc6ffe3eec
commit b366492f0e
4 changed files with 33 additions and 0 deletions

View File

@ -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) {

View File

@ -3,6 +3,7 @@
class Room;
class Hero;
class Obstacle;
class Human;
class BoxDrop : public std::enable_shared_from_this<BoxDrop>
{
@ -14,6 +15,7 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
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);

View File

@ -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();
}

View File

@ -520,6 +520,9 @@ void Trigger::RemoveEventHandlers(std::vector<std::weak_ptr<EventHandler>> handl
}
}
/*
!!!
*/
void Trigger::DispatchEvent(int event_id, const std::vector<std::any>& param)
{
auto itr = listeners_hash_.find(event_id);