aozhiwei 2b8063a97a 1
2023-02-13 13:11:59 +08:00

154 lines
5.3 KiB
C++

#include "precompile.h"
#include <a8/reflect.h>
#include "mt/Skill.h"
#include "mt/Buff.h"
#include "mt/SkillNumber.h"
#include "skillhelper.h"
IMPL_TABLE(mt::Skill)
namespace mt
{
void Skill::Init1()
{
{
std::vector<std::string> strings;
a8::Split(buff_list(), strings, '|');
for (auto& str : strings) {
_buff_list.insert(a8::XValue(str));
}
}
{
auto class_meta = GetClass();
for (int idx = 1; idx <= 100; ++idx) {
mt::SkillPhase phase;
{
auto field_desc = class_meta->GetFieldByName(a8::Format("phase%d_time_offset", {idx}));
if (!field_desc) {
break;
}
phase.phase_idx = _phases.size() + 1;
phase.time_offset = *((int*)((char*)this + field_desc->offset));
}
{
auto field_desc = class_meta->GetFieldByName(a8::Format("phase%d_func", {idx}));
phase.func_id = (SkillFunc_e)*((int*)((char*)this + field_desc->offset));
}
{
auto field_desc = class_meta->GetFieldByName(a8::Format("phase%d_param1", {idx}));
phase.phase_param1_str = *((std::string*)((char*)this + field_desc->offset));
}
{
auto field_desc = class_meta->GetFieldByName(a8::Format("phase%d_param2", {idx}));
phase.phase_param2_str = *((std::string*)((char*)this + field_desc->offset));
}
{
auto field_desc = class_meta->GetFieldByName(a8::Format("phase%d_param3", {idx}));
phase.phase_param3_str = *((std::string*)((char*)this + field_desc->offset));
}
{
phase.phase_param1 = a8::XValue(phase.phase_param1_str);
phase.phase_param2 = a8::XValue(phase.phase_param2_str);
phase.phase_param3 = a8::XValue(phase.phase_param3_str);
{
std::vector<std::string> strings;
a8::Split(phase.phase_param1_str, strings, '|');
for (auto& str : strings) {
phase.phase_param1_ints.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(phase.phase_param2_str, strings, '|');
for (auto& str : strings) {
phase.phase_param2_ints.push_back(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(phase.phase_param3_str, strings, '|');
for (auto& str : strings) {
phase.phase_param3_ints.push_back(a8::XValue(str));
}
}
if (phase.func_id != kSkill_FuncNone) {
_phases.push_back(phase);
}
_raw_phases.push_back(phase);
}
}
}
{
SkillHelper::GetMagicIdAndBaseSkillId(skill_id(), _magic_id, _base_skill_id);
}
}
void Skill::Init2()
{
if (!(skill_type() == kActiveSkill || skill_type() == kPassiveSkill)) {
A8_ABORT();
}
#if 0
if (!(use_method() == 1 || use_method() == 2 || use_method() == 3)) {
A8_ABORT();
}
#endif
{
for (int buff_id : _buff_list) {
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
if (!buff_meta) {
A8_ABORT();
}
if (skill_type() == kPassiveSkill) {
if (buff_meta->trigger_type() != kBTT_UseSkill) {
A8_ABORT();
}
}
auto itr = _trigger_type_buffs.find(buff_meta->trigger_type());
if (itr != _trigger_type_buffs.end()) {
itr->second.insert(buff_meta);
} else {
_trigger_type_buffs[buff_meta->trigger_type()] = std::set<const mt::Buff*>({buff_meta});
}
}
}
{
_base_skill_meta = mt::Skill::GetById(_base_skill_id);
if (_base_skill_id) {
if (!_base_skill_meta) {
abort();
}
}
}
{
_number_meta = mt::SkillNumber::GetById(skill_id());
if (!_number_meta && GetMagicId() != 0) {
abort();
}
if (_number_meta) {
skill_cd_ = _number_meta->_float_cd;
}
}
}
int Skill::GetMagicId() const
{
return _magic_id;
}
bool Skill::IsTurnOverSkill() const
{
return !_phases.empty() && _phases[0].func_id == kSkill_TurnOver;
}
void Skill::SetSkillDistance(float distance) const
{
((Skill*)this)->skill_distance_ = distance;
}
}