2020-03-05 10:25:41 +00:00
|
|
|
#include "../../src/Battling/Models/Creature.hpp"
|
2020-03-25 18:07:36 +00:00
|
|
|
#include "../Core.hpp"
|
2020-03-05 10:25:41 +00:00
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
using ConstString = Arbutils::CaseInsensitiveConstString;
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
|
|
|
|
const CreatureLib::Library::CreatureSpecies* species,
|
|
|
|
const CreatureLib::Library::SpeciesVariant* variant, uint8_t level,
|
|
|
|
uint32_t experience, uint32_t uid, CreatureLib::Library::Gender gender,
|
|
|
|
uint8_t coloring, const CreatureLib::Library::Item* heldItem,
|
2020-05-02 12:14:29 +00:00
|
|
|
const char* nickname, bool secretTalent, uint8_t talent,
|
2020-05-20 13:18:27 +00:00
|
|
|
LearnedAttack* attacks[], size_t attacksNum, bool allowedExperienceGain) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(auto attacksVec = List<LearnedAttack*>(attacks, attacks + attacksNum);
|
2020-05-24 18:57:22 +00:00
|
|
|
out = new Creature(library, std::shared_ptr<const CreatureLib::Library::CreatureSpecies>(species), variant,
|
|
|
|
level, experience, uid, gender, coloring,
|
|
|
|
std::shared_ptr<const CreatureLib::Library::Item>(heldItem), nickname,
|
2020-05-20 13:18:27 +00:00
|
|
|
CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec, allowedExperienceGain);)
|
2020-03-05 10:25:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
|
|
|
|
|
|
|
|
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
|
|
|
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
2020-05-24 18:57:22 +00:00
|
|
|
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
|
|
|
|
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
|
2020-03-05 10:25:41 +00:00
|
|
|
|
2020-05-24 18:57:22 +00:00
|
|
|
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
|
2020-03-05 10:25:41 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetLevel, uint8_t);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetExperience, uint32_t);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetColoring, uint8_t);
|
|
|
|
|
|
|
|
export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
|
|
|
|
return p->HasHeldItem(ConstString(name));
|
|
|
|
}
|
|
|
|
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
|
2020-05-24 18:57:22 +00:00
|
|
|
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetHeldItem, const CreatureLib::Library::Item*);
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
|
|
|
|
Try(p->SetHeldItem(ConstString(name));)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_SetHeldItemWithHash(Creature* p, uint32_t hash) { Try(p->SetHeldItem(hash);) }
|
2020-03-05 10:25:41 +00:00
|
|
|
export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
|
2020-05-24 18:57:22 +00:00
|
|
|
return p->SetHeldItem(std::shared_ptr<const CreatureLib::Library::Item>(item));
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetBattle, Battle*);
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
|
|
|
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
|
|
|
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().c_str(); }
|
2020-03-22 18:21:40 +00:00
|
|
|
export size_t CreatureLib_Creature_GetTypesCount(Creature* p) { return p->GetTypes().Count(); }
|
|
|
|
export const uint8_t* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().RawData(); }
|
2020-03-05 10:25:41 +00:00
|
|
|
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) { Try(p->ChangeLevelBy(level);) }
|
|
|
|
export uint8_t CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageSource source) {
|
|
|
|
Try(p->Damage(damage, source);)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canRevive) {
|
|
|
|
Try(p->Heal(health, canRevive);)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
|
|
|
|
Try(p->OverrideActiveTalent(ConstString(talent));)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_AddExperience(Creature* p, uint32_t experience) {
|
|
|
|
Try(p->AddExperience(experience);)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
|
|
|
|
export uint8_t CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
|
|
|
|
Try(p->AddVolatileScript(ConstString(scriptName));)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, Script* script) {
|
|
|
|
Try(p->AddVolatileScript(script);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
|
|
|
|
Try(p->RemoveVolatileScript(ConstString(scriptName));)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, Script* script) {
|
|
|
|
Try(p->RemoveVolatileScript(script);)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
|
|
|
|
return p->HasVolatileScript(ConstString(scriptName));
|
|
|
|
}
|
2020-03-22 18:21:40 +00:00
|
|
|
export size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
|
|
|
|
export LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { return p->GetAttacks().RawData(); }
|
2020-05-24 18:57:22 +00:00
|
|
|
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetDisplaySpecies, const CreatureLib::Library::CreatureSpecies*);
|
2020-03-05 10:25:41 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, GetDisplayVariant, const CreatureLib::Library::SpeciesVariant*);
|
|
|
|
export void CreatureLib_Creature_SetDisplaySpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species) {
|
2020-05-24 18:57:22 +00:00
|
|
|
return p->SetDisplaySpecies(std::shared_ptr<const CreatureLib::Library::CreatureSpecies>(species));
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
export void CreatureLib_Creature_SetDisplayVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
|
|
|
|
return p->SetDisplayVariant(variant);
|
|
|
|
}
|
2020-03-22 09:11:53 +00:00
|
|
|
export void CreatureLib_Creature_ChangeStatBoost(Creature* p, CreatureLib::Library::Statistic stat, int8_t diffAmount) {
|
2020-03-05 10:25:41 +00:00
|
|
|
p->ChangeStatBoost(stat, diffAmount);
|
|
|
|
}
|
2020-03-22 09:11:53 +00:00
|
|
|
export uint32_t CreatureLib_Creature_GetFlatStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
2020-03-05 10:25:41 +00:00
|
|
|
return p->GetFlatStat(stat);
|
|
|
|
}
|
2020-03-22 09:11:53 +00:00
|
|
|
export uint32_t CreatureLib_Creature_GetBoostedStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
2020-03-05 10:25:41 +00:00
|
|
|
return p->GetBoostedStat(stat);
|
|
|
|
}
|
2020-03-22 09:11:53 +00:00
|
|
|
export uint32_t CreatureLib_Creature_GetBaseStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
2020-03-05 10:25:41 +00:00
|
|
|
return p->GetBaseStat(stat);
|
|
|
|
}
|
2020-03-22 09:11:53 +00:00
|
|
|
export int8_t CreatureLib_Creature_GetStatBoost(Creature* p, CreatureLib::Library::Statistic stat) {
|
2020-03-05 10:25:41 +00:00
|
|
|
return p->GetStatBoost(stat);
|
|
|
|
}
|
|
|
|
|
2020-05-24 18:57:22 +00:00
|
|
|
#undef SIMPLE_GET_FUNC
|
|
|
|
#undef SIMPLE_GET_FUNC_SMART_PTR
|