From aa5e6661fcc31f80ccdab7ca5f2489cc5ded8277 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2024 17:23:29 +0800 Subject: [PATCH 01/39] 1 --- server/gameserver/roommgr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 18831075..2dc9b70b 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -84,7 +84,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr* hdr, const cs::CMJoin& msg) auto member = GetCustomMemberBySocket(hdr->socket_handle); if (member) { #if 1 - f8::UdpLog::Instance()->Warning("JoinError socket_not_exits socket_handle%d", + f8::UdpLog::Instance()->Warning("JoinError socket_not_exits socket_handle:%d", { hdr->socket_handle, }); From 72abfd9f94babdd4d57c866183caa597f92fba96 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2024 17:35:47 +0800 Subject: [PATCH 02/39] 1 --- server/gameserver/GGListener.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index dfd472c1..a599038f 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -73,6 +73,11 @@ public: } } + virtual void OnConnect() override + { + f8::UdpLog::Instance()->Warning("OnConnect socket_handle:%d", {socket_handle}); + } + virtual void OnRawHttpGet(const std::string& url, const std::string& querystr, std::string& response) override { @@ -91,6 +96,7 @@ public: virtual void OnDisConnect() override { + f8::UdpLog::Instance()->Warning("OnDisConnect socket_handle:%d", {socket_handle}); f8::MsgQueue::Instance()->PostMsg (IM_ClientSocketDisconnect, a8::Args From 3e424d81aa09299f2bbd6e6d16a85ba421215056 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2024 17:45:01 +0800 Subject: [PATCH 03/39] 1 --- server/gameserver/GGListener.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index a599038f..5e774d41 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -249,5 +249,17 @@ void GGListener::RemoveSocketDisconnectHandler(std::weak_ptr> del_handlers; + SocketDisconnectHandler *handle = nullptr, *tmp = nullptr; + list_for_each_entry_safe(handle, tmp, &itr->second, entry) { + del_handlers.push_back(handle->holder); + handle->cb(a8::Args({itr->first})); + } + for (auto handler : del_handlers) { + RemoveSocketDisconnectHandler(handler); + } + } PlayerMgr::Instance()->OnClientDisconnect(socket_handle); } From 7c3edc1074ac041074e2c96c943af8f77152e9f8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2024 17:56:50 +0800 Subject: [PATCH 04/39] 1 --- server/gameserver/roommgr.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 2dc9b70b..97066083 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -75,6 +75,13 @@ void RoomMgr::_CMJoin(f8::MsgHdr* hdr, const cs::CMJoin& msg) { #ifdef MYDEBUG a8::XPrintf("CMJoin socket_handle:%d\n", {hdr->socket_handle}); +#endif +#if 1 + f8::UdpLog::Instance()->Warning("CMJoin account_id:%s socket_handle:%d", + { + msg.account_id(), + hdr->socket_handle, + }); #endif if (IsLimitJoin()) { JoinErrorHandle(msg, 2, hdr->socket_handle); @@ -84,7 +91,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr* hdr, const cs::CMJoin& msg) auto member = GetCustomMemberBySocket(hdr->socket_handle); if (member) { #if 1 - f8::UdpLog::Instance()->Warning("JoinError socket_not_exits socket_handle:%d", + f8::UdpLog::Instance()->Warning("JoinError socket already exits socket_handle:%d", { hdr->socket_handle, }); From 0e2ac2bb592e0fbd9c82f40fbf354458c394bac6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2024 18:26:10 +0800 Subject: [PATCH 05/39] 1 --- server/gameserver/GGListener.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 5e774d41..5bc70739 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -237,7 +237,7 @@ void GGListener::RemoveSocketDisconnectHandler(std::weak_ptrcb = nullptr; p->holder = nullptr; #if 1 - f8::UdpLog::Instance()->Warning("RemoveSocketDisconnectHandler socket_handle%d time:%d", + f8::UdpLog::Instance()->Warning("RemoveSocketDisconnectHandler socket_handle:%d time:%d", { p->socket_handle, a8::XGetTickCount() - p->add_tick From 4781e964d3ef1fd76e7238de74994105d082afa7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 28 Aug 2024 15:18:47 +0800 Subject: [PATCH 06/39] 1 --- server/gameserver/GGListener.cc | 2 +- server/gameserver/roommgr.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 738fb028..8cadac36 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -75,7 +75,7 @@ public: virtual void OnConnect() override { - f8::UdpLog::Instance()->Warning("OnConnect socket_handle:%d", {socket_handle}); + f8::UdpLog::Instance()->Info("OnConnect socket_handle:%d", {socket_handle}); } virtual void OnRawHttpGet(const std::string& url, const std::string& querystr, diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 8c73b3e4..7d4ef5e2 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -87,7 +87,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr* hdr, const cs::CMJoin& msg) auto member = GetCustomMemberBySocket(hdr->socket_handle); if (member) { #if 1 - f8::UdpLog::Instance()->Warning("JoinError socket_not_exits socket_handle%d socket_hash_.size:%d", + f8::UdpLog::Instance()->Warning("JoinError socket_not_exits socket_handle:%d socket_hash_.size:%d", { hdr->socket_handle, socket_hash_.size() From f47f1c769ef42f41b38ed940f72e90ebbac39a8e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 28 Aug 2024 15:19:37 +0800 Subject: [PATCH 07/39] 1 --- server/gameserver/GGListener.cc | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 8cadac36..76fa51d4 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -259,18 +259,6 @@ void GGListener::RemoveSocketDisconnectHandler(std::weak_ptr> del_handlers; - SocketDisconnectHandler *handle = nullptr, *tmp = nullptr; - list_for_each_entry_safe(handle, tmp, &itr->second, entry) { - del_handlers.push_back(handle->holder); - handle->cb(a8::Args({itr->first})); - } - for (auto handler : del_handlers) { - RemoveSocketDisconnectHandler(handler); - } - } PlayerMgr::Instance()->OnClientDisconnect(socket_handle); auto itr = disconnect_listener_hash_.find(socket_handle); if (itr != disconnect_listener_hash_.end()) { From 60df47fa29a507f0e431d580b1c595c167dddbea Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 13:55:32 +0800 Subject: [PATCH 08/39] 1 --- server/gameserver/mt/Param.cc | 4 ++++ server/gameserver/mt/Param.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index 2fa9b34b..8087f1b7 100644 --- a/server/gameserver/mt/Param.cc +++ b/server/gameserver/mt/Param.cc @@ -107,6 +107,10 @@ namespace mt #endif s_.battle_auto_ready_min_time = GetIntParam("battle_auto_ready_min_time", 5); s_.battle_auto_ready_max_time = GetIntParam("battle_auto_ready_max_time", 8); + + s_.speed_rf = GetIntParam("SpeedRF", 5.0f); + s_.speed_rate_max = GetIntParam("SpeedRateMax", 0.2f); + #ifdef MYDEBUG s_.match_team_time = 6; s_.match_robot_time = 5; diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 164f9160..17ac2aca 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -164,6 +164,9 @@ namespace mt float battle_event_end_loss_rate_dead = 0.5f; float battle_event_end_loss_rate_quit = 1.0f; + float speed_rf = 5.0f; + float speed_rate_max = 0.2f; + std::vector block_effect_range; std::vector crit_effect_range; From 1c6d10574c7909aeb213ba49b45e78394db307ab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 15:45:05 +0800 Subject: [PATCH 09/39] 1 --- server/gameserver/ability.cc | 2 +- server/gameserver/ability.h | 8 +++++++- server/gameserver/buff/modify_attr.cc | 2 +- server/gameserver/commands.cc | 2 +- server/gameserver/creature.cc | 4 ++-- server/gameserver/netdata.cc | 4 ++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 78fc484d..86cfd817 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -543,7 +543,7 @@ bool Ability::HasDecAttr(int attr_id) } -void Ability::SetSource(AttrHandle handle, std::shared_ptr> cb) +void Ability::SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb) { auto p = handle.lock(); p->get_source = cb; diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index dab9fd77..3c894f52 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -2,6 +2,12 @@ #include "attrdefine.h" #include "weakptr.h" +enum AbilitySourceType_e +{ + kAstChip, + kAstOther +}; + class Ability { public: @@ -29,7 +35,7 @@ class Ability void GMDelAttr(int attr_id, int idx); void GMClearAttr(); std::vector GMShowAttrs(); - void SetSource(AttrHandle handle, std::shared_ptr> cb); + void SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb); private: void Clear(); diff --git a/server/gameserver/buff/modify_attr.cc b/server/gameserver/buff/modify_attr.cc index ae4b2904..8f3d3e91 100644 --- a/server/gameserver/buff/modify_attr.cc +++ b/server/gameserver/buff/modify_attr.cc @@ -33,7 +33,7 @@ void ModifyAttrBuff::Activate() { return source_name; }); - owner->GetAbility()->SetSource(attr_handle_, cb); + owner->GetAbility()->SetSource(attr_handle_, kAstOther, cb); } #endif } diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 2e3a0a56..df209df9 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -351,7 +351,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) { return source_name; }); - target->GetAbility()->SetSource(handle, cb); + target->GetAbility()->SetSource(handle, kAstOther, cb); } } } diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index a3aa37a6..87f22062 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -3498,7 +3498,7 @@ float Creature::InternalGetSpeed() ruduce = std::max(ruduce, GetAbility()->GetAttrRuduce(kHAT_vSpeedRateIn)); #endif float rate = addition + ruduce; - finaly_speed *= 1.0f + rate; + finaly_speed *= 1.0f + std::min(mt::Param::s().speed_rate_max, rate / mt::Param::s().speed_rf); #ifdef MYDEBUG if (IsPlayer() && finaly_speed > 500) { a8::XPrintf("player speed:%f\n", {finaly_speed}); @@ -4267,7 +4267,7 @@ void Creature::GenLevelAttr() { return source_name; }); - GetAbility()->SetSource(handle, cb); + GetAbility()->SetSource(handle, kAstOther, cb); } #endif } diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 48d54161..1b4785fc 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -305,7 +305,7 @@ private: { return source_name; }); - owner_.Get()->GetAbility()->SetSource(attr_handle, cb); + owner_.Get()->GetAbility()->SetSource(attr_handle, kAstOther, cb); #endif } } @@ -337,7 +337,7 @@ private: { return source_name; }); - owner_.Get()->GetAbility()->SetSource(attr_handle, cb); + owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, cb); #endif } } From fce35159dd996f4d333c3ce8b7e7e00af7a0f80c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 15:50:51 +0800 Subject: [PATCH 10/39] 1 --- server/gameserver/ability.cc | 2 ++ server/gameserver/ability.h | 1 + 2 files changed, 3 insertions(+) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 86cfd817..5adf116a 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -18,6 +18,7 @@ struct AttrAddition : public std::enable_shared_from_this list_head list_entry; int attr_id; float value; + int source_type = kAstNone; std::shared_ptr holder; std::shared_ptr> get_source; @@ -546,5 +547,6 @@ bool Ability::HasDecAttr(int attr_id) void Ability::SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb) { auto p = handle.lock(); + p->source_type = source_type; p->get_source = cb; } diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index 3c894f52..90c9460d 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -4,6 +4,7 @@ enum AbilitySourceType_e { + kAstNone, kAstChip, kAstOther }; From a4cee4dfa2d44c54a456fa987ab715a993dffac9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 15:52:29 +0800 Subject: [PATCH 11/39] 1 --- server/gameserver/netdata.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 1b4785fc..5c8a9872 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -338,6 +338,8 @@ private: return source_name; }); owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, cb); +#else + owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, nullptr); #endif } } From e5e24300470ea6d063e8c612f1a0d8e5de2cbf53 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:03:11 +0800 Subject: [PATCH 12/39] 1 --- server/gameserver/ability.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 5adf116a..ba57f96b 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -254,18 +254,22 @@ void Ability::RecalcAttrAddition(int attr_id) list_head* next = nullptr; float new_val = 0.0f; bool inited = false; - list_for_each_safe(pos, next, head) { - AttrAddition* e = list_entry(pos, - AttrAddition, - entry); - if (IsMulCalc(attr_id)) { - if (!inited) { - new_val = 1; - inited = true; + if (attr_id == kHAT_vSpeedRateIn) { + + } else { + list_for_each_safe(pos, next, head) { + AttrAddition* e = list_entry(pos, + AttrAddition, + entry); + if (IsMulCalc(attr_id)) { + if (!inited) { + new_val = 1; + inited = true; + } + new_val *= 1 + e->value; + } else { + new_val += e->value; } - new_val *= 1 + e->value; - } else { - new_val += e->value; } } if (IsValidHumanAttr(attr_id)) { From 638961c5edab2ee1e9ccba9827d299a2ca902c84 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:08:17 +0800 Subject: [PATCH 13/39] 1 --- server/gameserver/ability.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index 90c9460d..7c65eb44 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -6,7 +6,8 @@ enum AbilitySourceType_e { kAstNone, kAstChip, - kAstOther + kAstOther, + kAstEnd, }; class Ability From 6b7b6be7077ebe5276702aa1abc0abee56b02e94 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:15:10 +0800 Subject: [PATCH 14/39] 1 --- server/gameserver/ability.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index ba57f96b..7f23cba8 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -36,6 +36,13 @@ struct AttrAddition : public std::enable_shared_from_this }; +static std::array>, kAstEnd> s_speed_ratein_list = + { + std::vector>({}), + std::vector>({}), + std::vector>({}) + }; + static bool IsMulCalc(int attr_id) { switch (attr_id) { From 7b2031a64e81c7c9c8695b1ba1b08b7b292632ac Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:17:12 +0800 Subject: [PATCH 15/39] 1 --- server/gameserver/ability.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 7f23cba8..0aee0d42 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -43,6 +43,13 @@ static std::array>, kAstEnd> s_speed_r std::vector>({}) }; +static void ClearSpeedRateInList() +{ + for (auto& itr : s_speed_ratein_list) { + itr.clear(); + } +} + static bool IsMulCalc(int attr_id) { switch (attr_id) { From 8b81dc8c0d765f508064c9c0fc415d91635af947 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:19:16 +0800 Subject: [PATCH 16/39] 1 --- server/gameserver/ability.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 0aee0d42..c016bfa2 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -564,6 +564,9 @@ bool Ability::HasDecAttr(int attr_id) void Ability::SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb) { + if (source_type < kAstNone || source_type >= kAstEnd) { + A8_ABORT(); + } auto p = handle.lock(); p->source_type = source_type; p->get_source = cb; From 0c7047a18b9691b4ea8747df4d34c4c1d9556629 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:36:54 +0800 Subject: [PATCH 17/39] 1 --- server/gameserver/ability.cc | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index c016bfa2..be55ce24 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -43,11 +43,33 @@ static std::array>, kAstEnd> s_speed_r std::vector>({}) }; -static void ClearSpeedRateInList() +static float CalcSpeedRateIn(list_head* head) { + list_head* pos = nullptr; + list_head* next = nullptr; + list_for_each_safe(pos, next, head) { + AttrAddition* e = list_entry(pos, + AttrAddition, + entry); + switch (e->source_type) { + case kAstChip: + { + s_speed_ratein_list.at(e->source_type).push_back(e->holder); + } + break; + default: + { + if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { + s_speed_ratein_list.at(e->source_type).push_back(e->holder); + } + } + break; + } + } for (auto& itr : s_speed_ratein_list) { itr.clear(); } + return 0.0f; } static bool IsMulCalc(int attr_id) @@ -264,13 +286,13 @@ void Ability::RecalcAttrAddition(int attr_id) } else { return; } - list_head* pos = nullptr; - list_head* next = nullptr; float new_val = 0.0f; - bool inited = false; if (attr_id == kHAT_vSpeedRateIn) { - + new_val = CalcSpeedRateIn(head); } else { + list_head* pos = nullptr; + list_head* next = nullptr; + bool inited = false; list_for_each_safe(pos, next, head) { AttrAddition* e = list_entry(pos, AttrAddition, From d1a289b78d2e92f23174ae96d3d28822b7a2d8e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:46:35 +0800 Subject: [PATCH 18/39] 1 --- server/gameserver/ability.cc | 50 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index be55ce24..23e8c2a8 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -18,6 +18,7 @@ struct AttrAddition : public std::enable_shared_from_this list_head list_entry; int attr_id; float value; + float finaly_value; int source_type = kAstNone; std::shared_ptr holder; std::shared_ptr> get_source; @@ -45,29 +46,42 @@ static std::array>, kAstEnd> s_speed_r static float CalcSpeedRateIn(list_head* head) { - list_head* pos = nullptr; - list_head* next = nullptr; - list_for_each_safe(pos, next, head) { - AttrAddition* e = list_entry(pos, - AttrAddition, - entry); - switch (e->source_type) { - case kAstChip: - { - s_speed_ratein_list.at(e->source_type).push_back(e->holder); - } - break; - default: - { - if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { + { + list_head* pos = nullptr; + list_head* next = nullptr; + list_for_each_safe(pos, next, head) { + AttrAddition* e = list_entry(pos, + AttrAddition, + entry); + switch (e->source_type) { + case kAstChip: + { s_speed_ratein_list.at(e->source_type).push_back(e->holder); } + break; + default: + { + if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { + s_speed_ratein_list.at(e->source_type).push_back(e->holder); + } + } + break; } - break; } } - for (auto& itr : s_speed_ratein_list) { - itr.clear(); + { + for (auto& itr : s_speed_ratein_list) { + std::sort(itr.begin(), itr.end(), + [] (std::shared_ptr a, std::shared_ptr b) -> bool + { + return std::fabs(a->value) > std::fabs(b->value); + }); + } + } + { + for (auto& itr : s_speed_ratein_list) { + itr.clear(); + } } return 0.0f; } From 76354312aeccbac8d5c4943e3f91ba6eb1af012a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 16:51:09 +0800 Subject: [PATCH 19/39] 1 --- server/gameserver/ability.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 23e8c2a8..9b32989e 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -78,12 +78,13 @@ static float CalcSpeedRateIn(list_head* head) }); } } + float result = 0.0f; { for (auto& itr : s_speed_ratein_list) { itr.clear(); } } - return 0.0f; + return result; } static bool IsMulCalc(int attr_id) From 744299bea0133b697722a4e0be3c950103f315fe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:09:39 +0800 Subject: [PATCH 20/39] 1 --- server/gameserver/ability.cc | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 9b32989e..90495aa0 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -37,12 +37,7 @@ struct AttrAddition : public std::enable_shared_from_this }; -static std::array>, kAstEnd> s_speed_ratein_list = - { - std::vector>({}), - std::vector>({}), - std::vector>({}) - }; +static std::vector> s_speed_ratein_list; static float CalcSpeedRateIn(list_head* head) { @@ -56,34 +51,26 @@ static float CalcSpeedRateIn(list_head* head) switch (e->source_type) { case kAstChip: { - s_speed_ratein_list.at(e->source_type).push_back(e->holder); + s_speed_ratein_list.push_back(e->holder); } break; default: { - if (e->source_type >= 0 && e->source_type <= s_speed_ratein_list.size()) { - s_speed_ratein_list.at(e->source_type).push_back(e->holder); - } + s_speed_ratein_list.push_back(e->holder); } break; } } } { - for (auto& itr : s_speed_ratein_list) { - std::sort(itr.begin(), itr.end(), - [] (std::shared_ptr a, std::shared_ptr b) -> bool - { - return std::fabs(a->value) > std::fabs(b->value); - }); - } + std::sort(s_speed_ratein_list.begin(), s_speed_ratein_list.end(), + [] (std::shared_ptr a, std::shared_ptr b) -> bool + { + return std::fabs(a->value) > std::fabs(b->value); + }); } float result = 0.0f; - { - for (auto& itr : s_speed_ratein_list) { - itr.clear(); - } - } + s_speed_ratein_list.clear(); return result; } From e9f4ed77cf1c368e007ee3165ef5d5c3f60a5253 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:19:59 +0800 Subject: [PATCH 21/39] 1 --- server/gameserver/ability.cc | 4 +++- server/gameserver/mt/Param.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 90495aa0..e4463e52 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -51,11 +51,13 @@ static float CalcSpeedRateIn(list_head* head) switch (e->source_type) { case kAstChip: { + e->finaly_value = e->value; s_speed_ratein_list.push_back(e->holder); } break; default: { + e->finaly_value = e->value; s_speed_ratein_list.push_back(e->holder); } break; @@ -66,7 +68,7 @@ static float CalcSpeedRateIn(list_head* head) std::sort(s_speed_ratein_list.begin(), s_speed_ratein_list.end(), [] (std::shared_ptr a, std::shared_ptr b) -> bool { - return std::fabs(a->value) > std::fabs(b->value); + return std::fabs(a->finaly_value) > std::fabs(b->finaly_value); }); } float result = 0.0f; diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 17ac2aca..fa67ef2e 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -166,6 +166,8 @@ namespace mt float speed_rf = 5.0f; float speed_rate_max = 0.2f; + std::vector spd_eff_fac_vec; + std::vector spd_pun_fac_vec; std::vector block_effect_range; std::vector crit_effect_range; From d8d8b73c2741bc22feb60be698670747e28b3e9d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:23:05 +0800 Subject: [PATCH 22/39] 1 --- server/gameserver/ability.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index e4463e52..9f477f5f 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -11,6 +11,7 @@ #include "mt/Equip.h" #include "mt/Buff.h" +#include "mt/Param.h" struct AttrAddition : public std::enable_shared_from_this { @@ -51,7 +52,11 @@ static float CalcSpeedRateIn(list_head* head) switch (e->source_type) { case kAstChip: { - e->finaly_value = e->value; + if (mt::Param::s().spd_eff_fac_vec.size() >= 2) { + e->finaly_value = e->value * mt::Param::s().spd_eff_fac_vec.at(1); + } else { + e->finaly_value = e->value; + } s_speed_ratein_list.push_back(e->holder); } break; From 6fc087a1fd54196a27f4f4f333fc9d7bf264aac1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:32:35 +0800 Subject: [PATCH 23/39] 1 --- server/gameserver/ability.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 9f477f5f..c460fd0c 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -77,6 +77,19 @@ static float CalcSpeedRateIn(list_head* head) }); } float result = 0.0f; + { + bool inited = false; + for (size_t i = 0; i < s_speed_ratein_list.size(); ++i) { + if (i >= mt::Param::s().spd_pun_fac_vec.size()) { + break; + } + if (!inited) { + result = 1; + result = true; + } + result *= 1 + s_speed_ratein_list.at(i)->finaly_value; + } + } s_speed_ratein_list.clear(); return result; } From 857f3ef7730d99633c1474895c4a5f0a998696a4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:42:23 +0800 Subject: [PATCH 24/39] 1 --- server/gameserver/ability.cc | 34 +++++++++++++++++++--------------- server/gameserver/creature.cc | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index c460fd0c..f8586956 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -91,7 +91,7 @@ static float CalcSpeedRateIn(list_head* head) } } s_speed_ratein_list.clear(); - return result; + return result - 1.0f; } static bool IsMulCalc(int attr_id) @@ -352,22 +352,26 @@ void Ability::RecalcAttrRuduce(int attr_id) } else { return; } - list_head* pos = nullptr; - list_head* next = nullptr; float new_val = 0.0f; - bool inited = false; - list_for_each_safe(pos, next, head) { - AttrAddition* e = list_entry(pos, - AttrAddition, - entry); - if (IsMulCalc(attr_id)) { - if (!inited) { - new_val = 1; - inited = true; + if (attr_id == kHAT_vSpeedRateIn) { + new_val = CalcSpeedRateIn(head); + } else { + list_head* pos = nullptr; + list_head* next = nullptr; + bool inited = false; + list_for_each_safe(pos, next, head) { + AttrAddition* e = list_entry(pos, + AttrAddition, + entry); + if (IsMulCalc(attr_id)) { + if (!inited) { + new_val = 1; + inited = true; + } + new_val *= 1 + e->value; + } else { + new_val += e->value; } - new_val *= 1 + e->value; - } else { - new_val += e->value; } } if (IsValidHumanAttr(attr_id)) { diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 87f22062..f20f6a2e 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -3498,7 +3498,7 @@ float Creature::InternalGetSpeed() ruduce = std::max(ruduce, GetAbility()->GetAttrRuduce(kHAT_vSpeedRateIn)); #endif float rate = addition + ruduce; - finaly_speed *= 1.0f + std::min(mt::Param::s().speed_rate_max, rate / mt::Param::s().speed_rf); + finaly_speed *= 1.0f + rate; #ifdef MYDEBUG if (IsPlayer() && finaly_speed > 500) { a8::XPrintf("player speed:%f\n", {finaly_speed}); From ce02b947ac3b2e3f4a0601364fa9f34ea29f3688 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:44:48 +0800 Subject: [PATCH 25/39] 1 --- server/gameserver/mt/Param.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index 8087f1b7..2ba6df64 100644 --- a/server/gameserver/mt/Param.cc +++ b/server/gameserver/mt/Param.cc @@ -100,6 +100,22 @@ namespace mt s_.block_effect_range.push_back(a8::XValue(str).GetDouble()); } } + { + std::string tmp_str = GetStringParam("SpdEffFacVec", ""); + std::vector strings; + a8::Split(tmp_str, strings, '|'); + for (auto& str : strings) { + s_.spd_eff_fac_vec.push_back(a8::XValue(str).GetDouble()); + } + } + { + std::string tmp_str = GetStringParam("SpdPunFacVec", ""); + std::vector strings; + a8::Split(tmp_str, strings, '|'); + for (auto& str : strings) { + s_.spd_pun_fac_vec.push_back(a8::XValue(str).GetDouble()); + } + } s_.nature_recover_hp_switch = a8::XValue(GetStringParam("nature_recover_hp_switch", "0")); s_.nature_recover_hp_idletime = a8::XValue(GetStringParam("nature_recover_hp_idletime", "3")); s_.nature_recover_hp_interval = a8::XValue(GetStringParam("nature_recover_hp_interval1", "1")); From 72dad82547d08c7b5b452f7bc5caec6009baac66 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:47:45 +0800 Subject: [PATCH 26/39] 1 --- server/gameserver/commands.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index df209df9..598b2161 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -337,6 +337,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) room->GetCreatureByUniId(a8::XValue(cmds[1]).GetInt()); int attr_id = a8::XValue(cmds[2]); float value = a8::XValue(cmds[3]).GetDouble(); + int source_type = cmds.size() > 4 ? a8::XValue(cmds[4]).GetInt() : kAstOther; if (target) { auto handle = target->GetAbility()->AddAttr(attr_id, value); std::vector strings = target->GetAbility()->GMShowAttrs(); @@ -351,7 +352,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) { return source_name; }); - target->GetAbility()->SetSource(handle, kAstOther, cb); + target->GetAbility()->SetSource(handle, source_type, cb); } } } From c282e3158e7a8f8b201f8fcf5ea374d0108fadcc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Sep 2024 17:49:27 +0800 Subject: [PATCH 27/39] 1 --- server/gameserver/commands.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 598b2161..f14e1ca4 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -345,7 +345,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) SendDebugMsg("数值: " + str); } if (!handle.expired()) { - std::string source_name = "<-gm.self"; + std::string source_name = "<-gm.self." + a8::XValue(source_type).GetString(); auto cb = std::make_shared> ( [source_name] () -> std::string From 3dde0c2bf8d817c4c1773ee7b380fde19a585794 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 10:46:47 +0800 Subject: [PATCH 28/39] 1 --- server/gameserver/ability.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index f8586956..01f05c93 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -451,7 +451,7 @@ std::vector Ability::GMShowAttrs() owner_.Get()->GetNetData()->GetCrit(), owner_.Get()->GetHeroLevel(), owner_.Get()->GetHeroExp(), - owner_.Get()->GetSpeed() + owner_.Get()->GetSpeed() * 20 })); { std::vector tmp_strings; From ea392f000325bdb6547e8a16d0eb505a7a892836 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 10:58:49 +0800 Subject: [PATCH 29/39] 1 --- server/gameserver/ability.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 01f05c93..4d0a1d0d 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -76,7 +76,7 @@ static float CalcSpeedRateIn(list_head* head) return std::fabs(a->finaly_value) > std::fabs(b->finaly_value); }); } - float result = 0.0f; + float result = 1.0f; { bool inited = false; for (size_t i = 0; i < s_speed_ratein_list.size(); ++i) { From 52b00f81f214d1fce363e0dd2e5cf1f1e4cce339 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 10:59:47 +0800 Subject: [PATCH 30/39] 1 --- server/gameserver/ability.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 4d0a1d0d..3e311209 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -85,7 +85,7 @@ static float CalcSpeedRateIn(list_head* head) } if (!inited) { result = 1; - result = true; + inited = true; } result *= 1 + s_speed_ratein_list.at(i)->finaly_value; } From 1ee1f7ca6ddde4d797ae547b1d01879f4c671e07 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 11:11:30 +0800 Subject: [PATCH 31/39] 1 --- server/gameserver/ability.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 3e311209..244cb246 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -87,7 +87,7 @@ static float CalcSpeedRateIn(list_head* head) result = 1; inited = true; } - result *= 1 + s_speed_ratein_list.at(i)->finaly_value; + result *= 1 + (s_speed_ratein_list.at(i)->finaly_value * mt::Param::s().spd_pun_fac_vec.at(i)); } } s_speed_ratein_list.clear(); From f47a6d41327fae8ec36c3fe8e2dd0fc19070ced8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 11:52:41 +0800 Subject: [PATCH 32/39] 1 --- server/gameserver/commands.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index f14e1ca4..026aa4d6 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -340,10 +340,6 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) int source_type = cmds.size() > 4 ? a8::XValue(cmds[4]).GetInt() : kAstOther; if (target) { auto handle = target->GetAbility()->AddAttr(attr_id, value); - std::vector strings = target->GetAbility()->GMShowAttrs(); - for (auto& str : strings) { - SendDebugMsg("数值: " + str); - } if (!handle.expired()) { std::string source_name = "<-gm.self." + a8::XValue(source_type).GetString(); auto cb = std::make_shared> @@ -354,6 +350,10 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) }); target->GetAbility()->SetSource(handle, source_type, cb); } + std::vector strings = target->GetAbility()->GMShowAttrs(); + for (auto& str : strings) { + SendDebugMsg("数值: " + str); + } } } } else if (cmd == "del_attr") { From 528318d3ce20f61d0b5ee9035db1e370365d796f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 13:10:03 +0800 Subject: [PATCH 33/39] 1 --- server/gameserver/ability.cc | 12 ++++++------ server/gameserver/ability.h | 4 ++-- server/gameserver/buff/callfunc.cc | 4 ++-- server/gameserver/buff/modify_attr.cc | 4 ++-- server/gameserver/commands.cc | 4 ++-- server/gameserver/creature.cc | 4 ++-- server/gameserver/netdata.cc | 10 ++++------ 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 244cb246..e09c6858 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -241,13 +241,17 @@ bool Ability::CanImmune(const std::set& tags) return false; } -AttrHandle Ability::AddAttr(int attr_id, float val) +AttrHandle Ability::AddAttr(int attr_id, float val, int source_type) { float old_max_hp = owner_.Get()->GetMaxHP(); if (IsValidHumanAttr(attr_id) || IsValidHumanVirtualAttr(attr_id)) { + if (source_type < kAstNone || source_type >= kAstEnd) { + A8_ABORT(); + } auto p = std::make_shared(attr_id, val); p->holder = p; + p->source_type = source_type; if (p->IsAdd()) { if (IsValidHumanAttr(attr_id)) { list_add_tail(&p->entry, &std::get<1>(attr_add_[attr_id])); @@ -610,12 +614,8 @@ bool Ability::HasDecAttr(int attr_id) } -void Ability::SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb) +void Ability::SetSource(AttrHandle handle, std::shared_ptr> cb) { - if (source_type < kAstNone || source_type >= kAstEnd) { - A8_ABORT(); - } auto p = handle.lock(); - p->source_type = source_type; p->get_source = cb; } diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index 7c65eb44..4b7d5d09 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -24,7 +24,7 @@ class Ability void DecSwitch(int type); int GetSwitchTimes(int type); - AttrHandle AddAttr(int attr_id, float val); + AttrHandle AddAttr(int attr_id, float val, int source_type); void RemoveAttr(AttrHandle handler); float GetAttr(int attr_id); bool HasAttr(int attr_id); @@ -37,7 +37,7 @@ class Ability void GMDelAttr(int attr_id, int idx); void GMClearAttr(); std::vector GMShowAttrs(); - void SetSource(AttrHandle handle, int source_type, std::shared_ptr> cb); + void SetSource(AttrHandle handle, std::shared_ptr> cb); private: void Clear(); diff --git a/server/gameserver/buff/callfunc.cc b/server/gameserver/buff/callfunc.cc index 32b314b1..1d58f139 100644 --- a/server/gameserver/buff/callfunc.cc +++ b/server/gameserver/buff/callfunc.cc @@ -1971,9 +1971,9 @@ void CallFuncBuff::BulletDmgCalcProc() bool match = target->GetHP() / target->GetMaxHP() < cond; if (match) { if (target_type == 0) { - context->attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val); + context->attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val, kAstOther); } else if (target_type == 1) { - context->attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val); + context->attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val, kAstOther); } } } diff --git a/server/gameserver/buff/modify_attr.cc b/server/gameserver/buff/modify_attr.cc index 8f3d3e91..fe2702c3 100644 --- a/server/gameserver/buff/modify_attr.cc +++ b/server/gameserver/buff/modify_attr.cc @@ -16,7 +16,7 @@ void ModifyAttrBuff::Activate() int attr_id = meta->_int_buff_param1; float value = meta->GetBuffParam2(this); if (f8::App::Instance()->GetInstanceId() != 3) { - attr_handle_ = owner->GetAbility()->AddAttr(attr_id, value); + attr_handle_ = owner->GetAbility()->AddAttr(attr_id, value, kAstOther); #ifdef MYDEBUG if (!attr_handle_.expired()) { std::string source_name = a8::Format @@ -33,7 +33,7 @@ void ModifyAttrBuff::Activate() { return source_name; }); - owner->GetAbility()->SetSource(attr_handle_, kAstOther, cb); + owner->GetAbility()->SetSource(attr_handle_, cb); } #endif } diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 026aa4d6..ee3b5263 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -339,7 +339,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) float value = a8::XValue(cmds[3]).GetDouble(); int source_type = cmds.size() > 4 ? a8::XValue(cmds[4]).GetInt() : kAstOther; if (target) { - auto handle = target->GetAbility()->AddAttr(attr_id, value); + auto handle = target->GetAbility()->AddAttr(attr_id, value, source_type); if (!handle.expired()) { std::string source_name = "<-gm.self." + a8::XValue(source_type).GetString(); auto cb = std::make_shared> @@ -348,7 +348,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) { return source_name; }); - target->GetAbility()->SetSource(handle, source_type, cb); + target->GetAbility()->SetSource(handle, cb); } std::vector strings = target->GetAbility()->GMShowAttrs(); for (auto& str : strings) { diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index f20f6a2e..32d51bb0 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -4250,7 +4250,7 @@ void Creature::GenLevelAttr() } grow_attr_list_.clear(); for (auto tuple : *attrs) { - auto handle = GetAbility()->AddAttr(std::get<0>(tuple), std::get<1>(tuple)); + auto handle = GetAbility()->AddAttr(std::get<0>(tuple), std::get<1>(tuple), kAstOther); if (!handle.expired()) { grow_attr_list_.push_back(handle); } @@ -4267,7 +4267,7 @@ void Creature::GenLevelAttr() { return source_name; }); - GetAbility()->SetSource(handle, kAstOther, cb); + GetAbility()->SetSource(handle, cb); } #endif } diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 5c8a9872..f98d3271 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -292,7 +292,7 @@ private: int attr_id = a8::XValue(attr->Get("attr_id", "0")); float val = a8::XValue(attr->Get("val", "0")).GetDouble(); if (IsValidHumanAttr(attr_id)) { - auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val); + auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val, kAstOther); if (!attr_handle.expired()) { #ifdef MYDEBUG std::string source_name = a8::Format @@ -305,7 +305,7 @@ private: { return source_name; }); - owner_.Get()->GetAbility()->SetSource(attr_handle, kAstOther, cb); + owner_.Get()->GetAbility()->SetSource(attr_handle, cb); #endif } } @@ -324,7 +324,7 @@ private: int attr_id = a8::XValue(attr->Get("attr_id", "0")); float val = a8::XValue(attr->Get("val", "0")).GetDouble(); if (IsValidHumanAttr(attr_id)) { - auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val); + auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val, kAstChip); if (!attr_handle.expired()) { #ifdef MYDEBUG std::string source_name = a8::Format @@ -337,9 +337,7 @@ private: { return source_name; }); - owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, cb); -#else - owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, nullptr); + owner_.Get()->GetAbility()->SetSource(attr_handle, cb); #endif } } From 0b89e7130350fd1b8ae8fa72ba34690d4d4cd007 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 13:30:37 +0800 Subject: [PATCH 34/39] 1 --- server/tools/protobuild/cs_msgid.proto | 2 ++ server/tools/protobuild/cs_proto.proto | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index fb911b9d..2a18ada3 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -75,4 +75,6 @@ enum SMMessageId_e _SMTeamFullNotify = 1032; _SMTeamPartNotify = 1033; _SMBattlePreInfoUpdate = 1034; + _SMAddBattleHint = 1035; + _SMDelBattleHint = 1036; } diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 8d36854d..62a90b2f 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -2130,4 +2130,18 @@ message SMTeamPartNotify message SMBattlePreInfoUpdate { optional MFBattlePreInfo info = 1; //战前准备信息 +} + +//战斗提示-添加 +message SMAddBattleHint +{ + optional int32 uniid = 1; //唯一id + optional MFVec3 pos = 2; //坐标 + optional int32 duration = 3; //持续时间秒 +} + +//战斗提示-删除 +message SMDelBattleHint +{ + optional int32 uniid = 1; //唯一id } \ No newline at end of file From e0373b472cf04a89a7964c3c2ebd69e1ac574d29 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 14:10:17 +0800 Subject: [PATCH 35/39] 1 --- server/gameserver/human.h | 2 ++ server/gameserver/mt/Param.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 159f00f3..8a24e857 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -394,6 +394,8 @@ private: bool sending_battlereport_ = false; bool is_game_end_ = false; bool sent_personal_report_ = false; + long long last_battle_hint_frameno_ = 0; + int last_battle_hint_uniid_ = 0; long long jump_frameno_ = 0; float old_sync_speed = 0; diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index fa67ef2e..835a5380 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -169,6 +169,11 @@ namespace mt std::vector spd_eff_fac_vec; std::vector spd_pun_fac_vec; + int battle_hint_interval = 10; + int battle_hint_disappear = 10; + int battle_hint_view_range = 512; + int battle_hint_broadcast_range = 800; + std::vector block_effect_range; std::vector crit_effect_range; From 943e2b989e3711221fc654729803c9e3192a6b25 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 14:22:26 +0800 Subject: [PATCH 36/39] 1 --- server/gameserver/human.cc | 1 + server/gameserver/human.h | 1 + server/gameserver/pbutils.cc | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 106b157d..c3ef1e3b 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -412,6 +412,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string killer_name, in killer->GetUniId(), only_self); } + BroadcastBattleHint(); } else if (killer->IsHero()) { if (killer->AsHero()->master.Get() && killer->AsHero()->master.Get()->IsPlayer()) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 8a24e857..6c4a20c6 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -349,6 +349,7 @@ private: virtual void DoSkillPreProc(int skill_id, int target_id) override; virtual void DoSkillPostProc(bool used, int skill_id, int target_id) override; void FillMFSettlement(cs::SMGameOver* msg, cs::MFSettlement* settlement); + void BroadcastBattleHint(); protected: long long hide_frameno_ = 0; diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index afd85fb7..181a4e5c 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2183,6 +2183,16 @@ void Human::SendViewerUiMemberUpdate(std::vector member_ids) } } +void Human::BroadcastBattleHint() +{ + if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) { + last_battle_hint_frameno_ = room->GetFrameNo(); + if (last_battle_hint_uniid_ > 0) { + + } + } +} + void GGListener::SendError(int sockhandle, unsigned int seqid, int error_code, const std::string& error_msg, const char* file, int lineno, int error_param) From b6344aa461e22ce3b6d7528489d1b1255ee6e727 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 14:26:15 +0800 Subject: [PATCH 37/39] 1 --- server/gameserver/pbutils.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 181a4e5c..1772851c 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2188,7 +2188,10 @@ void Human::BroadcastBattleHint() if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) { last_battle_hint_frameno_ = room->GetFrameNo(); if (last_battle_hint_uniid_ > 0) { - + cs::SMDelBattleHint notify_msg; + notify_msg.set_uniid(last_battle_hint_uniid_); + SendNotifyMsg(notify_msg); + last_battle_hint_uniid_ = 0; } } } From da73a1f622c5bbfbed91fb7135f88b64bd7aa1b1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 14:41:19 +0800 Subject: [PATCH 38/39] 1 --- server/gameserver/mt/Param.h | 2 +- server/gameserver/pbutils.cc | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 835a5380..27a6be1a 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -170,7 +170,7 @@ namespace mt std::vector spd_pun_fac_vec; int battle_hint_interval = 10; - int battle_hint_disappear = 10; + int battle_hint_duration = 10; int battle_hint_view_range = 512; int battle_hint_broadcast_range = 800; diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 1772851c..e2022550 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2186,13 +2186,37 @@ void Human::SendViewerUiMemberUpdate(std::vector member_ids) void Human::BroadcastBattleHint() { if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) { - last_battle_hint_frameno_ = room->GetFrameNo(); if (last_battle_hint_uniid_ > 0) { - cs::SMDelBattleHint notify_msg; - notify_msg.set_uniid(last_battle_hint_uniid_); - SendNotifyMsg(notify_msg); + if (room->GetFrameNo() - last_battle_hint_frameno_ < + mt::Param::s().battle_hint_duration * SERVER_FRAME_RATE + 8) { + cs::SMDelBattleHint notify_msg; + notify_msg.set_uniid(last_battle_hint_uniid_); + SendNotifyMsg(notify_msg); + } last_battle_hint_uniid_ = 0; } + last_battle_hint_frameno_ = room->GetFrameNo(); + std::shared_ptr notify_msg; + room->TraversePlayerList + ( + [this, ¬ify_msg] (Player* hum) -> bool + { + if (!hum->dead) { + float distance = hum->GetPos().Distance2D2(GetPos()); + if (distance >= mt::Param::s().battle_hint_view_range && + distance <= mt::Param::s().battle_hint_broadcast_range) { + if (!notify_msg) { + last_battle_hint_uniid_ = room->AllocUniid(); + notify_msg = std::make_shared(); + notify_msg->set_uniid(last_battle_hint_uniid_); + notify_msg->set_duration(mt::Param::s().battle_hint_duration); + TypeConvert::ToPb(GetPos(), notify_msg->mutable_pos()); + } + hum->SendNotifyMsg(*notify_msg.get()); + } + } + return true; + }); } } From 72ead02eec6f949230920c471626b1bf61f79566 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 6 Sep 2024 14:44:28 +0800 Subject: [PATCH 39/39] 1 --- server/gameserver/pbutils.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index e2022550..d0e3eee5 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2213,6 +2213,9 @@ void Human::BroadcastBattleHint() TypeConvert::ToPb(GetPos(), notify_msg->mutable_pos()); } hum->SendNotifyMsg(*notify_msg.get()); +#ifdef MYDEBUG + a8::XPrintf("SMAddBattleHint:%s\n", {f8::PbToJson(notify_msg.get())}); +#endif } } return true;