2020-03-02 14:38:18 +00:00
|
|
|
#include "../../src/Library/Attacks/AttackData.hpp"
|
2020-03-25 18:07:36 +00:00
|
|
|
#include "../Core.hpp"
|
2020-03-02 14:38:18 +00:00
|
|
|
using namespace CreatureLib::Library;
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* name, uint8_t type,
|
|
|
|
AttackCategory category, uint8_t power, uint8_t accuracy,
|
|
|
|
uint8_t baseUsage, AttackTarget target, int8_t priority,
|
2020-04-10 15:54:45 +00:00
|
|
|
float effectChance, const char* effectName,
|
|
|
|
EffectParameter* effectParameters[], size_t effectParameterCount,
|
|
|
|
const char* flags[], size_t flagsCount) {
|
2020-04-10 14:35:24 +00:00
|
|
|
Try({
|
|
|
|
std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
|
|
|
for (size_t i = 0; i < flagsCount; i++) {
|
2020-06-26 15:08:23 +00:00
|
|
|
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
|
2020-04-10 14:35:24 +00:00
|
|
|
}
|
2020-05-26 16:31:06 +00:00
|
|
|
ArbUt::List<EffectParameter*> effectParameterList(effectParameterCount);
|
2020-04-10 14:35:24 +00:00
|
|
|
for (size_t i = 0; i < effectParameterCount; i++) {
|
|
|
|
effectParameterList[i] = effectParameters[i];
|
|
|
|
}
|
|
|
|
|
2020-06-26 15:08:23 +00:00
|
|
|
auto effect = new SecondaryEffect(effectChance, ArbUt::StringView(effectName), effectParameterList);
|
2020-03-02 14:38:18 +00:00
|
|
|
|
2020-06-26 15:08:23 +00:00
|
|
|
out = new AttackData(ArbUt::StringView(name), type, category, power, accuracy, baseUsage, target, priority,
|
|
|
|
effect, conversedFlags);
|
2020-04-10 14:35:24 +00:00
|
|
|
})
|
2020-03-02 14:38:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
|
|
|
|
|
|
|
|
export const char* CreatureLib_AttackData_GetName(const AttackData* p) { return p->GetName().c_str(); }
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetType, uint8_t);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetCategory, AttackCategory);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetBasePower, uint8_t);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetAccuracy, uint8_t);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetBaseUsages, uint8_t);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetTarget, AttackTarget);
|
|
|
|
SIMPLE_GET_FUNC(AttackData, GetPriority, int8_t);
|
|
|
|
|
2020-04-06 10:53:49 +00:00
|
|
|
export bool CreatureLib_AttackData_HasSecondaryEffect(const AttackData* p) { return p->HasSecondaryEffect(); }
|
|
|
|
|
2020-04-06 15:05:32 +00:00
|
|
|
export float CreatureLib_AttackData_GetSecondaryEffectChance(const AttackData* p) {
|
2020-04-10 20:17:48 +00:00
|
|
|
return p->GetSecondaryEffect()->GetChance();
|
2020-04-06 10:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackData* p) {
|
2020-04-10 20:17:48 +00:00
|
|
|
return p->GetSecondaryEffect()->GetEffectName().c_str();
|
2020-04-06 10:53:49 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 14:38:18 +00:00
|
|
|
export bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
2020-07-07 13:33:43 +00:00
|
|
|
}
|