aozhiwei dc0d264c71 1
2023-03-04 19:13:20 +08:00

333 lines
12 KiB
C++

#include "precompile.h"
#include "mt/Buff.h"
#include "mt/Hero.h"
IMPL_TABLE(mt::Buff)
namespace mt
{
void Buff::Init1()
{
_buff_param1 = a8::XValue(buff_param1()).GetDouble();
_buff_param2 = a8::XValue(buff_param2()).GetDouble();
_buff_param3 = a8::XValue(buff_param3()).GetDouble();
_buff_param4 = a8::XValue(buff_param4()).GetDouble();
_buff_param5 = a8::XValue(buff_param5()).GetDouble();
_int_buff_param1 = a8::XValue(buff_param1());
_int_buff_param2 = a8::XValue(buff_param2());
_int_buff_param3 = a8::XValue(buff_param3());
_int_buff_param4 = a8::XValue(buff_param4());
_int_buff_param5 = a8::XValue(buff_param5());
{
std::vector<std::string> strings;
a8::Split(child_buff(), strings, '|');
for (auto& str : strings) {
_child_buff_list.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(effect_list(), strings, '|');
for (auto& str : strings) {
_effect_list.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(immune_buffeffect_list(), strings, '|');
for (auto& str : strings) {
_immune_buffeffect.insert(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(buff_param1(), strings, '|');
for (auto& str : strings) {
_buff_param1_int_list.push_back(a8::XValue(str).GetInt());
_buff_param1_int_set.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(buff_param2(), strings, '|');
if (buff_param2().find(":") != std::string::npos) {
A8_ABORT();
}
for (auto& str : strings) {
_buff_param2_int_list.push_back(a8::XValue(str).GetInt());
_buff_param2_int_set.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(buff_param3(), strings, '|');
for (auto& str : strings) {
_buff_param3_int_list.push_back(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(buff_param4(), strings, '|');
for (auto& str : strings) {
_buff_param4_int_list.push_back(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> 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);
}
}
{
std::vector<std::string> 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);
}
}
{
std::vector<std::string> strings;
a8::Split(tag(), strings, '|');
for (auto& str : strings) {
_tags.insert(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(post_remove_action(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
if (strings2.size() >= 2) {
std::vector<std::string> strings3;
a8::Split(strings2[1], strings3, ';');
if (strings2[0] == "remove_buff_by_id" ||
strings2[0] == "remove_buff_by_effect" ||
strings2[0] == "add_buff") {
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") {
std::get<0>(action) = kRemoveBuffByEffectAction;
} else if (strings2[0] == "add_buff") {
std::get<0>(action) = kAddBuffAction;
}
for (auto& str3 : strings3) {
if (!str3.empty()) {
std::get<1>(action).push_back(a8::XValue(str3));
}
}
}
}
}
}
{
std::vector<std::string> strings;
a8::Split(buff_param1(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
if (strings2.size() >= 4) {
int through_wall = a8::XValue(strings2[0]);
float x = a8::XValue(strings2[1]).GetDouble();
float y = a8::XValue(strings2[2]).GetDouble();
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
(
std::make_tuple(through_wall, x, y, hero_id, num, life_time)
);
}
}
}
if (buff_effect() == kBET_BatchAddBuff) {
std::vector<std::string> strings1;
a8::Split(buff_param1(), strings1, '|');
for (auto& str1 : strings1) {
std::vector<std::string> strings2;
a8::Split(str1, strings2, '|');
for (auto& str2 : strings2) {
if (str2.size() < 1) {
A8_ABORT();
}
auto& p = a8::FastAppend(_batch_add_list);
if (str2[0] != '!') {
//概率
std::vector<std::string> strings3;
a8::Split(str2, strings3, ':');
if (strings3.size() != 2) {
A8_ABORT();
}
if (a8::XValue(strings3[1]).GetInt() <= 0) {
A8_ABORT();
}
std::get<0>(p) = -1;
std::get<1>(p).push_back
(
std::make_tuple(a8::XValue(strings3[0]),
a8::XValue(strings3[1]))
);
} else {
//权重
std::vector<std::string> strings3;
a8::Split(str2, strings3, '$');
int rand_space = 0;
for (const std::string& str3 : strings3) {
std::vector<std::string> strings4;
a8::Split(str3, strings4, ':');
if (strings4.size() != 2) {
A8_ABORT();
}
std::string tmp_str = strings4[0];
a8::ReplaceString(tmp_str, "!", "");
int buff_id = a8::XValue(tmp_str);
int weight = a8::XValue(strings4[1]);
if (weight <= 0) {
A8_ABORT();
}
rand_space += weight;
std::get<1>(p).push_back
(
std::make_tuple(buff_id,
rand_space)
);
}
std::get<0>(p) = rand_space;
}
}
}
}
if (buff_effect() == kBET_EventAdd) {
if (!IsValidCondBuff(_int_buff_param1)) {
A8_ABORT();
}
}
}
void Buff::Init2()
{
switch (buff_effect()) {
case kBET_ChgAttr:
{
assert(_int_buff_param2 == 1 || _int_buff_param2 == 2);
if (_int_buff_param2 == 2) {
if (buff_param3().find('.') != std::string::npos) {
A8_ABORT();
}
}
}
break;
case kBET_SummonHero:
{
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) {
A8_ABORT();
}
}
}
break;
case kBET_DelayAddBuff:
{
#if 0
assert(_buff_param1 < duration_time());
#endif
if (!mt::Buff::GetById(_int_buff_param2)) {
A8_ABORT();
}
}
break;
case kBET_IntervalAddBuff:
{
#if 0
assert(_int_buff_param1 < duration_time() * 1000);
#endif
if (!mt::Buff::GetById(_int_buff_param2)) {
A8_ABORT();
}
}
break;
case kBET_BatchAddBuff:
{
for (auto& tuple : _batch_add_list) {
int rand_space = std::get<0>(tuple);
const auto& items = std::get<1>(tuple);
if (rand_space == -1) {
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(items[0]));
if (!buff_meta) {
A8_ABORT();
}
} else {
for (const auto& item : items) {
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(item));
if (!buff_meta) {
A8_ABORT();
}
}
}
}
}
default:
{
}
break;
}
}
bool Buff::EffectCanStack() const
{
return true;
}
bool Buff::IsImmuneBuffEffect(int buff_effect) const
{
return _immune_buffeffect.find(buff_effect) != _immune_buffeffect.end();
}
bool Buff::Match(CondAddBuff_e cond, int val) const
{
switch (cond) {
case kCondBuffUpdateBuffId:
{
return val == buff_id();
}
break;
case kCondBuffUpdateBuffEffect:
{
return val == buff_effect();
}
break;
default:
{
return false;
}
break;
}
}
float Buff::GetDurationTime(const mt::Skill* skill_meta) const
{
return 0.0f;
}
std::string Buff::duration_time() const
{
return mtb::Buff::duration_time();
}
}