CreatureLib/CInterface/Battling/ExecutingAttack.cpp

57 lines
2.9 KiB
C++
Raw Normal View History

2020-04-06 15:05:32 +00:00
#include "../../src/Battling/Models/ExecutingAttack.hpp"
#include "../Core.hpp"
2020-04-06 15:05:32 +00:00
using namespace CreatureLib::Battling;
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, u8 numberHits, Creature* user,
LearnedAttack* attack,
CreatureLib::Library::AttackData* attackData,
BattleScript* script) {
Try(auto ls = ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>(targetCount);
for (size_t i = 0; i < targetCount; i++) { ls.Append(targets[i]); } auto s =
std::unique_ptr<BattleScript>(script);
out = new ExecutingAttack(ls, numberHits, user, attack, attackData, s);)
2020-04-06 15:05:32 +00:00
}
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
2020-04-06 15:05:32 +00:00
SIMPLE_GET_FUNC(ExecutingAttack, GetNumberOfHits, u8);
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_ExecutingAttack_GetHitData(ExecutingAttack::HitData*& out, ExecutingAttack* p,
Creature* target, u8 hit) {
Try(out = &p->GetHitData(target, hit);)
2020-04-06 15:05:32 +00:00
}
2022-04-02 10:33:26 +00:00
export_func bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
2020-04-06 15:05:32 +00:00
return p->IsCreatureTarget(target);
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
export_func const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
return reinterpret_cast<const Creature* const*>(p->GetTargets().RawData());
}
2020-04-06 15:05:32 +00:00
2022-04-02 10:33:26 +00:00
export_func Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
export_func LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack().GetRaw(); }
export_func const CreatureLib::Library::AttackData* CreatureLib_ExecutingAttack_GetUseAttack(ExecutingAttack* p) {
return p->GetUseAttack().GetRaw();
}
2020-04-06 15:05:32 +00:00
#define HITDATA_GET_FUNC(name, returnType) \
2022-04-02 10:33:26 +00:00
export_func returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
2020-04-06 15:05:32 +00:00
HITDATA_GET_FUNC(IsCritical, bool);
HITDATA_GET_FUNC(GetBasePower, u8);
2020-04-06 15:05:32 +00:00
HITDATA_GET_FUNC(GetEffectiveness, float);
HITDATA_GET_FUNC(GetDamage, u32);
HITDATA_GET_FUNC(GetType, u8);
2020-04-06 15:05:32 +00:00
#define HITDATA_SET_FUNC(name, type) \
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
2020-04-06 15:05:32 +00:00
HITDATA_SET_FUNC(SetCritical, bool);
HITDATA_SET_FUNC(SetBasePower, u8);
2020-04-06 15:05:32 +00:00
HITDATA_SET_FUNC(SetEffectiveness, float);
HITDATA_SET_FUNC(SetDamage, u32);
HITDATA_SET_FUNC(SetType, u8);
2020-04-06 15:05:32 +00:00
#undef HITDATA_GET_FUNC
#undef HITDATA_SET_FUNC