2020-03-05 10:25:41 +00:00
|
|
|
#include "../../src/Battling/Models/Creature.hpp"
|
2020-07-31 08:51:03 +00:00
|
|
|
#include "../Core.hpp"
|
2020-03-05 10:25:41 +00:00
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
|
|
|
|
const CreatureLib::Library::CreatureSpecies* species,
|
2020-08-19 18:11:00 +00:00
|
|
|
const CreatureLib::Library::SpeciesVariant* variant, level_int_t level,
|
2020-03-25 18:07:36 +00:00
|
|
|
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-05-31 15:26:39 +00:00
|
|
|
Try(auto attacksVec = std::vector<LearnedAttack*>(attacks, attacks + (attacksNum * sizeof(LearnedAttack*)));
|
2020-12-12 12:40:30 +00:00
|
|
|
out =
|
|
|
|
new Creature(library, ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species), variant,
|
|
|
|
level, experience, uid, gender, coloring,
|
|
|
|
ArbUt::OptionalBorrowedPtr<const CreatureLib::Library::Item>(heldItem), std::string(nickname),
|
|
|
|
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; }
|
|
|
|
|
2020-08-17 15:23:03 +00:00
|
|
|
export uint8_t CreatureLib_Creature_Initialize(Creature* p) { Try(p->Initialize();) }
|
|
|
|
|
2020-07-25 13:02:11 +00:00
|
|
|
BORROWED_GET_FUNC(Creature, GetLibrary, const CreatureLib::Battling::BattleLibrary*);
|
2020-07-07 13:33:43 +00:00
|
|
|
BORROWED_GET_FUNC(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
|
|
|
|
BORROWED_GET_FUNC(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
|
2020-06-10 12:39:20 +00:00
|
|
|
|
2020-08-13 08:38:56 +00:00
|
|
|
export uint8_t CreatureLib_Creature_ChangeSpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species,
|
|
|
|
const CreatureLib::Library::SpeciesVariant* variant) {
|
|
|
|
Try(p->ChangeSpecies(species, variant);)
|
|
|
|
}
|
2020-06-10 12:39:20 +00:00
|
|
|
export uint8_t CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
|
|
|
|
Try(p->ChangeVariant(variant);)
|
|
|
|
}
|
|
|
|
|
2020-08-19 18:11:00 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, GetLevel, level_int_t);
|
2020-03-05 10:25:41 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, GetExperience, uint32_t);
|
2020-08-09 09:48:40 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, GetUniqueIdentifier, uint32_t);
|
2020-03-05 10:25:41 +00:00
|
|
|
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) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->HasHeldItem(ArbUt::StringView(name));
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
|
2020-12-12 12:40:30 +00:00
|
|
|
OPTIONAL_GET_FUNC(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) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->SetHeldItem(ArbUt::StringView(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-26 16:31:06 +00:00
|
|
|
return p->SetHeldItem(ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(item));
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
|
2020-12-12 11:22:48 +00:00
|
|
|
OPTIONAL_GET_FUNC(Creature, GetBattle, Battle*);
|
|
|
|
OPTIONAL_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
2020-03-05 10:25:41 +00:00
|
|
|
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
2021-09-19 09:40:18 +00:00
|
|
|
export const char* CreatureLib_Creature_GetNickname(Creature* p) {
|
|
|
|
auto s = p->GetNickname();
|
|
|
|
if (s.has_value()) {
|
|
|
|
return p->GetNickname().value().data();
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2020-12-22 15:11:23 +00:00
|
|
|
export void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
|
2020-03-05 10:25:41 +00:00
|
|
|
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
2020-10-23 14:51:15 +00:00
|
|
|
export size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
|
|
|
|
export const uint8_t* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
|
2020-03-05 10:25:41 +00:00
|
|
|
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-08-08 09:32:25 +00:00
|
|
|
export uint8_t CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
|
2020-09-05 12:51:06 +00:00
|
|
|
|
|
|
|
export bool CreatureLib_Creature_GetRealTalentIsSecret(const Creature* p) { return p->GetRealTalent().IsSecret(); }
|
|
|
|
export bool CreatureLib_Creature_GetRealTalentIndex(const Creature* p) { return p->GetRealTalent().GetIndex(); }
|
|
|
|
|
2021-11-15 11:04:45 +00:00
|
|
|
export uint8_t CreatureLib_Creature_GetActiveTalent(const Creature* p, const CreatureLib::Library::Talent*& out) {
|
|
|
|
Try(out = p->GetActiveTalent().GetRaw();)
|
2020-07-24 08:16:57 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->OverrideActiveTalent(ArbUt::StringView(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) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->AddVolatileScript(ArbUt::StringView(scriptName));)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2021-03-07 09:26:41 +00:00
|
|
|
export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(p->AddVolatileScript(script);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->RemoveVolatileScript(ArbUt::StringView(scriptName));)
|
2020-03-25 18:07:36 +00:00
|
|
|
}
|
2021-03-07 09:26:41 +00:00
|
|
|
export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(p->RemoveVolatileScript(script);)
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
|
|
|
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->HasVolatileScript(ArbUt::StringView(scriptName));
|
2020-03-05 10:25:41 +00:00
|
|
|
}
|
2020-03-22 18:21:40 +00:00
|
|
|
export size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
|
2020-07-17 11:12:21 +00:00
|
|
|
export LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { return p->GetAttacks().RawData(); }
|
2020-08-09 09:48:40 +00:00
|
|
|
export bool CreatureLib_Creature_HasAttack(Creature* p, const char* scriptName) {
|
|
|
|
return p->HasAttack(ArbUt::StringView(scriptName));
|
|
|
|
}
|
2020-12-12 11:22:48 +00:00
|
|
|
OPTIONAL_GET_FUNC(Creature, GetDisplaySpecies, const CreatureLib::Library::CreatureSpecies*);
|
|
|
|
OPTIONAL_GET_FUNC(Creature, GetDisplayVariant, const CreatureLib::Library::SpeciesVariant*);
|
2020-03-05 10:25:41 +00:00
|
|
|
export void CreatureLib_Creature_SetDisplaySpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species) {
|
2020-05-26 16:31:06 +00:00
|
|
|
return p->SetDisplaySpecies(ArbUt::BorrowedPtr<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);
|
|
|
|
}
|
2021-06-26 09:48:13 +00:00
|
|
|
export bool CreatureLib_Creature_AllowedExperienceGain(Creature* p) { return p->AllowedExperienceGain(); }
|
|
|
|
export void CreatureLib_Creature_SetAllowedExperienceGain(Creature* p, bool b) { p->SetAllowedExperienceGain(b); }
|
|
|
|
|
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-08-12 15:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SIMPLE_GET_FUNC(Creature, GetAvailableAttackSlot, uint8_t);
|
|
|
|
export uint8_t CreatureLib_Creature_AddAttack(Creature* p, LearnedAttack* attack) { Try(p->AddAttack(attack);) }
|
|
|
|
export uint8_t CreatureLib_Creature_ReplaceAttack(Creature* p, size_t index, LearnedAttack* attack) {
|
|
|
|
Try(p->ReplaceAttack(index, attack);)
|
2020-08-12 16:54:01 +00:00
|
|
|
}
|
2021-07-09 13:33:30 +00:00
|
|
|
export uint8_t CreatureLib_Creature_SwapAttack(Creature* p, size_t a, size_t b) { Try(p->SwapAttacks(a, b);) }
|
|
|
|
|
|
|
|
export u8 CreatureLib_Creature_SetStatus(Creature* p, const char* name) { Try(p->SetStatus(ArbUt::StringView(name))); };
|
|
|
|
export u8 CreatureLib_Creature_ClearStatus(Creature* p) { Try(p->ClearStatus()); };
|
2021-07-09 13:53:24 +00:00
|
|
|
export const char* CreatureLib_Creature_GetStatusName(Creature* p) { return p->GetStatusName().c_str(); }
|