添加新匹配规则
This commit is contained in:
parent
d8b77f3381
commit
3f49f06c0e
@ -75,6 +75,11 @@ void AndroidNewAI::Update(int delta_time)
|
||||
UpdateNewAI();
|
||||
}
|
||||
|
||||
float AndroidNewAI::GetAttackRate()
|
||||
{
|
||||
return ai_meta->i->attack_rate();
|
||||
}
|
||||
|
||||
void AndroidNewAI::DefaultAi()
|
||||
{
|
||||
Human* hum = (Human*)owner;
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
virtual ~AndroidNewAI() override;
|
||||
virtual void Update(int delta_time) override;
|
||||
float GetAttackRate();
|
||||
|
||||
private:
|
||||
void DefaultAi();
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "collider.h"
|
||||
#include "obstacle.h"
|
||||
#include "player.h"
|
||||
#include "android.h"
|
||||
#include "android_new.ai.h"
|
||||
#include "app.h"
|
||||
#include "perfmonitor.h"
|
||||
|
||||
@ -235,6 +237,11 @@ void Bullet::MapServiceUpdate()
|
||||
|
||||
float Bullet::GetAtk()
|
||||
{
|
||||
return gun_meta->i->atk() +
|
||||
float atk = gun_meta->i->atk() +
|
||||
(gun_upgrade_meta ? gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_Atk) : 0);
|
||||
if (player->IsAndroid()) {
|
||||
Android* android = (Android*)player;
|
||||
atk *= android->ai->GetAttackRate();
|
||||
}
|
||||
return atk;
|
||||
}
|
||||
|
@ -235,52 +235,77 @@ public:
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(mini_room_ai, "");
|
||||
METAMGR_READ_STR(a_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->mini_room_ai, tmpstrings, '|');
|
||||
a8::Split(MetaMgr::Instance()->a_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->mini_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->mini_room_ai_weights.push_back
|
||||
MetaMgr::Instance()->a_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->a_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->mini_room_ai_weights_space
|
||||
MetaMgr::Instance()->a_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->mini_room_ai_weights.size() != 8) {
|
||||
if (MetaMgr::Instance()->a_room_ai_weights.size() != 8) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->mini_room_ai_weights_space <= 0) {
|
||||
if (MetaMgr::Instance()->a_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(normal_room_ai, "");
|
||||
METAMGR_READ_STR(b_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->mini_room_ai, tmpstrings, '|');
|
||||
a8::Split(MetaMgr::Instance()->b_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->normal_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->normal_room_ai_weights.push_back
|
||||
MetaMgr::Instance()->b_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->b_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->normal_room_ai_weights_space
|
||||
MetaMgr::Instance()->b_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->normal_room_ai_weights.size() != 8) {
|
||||
if (MetaMgr::Instance()->b_room_ai_weights.size() != 8) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->normal_room_ai_weights_space <= 0) {
|
||||
if (MetaMgr::Instance()->b_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(c_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->c_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->c_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->c_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->c_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->c_room_ai_weights.size() != 8) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->c_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -92,12 +92,15 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
int level0room_robot_autodie_distance = 0;
|
||||
std::set<int> level0room_spec_things_set;
|
||||
std::vector<int> level0room_spec_airdrops;
|
||||
std::vector<std::tuple<int, int>> mini_room_ai_weights;
|
||||
int mini_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> normal_room_ai_weights;
|
||||
int normal_room_ai_weights_space = 0;
|
||||
std::string mini_room_ai;
|
||||
std::string normal_room_ai;
|
||||
std::vector<std::tuple<int, int>> a_room_ai_weights;
|
||||
int a_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> b_room_ai_weights;
|
||||
int b_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> c_room_ai_weights;
|
||||
int c_room_ai_weights_space = 0;
|
||||
std::string a_room_ai;
|
||||
std::string b_room_ai;
|
||||
std::string c_room_ai;
|
||||
|
||||
int level1room_shua_robot_min_time = 0;
|
||||
int level1room_shua_robot_max_time = 0;
|
||||
|
@ -2907,6 +2907,34 @@ void Room::InitAndroidAI()
|
||||
androids.push_back((Android*)hum);
|
||||
}
|
||||
}
|
||||
std::vector<std::tuple<int, int>>* ai_weights = nullptr;
|
||||
int ai_weights_space = 0;
|
||||
switch (GetRoomType()) {
|
||||
case RT_OldBrid1:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->a_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->a_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
case RT_OldBrid2:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->b_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->b_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
case RT_OldBrid3:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->c_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->c_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->a_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->a_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (Android* hum : androids) {
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
@ -2914,27 +2942,14 @@ void Room::InitAndroidAI()
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
if (IsMiniRoom()) {
|
||||
int rnd = rand() % MetaMgr::Instance()->mini_room_ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : MetaMgr::Instance()->mini_room_ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int rnd = rand() % MetaMgr::Instance()->normal_room_ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : MetaMgr::Instance()->normal_room_ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
break;
|
||||
}
|
||||
int rnd = rand() % ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : *ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
|
||||
}
|
||||
//游戏次数,吃鸡数,击杀数,段位
|
||||
game_times = a8::XValue(tmp_strings[0]);
|
||||
int rank = tmp_strings.size() > 3 ? a8::XValue(tmp_strings[3]).GetInt() : 0;
|
||||
int room_rank = tmp_strings.size() > 3 ? a8::XValue(tmp_strings[3]).GetInt() : 0;
|
||||
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
||||
#if 1
|
||||
#else
|
||||
if (!f8::IsOnlineEnv() || RoomMgr::Instance()->IsGM(msg)) {
|
||||
@ -43,62 +44,64 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!msg.team_uuid().empty()) {
|
||||
bool has_mid_brid = false;
|
||||
bool has_old_brid1 = false;
|
||||
bool has_old_brid2 = false;
|
||||
if (!msg.team_uuid().empty() && msg.team_members().size() > 1) {
|
||||
for (auto& team_member : msg.team_members()) {
|
||||
if (team_member.game_times() >= 1 && team_member.game_times() <= 1) {
|
||||
has_mid_brid = true;
|
||||
if (team_member.rank() > 0) {
|
||||
if (team_member.rank() > room_rank) {
|
||||
room_rank = team_member.rank();
|
||||
register_time = team_member.create_time();
|
||||
} else if(team_member.rank() == room_rank &&
|
||||
team_member.create_time() > register_time) {
|
||||
register_time = team_member.create_time();
|
||||
}
|
||||
}
|
||||
if (team_member.game_times() >= 2 && team_member.game_times() <= 2) {
|
||||
has_old_brid1 = true;
|
||||
}
|
||||
if (team_member.rank() > 6) {
|
||||
has_old_brid2 = true;
|
||||
}
|
||||
}
|
||||
if (has_old_brid2) {
|
||||
return RT_OldBrid2;
|
||||
}
|
||||
if (has_mid_brid) {
|
||||
return RT_MidBrid;
|
||||
}
|
||||
if (has_old_brid1) {
|
||||
return RT_OldBrid1;
|
||||
}
|
||||
} else {
|
||||
if (msg.force_entry_newbie_room()) {
|
||||
return RT_NewBrid;
|
||||
}
|
||||
}
|
||||
|
||||
if (game_times <= 0) {
|
||||
return RT_NewBrid;
|
||||
} else if (game_times == 1) {
|
||||
return RT_MidBrid;
|
||||
} else {
|
||||
switch (game_times) {
|
||||
case 2:
|
||||
{
|
||||
if (msg.team_uuid().empty()) {
|
||||
return RT_NewBrid;
|
||||
} else {
|
||||
return RT_OldBrid1;
|
||||
if (game_times <= 0) {
|
||||
return RT_NewBrid;
|
||||
} else if (game_times == 1) {
|
||||
return RT_MidBrid;
|
||||
} else {
|
||||
switch (game_times) {
|
||||
case 2:
|
||||
{
|
||||
if (msg.team_uuid().empty()) {
|
||||
return RT_NewBrid;
|
||||
} else {
|
||||
return RT_OldBrid1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rank >= 0 && rank <= 6) {
|
||||
return RT_OldBrid1;
|
||||
if (!msg.team_uuid().empty() && msg.team_members().size() > 1) {
|
||||
if (room_rank >= 0 && room_rank <= 6) {
|
||||
return RT_OldBrid1;
|
||||
} else if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
|
||||
return RT_OldBrid2;
|
||||
} else {
|
||||
return RT_OldBrid3;
|
||||
}
|
||||
} else {
|
||||
return RT_OldBrid2;
|
||||
if (room_rank >= 0 && room_rank <= 6) {
|
||||
//黄金段位以下
|
||||
return RT_OldBrid1;
|
||||
} else if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
|
||||
//第一天,黄金段位以上
|
||||
return RT_OldBrid2;
|
||||
} else {
|
||||
//其他
|
||||
return RT_OldBrid3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,7 @@ message AI
|
||||
optional string random_move_idle_time = 8;
|
||||
optional string random_move_time = 9;
|
||||
optional int32 attack_range = 10;
|
||||
optional int32 attack_rate = 11;
|
||||
}
|
||||
|
||||
//end
|
||||
|
Loading…
x
Reference in New Issue
Block a user