This commit is contained in:
aozhiwei 2022-12-23 11:33:58 +08:00
parent 72527dc095
commit ec3a94d9ef
6 changed files with 132 additions and 131 deletions

View File

@ -9,68 +9,68 @@ namespace mt
void AI::Init1()
{
param1 = a8::XValue(pb->param1()).GetDouble();
param2 = a8::XValue(pb->param2()).GetDouble();
param3 = a8::XValue(pb->param3()).GetDouble();
param4 = a8::XValue(pb->param4()).GetDouble();
param5 = a8::XValue(pb->param5()).GetDouble();
int_param1 = a8::XValue(pb->param1());
int_param2 = a8::XValue(pb->param2());
int_param3 = a8::XValue(pb->param3());
int_param4 = a8::XValue(pb->param4());
int_param5 = a8::XValue(pb->param5());
_param1 = a8::XValue(param1()).GetDouble();
_param2 = a8::XValue(param2()).GetDouble();
_param3 = a8::XValue(param3()).GetDouble();
_param4 = a8::XValue(param4()).GetDouble();
_param5 = a8::XValue(param5()).GetDouble();
_int_param1 = a8::XValue(param1());
_int_param2 = a8::XValue(param2());
_int_param3 = a8::XValue(param3());
_int_param4 = a8::XValue(param4());
_int_param5 = a8::XValue(param5());
{
std::vector<std::string> strings;
a8::Split(pb->param1(), strings, '|');
a8::Split(param1(), strings, '|');
for (auto& str : strings) {
int_list_param1.push_back(a8::XValue(str).GetInt());
int_set_param1.insert(a8::XValue(str).GetInt());
_int_list_param1.push_back(a8::XValue(str).GetInt());
_int_set_param1.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->param2(), strings, '|');
a8::Split(param2(), strings, '|');
for (auto& str : strings) {
int_list_param2.push_back(a8::XValue(str).GetInt());
int_set_param2.insert(a8::XValue(str).GetInt());
_int_list_param2.push_back(a8::XValue(str).GetInt());
_int_set_param2.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->param3(), strings, '|');
a8::Split(param3(), strings, '|');
for (auto& str : strings) {
int_list_param3.push_back(a8::XValue(str).GetInt());
int_set_param3.insert(a8::XValue(str).GetInt());
_int_list_param3.push_back(a8::XValue(str).GetInt());
_int_set_param3.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->param4(), strings, '|');
a8::Split(param4(), strings, '|');
for (auto& str : strings) {
int_list_param4.push_back(a8::XValue(str).GetInt());
int_set_param4.insert(a8::XValue(str).GetInt());
_int_list_param4.push_back(a8::XValue(str).GetInt());
_int_set_param4.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->param5(), strings, '|');
a8::Split(param5(), strings, '|');
for (auto& str : strings) {
int_list_param5.push_back(a8::XValue(str).GetInt());
int_set_param5.insert(a8::XValue(str).GetInt());
_int_list_param5.push_back(a8::XValue(str).GetInt());
_int_set_param5.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->random_move_idle_time(), strings, ';');
if (!pb->random_move_idle_time().empty()) {
random_move_idle_time_ = std::make_tuple
a8::Split(random_move_idle_time(), strings, ';');
if (!random_move_idle_time().empty()) {
_random_move_idle_time = std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
a8::XValue(strings[1]).GetInt()
);
} else {
random_move_idle_time_ = std::make_tuple
_random_move_idle_time = std::make_tuple
(
2,
3
@ -79,27 +79,27 @@ namespace mt
}
{
std::vector<std::string> strings;
a8::Split(pb->random_move_time(), strings, ';');
if (!pb->random_move_time().empty()) {
random_move_time_ = std::make_tuple
a8::Split(random_move_time(), strings, ';');
if (!random_move_time().empty()) {
_random_move_time = std::make_tuple
(
a8::XValue(strings[0]).GetInt(),
a8::XValue(strings[1]).GetInt()
);
} else {
random_move_time_ = std::make_tuple
_random_move_time = std::make_tuple
(
3,
5
);
}
}
if (pb->ai_kind() == kAI_MineSweeper) {
for (int n : int_list_param2) {
if (ai_kind() == kAI_MineSweeper) {
for (int n : _int_list_param2) {
if (n <= 0 || n > 63) {
A8_ABORT();
}
a8::SetBitFlag(bits_param2, n);
a8::SetBitFlag(_bits_param2, n);
}
}
}
@ -112,16 +112,16 @@ namespace mt
int AI::GetMoveIdleTime()
{
return a8::RandEx(
std::get<0>(random_move_idle_time_),
std::get<1>(random_move_idle_time_)
std::get<0>(_random_move_idle_time),
std::get<1>(_random_move_idle_time)
);
}
int AI::GetMoveTime()
{
return a8::RandEx(
std::get<0>(random_move_time_),
std::get<1>(random_move_time_)
std::get<0>(_random_move_time),
std::get<1>(_random_move_time)
);
}

View File

@ -7,12 +7,12 @@ IMPL_TABLE(mt::AirDrop)
namespace mt
{
void AirDrop::Init()
void AirDrop::Init1()
{
{
int total_weight = 0;
std::vector<std::string> strings;
a8::Split(pb->drop_id(), strings, '|');
a8::Split(drop_id(), strings, '|');
for (const std::string& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
@ -20,7 +20,7 @@ namespace mt
int drop_id = a8::XValue(strings2[0]);
int weight = a8::XValue(strings2[1]);
total_weight += weight;
drop.push_back
_drop.push_back
(std::make_tuple(
drop_id,
total_weight
@ -33,9 +33,9 @@ namespace mt
int AirDrop::RandDrop()
{
if (HasDrop()) {
int total_weight = std::get<1>(drop[drop.size() - 1]);
int total_weight = std::get<1>(_drop[_drop.size() - 1]);
int rnd = rand() % total_weight;
for (auto& tuple : drop) {
for (auto& tuple : _drop) {
if (rnd < std::get<1>(tuple)) {
return std::get<0>(tuple);
}

View File

@ -1,25 +1,25 @@
#include "precompile.h"
#include "mt/Buff.h"
#include "mt/AirLine.h"
IMPL_TABLE(mt::Buff)
IMPL_TABLE(mt::AirLine)
namespace mt
{
void AirLine::Init()
void AirLine::Init1()
{
{
std::vector<std::string> strings;
a8::Split(pb->start_point(), strings, ':');
start_point_x = a8::XValue(strings[0]).GetDouble();
start_point_y = a8::XValue(strings[1]).GetDouble();
a8::Split(start_point(), strings, ':');
_start_point_x = a8::XValue(strings[0]).GetDouble();
_start_point_y = a8::XValue(strings[1]).GetDouble();
}
{
std::vector<std::string> strings;
a8::Split(pb->end_point(), strings, ':');
end_point_x = a8::XValue(strings[0]).GetDouble();
end_point_y = a8::XValue(strings[1]).GetDouble();
a8::Split(end_point(), strings, ':');
_end_point_x = a8::XValue(strings[0]).GetDouble();
_end_point_y = a8::XValue(strings[1]).GetDouble();
}
}

View File

@ -6,22 +6,22 @@ IMPL_TABLE(mt::AirRaid)
namespace mt
{
void AirRaid::Init()
void AirRaid::Init1()
{
{
std::vector<std::string> strings;
a8::Split(pb->bomb_id(), strings, '|');
a8::Split(bomb_id(), strings, '|');
for (auto& str : strings) {
bomb_ids.push_back(a8::XValue(str));
_bomb_ids.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(pb->raid_wave(), strings, '|');
a8::Split(raid_wave(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
raid_waves.push_back(std::make_tuple(
_raid_waves.push_back(std::make_tuple(
a8::XValue(strings2[0]).GetInt(),
a8::XValue(strings2[1]).GetInt()
)

View File

@ -1,103 +1,104 @@
#include "precompile.h"
#include "mt/Buff.h"
#include "mt/Hero.h"
IMPL_TABLE(mt::Buff)
namespace mt
{
void Buff::Init()
void Buff::Init1()
{
param1 = a8::XValue(pb->buff_param1()).GetDouble();
param2 = a8::XValue(pb->buff_param2()).GetDouble();
param3 = a8::XValue(pb->buff_param3()).GetDouble();
param4 = a8::XValue(pb->buff_param4()).GetDouble();
param5 = a8::XValue(pb->buff_param5()).GetDouble();
int_param1 = a8::XValue(pb->buff_param1());
int_param2 = a8::XValue(pb->buff_param2());
int_param3 = a8::XValue(pb->buff_param3());
int_param4 = a8::XValue(pb->buff_param4());
int_param5 = a8::XValue(pb->buff_param5());
_param1 = a8::XValue(buff_param1()).GetDouble();
_param2 = a8::XValue(buff_param2()).GetDouble();
_param3 = a8::XValue(buff_param3()).GetDouble();
_param4 = a8::XValue(buff_param4()).GetDouble();
_param5 = a8::XValue(buff_param5()).GetDouble();
_int_param1 = a8::XValue(buff_param1());
_int_param2 = a8::XValue(buff_param2());
_int_param3 = a8::XValue(buff_param3());
_int_param4 = a8::XValue(buff_param4());
_int_param5 = a8::XValue(buff_param5());
{
std::vector<std::string> strings;
a8::Split(pb->child_buff(), strings, '|');
a8::Split(child_buff(), strings, '|');
for (auto& str : strings) {
child_buff_list.push_back(a8::XValue(str));
_child_buff_list.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(pb->immune_buffeffect_list(), strings, '|');
a8::Split(immune_buffeffect_list(), strings, '|');
for (auto& str : strings) {
immune_buffeffect.insert(a8::XValue(str));
_immune_buffeffect.insert(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(pb->buff_param1(), strings, '|');
a8::Split(buff_param1(), strings, '|');
for (auto& str : strings) {
param1_int_list.push_back(a8::XValue(str).GetInt());
param1_int_set.insert(a8::XValue(str).GetInt());
_param1_int_list.push_back(a8::XValue(str).GetInt());
_param1_int_set.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->buff_param2(), strings, '|');
if (pb->buff_param2().find(":") != std::string::npos) {
a8::Split(buff_param2(), strings, '|');
if (buff_param2().find(":") != std::string::npos) {
A8_ABORT();
}
for (auto& str : strings) {
param2_int_list.push_back(a8::XValue(str).GetInt());
param2_int_set.insert(a8::XValue(str).GetInt());
_param2_int_list.push_back(a8::XValue(str).GetInt());
_param2_int_set.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->buff_param3(), strings, '|');
a8::Split(buff_param3(), strings, '|');
for (auto& str : strings) {
param3_int_list.push_back(a8::XValue(str).GetInt());
_param3_int_list.push_back(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->buff_param4(), strings, '|');
a8::Split(buff_param4(), strings, '|');
for (auto& str : strings) {
param4_int_list.push_back(a8::XValue(str).GetInt());
_param4_int_list.push_back(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->only_spec_race(), strings, '|');
a8::Split(only_spec_race(), strings, '|');
for (auto& str : strings) {
int n = a8::XValue(str);
if (n <= 0 || n > 63) {
A8_ABORT();
}
a8::SetBitFlag(only_spec_race, n);
a8::SetBitFlag(_only_spec_race, n);
}
}
{
std::vector<std::string> strings;
a8::Split(pb->exclude_spec_race(), strings, '|');
a8::Split(exclude_spec_race(), strings, '|');
for (auto& str : strings) {
int n = a8::XValue(str);
if (n <= 0 || n > 63) {
A8_ABORT();
}
a8::SetBitFlag(exclude_spec_race, n);
a8::SetBitFlag(_exclude_spec_race, n);
}
}
{
std::vector<std::string> strings;
a8::Split(pb->tag(), strings, '|');
a8::Split(tag(), strings, '|');
for (auto& str : strings) {
tags.insert(a8::XValue(str).GetInt());
_tags.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(pb->post_remove_action(), strings, '|');
a8::Split(post_remove_action(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
@ -107,7 +108,7 @@ namespace mt
if (strings2[0] == "remove_buff_by_id" ||
strings2[0] == "remove_buff_by_effect" ||
strings2[0] == "add_buff") {
auto& action = a8::FastAppend(post_remove_action);
auto& action = a8::FastAppend(_post_remove_action);
if (strings2[0] == "remove_buff_by_id") {
std::get<0>(action) = kRemoveBuffByIdAction;
} else if (strings2[0] == "remove_buff_by_effect") {
@ -126,7 +127,7 @@ namespace mt
}
{
std::vector<std::string> strings;
a8::Split(pb->buff_param1(), strings, '|');
a8::Split(buff_param1(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
@ -137,16 +138,16 @@ namespace mt
int hero_id = a8::XValue(strings2[3]);
int num = strings2.size() > 4 ? a8::XValue(strings2[4]).GetInt() : 10000;
int life_time = strings2.size() > 5 ? a8::XValue(strings2[5]).GetInt() : 1000;
hero_infos.push_back
_hero_infos.push_back
(
std::make_tuple(through_wall, x, y, hero_id, num, life_time)
);
}
}
}
if (pb->buff_effect() == kBET_BatchAddBuff) {
if (buff_effect() == kBET_BatchAddBuff) {
std::vector<std::string> strings1;
a8::Split(pb->buff_param1(), strings1, '|');
a8::Split(buff_param1(), strings1, '|');
for (auto& str1 : strings1) {
std::vector<std::string> strings2;
a8::Split(str1, strings2, '|');
@ -154,7 +155,7 @@ namespace mt
if (str2.size() < 1) {
A8_ABORT();
}
auto& p = a8::FastAppend(batch_add_list);
auto& p = a8::FastAppend(_batch_add_list);
if (str2[0] != '!') {
//概率
std::vector<std::string> strings3;
@ -202,8 +203,8 @@ namespace mt
}
}
}
if (pb->buff_effect() == kBET_CondAddBuff) {
if (!IsValidCondBuff(int_param1)) {
if (buff_effect() == kBET_CondAddBuff) {
if (!IsValidCondBuff(_int_param1)) {
A8_ABORT();
}
}
@ -211,12 +212,12 @@ namespace mt
void Buff::Init2()
{
switch (pb->buff_effect()) {
switch (buff_effect()) {
case kBET_ChgAttr:
{
assert(int_param2 == 1 || int_param2 == 2);
if (int_param2 == 2) {
if (pb->buff_param3().find('.') != std::string::npos) {
assert(_int_param2 == 1 || _int_param2 == 2);
if (_int_param2 == 2) {
if (buff_param3().find('.') != std::string::npos) {
A8_ABORT();
}
}
@ -224,7 +225,7 @@ namespace mt
break;
case kBET_SummonHero:
{
for (auto& info : hero_infos) {
for (auto& info : _hero_infos) {
int hero_id = std::get<3>(info);
const mt::Hero* hero_meta = mt::Hero::GetById(hero_id);
if (!hero_meta) {
@ -233,7 +234,7 @@ namespace mt
// 777
#if 1
#else
MetaData::AI* ai_meta = MetaMgr::Instance()->GetHeroAI(hero_meta->pb->ai());
MetaData::AI* ai_meta = MetaMgr::Instance()->GetHeroAI(hero_meta->ai());
if (!ai_meta) {
A8_ABORT();
}
@ -243,33 +244,33 @@ namespace mt
break;
case kBET_DelayAddBuff:
{
assert(param1 < pb->duration_time());
if (!MetaMgr::Instance()->GetBuff(int_param2)) {
assert(_param1 < duration_time());
if (!mt::Buff::GetById(_int_param2)) {
A8_ABORT();
}
}
break;
case kBET_IntervalAddBuff:
{
assert(int_param1 < pb->duration_time() * 1000);
if (!MetaMgr::Instance()->GetBuff(int_param2)) {
assert(_int_param1 < duration_time() * 1000);
if (!mt::Buff::GetById(_int_param2)) {
A8_ABORT();
}
}
break;
case kBET_BatchAddBuff:
{
for (auto& tuple : batch_add_list) {
for (auto& tuple : _batch_add_list) {
int rand_space = std::get<0>(tuple);
const auto& items = std::get<1>(tuple);
if (rand_space == -1) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(std::get<0>(items[0]));
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(items[0]));
if (!buff_meta) {
A8_ABORT();
}
} else {
for (const auto& item : items) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(std::get<0>(item));
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(item));
if (!buff_meta) {
A8_ABORT();
}
@ -291,7 +292,7 @@ namespace mt
bool Buff::IsImmuneBuffEffect(int buff_effect)
{
return immune_buffeffect.find(buff_effect) != immune_buffeffect.end();
return _immune_buffeffect.find(buff_effect) != _immune_buffeffect.end();
}
bool Buff::Match(CondAddBuff_e cond, int val)
@ -299,12 +300,12 @@ namespace mt
switch (cond) {
case kCondBuffUpdateBuffId:
{
return val == pb->buff_id();
return val == buff_id();
}
break;
case kCondBuffUpdateBuffEffect:
{
return val == pb->buff_effect();
return val == buff_effect();
}
break;
default:

View File

@ -11,21 +11,21 @@ namespace mt
{
std::vector<std::string> item_list;
{
a8::Split(pb->item_id(), item_list, '|');
a8::Split(item_id(), item_list, '|');
}
std::vector<std::string> num_list;
{
a8::Split(pb->num(), num_list, '|');
a8::Split(num(), num_list, '|');
}
std::vector<std::string> weight_list;
{
a8::Split(pb->weight(), weight_list, '|');
a8::Split(weight(), weight_list, '|');
}
assert(item_list.size() == num_list.size() &&
item_list.size() == weight_list.size());
total_weight = 0;
_total_weight = 0;
for (size_t i = 0; i < item_list.size(); ++i) {
total_weight += a8::XValue(weight_list[i]).GetInt();
_total_weight += a8::XValue(weight_list[i]).GetInt();
std::vector<int> itemids;
{
std::vector<std::string> strings;
@ -49,31 +49,31 @@ namespace mt
item_lvs.push_back(1);
}
#endif
if (this->pb->type() == 1) {
if (this->type() == 1) {
auto item_tuple = std::make_tuple(
itemids,
nums,
item_lvs,
a8::XValue(weight_list[i]).GetInt()
);
items.push_back(item_tuple);
_items.push_back(item_tuple);
} else {
auto item_tuple = std::make_tuple(
itemids,
nums,
item_lvs,
total_weight
_total_weight
);
items.push_back(item_tuple);
_items.push_back(item_tuple);
}
}
assert(pb->type() == 1 || pb->type() == 2);
assert(type() == 1 || type() == 2);
}
void Drop::RandItems(std::vector<std::tuple<int, int, int>>& drop_items)
{
if (pb->type() == 1) {
for (auto& item : items) {
if (type() == 1) {
for (auto& item : _items) {
if ((rand() % 10000) <= std::get<3>(item)) {
for (size_t i = 0; i < std::get<0>(item).size(); ++i) {
drop_items.push_back(std::make_tuple(
@ -84,9 +84,9 @@ namespace mt
}
}
}
} else if (total_weight > 0) {
int rnd = rand() % (total_weight + 1);
for (auto& item : items) {
} else if (_total_weight > 0) {
int rnd = rand() % (_total_weight + 1);
for (auto& item : _items) {
if (std::get<3>(item) >= rnd) {
for (size_t i = 0; i < std::get<0>(item).size(); ++i) {
drop_items.push_back(std::make_tuple(