From 537230305aa68ab0bbc53fbf36aa25969ebc9f65 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 2 Apr 2021 10:00:29 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 70 ++++++++++++++------------ server/gameserver/human.h | 2 +- server/gameserver/metamgr.cc | 1 + server/gameserver/metamgr.h | 1 + server/tools/protobuild/cs_proto.proto | 23 ++++++++- 5 files changed, 64 insertions(+), 33 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index b677d3a..4f6eecb 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -110,7 +110,7 @@ float Human::GetSpeed() float speed = meta->i->move_speed(); speed = (speed + GetBuffAttrAbs(kHAT_Speed)) * (1 + GetBuffAttrRate(kHAT_Speed)); if (a8::HasBitFlag(cell_flags_, kColliderTag_Water)) { - speed *= 0.5f; + speed *= MetaMgr::Instance()->water_move_coefficient; } return std::max(speed, 1.0f); } @@ -734,6 +734,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) room->CheckPartObjects(); #endif if (!dead && !room->IsGameOver() && !real_dead) { + cs::SMRollMsg roll_msg; lethal_weapon = weapon_id; Entity* hum = room->GetEntityByUniId(killer_id); if (hum && hum->IsEntityType(ET_Player)) { @@ -742,7 +743,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { killer_name, }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } else { ((Human*)hum)->stats.kills++; ((Human*)hum)->stats.last_kill_frameno = room->GetFrameNo(); @@ -754,7 +755,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) killer_name, name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } else { MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(weapon_id); if (equip_meta) { @@ -764,7 +765,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) equip_meta->i->name(), name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } } } @@ -776,7 +777,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } break; case VW_Spectate: @@ -785,7 +786,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } break; case VW_SelfDetonate: @@ -794,7 +795,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } break; case VW_Mine: @@ -803,7 +804,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { name }); - SendRollMsg(msg); + SendRollMsg(roll_msg); } break; } @@ -1502,30 +1503,37 @@ void Human::SendDebugMsg(const std::string& debug_msg) SendNotifyMsg(notify_msg); } -void Human::SendRollMsg(const std::string& roll_msg) +void Human::SendRollMsg(const cs::SMRollMsg& msg) { - room->xtimer.AddDeadLineTimerAndAttach( - 0, - a8::XParams() - .SetSender(this) - .SetParam1(roll_msg), - [] (const a8::XParams& param) - { - Human* target = (Human*)param.sender.GetUserData(); - std::string roll_msg = param.param1; - target->room->TouchHumanList(a8::XParams(), - [target, roll_msg] (Human* hum, a8::XParams& param) -> bool - { - if (target != hum) { - cs::SMRollMsg msg; - msg.set_msg(roll_msg); - hum->SendNotifyMsg(msg); - } - return true; - }); - }, - &xtimer_attacher.timer_list_ - ); + cs::SMRollMsg* msg_copy = new cs::SMRollMsg; + *msg_copy = msg; + room->xtimer.AddDeadLineTimerAndAttach + ( + 0, + a8::XParams() + .SetSender(this) + .SetParam1(msg_copy), + [] (const a8::XParams& param) + { + Human* target = (Human*)param.sender.GetUserData(); + cs::SMRollMsg* msg = (cs::SMRollMsg*)param.param1.GetUserData(); + target->room->TouchPlayerList + (a8::XParams(), + [target, msg] (Human* hum, a8::XParams& param) -> bool + { + if (target != hum) { + hum->SendNotifyMsg(*msg); + } + return true; + }); + }, + &xtimer_attacher.timer_list_, + [] (const a8::XParams& param) + { + cs::SMRollMsg* msg = (cs::SMRollMsg*)param.param1.GetUserData(); + delete msg; + } + ); } void Human::UpdateAction() diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 5e1acf4..0364645 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -199,7 +199,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& roll_msg); + void SendRollMsg(const cs::SMRollMsg& msg); void UpdateAction(); void SendUIUpdate(); void SendWxVoip(); diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index eebacc3..640b1ef 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -232,6 +232,7 @@ public: METAMGR_READ(level0room_robot_protect_time, 60); METAMGR_READ(level0room_robot_autodie_time, 10); METAMGR_READ(level0room_robot_autodie_distance, 500); + METAMGR_READ(water_move_coefficient, 0.75); { METAMGR_READ_STR(level0room_spec_things, ""); std::vector tmpstrings; diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index 5ec8475..6496744 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -134,6 +134,7 @@ class MetaMgr : public a8::Singleton float water_invisible_time = 0.5; float water_show_time = 0.5f; float water_invisible_time2 = 2.0f; + double water_move_coefficient = 0.75f; float ice_invisible_time = 0.5; float ice_show_time = 0.5f; float ice_invisible_time2 = 2.0f; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 0da2448..37f15ba 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -318,6 +318,8 @@ message MFLootFull { optional int32 obj_uniid = 1; //唯一id optional MFVec2 pos = 2; //位置 + optional MFVec2 born_pos = 3; //出生位置 + optional bool drop_at_thisframe = 4; //是否在这帧掉落 optional int32 item_id = 6; //道具id optional int32 count = 7; //数量 @@ -749,6 +751,25 @@ message MFSkill optional int32 cd_time = 3; //技能cd时间(总时间) } +message TextElement +{ + optional string text = 1; //文本内容 + optional int32 color = 2; //默认系统颜色rgb +} + +message ImageElement +{ + optional int32 id = 1; //装备id +} + +message RichTextElement +{ + //1:TextElement 2:ImageElement + optional int32 element_type = 1; //富文本类型 + optional TextElement union_obj_1 = 2; //文本元素 + optional ImageElement union_obj_2 = 3; //图片元素 +} + //end mfmsg //加入 @@ -1010,7 +1031,7 @@ message SMUpdate //滚动消息 message SMRollMsg { - optional string msg = 6; //死者名字 + repeated RichTextElement elements = 1; //富文本信息 } //个人信息统计