diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index d242ec4..33c76b8 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -215,6 +215,8 @@ enum VirtualWeapon_e enum VirtualPlayer_e { VP_Gas = 9000000, + VP_Buff = 9000001, + VP_Explosion = 9000002, }; enum EquipType_e diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 62312f6..9e9ff47 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -162,7 +162,6 @@ class Creature : public MoveableEntity void ActiveAllSkill(); MetaData::SkillPhase* GetCurrSkillPhase(); bool CanSee(const Creature* c) const; - virtual std::string GetName() { return "";}; virtual void SendDebugMsg(const std::string& debug_msg); virtual void DropItems(Obstacle* obstacle) {}; bool IsPlayer() const; diff --git a/server/gameserver/entity.h b/server/gameserver/entity.h index 79d3f19..c54e388 100644 --- a/server/gameserver/entity.h +++ b/server/gameserver/entity.h @@ -52,6 +52,7 @@ class Entity virtual bool CanSeeMe(Human* hum) { return true; }; virtual bool Attackable(Room* room) { return false; }; virtual bool ReceiveExplosionDmg(Explosion* explosion) { return false; }; + virtual std::string GetName() { return "";}; int GetUniId() const { return uniid_; } EntityType_e GetEntityType() const { return entity_type_; } EntitySubType_e GetEntitySubType() const { return entity_subtype_; } diff --git a/server/gameserver/killmgr.cc b/server/gameserver/killmgr.cc index 99d6433..ef32a4c 100644 --- a/server/gameserver/killmgr.cc +++ b/server/gameserver/killmgr.cc @@ -27,45 +27,60 @@ void KillMgr::UnInit() */ void KillMgr::OnHumanDead(Human* dead_hum, KillInfo* info) { + RollMsgHintInfo hint_info; std::shared_ptr pb_msg = std::make_shared(); - Entity* killer = dead_hum->room->GetEntityByUniId(info->killer_id); - if (killer && killer->IsEntityType(ET_Player)) { - if (info->killer_id == dead_hum->GetUniId()) { - PreprocessRollMsg(pb_msg, - TEXT("battle_server_dead_specate", "%s 自杀").c_str(), - { - info->killer_name - }); - } else { - PreprocessRollMsg(pb_msg, - TEXT("battle_server_dead_weapon", "%s 使用 ${weapon_text_icon} 干掉了 %s").c_str(), - { - info->killer_name, - dead_hum->name - }); + FillHintInfo(dead_hum, info, hint_info); + PreprocessRollMsg(pb_msg, hint_info); + BoradcastRollMsg(dead_hum, info, 0, pb_msg); +} + +void KillMgr::FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hint_info) +{ + hint_info.dead_name = dead_hum->GetName(); + + switch (info->killer_id) { + case VP_Gas: + { + hint_info.killer_name = ""; + hint_info.template_name = "battle_server_dead_text_gas"; + hint_info.template_defval = "%s 被${weapon_text_icon}干掉"; } - } else { - Entity* root_master = dead_hum->room->GetEntityByUniId(info->root_master_id); - if (root_master && root_master->IsEntityType(ET_Player)) { + break; + case VP_Buff: + { + hint_info.killer_name = ""; + hint_info.template_name = "battle_server_dead_text_gas"; + hint_info.template_defval = "%s 被${weapon_text_icon}干掉"; } + break; + case VP_Explosion: + { + hint_info.killer_name = ""; + hint_info.template_name = "battle_server_dead_text_gas"; + hint_info.template_defval = "%s 被${weapon_text_icon}干掉"; + } + break; + default: + { + Entity* killer = dead_hum->room->GetEntityByUniId(info->killer_id); + if (killer) { + hint_info.killer_name = killer->GetName(); + if (info->killer_id == dead_hum->GetUniId()) { + hint_info.template_name = "battle_server_dead_text_specate"; + hint_info.template_defval = "${dead.name} 自杀"; + } else { + hint_info.template_name = "battle_server_dead_text_weapon"; + hint_info.template_defval = "${killer.name} 使用 ${weapon.text_icon} 干掉了 ${dead.name}"; + } + } else { + } + } + break; } - #if 0 - { -#if 0 - SendRollMsgEx - (info, - TEXT("battle_server_dead_gas", "%s 被${weapon_text_icon}干掉").c_str(), - { - name - }); -#endif - } - #endif } void KillMgr::PreprocessRollMsg(std::shared_ptr pb_msg, - const char* fmt, - std::initializer_list args) + RollMsgHintInfo& hint_info) { #if 0 cs::SMRollMsg *pb_msg = new cs::SMRollMsg; diff --git a/server/gameserver/killmgr.h b/server/gameserver/killmgr.h index 660878e..54f55c5 100644 --- a/server/gameserver/killmgr.h +++ b/server/gameserver/killmgr.h @@ -13,6 +13,17 @@ struct KillInfo int weapon_id = 0; }; +struct RollMsgHintInfo +{ + std::string master_name; + std::string killer_name; + std::string dead_name; + std::string weapon_text_icon; + + std::string template_name; + std::string template_defval; +}; + class Human; class KillMgr : public a8::Singleton { @@ -28,9 +39,9 @@ class KillMgr : public a8::Singleton void OnHumanDead(Human* dead_hum, KillInfo* info); private: + void FillHintInfo(Human* dead_hum, KillInfo* info, RollMsgHintInfo& hint_info); void PreprocessRollMsg(std::shared_ptr pb_msg, - const char* fmt, - std::initializer_list args); + RollMsgHintInfo& hint_info); void BoradcastRollMsg(Human* dead_hum, KillInfo* info, int killer_team_id,