死亡富文本

This commit is contained in:
aozhiwei 2021-05-31 17:13:08 +08:00
parent 66dc8027f1
commit ddf18e76f4
3 changed files with 29 additions and 13 deletions

View File

@ -760,7 +760,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
equip_meta->i->name(),
name
});
SendRollMsg(msg, killer->GetEntityUniId(), killer->team_id);
SendRollMsg(msg, killer->GetEntityUniId(), killer->team_id, weapon_id);
}
}
}
@ -1522,39 +1522,45 @@ void Human::SendDebugMsg(const std::string& debug_msg)
SendNotifyMsg(notify_msg);
}
void Human::SendRollMsg(const std::string& msg, int killer_id, bool killer_team_id)
void Human::SendRollMsg(const std::string& msg, int killer_id, bool killer_team_id, int weapon_id)
{
KillInfo* info = new KillInfo;
info->killer_id = killer_id;
info->killer_team_id = killer_team_id;
info->weapon_id = weapon_id;
info->msg = msg;
room->xtimer.AddDeadLineTimerAndAttach
(
0,
a8::XParams()
.SetSender(this)
.SetParam1(killer_id)
.SetParam2(killer_team_id)
.SetParam3(msg),
.SetParam1(info),
[] (const a8::XParams& param)
{
Human* target = (Human*)param.sender.GetUserData();
int killer_id = param.param1;
int killer_team_id = param.param2;
std::string text = param.param3.GetString();
KillInfo* info = (KillInfo*)param.param1.GetUserData();
target->room->TraversePlayerList
(a8::XParams(),
[target, killer_id, killer_team_id, text] (Human* hum, a8::XParams& param) -> bool
[target, info] (Human* hum, a8::XParams& param) -> bool
{
cs::SMRollMsg msg;
auto element = msg.add_elements();
element->set_element_type(1);
element->mutable_union_obj_1()->set_text(text);
if (killer_id == hum->GetEntityUniId()){
element->mutable_union_obj_1()->set_text(info->msg);
if (info->killer_id == hum->GetEntityUniId()){
element->mutable_union_obj_1()->set_color(MetaMgr::Instance()->self_kill_color);
} else if (killer_team_id == hum->team_id) {
} else if (info->killer_team_id == hum->team_id) {
element->mutable_union_obj_1()->set_color(MetaMgr::Instance()->teammate_kill_color);
} else if (target == hum) {
element->mutable_union_obj_1()->set_color(MetaMgr::Instance()->self_bekill_color);
} else if (target->team_id == hum->team_id) {
element->mutable_union_obj_1()->set_color(MetaMgr::Instance()->teammate_bekill_color);
}
if (info->weapon_id != 0) {
auto img_element = msg.add_elements();
img_element->set_element_type(2);
img_element->mutable_union_obj_2()->set_id(info->weapon_id);
}
hum->SendNotifyMsg(msg);
return true;
});
@ -1562,6 +1568,8 @@ void Human::SendRollMsg(const std::string& msg, int killer_id, bool killer_team_
&xtimer_attacher.timer_list_,
[] (const a8::XParams& param)
{
KillInfo* info = (KillInfo*)param.param1.GetUserData();
delete info;
}
);
}

View File

@ -211,7 +211,7 @@ class Human : public Creature
void SendGameOver();
void FollowTarget(Human* target);
virtual void SendDebugMsg(const std::string& debug_msg) override;
void SendRollMsg(const std::string& msg, int killer_id, bool killer_team_id);
void SendRollMsg(const std::string& msg, int killer_id, bool killer_team_id, int weapon_id = 0);
void UpdateAction();
void SendUIUpdate();
void SendWxVoip();

View File

@ -153,6 +153,14 @@ struct ObstacleData
DoorState_e door_state = DoorStateClose;
};
struct KillInfo
{
int killer_id = 0;
int killer_team_id = 0;
int weapon_id = 0;
std::string msg;
};
#pragma pack(1)
struct ObjectSyncFlags
{