483 lines
18 KiB
C++
483 lines
18 KiB
C++
#include "precompile.h"
|
|
|
|
#include <math.h>
|
|
|
|
#include "mt/Param.h"
|
|
#include "mt/SafeArea.h"
|
|
|
|
IMPL_TABLE(mt::Param)
|
|
mt::Param::S mt::Param::s_;
|
|
|
|
#define METAMGR_READ(field_name, def_val) s_.field_name = \
|
|
a8::XValue(GetStringParam(#field_name, #def_val));
|
|
|
|
#define METAMGR_READ_STR(field_name, def_val) s_.field_name = \
|
|
a8::XValue(GetStringParam(#field_name, def_val)).GetString();
|
|
|
|
namespace mt
|
|
{
|
|
|
|
void Param::StaticPostInit()
|
|
{
|
|
{
|
|
s_.gas_inactive_time = GetIntParam("gas_inactive_time");
|
|
s_.rank_gas_inactive_time = GetIntParam("rank_gas_inactive_time", 40);
|
|
s_.master_rank_gas_inactive_time = GetIntParam("rank_gas_inactive_time", 60);
|
|
|
|
s_.downed_relive_recover_hp = GetIntParam("downed_relive_recover_hp");
|
|
|
|
s_.kill_param = GetFloatParam("kill_parameter");
|
|
s_.rank_param = GetFloatParam("rank_parameter");
|
|
s_.fighting_mode = GetIntParam("fighting_mode", 1);
|
|
s_.max_oil = GetIntParam("max_oil");
|
|
s_.max_mount_horse_distance = GetFloatParam("max_mount_horse_distance", 100);
|
|
s_.map_cell_width = GetIntParam("map_cell_width", 64 * 8);
|
|
#ifdef MYDEBUG
|
|
s_.map_cell_width = 512;
|
|
#endif
|
|
s_.bullet_planck_step_length = std::max(15, GetIntParam("bullet_planck_step_length", 15));
|
|
s_.match_team_time = GetIntParam("match_team_time", 0);
|
|
s_.match_robot_time = GetIntParam("match_robot_time", 0);
|
|
s_.match_choose_time = GetIntParam("match_choose_time", 0);
|
|
s_.match_lock_time = GetIntParam("match_lock_time", 0);
|
|
s_.pickup_weapon_replace_type = GetIntParam("pickup_weapon_replace_type", 0);
|
|
s_.sand_table_move_speed = GetIntParam("sand_table_move_speed", 500);
|
|
s_.wait_cloud_time = GetIntParam("wait_cloud_time", 10);
|
|
s_.mid_room_max_rank = GetIntParam("mid_room_max_rank", 0);
|
|
s_.new_room_max_level = GetIntParam("new_room_max_level", 5);
|
|
s_.mid_room_max_level = GetIntParam("mid_room_max_level", 10);
|
|
#if 1
|
|
s_.match_lock_time++;
|
|
#endif
|
|
s_.pre_client_shot = GetIntParam("pre_client_shot", 0);
|
|
s_.rank_mode_wait_time = GetIntParam("rank_mode_wait_time", 10);
|
|
s_.rank_mode_min_player = GetIntParam("rank_mode_min_player", 3);
|
|
s_.downed_switch = GetIntParam("downed_switch", 0);
|
|
s_.bullet_through_wall_check = GetIntParam("bullet_through_wall_check", 1);
|
|
s_.revive_count = GetIntParam("revive_count", 1);
|
|
s_.pvp_revive_time = GetIntParam("pvp_revive_time", 10);
|
|
|
|
s_.battle_gain_exp_radium = GetFloatParam("battle_gain_exp_radium", 2000);
|
|
s_.battle_gain_exp_rate_killer = GetFloatParam("battle_gain_exp_rate_killer", 0.5);
|
|
s_.battle_gain_exp_rate_teammate = GetFloatParam("battle_gain_exp_rate_teammate", 0.3);
|
|
|
|
s_.magma_dec_hp_rate = GetFloatParam("magma_dec_hp_rate", 0.1);
|
|
|
|
#ifdef MYDEBUG1
|
|
s_.moba_room_time = 60;
|
|
s_.moba_kill_times = GetIntParam("moba_kill_times", 1);
|
|
#endif
|
|
#if 1
|
|
{
|
|
std::string tmp_str = GetStringParam("crit_effect_range", "");
|
|
std::vector<std::string> strings;
|
|
a8::Split(tmp_str, strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.crit_effect_range.push_back(a8::XValue(str).GetDouble());
|
|
}
|
|
}
|
|
{
|
|
std::string tmp_str = GetStringParam("performance_score_weight_4V4", "");
|
|
std::vector<std::string> strings;
|
|
a8::Split(tmp_str, strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.performance_score_weight_4V4.push_back(a8::XValue(str).GetDouble());
|
|
}
|
|
}
|
|
{
|
|
std::string tmp_str = GetStringParam("performance_score_weight_BR", "");
|
|
std::vector<std::string> strings;
|
|
a8::Split(tmp_str, strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.performance_score_weight_BR.push_back(a8::XValue(str).GetDouble());
|
|
}
|
|
}
|
|
{
|
|
std::string tmp_str = GetStringParam("block_effect_range", "");
|
|
std::vector<std::string> strings;
|
|
a8::Split(tmp_str, strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.block_effect_range.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"));
|
|
s_.nature_recover_hp_rate = a8::XValue(GetStringParam("nature_recover_hp_rate", "0.1")).GetDouble();
|
|
#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);
|
|
#ifdef MYDEBUG
|
|
s_.match_team_time = 6;
|
|
s_.match_robot_time = 5;
|
|
s_.match_choose_time = 25;
|
|
s_.match_lock_time = 3;
|
|
#endif
|
|
{
|
|
METAMGR_READ(android_auto_combine_team, 1);
|
|
METAMGR_READ(level0room_shua_robot_min_time, 5);
|
|
METAMGR_READ(level0room_shua_robot_max_time, 7);
|
|
METAMGR_READ(level0room_shua_robot_min_num, 1);
|
|
METAMGR_READ(level0room_shua_robot_max_num, 3);
|
|
METAMGR_READ(level0room_die_robot_min_time, 10);
|
|
METAMGR_READ(level0room_die_robot_max_time, 20);
|
|
METAMGR_READ(level0room_die_robot_min_num, 1);
|
|
METAMGR_READ(level0room_die_robot_max_num, 3);
|
|
METAMGR_READ(level0room_robot_water, 3);
|
|
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(teammate_kill_color, 0xFFFF00);
|
|
METAMGR_READ(teammate_bekill_color, 0x00FF00);
|
|
METAMGR_READ(self_kill_color, 0xFFFF00);
|
|
METAMGR_READ(self_bekill_color, 0x00FF00);
|
|
|
|
METAMGR_READ(battling_disengage_time, 3000);
|
|
METAMGR_READ(battling_detection_range, 500);
|
|
METAMGR_READ(battling_grass_hide_delay_time, 1000);
|
|
|
|
METAMGR_READ(frag_dinshen_time, 1200);
|
|
|
|
METAMGR_READ(view_objects_out_distance, 530);
|
|
METAMGR_READ(view_objects_in_distance, 530);
|
|
|
|
METAMGR_READ(incubator_base_length, 501);
|
|
METAMGR_READ(incubator_rand_length, 10);
|
|
METAMGR_READ(incubator_canset_distance, 520);
|
|
|
|
METAMGR_READ(prebattle_can_use_skill, 1);
|
|
METAMGR_READ(watchable, 1);
|
|
METAMGR_READ(prebattle_combine_team, 1);
|
|
|
|
METAMGR_READ(refresh_view_time, 4);
|
|
|
|
METAMGR_READ(level1room_shua_robot_min_time, 5);
|
|
METAMGR_READ(level1room_shua_robot_max_time, 7);
|
|
METAMGR_READ(level1room_shua_robot_min_num, 2);
|
|
METAMGR_READ(level1room_shua_robot_max_num, 5);
|
|
METAMGR_READ(level1room_die_robot_min_time, 10);
|
|
METAMGR_READ(level1room_die_robot_max_time, 14);
|
|
METAMGR_READ(level1room_die_robot_min_num, 1);
|
|
METAMGR_READ(level1room_die_robot_max_num, 3);
|
|
METAMGR_READ(level1room_robot_water, 8);
|
|
METAMGR_READ(level1room_robot_autodie_time, 10);
|
|
METAMGR_READ(level1room_robot_autodie_distance, 500);
|
|
METAMGR_READ_STR(level1room_born_point, "");
|
|
|
|
METAMGR_READ(dive_oxygen_total, 200);
|
|
METAMGR_READ(dive_oxygen_consume, 20);
|
|
METAMGR_READ(dive_hp_consume, 20);
|
|
METAMGR_READ(dive_explosion_dmg_switch, 0);
|
|
METAMGR_READ(inwater_oxygen_recover, 20);
|
|
|
|
METAMGR_READ(move_step_len, 80);
|
|
|
|
METAMGR_READ(early_parachute_jump, 0);
|
|
|
|
METAMGR_READ(box_open_delay, 0);
|
|
}
|
|
#if 0
|
|
{
|
|
human_meta = MetaMgr::Instance()->GetPlayer(40001);
|
|
if (!human_meta) {
|
|
A8_ABORT();
|
|
}
|
|
android_meta = MetaMgr::Instance()->GetPlayer(40002);
|
|
if (!android_meta) {
|
|
A8_ABORT();
|
|
}
|
|
}
|
|
#endif
|
|
{
|
|
{
|
|
if (s_.level0room_shua_robot_min_time >
|
|
s_.level0room_shua_robot_max_time) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level0room_shua_robot_min_num >
|
|
s_.level0room_shua_robot_max_num) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level0room_die_robot_min_time >
|
|
s_.level0room_die_robot_max_time) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level0room_die_robot_min_num >
|
|
s_.level0room_die_robot_max_num) {
|
|
A8_ABORT();
|
|
}
|
|
}
|
|
|
|
{
|
|
if (s_.level1room_shua_robot_min_time >
|
|
s_.level1room_shua_robot_max_time) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level1room_shua_robot_min_num >
|
|
s_.level1room_shua_robot_max_num) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level1room_die_robot_min_time >
|
|
s_.level1room_die_robot_max_time) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.level1room_die_robot_min_num >
|
|
s_.level1room_die_robot_max_num) {
|
|
A8_ABORT();
|
|
}
|
|
}
|
|
|
|
if (s_.match_team_time <= 0) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.match_robot_time <= 0) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.match_robot_time >= s_.match_team_time) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.match_choose_time <= 0) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.match_lock_time <= 0) {
|
|
A8_ABORT();
|
|
}
|
|
if (s_.match_lock_time >= s_.match_choose_time) {
|
|
A8_ABORT();
|
|
}
|
|
|
|
}
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("robot_placement"), strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.robot_placement.push_back(a8::XValue(str).GetDouble());
|
|
}
|
|
if (s_.robot_placement.size() != 9) {
|
|
abort();
|
|
}
|
|
}
|
|
{
|
|
s_.robot_placement_time = GetIntParam("robot_placement_time");
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("robot_placement_type"), strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.robot_placement_type.push_back(a8::XValue(str).GetDouble());
|
|
}
|
|
if (s_.robot_placement_type.size() != 2) {
|
|
abort();
|
|
}
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("boss_skill_order"), strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.boss_skill_order.push_back(a8::XValue(str).GetInt());
|
|
}
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("star_get_num"), strings, '|');
|
|
for (auto& str : strings) {
|
|
s_.star_get_nums.push_back(a8::XValue(str).GetInt());
|
|
}
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("performance_score_range"), strings, '|');
|
|
if (strings.size() != 2) {
|
|
A8_ABORT();
|
|
}
|
|
s_.battle_score_param0 = a8::XValue(strings[0]).GetDouble();
|
|
s_.battle_score_param1 = a8::XValue(strings[1]).GetDouble();
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(GetStringParam("battle_event_end_loss_rate"), strings, '|');
|
|
if (strings.size() >= 3) {
|
|
s_.battle_event_end_loss_rate_win = a8::XValue(strings[0]).GetDouble();
|
|
s_.battle_event_end_loss_rate_dead = a8::XValue(strings[1]).GetDouble();
|
|
s_.battle_event_end_loss_rate_quit = a8::XValue(strings[2]).GetDouble();
|
|
}
|
|
}
|
|
{
|
|
{
|
|
auto p = std::make_shared<mt::RankMatchConf>();
|
|
p->room_type = RoomType_Rank1;
|
|
p->min_elo = 150;
|
|
p->max_elo = 650;
|
|
p->min_level = 1;
|
|
p->max_level = 4;
|
|
p->hero_min_lv = 1;
|
|
p->hero_max_lv = 4;
|
|
s_.rank_mode_confs.push_back(p);
|
|
}
|
|
|
|
{
|
|
auto p = std::make_shared<mt::RankMatchConf>();
|
|
p->room_type = RoomType_Rank2;
|
|
p->min_elo = 650;
|
|
p->max_elo = 1150;
|
|
p->min_level = 5;
|
|
p->max_level = 9;
|
|
p->hero_min_lv = 5;
|
|
p->hero_max_lv = 9;
|
|
s_.rank_mode_confs.push_back(p);
|
|
}
|
|
|
|
{
|
|
auto p = std::make_shared<mt::RankMatchConf>();
|
|
p->room_type = RoomType_Rank3;
|
|
p->min_elo = 1150;
|
|
p->max_elo = 1650;
|
|
p->min_level = 10;
|
|
p->max_level = 14;
|
|
p->hero_min_lv = 10;
|
|
p->hero_max_lv = 14;
|
|
s_.rank_mode_confs.push_back(p);
|
|
}
|
|
|
|
{
|
|
auto p = std::make_shared<mt::RankMatchConf>();
|
|
p->room_type = RoomType_MasterRank;
|
|
p->min_elo = 1650;
|
|
p->max_elo = 165000000;
|
|
p->min_level = 15;
|
|
p->max_level = 15;
|
|
p->hero_min_lv = 15;
|
|
p->hero_max_lv = 15;
|
|
s_.rank_mode_confs.push_back(p);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
int Param::GetIntParam(const std::string& param_name, int def_val)
|
|
{
|
|
auto p = GetByName(param_name);
|
|
return p ? a8::XValue(p->param_value()).GetInt() : def_val;
|
|
}
|
|
|
|
double Param::GetFloatParam(const std::string& param_name, double def_val)
|
|
{
|
|
auto p = GetByName(param_name);
|
|
return p ? a8::XValue(p->param_value()).GetDouble() : def_val;
|
|
}
|
|
|
|
std::string Param::GetStringParam(const std::string& param_name, const char* def_val)
|
|
{
|
|
auto p = GetByName(param_name);
|
|
return p ? a8::XValue(p->param_value()).GetString() : def_val;
|
|
}
|
|
|
|
int Param::GetStarNum(int rank)
|
|
{
|
|
if (rank > 0 && rank <= s_.star_get_nums.size()) {
|
|
return s_.star_get_nums.at(rank - 1);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
const RankMatchConf* Param::GetRankModeConfByElo(int elo)
|
|
{
|
|
if (s_.rank_mode_confs.empty()) {
|
|
abort();
|
|
}
|
|
for (auto conf : s_.rank_mode_confs) {
|
|
if (conf->min_elo >= elo) {
|
|
return conf.get();
|
|
}
|
|
}
|
|
return s_.rank_mode_confs.at(s_.rank_mode_confs.size() - 1).get();
|
|
}
|
|
|
|
const RankMatchConf* Param::GetRankModeConfByHeroLv(int hero_lv)
|
|
{
|
|
if (s_.rank_mode_confs.empty()) {
|
|
abort();
|
|
}
|
|
for (auto conf : s_.rank_mode_confs) {
|
|
if (conf->max_level >= hero_lv) {
|
|
return conf.get();
|
|
}
|
|
}
|
|
return s_.rank_mode_confs.at(s_.rank_mode_confs.size() - 1).get();
|
|
}
|
|
|
|
const RankMatchConf* Param::GetRankModeConfByRoomType(int room_type)
|
|
{
|
|
if (s_.rank_mode_confs.empty()) {
|
|
abort();
|
|
}
|
|
for (auto conf : s_.rank_mode_confs) {
|
|
if (conf->room_type == room_type) {
|
|
return conf.get();
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
int Param::RandHeroLv(int room_type)
|
|
{
|
|
switch (room_type) {
|
|
case RoomType_OldBrid1:
|
|
{
|
|
return a8::RandEx(1, 4);
|
|
break;
|
|
}
|
|
case RoomType_OldBrid2:
|
|
{
|
|
return a8::RandEx(5, 10);
|
|
break;
|
|
}
|
|
case RoomType_OldBrid3:
|
|
{
|
|
return a8::RandEx(11, 15);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return a8::RandEx(1, 5);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
int Param::GetCritEffect(float E)
|
|
{
|
|
float E_abs = std::fabs(E);
|
|
if (E_abs <= 0.000001f) {
|
|
return 0;
|
|
}
|
|
int effect = 0;
|
|
for (int i = 0; i < s().crit_effect_range.size(); ++i) {
|
|
if (E_abs <= s().crit_effect_range.at(i)) {
|
|
effect = i + 1;
|
|
break;
|
|
}
|
|
}
|
|
return effect;
|
|
}
|
|
|
|
int Param::GetBlockEffect(float E)
|
|
{
|
|
float E_abs = std::fabs(E);
|
|
if (E_abs <= 0.000001f) {
|
|
return 0;
|
|
}
|
|
int effect = 0;
|
|
for (int i = 0; i < s().block_effect_range.size(); ++i) {
|
|
if (E_abs <= s().block_effect_range.at(i)) {
|
|
effect = i + 11;
|
|
break;
|
|
}
|
|
}
|
|
return effect;
|
|
}
|
|
|
|
}
|