diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 7a546059..76fa51d4 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -73,6 +73,11 @@ public: } } + virtual void OnConnect() override + { + f8::UdpLog::Instance()->Info("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 @@ -241,7 +247,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 diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index 78fc484d..e09c6858 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 { @@ -18,6 +19,8 @@ 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; @@ -35,6 +38,62 @@ struct AttrAddition : public std::enable_shared_from_this }; +static std::vector> s_speed_ratein_list; + +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: + { + 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; + default: + { + e->finaly_value = e->value; + s_speed_ratein_list.push_back(e->holder); + } + break; + } + } + } + { + 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->finaly_value) > std::fabs(b->finaly_value); + }); + } + float result = 1.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; + inited = true; + } + result *= 1 + (s_speed_ratein_list.at(i)->finaly_value * mt::Param::s().spd_pun_fac_vec.at(i)); + } + } + s_speed_ratein_list.clear(); + return result - 1.0f; +} + static bool IsMulCalc(int attr_id) { switch (attr_id) { @@ -182,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])); @@ -249,22 +312,26 @@ void Ability::RecalcAttrAddition(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)) { @@ -289,22 +356,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)) { @@ -384,7 +455,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; diff --git a/server/gameserver/ability.h b/server/gameserver/ability.h index dab9fd77..4b7d5d09 100644 --- a/server/gameserver/ability.h +++ b/server/gameserver/ability.h @@ -2,6 +2,14 @@ #include "attrdefine.h" #include "weakptr.h" +enum AbilitySourceType_e +{ + kAstNone, + kAstChip, + kAstOther, + kAstEnd, +}; + class Ability { public: @@ -16,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); 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 ae4b2904..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 diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 2e3a0a56..ee3b5263 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -337,14 +337,11 @@ 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(); - for (auto& str : strings) { - SendDebugMsg("数值: " + str); - } + auto handle = target->GetAbility()->AddAttr(attr_id, value, source_type); 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 @@ -353,6 +350,10 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) }); target->GetAbility()->SetSource(handle, cb); } + std::vector strings = target->GetAbility()->GMShowAttrs(); + for (auto& str : strings) { + SendDebugMsg("数值: " + str); + } } } } else if (cmd == "del_attr") { diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index a3aa37a6..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); } 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 0978c1b1..f78b8452 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -350,6 +350,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; @@ -395,6 +396,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.cc b/server/gameserver/mt/Param.cc index 2fa9b34b..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")); @@ -107,6 +123,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..27a6be1a 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -164,6 +164,16 @@ 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 spd_eff_fac_vec; + std::vector spd_pun_fac_vec; + + int battle_hint_interval = 10; + int battle_hint_duration = 10; + int battle_hint_view_range = 512; + int battle_hint_broadcast_range = 800; + std::vector block_effect_range; std::vector crit_effect_range; diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 48d54161..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 @@ -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 diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 19133f83..3ddaf741 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2183,6 +2183,46 @@ void Human::SendViewerUiMemberUpdate(std::vector member_ids) } } +void Human::BroadcastBattleHint() +{ + if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) { + if (last_battle_hint_uniid_ > 0) { + 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()); +#ifdef MYDEBUG + a8::XPrintf("SMAddBattleHint:%s\n", {f8::PbToJson(notify_msg.get())}); +#endif + } + } + return true; + }); + } +} + void GGListener::SendError(int sockhandle, unsigned int seqid, int error_code, const std::string& error_msg, const char* file, int lineno, int error_param) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 736fd82b..27eea6b8 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() 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 2db8768b..30983558 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -2132,4 +2132,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