529 lines
18 KiB
C++
529 lines
18 KiB
C++
#include "precompile.h"
|
|
|
|
#include "lispenv.h"
|
|
|
|
#include "mt/Buff.h"
|
|
#include "mt/Hero.h"
|
|
|
|
#include "buff/callfunc.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();
|
|
_buff_param6 = a8::XValue(buff_param6()).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());
|
|
_int_buff_param6 = a8::XValue(buff_param6());
|
|
_res_scale = a8::XValue(res_scale()).GetDouble();
|
|
{
|
|
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());
|
|
}
|
|
}
|
|
{
|
|
if (buff_effect() == kBET_CallFunc &&
|
|
(int)BuffCallFunc_e::kSetBulletBornOffset == _int_buff_param1) {
|
|
} else {
|
|
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(buff_param5(), strings, '|');
|
|
for (auto& str : strings) {
|
|
_buff_param5_int_list.push_back(a8::XValue(str).GetInt());
|
|
_buff_param5_int_set.insert(a8::XValue(str).GetInt());
|
|
}
|
|
}
|
|
{
|
|
std::vector<std::string> strings;
|
|
a8::Split(buff_param6(), strings, '|');
|
|
for (auto& str : strings) {
|
|
_buff_param6_int_list.push_back(a8::XValue(str).GetInt());
|
|
_buff_param6_int_set.insert(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());
|
|
}
|
|
}
|
|
{
|
|
if (a8::lisp::Expr::MaybeExpr(duration_time())) {
|
|
_duration_time_expr = LispEnv::Instance()->CompileSkillNumberExpr(duration_time());
|
|
} else {
|
|
_duration_time = a8::XValue(duration_time()).GetDouble();
|
|
}
|
|
}
|
|
{
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param1())) {
|
|
_buff_param1_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param1());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param2())) {
|
|
_buff_param2_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param2());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param3())) {
|
|
_buff_param3_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param3());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param4())) {
|
|
_buff_param4_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param4());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param5())) {
|
|
_buff_param5_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param5());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_param6())) {
|
|
_buff_param6_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_param6());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(res_scale())) {
|
|
_res_scale_expr = LispEnv::Instance()->CompileSkillNumberExpr(res_scale());
|
|
}
|
|
if (a8::lisp::Expr::MaybeExpr(buff_interval())) {
|
|
_buff_interval_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_interval());
|
|
} else {
|
|
_buff_interval = a8::XValue(buff_interval()).GetDouble();
|
|
}
|
|
}
|
|
{
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#if 0
|
|
{
|
|
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)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
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 (!IsValidEventBuff(_int_buff_param1)) {
|
|
A8_ABORT();
|
|
}
|
|
}
|
|
{
|
|
if (buff_effect() == kBET_CallFunc &&
|
|
(int)BuffCallFunc_e::kSetBulletBornOffset == _int_buff_param1) {
|
|
std::string data = buff_param2();
|
|
std::vector<std::string> strings;
|
|
a8::Split(data, strings, '|');
|
|
for (auto& str : strings) {
|
|
std::vector<std::string> strings2;
|
|
a8::Split(str, strings2, ':');
|
|
if (strings2.size() < 2) {
|
|
abort();
|
|
}
|
|
_bullet_born_offset.push_back
|
|
(std::make_tuple(
|
|
a8::XValue(strings2[0]).GetDouble(),
|
|
a8::XValue(strings2[1]).GetDouble(),
|
|
strings2.size() > 2 ? a8::XValue(strings2[2]).GetDouble() : 0,
|
|
strings2.size() > 3 ? a8::XValue(strings2[3]).GetInt() : 0,
|
|
strings2.size() > 4 ? a8::XValue(strings2[4]).GetInt() : 0,
|
|
strings2.size() > 5 ? a8::XValue(strings2[5]).GetInt() : 0
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Buff::Init2()
|
|
{
|
|
if (buff_effect() == 7 &&
|
|
(_int_buff_param1 == 2 ||
|
|
_int_buff_param1 == 6 ||
|
|
_int_buff_param1 == 14 ||
|
|
_int_buff_param1 == 15 ||
|
|
_int_buff_param1 == 9
|
|
)) {
|
|
abort();
|
|
}
|
|
switch (buff_effect()) {
|
|
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(EventAddBuff_e event, int val) const
|
|
{
|
|
switch (event) {
|
|
case kEventBuffUpdateBuffId:
|
|
{
|
|
return val == buff_id();
|
|
}
|
|
break;
|
|
case kEventBuffUpdateBuffEffect:
|
|
{
|
|
return val == buff_effect();
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
float Buff::GetDurationTime(::Buff* buff) const
|
|
{
|
|
if (_duration_time_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_duration_time_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _duration_time;
|
|
}
|
|
|
|
float Buff::GetBuffParam1(::Buff* buff) const
|
|
{
|
|
if (_buff_param1_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param1_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param1;
|
|
}
|
|
|
|
float Buff::GetBuffParam2(::Buff* buff) const
|
|
{
|
|
if (_buff_param2_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param2_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param2;
|
|
}
|
|
|
|
float Buff::GetBuffParam3(::Buff* buff) const
|
|
{
|
|
if (_buff_param3_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param3_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param3;
|
|
}
|
|
|
|
float Buff::GetBuffParam4(::Buff* buff) const
|
|
{
|
|
if (_buff_param4_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param4_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param4;
|
|
}
|
|
|
|
float Buff::GetBuffParam5(::Buff* buff) const
|
|
{
|
|
if (_buff_param5_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param5_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param5;
|
|
}
|
|
|
|
float Buff::GetBuffParam6(::Buff* buff) const
|
|
{
|
|
if (_buff_param6_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_param6_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_param6;
|
|
}
|
|
|
|
float Buff::GetResScale(::Buff* buff) const
|
|
{
|
|
if (_res_scale_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_res_scale_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _res_scale;
|
|
}
|
|
|
|
std::string Buff::duration_time() const
|
|
{
|
|
return mtb::Buff::duration_time();
|
|
}
|
|
|
|
float Buff::GetBuffInterval(::Buff* buff) const
|
|
{
|
|
if (_buff_interval_expr) {
|
|
return LispEnv::Instance()->EvalSkillNumberExpr
|
|
(
|
|
_buff_interval_expr,
|
|
buff
|
|
);
|
|
}
|
|
return _buff_interval;
|
|
}
|
|
|
|
bool Buff::HasBuffInterval() const
|
|
{
|
|
return !buff_interval().empty();
|
|
}
|
|
|
|
}
|