CreatureLib/CInterface/Battling/ExecutingAttack.cpp

55 lines
2.7 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;
export 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
}
export void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
SIMPLE_GET_FUNC(ExecutingAttack, GetNumberOfHits, u8);
export 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
}
export bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
return p->IsCreatureTarget(target);
}
export u8 CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
export 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
export Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
export LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack().GetRaw(); }
export 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) \
export returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
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) \
export void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
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