From 9eab86b9dab1775974c5f849ff5ef7195f43e182 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 13:39:07 +0800 Subject: [PATCH 1/8] 1 --- server/gameserver/netdata.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 857d46d6..db2dd4e3 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -904,10 +904,6 @@ void BattleDataContext::ForceInit(long long hero_uniid, weapon2_ability_->weapon_uniid = weapon2_uniid; weapon2_ability_->weapon_meta = weapon2_meta; } - auto match_conf = owner_.Get()->room->GetRankMatchConf(); - if (owner_.Get()->IsAndroid() && match_conf) { - - } } void BattleDataContext::Init(Creature* c) @@ -942,6 +938,10 @@ void BattleDataContext::Init(Creature* c) spec_weapon.ammo = spec_weapon.GetClipVolume(c); } } + } + auto match_conf = owner_.Get()->room->GetRankMatchConf(); + if (owner_.Get()->IsAndroid() && match_conf) { + } c->NetInitOk(); } From dcffc2f37dd10b92bc600c15a008d4b1d7d51856 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 15:48:34 +0800 Subject: [PATCH 2/8] 1 --- server/gameserver/mtb/NpcStandard.h | 7 ++++++- server/gameserver/mtb/mtb.all.cc | 2 ++ server/tools/protobuild/mt.proto | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/gameserver/mtb/NpcStandard.h b/server/gameserver/mtb/NpcStandard.h index db7dcd6f..91728c9a 100644 --- a/server/gameserver/mtb/NpcStandard.h +++ b/server/gameserver/mtb/NpcStandard.h @@ -15,12 +15,15 @@ namespace mtb int hp() const { return hp_; }; int damage() const { return damage_; }; int defence() const { return defence_; }; + int hero_id() const { return hero_id_; }; bool has_id() const { return __flags__.test(0);}; bool has_quality() const { return __flags__.test(1);}; bool has_hp() const { return __flags__.test(2);}; bool has_damage() const { return __flags__.test(3);}; bool has_defence() const { return __flags__.test(4);}; + bool has_hero_id() const { return __flags__.test(5);}; + bool has_level() const { return __flags__.test(6);}; protected: @@ -29,9 +32,11 @@ namespace mtb int hp_ = 0; int damage_ = 0; int defence_ = 0; + int hero_id_ = 0; + int level_ = 0; public: - std::bitset<5> __flags__; + std::bitset<7> __flags__; }; }; diff --git a/server/gameserver/mtb/mtb.all.cc b/server/gameserver/mtb/mtb.all.cc index 3ac66485..883bfeec 100644 --- a/server/gameserver/mtb/mtb.all.cc +++ b/server/gameserver/mtb/mtb.all.cc @@ -447,6 +447,8 @@ namespace mtb meta_class->SetSimpleField(2, "hp", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, hp_)); meta_class->SetSimpleField(3, "damage", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, damage_)); meta_class->SetSimpleField(4, "defence", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, defence_)); + meta_class->SetSimpleField(5, "hero_id", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, hero_id_)); + meta_class->SetSimpleField(6, "level", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, level_)); } return meta_class; } diff --git a/server/tools/protobuild/mt.proto b/server/tools/protobuild/mt.proto index fc7f5dc5..6f9578bb 100755 --- a/server/tools/protobuild/mt.proto +++ b/server/tools/protobuild/mt.proto @@ -363,6 +363,8 @@ message NpcStandard optional int32 hp = 3; optional int32 damage = 4; optional int32 defence = 5; + optional int32 hero_id = 6; + optional int32 level = 7; } message Buff From 17b79ff66c507e06b0bf8e0ed9ba8936000c3818 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 16:05:23 +0800 Subject: [PATCH 3/8] 1 --- server/gameserver/mt/NpcStandard.cc | 18 ++++++++++++++++++ server/gameserver/mt/NpcStandard.h | 5 +++++ server/gameserver/mtb/NpcStandard.h | 1 + 3 files changed, 24 insertions(+) diff --git a/server/gameserver/mt/NpcStandard.cc b/server/gameserver/mt/NpcStandard.cc index 8b3ba5c6..95a65dbd 100644 --- a/server/gameserver/mt/NpcStandard.cc +++ b/server/gameserver/mt/NpcStandard.cc @@ -4,7 +4,25 @@ IMPL_TABLE(mt::NpcStandard) +std::map mt::NpcStandard::hero_lv_hash_; + namespace mt { + void NpcStandard::Init() + { + hero_lv_hash_[a8::MakeInt64(hero_id(), level())] = this; + } + + void NpcStandard::StaticPostInit() + { + + } + + const mt::NpcStandard* NpcStandard::GetByHeroAndLv(int hero_id, int lv) + { + auto itr = hero_lv_hash_.find(a8::MakeInt64(hero_id, lv)); + return itr != hero_lv_hash_.end() ? itr->second : nullptr; + } + } diff --git a/server/gameserver/mt/NpcStandard.h b/server/gameserver/mt/NpcStandard.h index d80d289d..9020207a 100644 --- a/server/gameserver/mt/NpcStandard.h +++ b/server/gameserver/mt/NpcStandard.h @@ -10,7 +10,12 @@ namespace mt "npcStandard@npcStandard.json", "id") public: + void Init(); + static void StaticPostInit(); + const mt::NpcStandard* GetByHeroAndLv(int hero_id, int lv); + private: + static std::map hero_lv_hash_; }; } diff --git a/server/gameserver/mtb/NpcStandard.h b/server/gameserver/mtb/NpcStandard.h index 91728c9a..7040e285 100644 --- a/server/gameserver/mtb/NpcStandard.h +++ b/server/gameserver/mtb/NpcStandard.h @@ -16,6 +16,7 @@ namespace mtb int damage() const { return damage_; }; int defence() const { return defence_; }; int hero_id() const { return hero_id_; }; + int level() const { return level_; }; bool has_id() const { return __flags__.test(0);}; bool has_quality() const { return __flags__.test(1);}; From 1139e5c959e2fe0938958136235a47c398aff98e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 16:06:43 +0800 Subject: [PATCH 4/8] 1 --- server/gameserver/mt/NpcStandard.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/gameserver/mt/NpcStandard.cc b/server/gameserver/mt/NpcStandard.cc index 95a65dbd..13fb5efc 100644 --- a/server/gameserver/mt/NpcStandard.cc +++ b/server/gameserver/mt/NpcStandard.cc @@ -11,6 +11,9 @@ namespace mt void NpcStandard::Init() { + if (GetByHeroAndLv(hero_id(), level())) { + abort(); + } hero_lv_hash_[a8::MakeInt64(hero_id(), level())] = this; } From 76f5d09b98c3a82a927072bac852db31d346ce3a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 16:14:42 +0800 Subject: [PATCH 5/8] 1 --- server/gameserver/mt/Hero.cc | 8 ++++++++ server/gameserver/mt/NpcStandard.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/gameserver/mt/Hero.cc b/server/gameserver/mt/Hero.cc index aaabbf90..48af2edf 100644 --- a/server/gameserver/mt/Hero.cc +++ b/server/gameserver/mt/Hero.cc @@ -5,6 +5,7 @@ #include "mt/MetaMgr.h" #include "mt/Hero.h" #include "mt/Equip.h" +#include "mt/NpcStandard.h" IMPL_TABLE(mt::Hero) @@ -117,6 +118,13 @@ namespace mt if (swim_speed() < 0.0001f) { swim_speed_ = 1.0f; } + if (default_weapon()) { + for (int i = 1; i <= 15; ++i) { + if (!mt::NpcStandard::GetByHeroAndLv(id(), i)) { + abort(); + } + } + } } } diff --git a/server/gameserver/mt/NpcStandard.h b/server/gameserver/mt/NpcStandard.h index 9020207a..2c78adcc 100644 --- a/server/gameserver/mt/NpcStandard.h +++ b/server/gameserver/mt/NpcStandard.h @@ -12,7 +12,7 @@ namespace mt public: void Init(); static void StaticPostInit(); - const mt::NpcStandard* GetByHeroAndLv(int hero_id, int lv); + static const mt::NpcStandard* GetByHeroAndLv(int hero_id, int lv); private: static std::map hero_lv_hash_; From fe45d21f94b8f8ab66a8531e043a5f9b03304132 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 16:52:44 +0800 Subject: [PATCH 6/8] 1 --- server/gameserver/mt/Param.cc | 26 ++++++++++++++++++++++++++ server/gameserver/mt/Param.h | 2 +- server/gameserver/netdata.cc | 24 ++++++++++++++++++------ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index 4facb680..b354b05a 100644 --- a/server/gameserver/mt/Param.cc +++ b/server/gameserver/mt/Param.cc @@ -353,4 +353,30 @@ namespace mt return s_.rank_mode_confs.at(s_.rank_mode_confs.size() - 1).get(); } + int Param::RandHeroLv(int room_type) + { + switch (room_type) { + case RoomType_OldBrid1: + { + return a8::RandEx(1, 1); + break; + } + case RoomType_OldBrid2: + { + return a8::RandEx(2, 10); + break; + } + case RoomType_OldBrid3: + { + return a8::RandEx(11, 15); + break; + } + default: + { + return a8::RandEx(1, 5); + break; + } + } + } + } diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 50c2365d..149099bb 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -144,7 +144,7 @@ namespace mt static int GetStarNum(int rank); static const RankMatchConf* GetRankModeConfByElo(int elo); static const RankMatchConf* GetRankModeConfByRoomType(int room_type); - + static int RandHeroLv(int room_type); private: static S s_; }; diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index db2dd4e3..d82ba205 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -146,8 +146,7 @@ private: const mt::NpcStandard* standard_meta = mt::NpcStandard::GetById (c->room->pve_instance->gemini_lv()); if (standard_meta) { - hp_ = standard_meta->hp() * hero_meta->hp_ratio() * - c->room->pve_instance->GetHpMul(c->room->GetHumanNum()); + hp_ = standard_meta->hp(); atk_ = standard_meta->damage() * hero_meta->damage_ratio(); def_ = standard_meta->defence() * hero_meta->defence_ratio(); } else { @@ -155,6 +154,23 @@ private: abort(); #endif } + } else { + const mt::NpcStandard* standard_meta = nullptr; + auto match_conf = c->room->GetRankMatchConf(); + if (match_conf) { + standard_meta = mt::NpcStandard::GetByHeroAndLv + (hero_meta->id(), + a8::RandEx(match_conf->hero_min_lv, match_conf->hero_max_lv)); + } else { + standard_meta = mt::NpcStandard::GetByHeroAndLv + (hero_meta->id(), + mt::Param::RandHeroLv(c->room->GetRoomType())); + } + if (standard_meta) { + hp_ = standard_meta->hp(); + atk_ = standard_meta->damage() * hero_meta->damage_ratio(); + def_ = standard_meta->defence() * hero_meta->defence_ratio(); + } } } @@ -938,10 +954,6 @@ void BattleDataContext::Init(Creature* c) spec_weapon.ammo = spec_weapon.GetClipVolume(c); } } - } - auto match_conf = owner_.Get()->room->GetRankMatchConf(); - if (owner_.Get()->IsAndroid() && match_conf) { - } c->NetInitOk(); } From 30dbd7f3b2ab174258be7c793ded6cfb90bae5b8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 18:45:37 +0800 Subject: [PATCH 7/8] 1 --- server/gameserver/mt/Hero.cc | 16 +++++++++------- server/gameserver/mt/NpcStandard.cc | 2 +- server/gameserver/mt/NpcStandard.h | 2 +- server/gameserver/mtb/mtb.all.cc | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/server/gameserver/mt/Hero.cc b/server/gameserver/mt/Hero.cc index 48af2edf..32322fa0 100644 --- a/server/gameserver/mt/Hero.cc +++ b/server/gameserver/mt/Hero.cc @@ -118,13 +118,6 @@ namespace mt if (swim_speed() < 0.0001f) { swim_speed_ = 1.0f; } - if (default_weapon()) { - for (int i = 1; i <= 15; ++i) { - if (!mt::NpcStandard::GetByHeroAndLv(id(), i)) { - abort(); - } - } - } } } @@ -170,6 +163,15 @@ namespace mt abort(); } } + #if 0 + if (hero->default_weapon()) { + for (int i = 1; i <= 15; ++i) { + if (!mt::NpcStandard::GetByHeroAndLv(hero->id(), i)) { + abort(); + } + } + } + #endif }); } diff --git a/server/gameserver/mt/NpcStandard.cc b/server/gameserver/mt/NpcStandard.cc index 13fb5efc..227838e6 100644 --- a/server/gameserver/mt/NpcStandard.cc +++ b/server/gameserver/mt/NpcStandard.cc @@ -9,7 +9,7 @@ std::map mt::NpcStandard::hero_lv_hash_; namespace mt { - void NpcStandard::Init() + void NpcStandard::Init1() { if (GetByHeroAndLv(hero_id(), level())) { abort(); diff --git a/server/gameserver/mt/NpcStandard.h b/server/gameserver/mt/NpcStandard.h index 2c78adcc..8a312e9f 100644 --- a/server/gameserver/mt/NpcStandard.h +++ b/server/gameserver/mt/NpcStandard.h @@ -10,7 +10,7 @@ namespace mt "npcStandard@npcStandard.json", "id") public: - void Init(); + void Init1(); static void StaticPostInit(); static const mt::NpcStandard* GetByHeroAndLv(int hero_id, int lv); diff --git a/server/gameserver/mtb/mtb.all.cc b/server/gameserver/mtb/mtb.all.cc index 883bfeec..09c3ff8f 100644 --- a/server/gameserver/mtb/mtb.all.cc +++ b/server/gameserver/mtb/mtb.all.cc @@ -441,7 +441,7 @@ namespace mtb { a8::reflect::Class* meta_class = nullptr; if (!meta_class) { - meta_class = new a8::reflect::Class("NpcStandard", 5, 0); + meta_class = new a8::reflect::Class("NpcStandard", 7, 0); meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, id_)); meta_class->SetSimpleField(1, "quality", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, quality_)); meta_class->SetSimpleField(2, "hp", a8::reflect::ET_INT32, my_offsetof2(NpcStandard, hp_)); From f5626febf7448f993cff0df1202d0d24dd130665 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Jul 2023 18:56:56 +0800 Subject: [PATCH 8/8] 1 --- server/gameserver/netdata.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index d82ba205..7ef91a17 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -147,8 +147,8 @@ private: (c->room->pve_instance->gemini_lv()); if (standard_meta) { hp_ = standard_meta->hp(); - atk_ = standard_meta->damage() * hero_meta->damage_ratio(); - def_ = standard_meta->defence() * hero_meta->defence_ratio(); + atk_ = standard_meta->damage(); + def_ = standard_meta->defence(); } else { #ifdef DEBUG abort(); @@ -168,8 +168,8 @@ private: } if (standard_meta) { hp_ = standard_meta->hp(); - atk_ = standard_meta->damage() * hero_meta->damage_ratio(); - def_ = standard_meta->defence() * hero_meta->defence_ratio(); + atk_ = standard_meta->damage(); + def_ = standard_meta->defence(); } } }