Update to latest Arbutils, use new integer defines
This commit is contained in:
parent
52127f6555
commit
3cc19de61f
|
@ -2,9 +2,9 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
|
||||
size_t numberOfParties, bool canFlee, uint8_t numberOfSides,
|
||||
uint8_t creaturesPerSide, uint_fast32_t randomSeed) {
|
||||
export u8 CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
|
||||
size_t numberOfParties, bool canFlee, u8 numberOfSides, u8 creaturesPerSide,
|
||||
uint_fast32_t randomSeed) {
|
||||
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
|
||||
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide, randomSeed);)
|
||||
}
|
||||
|
@ -12,38 +12,36 @@ export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* l
|
|||
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
|
||||
|
||||
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
|
||||
export uint8_t CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
||||
export u8 CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
||||
Try(out = p->CanUse(turnChoice);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
||||
export u8 CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
||||
Try(out = p->TrySetChoice(turnChoice);)
|
||||
}
|
||||
export bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
|
||||
export uint8_t CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
|
||||
export uint32_t CreatureLib_Battle_GetCurrentTurn(Battle* p) { return p->GetCurrentTurn(); }
|
||||
export uint32_t CreatureLib_Battle_GetCreaturesPerSide(Battle* p) { return p->GetCreaturesPerSide(); }
|
||||
export u8 CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
|
||||
export u32 CreatureLib_Battle_GetCurrentTurn(Battle* p) { return p->GetCurrentTurn(); }
|
||||
export u32 CreatureLib_Battle_GetCreaturesPerSide(Battle* p) { return p->GetCreaturesPerSide(); }
|
||||
|
||||
export ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) {
|
||||
return p->GetCurrentTurnQueue().GetRaw();
|
||||
}
|
||||
export BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
|
||||
export uint8_t CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
|
||||
export u8 CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
|
||||
Try(out = p->CreatureInField(c);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, uint8_t side, uint8_t target) {
|
||||
export u8 CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, u8 side, u8 target) {
|
||||
Try(out = p->GetCreature(side, target).GetValue();)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_Battle_ForceRecall(Battle* p, uint8_t side, uint8_t target) {
|
||||
Try(p->ForceRecall(side, target);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_SwitchCreature(Battle* p, uint8_t side, uint8_t target, Creature* c) {
|
||||
export u8 CreatureLib_Battle_ForceRecall(Battle* p, u8 side, u8 target) { Try(p->ForceRecall(side, target);) }
|
||||
export u8 CreatureLib_Battle_SwitchCreature(Battle* p, u8 side, u8 target, Creature* c) {
|
||||
Try(p->SwitchCreature(side, target, c);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, uint8_t side, uint8_t target) {
|
||||
export u8 CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, u8 side, u8 target) {
|
||||
Try(out = p->CanSlotBeFilled(side, target);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
|
||||
export u8 CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
|
||||
export bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
|
||||
|
||||
export bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
|
||||
|
@ -64,29 +62,27 @@ export BattleScript* CreatureLib_Battle_GetVolatileScript(Battle* p, const char*
|
|||
}
|
||||
return v.GetValue();
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
|
||||
export u8 CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
|
||||
Try(p->AddVolatileScript(ArbUt::StringView(key));)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) {
|
||||
Try(p->AddVolatileScript(script);)
|
||||
}
|
||||
export u8 CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) { Try(p->AddVolatileScript(script);) }
|
||||
|
||||
export uint8_t CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
|
||||
export u8 CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
|
||||
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) {
|
||||
export u8 CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) {
|
||||
Try(p->RemoveVolatileScript(script);)
|
||||
}
|
||||
export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
|
||||
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
|
||||
export u8 CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
|
||||
Try(p->RegisterEventListener(func);)
|
||||
}
|
||||
export const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return p->GetHistory(); }
|
||||
|
||||
export uint8_t CreatureLib_Battle_EndBattle(Battle* p) { Try(p->EndBattle()) }
|
||||
export uint8_t CreatureLib_Battle_ClearBattle(Battle* p) { Try(p->ClearBattle()) }
|
||||
export u8 CreatureLib_Battle_EndBattle(Battle* p) { Try(p->EndBattle()) }
|
||||
export u8 CreatureLib_Battle_ClearBattle(Battle* p) { Try(p->ClearBattle()) }
|
||||
|
||||
SIMPLE_GET_FUNC(Battle, GetLastTurnTimeMicroseconds, long);
|
|
@ -2,11 +2,11 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out,
|
||||
const CreatureLib::Library::DataLibrary* staticLib,
|
||||
BattleStatCalculator* statCalculator, DamageLibrary* damageLibrary,
|
||||
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver,
|
||||
MiscLibrary* miscLibrary) {
|
||||
export u8 CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out,
|
||||
const CreatureLib::Library::DataLibrary* staticLib,
|
||||
BattleStatCalculator* statCalculator, DamageLibrary* damageLibrary,
|
||||
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver,
|
||||
MiscLibrary* miscLibrary) {
|
||||
Try(out = new BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary, scriptResolver,
|
||||
miscLibrary);)
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ using namespace CreatureLib::Battling;
|
|||
|
||||
// Note that creatureIndices should be twice the size of numberOfIndices, and have index of side, index of creature on
|
||||
// side, one after the other.
|
||||
export uint8_t CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, uint8_t creatureIndices[],
|
||||
size_t numberOfIndices) {
|
||||
export u8 CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, u8 creatureIndices[],
|
||||
size_t numberOfIndices) {
|
||||
Try(ArbUt::List<CreatureIndex> indices(numberOfIndices); for (size_t i = 0; i < numberOfIndices; i++) {
|
||||
indices.Append(CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]));
|
||||
} out = new BattleParty(p, indices);)
|
||||
|
@ -14,8 +14,7 @@ export uint8_t CreatureLib_BattleParty_Construct(BattleParty*& out, CreaturePart
|
|||
export void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }
|
||||
|
||||
BORROWED_GET_FUNC(BattleParty, GetParty, CreatureParty*);
|
||||
export uint8_t CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const BattleParty* p, uint8_t side,
|
||||
uint8_t creature) {
|
||||
export u8 CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const BattleParty* p, u8 side, u8 creature) {
|
||||
Try(out = p->IsResponsibleForIndex(side, creature);)
|
||||
}
|
||||
export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); }
|
||||
|
|
|
@ -4,92 +4,92 @@ using namespace CreatureLib::Battling;
|
|||
|
||||
export void CreatureLib_Script_Destruct(BattleScript* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_Script_Stack(BattleScript* p) { Try(p->Stack()); }
|
||||
export uint8_t CreatureLib_Script_OnRemove(BattleScript* p) { Try(p->OnRemove()); }
|
||||
export u8 CreatureLib_Script_Stack(BattleScript* p) { Try(p->Stack()); }
|
||||
export u8 CreatureLib_Script_OnRemove(BattleScript* p) { Try(p->OnRemove()); }
|
||||
export const char* CreatureLib_Script_GetName(BattleScript* p) { return p->GetName().c_str(); }
|
||||
|
||||
export uint8_t CreatureLib_Script_OnBeforeTurn(BattleScript* p, const BaseTurnChoice* choice) {
|
||||
export u8 CreatureLib_Script_OnBeforeTurn(BattleScript* p, const BaseTurnChoice* choice) {
|
||||
Try(p->OnBeforeTurn(choice));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ChangeAttack(BattleScript* p, AttackTurnChoice* choice, const char*& outAttack) {
|
||||
export u8 CreatureLib_Script_ChangeAttack(BattleScript* p, AttackTurnChoice* choice, const char*& outAttack) {
|
||||
Try(auto sv = ArbUt::StringView(outAttack); p->ChangeAttack(choice, &sv); outAttack = sv.c_str(););
|
||||
}
|
||||
export uint8_t CreatureLib_Script_PreventAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
export u8 CreatureLib_Script_PreventAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
Try(p->PreventAttack(attack, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_FailAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
export u8 CreatureLib_Script_FailAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
Try(p->FailAttack(attack, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_StopBeforeAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
export u8 CreatureLib_Script_StopBeforeAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
|
||||
Try(p->StopBeforeAttack(attack, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OnBeforeAttack(BattleScript* p, ExecutingAttack* attack) {
|
||||
export u8 CreatureLib_Script_OnBeforeAttack(BattleScript* p, ExecutingAttack* attack) {
|
||||
Try(p->OnBeforeAttack(attack));
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_Script_FailIncomingAttack(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
bool* outResult) {
|
||||
export u8 CreatureLib_Script_FailIncomingAttack(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
bool* outResult) {
|
||||
Try(p->FailIncomingAttack(attack, target, outResult));
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_Script_IsInvulnerable(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
bool* outResult) {
|
||||
export u8 CreatureLib_Script_IsInvulnerable(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
bool* outResult) {
|
||||
Try(p->IsInvulnerable(attack, target, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OnAttackMiss(BattleScript* p, ExecutingAttack* attack, Creature* target) {
|
||||
export u8 CreatureLib_Script_OnAttackMiss(BattleScript* p, ExecutingAttack* attack, Creature* target) {
|
||||
Try(p->OnAttackMiss(attack, target));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ChangeAttackType(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, uint8_t* outType) {
|
||||
export u8 CreatureLib_Script_ChangeAttackType(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
|
||||
u8* outType) {
|
||||
Try(p->ChangeAttackType(attack, target, hitNumber, outType))
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OverrideBasePower(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, uint8_t* basePower) {
|
||||
export u8 CreatureLib_Script_OverrideBasePower(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
|
||||
u8* basePower) {
|
||||
Try(p->OverrideBasePower(attack, target, hitNumber, basePower));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ChangeDamageStatsUser(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, Creature** statsUser) {
|
||||
export u8 CreatureLib_Script_ChangeDamageStatsUser(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, Creature** statsUser) {
|
||||
Try(p->ChangeDamageStatsUser(attack, target, hitNumber, statsUser));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_BypassDefensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, bool* bypass) {
|
||||
export u8 CreatureLib_Script_BypassDefensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, bool* bypass) {
|
||||
Try(p->BypassDefensiveStat(attack, target, hitNumber, bypass));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_BypassOffensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, bool* bypass) {
|
||||
export u8 CreatureLib_Script_BypassOffensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, bool* bypass) {
|
||||
Try(p->BypassOffensiveStat(attack, target, hitNumber, bypass));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ModifyStatModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, float* modifier) {
|
||||
export u8 CreatureLib_Script_ModifyStatModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, float* modifier) {
|
||||
Try(p->ModifyStatModifier(attack, target, hitNumber, modifier));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ModifyDamageModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, float* modifier) {
|
||||
export u8 CreatureLib_Script_ModifyDamageModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, float* modifier) {
|
||||
Try(p->ModifyDamageModifier(attack, target, hitNumber, modifier));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OverrideDamage(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, uint32_t* damage) {
|
||||
export u8 CreatureLib_Script_OverrideDamage(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
|
||||
u32* damage) {
|
||||
Try(p->OverrideDamage(attack, target, hitNumber, damage));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_PreventSecondaryEffects(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber, bool* outResult) {
|
||||
export u8 CreatureLib_Script_PreventSecondaryEffects(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber, bool* outResult) {
|
||||
Try(p->PreventSecondaryEffects(attack, target, hitNumber, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OnSecondaryEffect(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hitNumber) {
|
||||
export u8 CreatureLib_Script_OnSecondaryEffect(BattleScript* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hitNumber) {
|
||||
Try(p->OnSecondaryEffect(attack, target, hitNumber));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_OnAfterHits(BattleScript* p, ExecutingAttack* attack, Creature* target) {
|
||||
export u8 CreatureLib_Script_OnAfterHits(BattleScript* p, ExecutingAttack* attack, Creature* target) {
|
||||
Try(p->OnAfterHits(attack, target));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_PreventSelfSwitch(BattleScript* p, const SwitchTurnChoice* choice, bool* outResult) {
|
||||
export u8 CreatureLib_Script_PreventSelfSwitch(BattleScript* p, const SwitchTurnChoice* choice, bool* outResult) {
|
||||
Try(p->PreventSelfSwitch(choice, outResult));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ModifyEffectChance(BattleScript* p, const ExecutingAttack* attack, Creature* target,
|
||||
float* chance) {
|
||||
export u8 CreatureLib_Script_ModifyEffectChance(BattleScript* p, const ExecutingAttack* attack, Creature* target,
|
||||
float* chance) {
|
||||
Try(p->ModifyEffectChance(attack, target, chance));
|
||||
}
|
||||
export uint8_t CreatureLib_Script_ModifyIncomingEffectChance(BattleScript* p, const ExecutingAttack* attack,
|
||||
Creature* target, float* chance) {
|
||||
export u8 CreatureLib_Script_ModifyIncomingEffectChance(BattleScript* p, const ExecutingAttack* attack,
|
||||
Creature* target, float* chance) {
|
||||
Try(p->ModifyIncomingEffectChance(attack, target, chance));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export BattleSide* CreatureLib_BattleSide_Construct(uint8_t index, Battle* battle, uint8_t creaturesPerSide) {
|
||||
export BattleSide* CreatureLib_BattleSide_Construct(u8 index, Battle* battle, u8 creaturesPerSide) {
|
||||
return new BattleSide(index, battle, creaturesPerSide);
|
||||
}
|
||||
|
||||
|
@ -11,30 +11,28 @@ export void CreatureLib_BattleSide_Destruct(BattleSide* p) { delete p; }
|
|||
export Battle* CreatureLib_BattleSide_GetBattle(BattleSide* p) { return p->GetBattle(); }
|
||||
export bool CreatureLib_BattleSide_AllChoicesSet(BattleSide* p) { return p->AllChoicesSet(); }
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_AllPossibleSlotsFilled(bool& out, BattleSide* p) {
|
||||
export u8 CreatureLib_BattleSide_AllPossibleSlotsFilled(bool& out, BattleSide* p) {
|
||||
Try(out = p->AllPossibleSlotsFilled());
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_SetChoice(BattleSide* p, BaseTurnChoice* choice) { Try(p->SetChoice(choice);) }
|
||||
export u8 CreatureLib_BattleSide_SetChoice(BattleSide* p, BaseTurnChoice* choice) { Try(p->SetChoice(choice);) }
|
||||
|
||||
export void CreatureLib_BattleSide_ResetChoices(BattleSide* p) { p->ResetChoices(); }
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creature, uint8_t index) {
|
||||
export u8 CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creature, u8 index) {
|
||||
Try(p->SetCreature(creature, index));
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, uint8_t index) {
|
||||
export u8 CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, u8 index) {
|
||||
Try(out = p->GetCreature(index).GetValue());
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
|
||||
export uint8_t CreatureLib_BattleSide_GetCreatureIndex(uint8_t& out, BattleSide* p, Creature* c) {
|
||||
export u8 CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
|
||||
export u8 CreatureLib_BattleSide_GetCreatureIndex(u8& out, BattleSide* p, Creature* c) {
|
||||
Try(out = p->GetCreatureIndex(c));
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_MarkSlotAsUnfillable(BattleSide* p, Creature* c) {
|
||||
Try(p->MarkSlotAsUnfillable(c));
|
||||
}
|
||||
export u8 CreatureLib_BattleSide_MarkSlotAsUnfillable(BattleSide* p, Creature* c) { Try(p->MarkSlotAsUnfillable(c)); }
|
||||
|
||||
export bool CreatureLib_BattleSide_IsDefeated(BattleSide* p) { return p->IsDefeated(); }
|
||||
export bool CreatureLib_BattleSide_HasFled(BattleSide* p) { return p->HasFled(); }
|
||||
|
@ -51,17 +49,17 @@ export BattleScript* CreatureLib_BattleSide_GetVolatileScript(BattleSide* p, con
|
|||
}
|
||||
return v.GetValue();
|
||||
}
|
||||
export uint8_t CreatureLib_BattleSide_AddVolatileScriptByName(BattleSide* p, const char* key) {
|
||||
export u8 CreatureLib_BattleSide_AddVolatileScriptByName(BattleSide* p, const char* key) {
|
||||
Try(p->AddVolatileScript(ArbUt::StringView(key));)
|
||||
}
|
||||
export uint8_t CreatureLib_BattleSide_AddVolatileScript(BattleSide* p, BattleScript* script) {
|
||||
export u8 CreatureLib_BattleSide_AddVolatileScript(BattleSide* p, BattleScript* script) {
|
||||
Try(p->AddVolatileScript(script);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_RemoveVolatileScript(BattleSide* p, const char* key) {
|
||||
export u8 CreatureLib_BattleSide_RemoveVolatileScript(BattleSide* p, const char* key) {
|
||||
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
|
||||
}
|
||||
export uint8_t CreatureLib_BattleSide_RemoveVolatileScriptWithScript(BattleSide* p, BattleScript* script) {
|
||||
export u8 CreatureLib_BattleSide_RemoveVolatileScriptWithScript(BattleSide* p, BattleScript* script) {
|
||||
Try(p->RemoveVolatileScript(script);)
|
||||
}
|
||||
export bool CreatureLib_BattleSide_HasVolatileScript(BattleSide* p, const char* key) {
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
|
||||
const CreatureLib::Library::CreatureSpecies* species,
|
||||
const CreatureLib::Library::SpeciesVariant* variant, level_int_t level,
|
||||
uint32_t experience, uint32_t uid, CreatureLib::Library::Gender gender,
|
||||
uint8_t coloring, const CreatureLib::Library::Item* heldItem,
|
||||
const char* nickname, bool secretTalent, uint8_t talent,
|
||||
LearnedAttack* attacks[], size_t attacksNum, bool allowedExperienceGain) {
|
||||
export u8 CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
|
||||
const CreatureLib::Library::CreatureSpecies* species,
|
||||
const CreatureLib::Library::SpeciesVariant* variant, level_int_t level,
|
||||
u32 experience, u32 uid, CreatureLib::Library::Gender gender, u8 coloring,
|
||||
const CreatureLib::Library::Item* heldItem, const char* nickname,
|
||||
bool secretTalent, u8 talent, LearnedAttack* attacks[], size_t attacksNum,
|
||||
bool allowedExperienceGain) {
|
||||
Try(auto attacksVec = std::vector<LearnedAttack*>(attacks, attacks + (attacksNum * sizeof(LearnedAttack*)));
|
||||
out =
|
||||
new Creature(library, ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species), variant,
|
||||
|
@ -19,39 +19,39 @@ export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrar
|
|||
|
||||
export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_Creature_Initialize(Creature* p) { Try(p->Initialize();) }
|
||||
export u8 CreatureLib_Creature_Initialize(Creature* p) { Try(p->Initialize();) }
|
||||
|
||||
BORROWED_GET_FUNC(Creature, GetLibrary, const CreatureLib::Battling::BattleLibrary*);
|
||||
BORROWED_GET_FUNC(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
|
||||
BORROWED_GET_FUNC(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
|
||||
|
||||
export uint8_t CreatureLib_Creature_ChangeSpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species,
|
||||
const CreatureLib::Library::SpeciesVariant* variant) {
|
||||
export u8 CreatureLib_Creature_ChangeSpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species,
|
||||
const CreatureLib::Library::SpeciesVariant* variant) {
|
||||
Try(p->ChangeSpecies(species, variant);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
|
||||
export u8 CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
|
||||
Try(p->ChangeVariant(variant);)
|
||||
}
|
||||
|
||||
SIMPLE_GET_FUNC(Creature, GetLevel, level_int_t);
|
||||
SIMPLE_GET_FUNC(Creature, GetExperience, uint32_t);
|
||||
SIMPLE_GET_FUNC(Creature, GetUniqueIdentifier, uint32_t);
|
||||
SIMPLE_GET_FUNC(Creature, GetExperience, u32);
|
||||
SIMPLE_GET_FUNC(Creature, GetUniqueIdentifier, u32);
|
||||
SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
|
||||
SIMPLE_GET_FUNC(Creature, GetColoring, uint8_t);
|
||||
SIMPLE_GET_FUNC(Creature, GetColoring, u8);
|
||||
|
||||
export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
|
||||
return p->HasHeldItem(ArbUt::StringView(name));
|
||||
}
|
||||
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
|
||||
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, u32 hash) { return p->HasHeldItem(hash); }
|
||||
OPTIONAL_GET_FUNC(Creature, GetHeldItem, const CreatureLib::Library::Item*);
|
||||
export uint8_t CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
|
||||
export u8 CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
|
||||
Try(p->SetHeldItem(ArbUt::StringView(name));)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_SetHeldItemWithHash(Creature* p, uint32_t hash) { Try(p->SetHeldItem(hash);) }
|
||||
export u8 CreatureLib_Creature_SetHeldItemWithHash(Creature* p, u32 hash) { Try(p->SetHeldItem(hash);) }
|
||||
export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
|
||||
return p->SetHeldItem(ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(item));
|
||||
}
|
||||
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
|
||||
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, u32);
|
||||
OPTIONAL_GET_FUNC(Creature, GetBattle, Battle*);
|
||||
OPTIONAL_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
||||
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
||||
|
@ -63,42 +63,36 @@ export const char* CreatureLib_Creature_GetNickname(Creature* p) {
|
|||
return "";
|
||||
}
|
||||
export void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
|
||||
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
||||
export bool CreatureLib_Creature_HasType(Creature* p, u8 type) { return p->HasType(type); }
|
||||
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(); }
|
||||
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
|
||||
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);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canRevive) {
|
||||
Try(p->Heal(health, canRevive);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
|
||||
export const u8* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
|
||||
SIMPLE_GET_FUNC(Creature, GetMaxHealth, u32);
|
||||
export u8 CreatureLib_Creature_ChangeLevelBy(Creature* p, i8 level) { Try(p->ChangeLevelBy(level);) }
|
||||
export u8 CreatureLib_Creature_Damage(Creature* p, u32 damage, DamageSource source) { Try(p->Damage(damage, source);) }
|
||||
export u8 CreatureLib_Creature_Heal(Creature* p, u32 health, bool canRevive) { Try(p->Heal(health, canRevive);) }
|
||||
export u8 CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
|
||||
|
||||
export bool CreatureLib_Creature_GetRealTalentIsSecret(const Creature* p) { return p->GetRealTalent().IsSecret(); }
|
||||
export bool CreatureLib_Creature_GetRealTalentIndex(const Creature* p) { return p->GetRealTalent().GetIndex(); }
|
||||
|
||||
export uint8_t CreatureLib_Creature_GetActiveTalent(const Creature* p, const CreatureLib::Library::Talent*& out) {
|
||||
export u8 CreatureLib_Creature_GetActiveTalent(const Creature* p, const CreatureLib::Library::Talent*& out) {
|
||||
Try(out = p->GetActiveTalent().GetRaw();)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
|
||||
export u8 CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
|
||||
Try(p->OverrideActiveTalent(ArbUt::StringView(talent));)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_AddExperience(Creature* p, uint32_t experience) {
|
||||
Try(p->AddExperience(experience);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
|
||||
export uint8_t CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
|
||||
export u8 CreatureLib_Creature_AddExperience(Creature* p, u32 experience) { Try(p->AddExperience(experience);) }
|
||||
export u8 CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
|
||||
export u8 CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
|
||||
Try(p->AddVolatileScript(ArbUt::StringView(scriptName));)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) {
|
||||
export u8 CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) {
|
||||
Try(p->AddVolatileScript(script);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
|
||||
export u8 CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
|
||||
Try(p->RemoveVolatileScript(ArbUt::StringView(scriptName));)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) {
|
||||
export u8 CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) {
|
||||
Try(p->RemoveVolatileScript(script);)
|
||||
}
|
||||
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
|
||||
|
@ -120,28 +114,28 @@ export void CreatureLib_Creature_SetDisplayVariant(Creature* p, const CreatureLi
|
|||
export bool CreatureLib_Creature_AllowedExperienceGain(Creature* p) { return p->AllowedExperienceGain(); }
|
||||
export void CreatureLib_Creature_SetAllowedExperienceGain(Creature* p, bool b) { p->SetAllowedExperienceGain(b); }
|
||||
|
||||
export void CreatureLib_Creature_ChangeStatBoost(Creature* p, CreatureLib::Library::Statistic stat, int8_t diffAmount) {
|
||||
export void CreatureLib_Creature_ChangeStatBoost(Creature* p, CreatureLib::Library::Statistic stat, i8 diffAmount) {
|
||||
p->ChangeStatBoost(stat, diffAmount);
|
||||
}
|
||||
export uint32_t CreatureLib_Creature_GetFlatStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
export u32 CreatureLib_Creature_GetFlatStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
return p->GetFlatStat(stat);
|
||||
}
|
||||
export uint32_t CreatureLib_Creature_GetBoostedStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
export u32 CreatureLib_Creature_GetBoostedStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
return p->GetBoostedStat(stat);
|
||||
}
|
||||
export uint32_t CreatureLib_Creature_GetBaseStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
export u32 CreatureLib_Creature_GetBaseStat(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
return p->GetBaseStat(stat);
|
||||
}
|
||||
export int8_t CreatureLib_Creature_GetStatBoost(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
export i8 CreatureLib_Creature_GetStatBoost(Creature* p, CreatureLib::Library::Statistic stat) {
|
||||
return p->GetStatBoost(stat);
|
||||
}
|
||||
|
||||
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) {
|
||||
SIMPLE_GET_FUNC(Creature, GetAvailableAttackSlot, u8);
|
||||
export u8 CreatureLib_Creature_AddAttack(Creature* p, LearnedAttack* attack) { Try(p->AddAttack(attack);) }
|
||||
export u8 CreatureLib_Creature_ReplaceAttack(Creature* p, size_t index, LearnedAttack* attack) {
|
||||
Try(p->ReplaceAttack(index, attack);)
|
||||
}
|
||||
export uint8_t CreatureLib_Creature_SwapAttack(Creature* p, size_t a, size_t b) { Try(p->SwapAttacks(a, b);) }
|
||||
export u8 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()); };
|
||||
|
|
|
@ -9,14 +9,14 @@ export CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* cre
|
|||
|
||||
export void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const CreatureParty* p, size_t index) {
|
||||
export u8 CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const CreatureParty* p, size_t index) {
|
||||
Try(out = p->GetAtIndex(index).GetValue();)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
|
||||
export uint8_t CreatureLib_CreatureParty_PackParty(CreatureParty* p) { Try(p->PackParty();) }
|
||||
export u8 CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
|
||||
export u8 CreatureLib_CreatureParty_PackParty(CreatureParty* p) { Try(p->PackParty();) }
|
||||
|
||||
export uint8_t CreatureLib_CreatureParty_SwapInto(Creature*& out, CreatureParty* p, size_t index, Creature* creature) {
|
||||
export u8 CreatureLib_CreatureParty_SwapInto(Creature*& out, CreatureParty* p, size_t index, Creature* creature) {
|
||||
Try(out = p->SwapInto(index, creature);)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,24 +6,21 @@ export const DamageLibrary* CreatureLib_DamageLibrary_Construct() { return new D
|
|||
|
||||
export void CreatureLib_DamageLibrary_Destruct(const DamageLibrary* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_DamageLibrary_GetDamage(uint32_t& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, uint8_t hitIndex,
|
||||
ExecutingAttack::HitData* hitData) {
|
||||
export u8 CreatureLib_DamageLibrary_GetDamage(u32& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
|
||||
Try(out = p->GetDamage(attack, target, hitIndex, *hitData);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_DamageLibrary_GetBasePower(uint8_t& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, uint8_t hitIndex,
|
||||
ExecutingAttack::HitData* hitData) {
|
||||
export u8 CreatureLib_DamageLibrary_GetBasePower(u8& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
|
||||
Try(out = p->GetBasePower(attack, target, hitIndex, *hitData);)
|
||||
}
|
||||
export uint8_t CreatureLib_DamageLibrary_GetStatModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, uint8_t hitIndex,
|
||||
ExecutingAttack::HitData* hitData) {
|
||||
export u8 CreatureLib_DamageLibrary_GetStatModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
|
||||
Try(out = p->GetStatModifier(attack, target, hitIndex, *hitData);)
|
||||
}
|
||||
export uint8_t CreatureLib_DamageLibrary_GetDamageModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, uint8_t hitIndex,
|
||||
ExecutingAttack::HitData* hitData) {
|
||||
export u8 CreatureLib_DamageLibrary_GetDamageModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
|
||||
Creature* target, u8 hitIndex,
|
||||
ExecutingAttack::HitData* hitData) {
|
||||
Try(out = p->GetDamageModifier(attack, target, hitIndex, *hitData);)
|
||||
}
|
||||
|
|
|
@ -8,21 +8,21 @@ SIMPLE_GET_FUNC(EventData, GetKind, EventDataKind);
|
|||
|
||||
BORROWED_GET_FUNC(DamageEvent, GetCreature, Creature*);
|
||||
SIMPLE_GET_FUNC(DamageEvent, GetDamageSource, DamageSource);
|
||||
SIMPLE_GET_FUNC(DamageEvent, GetOriginalHealth, uint32_t);
|
||||
SIMPLE_GET_FUNC(DamageEvent, GetNewHealth, uint32_t);
|
||||
SIMPLE_GET_FUNC(DamageEvent, GetOriginalHealth, u32);
|
||||
SIMPLE_GET_FUNC(DamageEvent, GetNewHealth, u32);
|
||||
DESTRUCTOR(DamageEvent);
|
||||
|
||||
BORROWED_GET_FUNC(HealEvent, GetCreature, Creature*);
|
||||
SIMPLE_GET_FUNC(HealEvent, GetOriginalHealth, uint32_t);
|
||||
SIMPLE_GET_FUNC(HealEvent, GetNewHealth, uint32_t);
|
||||
SIMPLE_GET_FUNC(HealEvent, GetOriginalHealth, u32);
|
||||
SIMPLE_GET_FUNC(HealEvent, GetNewHealth, u32);
|
||||
DESTRUCTOR(HealEvent);
|
||||
|
||||
BORROWED_GET_FUNC(FaintEvent, GetCreature, Creature*);
|
||||
DESTRUCTOR(FaintEvent);
|
||||
|
||||
BORROWED_GET_FUNC(SwitchEvent, GetNewCreature, Creature*);
|
||||
export uint8_t CreatureLib_SwitchEvent_GetSide(const SwitchEvent* p) { return p->GetIndex().GetSideIndex(); }
|
||||
export uint8_t CreatureLib_SwitchEvent_GetIndex(const SwitchEvent* p) { return p->GetIndex().GetCreatureIndex(); }
|
||||
export u8 CreatureLib_SwitchEvent_GetSide(const SwitchEvent* p) { return p->GetIndex().GetSideIndex(); }
|
||||
export u8 CreatureLib_SwitchEvent_GetIndex(const SwitchEvent* p) { return p->GetIndex().GetCreatureIndex(); }
|
||||
DESTRUCTOR(SwitchEvent);
|
||||
|
||||
DESTRUCTOR(TurnStartEvent);
|
||||
|
@ -30,8 +30,8 @@ DESTRUCTOR(TurnStartEvent);
|
|||
DESTRUCTOR(TurnEndEvent);
|
||||
|
||||
BORROWED_GET_FUNC(ExperienceGainEvent, GetCreature, const Creature*);
|
||||
SIMPLE_GET_FUNC(ExperienceGainEvent, GetPreviousExperience, uint32_t);
|
||||
SIMPLE_GET_FUNC(ExperienceGainEvent, GetNewExperience, uint32_t);
|
||||
SIMPLE_GET_FUNC(ExperienceGainEvent, GetPreviousExperience, u32);
|
||||
SIMPLE_GET_FUNC(ExperienceGainEvent, GetNewExperience, u32);
|
||||
DESTRUCTOR(ExperienceGainEvent);
|
||||
|
||||
BORROWED_GET_FUNC(MissEvent, GetCreature, const Creature*);
|
||||
|
@ -53,7 +53,7 @@ export void CreatureLib_DisplayTextEvent_Destruct(const DisplayTextEvent* p) { d
|
|||
|
||||
BORROWED_GET_FUNC(ChangeStatBoostEvent, GetCreature, const Creature*);
|
||||
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetStatistic, CreatureLib::Library::Statistic);
|
||||
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetOldValue, int8_t);
|
||||
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetNewValue, int8_t);
|
||||
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetOldValue, i8);
|
||||
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetNewValue, i8);
|
||||
|
||||
DESTRUCTOR(ChangeStatBoostEvent);
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
|
||||
size_t targetCount, uint8_t numberHits, Creature* user,
|
||||
LearnedAttack* attack,
|
||||
CreatureLib::Library::AttackData* attackData,
|
||||
BattleScript* script) {
|
||||
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);
|
||||
|
@ -15,16 +13,16 @@ export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Crea
|
|||
|
||||
export void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
|
||||
|
||||
SIMPLE_GET_FUNC(ExecutingAttack, GetNumberOfHits, uint8_t);
|
||||
export uint8_t CreatureLib_ExecutingAttack_GetHitData(ExecutingAttack::HitData*& out, ExecutingAttack* p,
|
||||
Creature* target, uint8_t hit) {
|
||||
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);)
|
||||
}
|
||||
|
||||
export bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
|
||||
return p->IsCreatureTarget(target);
|
||||
}
|
||||
export uint8_t CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
|
||||
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());
|
||||
}
|
||||
|
@ -39,19 +37,19 @@ export const CreatureLib::Library::AttackData* CreatureLib_ExecutingAttack_GetUs
|
|||
export returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
|
||||
|
||||
HITDATA_GET_FUNC(IsCritical, bool);
|
||||
HITDATA_GET_FUNC(GetBasePower, uint8_t);
|
||||
HITDATA_GET_FUNC(GetBasePower, u8);
|
||||
HITDATA_GET_FUNC(GetEffectiveness, float);
|
||||
HITDATA_GET_FUNC(GetDamage, uint32_t);
|
||||
HITDATA_GET_FUNC(GetType, uint8_t);
|
||||
HITDATA_GET_FUNC(GetDamage, u32);
|
||||
HITDATA_GET_FUNC(GetType, u8);
|
||||
|
||||
#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, uint8_t);
|
||||
HITDATA_SET_FUNC(SetBasePower, u8);
|
||||
HITDATA_SET_FUNC(SetEffectiveness, float);
|
||||
HITDATA_SET_FUNC(SetDamage, uint32_t);
|
||||
HITDATA_SET_FUNC(SetType, uint8_t);
|
||||
HITDATA_SET_FUNC(SetDamage, u32);
|
||||
HITDATA_SET_FUNC(SetType, u8);
|
||||
|
||||
#undef HITDATA_GET_FUNC
|
||||
#undef HITDATA_SET_FUNC
|
|
@ -3,18 +3,16 @@
|
|||
using namespace CreatureLib::Battling;
|
||||
|
||||
export void CreatureLib_ItemUseScript_Destruct(ItemUseScript* p) { delete p; }
|
||||
export uint8_t CreatureLib_ItemUseScript_IsItemUsable(ItemUseScript* p, uint8_t& out) { Try(out = p->IsItemUsable()) }
|
||||
export uint8_t CreatureLib_ItemUseScript_IsCreatureUseItem(ItemUseScript* p, uint8_t& out) {
|
||||
Try(out = p->IsCreatureUseItem())
|
||||
}
|
||||
export u8 CreatureLib_ItemUseScript_IsItemUsable(ItemUseScript* p, u8& out) { Try(out = p->IsItemUsable()) }
|
||||
export u8 CreatureLib_ItemUseScript_IsCreatureUseItem(ItemUseScript* p, u8& out) { Try(out = p->IsCreatureUseItem()) }
|
||||
|
||||
export uint8_t CreatureLib_ItemUseScript_IsUseValidForCreature(ItemUseScript* p, Creature* creature, uint8_t& out) {
|
||||
export u8 CreatureLib_ItemUseScript_IsUseValidForCreature(ItemUseScript* p, Creature* creature, u8& out) {
|
||||
Try(out = p->IsUseValidForCreature(creature))
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_ItemUseScript_IsHoldable(ItemUseScript* p, uint8_t& out) { Try(out = p->IsHoldable()) }
|
||||
export u8 CreatureLib_ItemUseScript_IsHoldable(ItemUseScript* p, u8& out) { Try(out = p->IsHoldable()) }
|
||||
|
||||
export uint8_t CreatureLib_ItemUseScript_OnUse(ItemUseScript* p, Battle* battle) { Try(p->OnUse(battle)) }
|
||||
export uint8_t CreatureLib_ItemUseScript_OnCreatureUse(ItemUseScript* p, Creature* creature, bool isBattle) {
|
||||
export u8 CreatureLib_ItemUseScript_OnUse(ItemUseScript* p, Battle* battle) { Try(p->OnUse(battle)) }
|
||||
export u8 CreatureLib_ItemUseScript_OnCreatureUse(ItemUseScript* p, Creature* creature, bool isBattle) {
|
||||
Try(p->OnCreatureUse(creature, isBattle))
|
||||
}
|
|
@ -2,19 +2,19 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
|
||||
uint8_t maxUses, AttackLearnMethod learnMethod) {
|
||||
export u8 CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
|
||||
u8 maxUses, AttackLearnMethod learnMethod) {
|
||||
Try(out = new LearnedAttack(ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>(attack), maxUses,
|
||||
learnMethod);)
|
||||
}
|
||||
export void CreatureLib_LearnedAttack_Destruct(LearnedAttack* p) { delete p; }
|
||||
|
||||
BORROWED_GET_FUNC(LearnedAttack, GetAttack, const CreatureLib::Library::AttackData*);
|
||||
SIMPLE_GET_FUNC(LearnedAttack, GetMaxUses, uint8_t);
|
||||
SIMPLE_GET_FUNC(LearnedAttack, GetRemainingUses, uint8_t);
|
||||
SIMPLE_GET_FUNC(LearnedAttack, GetMaxUses, u8);
|
||||
SIMPLE_GET_FUNC(LearnedAttack, GetRemainingUses, u8);
|
||||
SIMPLE_GET_FUNC(LearnedAttack, GetLearnMethod, AttackLearnMethod);
|
||||
|
||||
export bool CreatureLib_LearnedAttack_TryUse(LearnedAttack* p, uint8_t uses) { return p->TryUse(uses); }
|
||||
export void CreatureLib_LearnedAttack_DecreaseUses(LearnedAttack* p, uint8_t uses) { p->DecreaseUses(uses); }
|
||||
export void CreatureLib_LearnedAttack_RestoreUses(LearnedAttack* p, uint8_t uses) { p->RestoreUses(uses); }
|
||||
export bool CreatureLib_LearnedAttack_TryUse(LearnedAttack* p, u8 uses) { return p->TryUse(uses); }
|
||||
export void CreatureLib_LearnedAttack_DecreaseUses(LearnedAttack* p, u8 uses) { p->DecreaseUses(uses); }
|
||||
export void CreatureLib_LearnedAttack_RestoreUses(LearnedAttack* p, u8 uses) { p->RestoreUses(uses); }
|
||||
export void CreatureLib_LearnedAttack_RestoreAllUses(LearnedAttack* p) { p->RestoreAllUses(); }
|
|
@ -6,14 +6,14 @@ export MiscLibrary* CreatureLib_MiscLibrary_Construct() { return new MiscLibrary
|
|||
|
||||
export void CreatureLib_MiscLibrary_Destruct(const MiscLibrary* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_MiscLibrary_IsCritical(bool& out, MiscLibrary* p, ExecutingAttack* attack, Creature* target,
|
||||
uint8_t hit) {
|
||||
export u8 CreatureLib_MiscLibrary_IsCritical(bool& out, MiscLibrary* p, ExecutingAttack* attack, Creature* target,
|
||||
u8 hit) {
|
||||
Try(out = p->IsCritical(attack, target, hit);)
|
||||
};
|
||||
export uint8_t CreatureLib_MiscLibrary_CanFlee(bool& out, MiscLibrary* p, FleeTurnChoice* switchChoice) {
|
||||
export u8 CreatureLib_MiscLibrary_CanFlee(bool& out, MiscLibrary* p, FleeTurnChoice* switchChoice) {
|
||||
Try(out = p->CanFlee(switchChoice);)
|
||||
};
|
||||
export uint8_t CreatureLib_MiscLibrary_ReplacementAttack(BaseTurnChoice*& out, MiscLibrary* p, Creature* user,
|
||||
uint8_t sideTarget, uint8_t creatureTarget) {
|
||||
export u8 CreatureLib_MiscLibrary_ReplacementAttack(BaseTurnChoice*& out, MiscLibrary* p, Creature* user, u8 sideTarget,
|
||||
u8 creatureTarget) {
|
||||
Try(out = p->ReplacementAttack(user, CreatureIndex(sideTarget, creatureTarget));)
|
||||
};
|
||||
|
|
|
@ -6,15 +6,15 @@ export ScriptResolver* CreatureLib_ScriptResolver_Construct() { return new Scrip
|
|||
|
||||
export void CreatureLib_ScriptResolver_Destruct(const ScriptResolver* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLibrary* library) {
|
||||
export u8 CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLibrary* library) {
|
||||
Try(p->Initialize(library);)
|
||||
};
|
||||
export uint8_t CreatureLib_ScriptResolver_LoadScript(BattleScript*& out, ScriptResolver* p, void* owner,
|
||||
ScriptCategory category, const char* scriptName) {
|
||||
export u8 CreatureLib_ScriptResolver_LoadScript(BattleScript*& out, ScriptResolver* p, void* owner,
|
||||
ScriptCategory category, const char* scriptName) {
|
||||
Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName));)
|
||||
};
|
||||
|
||||
export uint8_t CreatureLib_ScriptResolver_LoadItemScript(ItemUseScript*& out, ScriptResolver* p,
|
||||
const CreatureLib::Library::Item* item) {
|
||||
export u8 CreatureLib_ScriptResolver_LoadItemScript(ItemUseScript*& out, ScriptResolver* p,
|
||||
const CreatureLib::Library::Item* item) {
|
||||
Try(out = p->LoadItemScript(item);)
|
||||
};
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack,
|
||||
uint8_t sideIndex, uint8_t targetIndex) {
|
||||
export AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack, u8 sideIndex,
|
||||
u8 targetIndex) {
|
||||
return new AttackTurnChoice(user, attack, CreatureIndex(sideIndex, targetIndex));
|
||||
}
|
||||
export void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
||||
|
@ -25,15 +25,13 @@ BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
|
|||
BORROWED_GET_FUNC(AttackTurnChoice, GetAttack, LearnedAttack*)
|
||||
SIMPLE_GET_FUNC(AttackTurnChoice, GetKind, TurnChoiceKind)
|
||||
|
||||
export uint8_t CreatureLib_AttackTurnChoice_GetPriority(int8_t& out, AttackTurnChoice* p) {
|
||||
Try(out = p->GetPriority());
|
||||
}
|
||||
export u8 CreatureLib_AttackTurnChoice_GetPriority(i8& out, AttackTurnChoice* p) { Try(out = p->GetPriority()); }
|
||||
|
||||
SMART_GET_FUNC(AttackTurnChoice, GetAttackScript, BattleScript*)
|
||||
export uint8_t CreatureLib_AttackTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
|
||||
export u8 CreatureLib_AttackTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
|
||||
return p->GetTarget().GetSideIndex();
|
||||
}
|
||||
export uint8_t CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackTurnChoice* p) {
|
||||
export u8 CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackTurnChoice* p) {
|
||||
return p->GetTarget().GetCreatureIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
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,
|
||||
float effectChance, const char* effectName,
|
||||
EffectParameter* effectParameters[], size_t effectParameterCount,
|
||||
const char* flags[], size_t flagsCount) {
|
||||
export u8 CreatureLib_AttackData_Construct(AttackData*& out, const char* name, u8 type, AttackCategory category,
|
||||
u8 power, u8 accuracy, u8 baseUsage, AttackTarget target, i8 priority,
|
||||
float effectChance, const char* effectName,
|
||||
EffectParameter* effectParameters[], size_t effectParameterCount,
|
||||
const char* flags[], size_t flagsCount) {
|
||||
Try({
|
||||
std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
||||
std::unordered_set<u32> conversedFlags(flagsCount);
|
||||
for (size_t i = 0; i < flagsCount; i++) {
|
||||
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
|
||||
}
|
||||
|
@ -28,13 +27,13 @@ export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* na
|
|||
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, GetType, u8);
|
||||
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, GetBasePower, u8);
|
||||
SIMPLE_GET_FUNC(AttackData, GetAccuracy, u8);
|
||||
SIMPLE_GET_FUNC(AttackData, GetBaseUsages, u8);
|
||||
SIMPLE_GET_FUNC(AttackData, GetTarget, AttackTarget);
|
||||
SIMPLE_GET_FUNC(AttackData, GetPriority, int8_t);
|
||||
SIMPLE_GET_FUNC(AttackData, GetPriority, i8);
|
||||
|
||||
export bool CreatureLib_AttackData_HasSecondaryEffect(const AttackData* p) { return p->HasSecondaryEffect(); }
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export uint8_t CreatureLib_AttackLibrary_Construct(AttackLibrary*& library, size_t initialCapacity = 32) {
|
||||
export u8 CreatureLib_AttackLibrary_Construct(AttackLibrary*& library, size_t initialCapacity = 32) {
|
||||
Try(library = new AttackLibrary(initialCapacity);)
|
||||
};
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
#include "../Core.hpp"
|
||||
|
||||
#define BASELIBRARY(simpleName, fullname, returnType) \
|
||||
export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
||||
export u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
||||
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_InsertWithHash(fullname* p, uint32_t hashedKey, returnType* t) { \
|
||||
Try(p->Insert(hashedKey, t);) \
|
||||
} \
|
||||
export u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { Try(p->Insert(hashedKey, t);) } \
|
||||
\
|
||||
export uint8_t simpleName##_Delete(fullname* p, const char* name) { \
|
||||
export u8 simpleName##_Delete(fullname* p, const char* name) { \
|
||||
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_DeleteWithHash(fullname* p, uint32_t hashedKey) { Try(p->Delete(hashedKey);) } \
|
||||
export u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
|
||||
\
|
||||
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
|
@ -27,7 +25,7 @@
|
|||
} \
|
||||
} \
|
||||
\
|
||||
export bool simpleName##_TryGetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
||||
export bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
auto v = p->TryGet(hashedKey); \
|
||||
if (!v.has_value()) { \
|
||||
|
@ -39,15 +37,15 @@
|
|||
} \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
||||
export u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
||||
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
||||
export u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
||||
Try(out = p->Get(hashedKey).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
|
||||
export uint8_t simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
|
||||
export u8 simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
|
||||
Try(out = p->GetAtIndex(index).GetRaw();) \
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint16_t id, const char* name,
|
||||
SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const char* growthRate, uint8_t captureRate, const char* flags[],
|
||||
size_t flagsCount) {
|
||||
export u8 CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, u16 id, const char* name,
|
||||
SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const char* growthRate, u8 captureRate, const char* flags[],
|
||||
size_t flagsCount) {
|
||||
|
||||
Try(std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
||||
Try(std::unordered_set<u32> conversedFlags(flagsCount);
|
||||
for (size_t i = 0; i < flagsCount; i++) { conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i])); }
|
||||
|
||||
out = new CreatureSpecies(id, ArbUt::StringView(name), defaultVariant, genderRatio,
|
||||
|
@ -16,9 +16,9 @@ export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint
|
|||
|
||||
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
|
||||
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetId, uint16_t);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetId, u16);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetGenderRate, float);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, uint8_t);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, u8);
|
||||
export const char* CreatureLib_CreatureSpecies_GetName(const CreatureSpecies* p) { return p->GetName().c_str(); }
|
||||
export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpecies* p) {
|
||||
return p->GetGrowthRate().c_str();
|
||||
|
@ -26,7 +26,7 @@ export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpeci
|
|||
export bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
|
||||
return p->HasVariant(ArbUt::StringView::CalculateHash(name));
|
||||
}
|
||||
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, uint32_t hash) {
|
||||
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, u32 hash) {
|
||||
return p->HasVariant(hash);
|
||||
}
|
||||
export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
|
||||
|
@ -37,7 +37,7 @@ export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p,
|
|||
out = res.value();
|
||||
return true;
|
||||
}
|
||||
export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, uint32_t hash,
|
||||
export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, u32 hash,
|
||||
const SpeciesVariant*& out) {
|
||||
auto res = p->TryGetVariant(hash);
|
||||
if (!res.has_value())
|
||||
|
@ -46,15 +46,15 @@ export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpec
|
|||
return true;
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
|
||||
const char* name) {
|
||||
export u8 CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
|
||||
const char* name) {
|
||||
Try(out = p->GetVariant(ArbUt::StringView::CalculateHash(name)).GetRaw();)
|
||||
}
|
||||
export uint8_t CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
|
||||
uint32_t hash) {
|
||||
export u8 CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
|
||||
u32 hash) {
|
||||
Try(out = p->GetVariant(hash).GetRaw();)
|
||||
}
|
||||
export uint8_t CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
|
||||
export u8 CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
|
||||
Try(p->SetVariant(ArbUt::StringView(name), variant);)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export uint8_t CreatureLib_DataLibrary_Construct(const DataLibrary*& out, LibrarySettings* settings,
|
||||
SpeciesLibrary* species, AttackLibrary* attacks, ItemLibrary* items,
|
||||
GrowthRateLibrary* growthRates, TypeLibrary* typeLibrary,
|
||||
TalentLibrary* talentLibrary) {
|
||||
export u8 CreatureLib_DataLibrary_Construct(const DataLibrary*& out, LibrarySettings* settings, SpeciesLibrary* species,
|
||||
AttackLibrary* attacks, ItemLibrary* items, GrowthRateLibrary* growthRates,
|
||||
TypeLibrary* typeLibrary, TalentLibrary* talentLibrary) {
|
||||
Try(out = new DataLibrary(settings, species, attacks, items, growthRates, typeLibrary, talentLibrary);)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
using namespace CreatureLib::Library;
|
||||
|
||||
export EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return new EffectParameter(b); }
|
||||
export EffectParameter* CreatureLib_EffectParameter_FromInt(int64_t i) { return new EffectParameter(i); }
|
||||
export EffectParameter* CreatureLib_EffectParameter_FromInt(i64 i) { return new EffectParameter(i); }
|
||||
export EffectParameter* CreatureLib_EffectParameter_FromFloat(float f) { return new EffectParameter(f); }
|
||||
export EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
|
||||
return new EffectParameter(ArbUt::StringView(c));
|
||||
|
@ -11,9 +11,9 @@ export EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
|
|||
|
||||
export void CreatureLib_EffectParameter_Destruct(const EffectParameter* p) { delete p; }
|
||||
export EffectParameterType CreatureLib_EffectParameter_GetType(const EffectParameter* p) { return p->GetType(); }
|
||||
export uint8_t CreatureLib_EffectParameter_AsBool(const EffectParameter* p, bool& out) { Try(out = p->AsBool();) }
|
||||
export uint8_t CreatureLib_EffectParameter_AsInt(const EffectParameter* p, int64_t& out) { Try(out = p->AsInt();) }
|
||||
export uint8_t CreatureLib_EffectParameter_AsFloat(const EffectParameter* p, float& out) { Try(out = p->AsFloat();) }
|
||||
export uint8_t CreatureLib_EffectParameter_AsString(const EffectParameter* p, const char*& out) {
|
||||
export u8 CreatureLib_EffectParameter_AsBool(const EffectParameter* p, bool& out) { Try(out = p->AsBool();) }
|
||||
export u8 CreatureLib_EffectParameter_AsInt(const EffectParameter* p, i64& out) { Try(out = p->AsInt();) }
|
||||
export u8 CreatureLib_EffectParameter_AsFloat(const EffectParameter* p, float& out) { Try(out = p->AsFloat();) }
|
||||
export u8 CreatureLib_EffectParameter_AsString(const EffectParameter* p, const char*& out) {
|
||||
Try(out = p->AsString().c_str();)
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePerLevel[], size_t count) {
|
||||
ArbUt::List<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
|
||||
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(u32 experiencePerLevel[], size_t count) {
|
||||
ArbUt::List<u32> exp(experiencePerLevel, experiencePerLevel + count);
|
||||
return new LookupGrowthRate(exp);
|
||||
};
|
||||
|
||||
export uint8_t CreatureLib_ExternGrowthRate_Construct(GrowthRate*& out, level_int_t (*calcLevel)(uint32_t),
|
||||
uint32_t (*calcExperience)(level_int_t)) {
|
||||
export u8 CreatureLib_ExternGrowthRate_Construct(GrowthRate*& out, level_int_t (*calcLevel)(u32),
|
||||
u32 (*calcExperience)(level_int_t)) {
|
||||
Try(out = new ExternGrowthRate(calcLevel, calcExperience);)
|
||||
};
|
||||
|
||||
|
@ -18,10 +18,10 @@ export void CreatureLib_GrowthRate_Destruct(const GrowthRate* p) { delete p; }
|
|||
export void CreatureLib_LookupGrowthRate_Destruct(const LookupGrowthRate* p) { delete p; }
|
||||
export void CreatureLib_ExternGrowthRate_Destruct(const ExternGrowthRate* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_GrowthRate_CalculateLevel(level_int_t& out, const GrowthRate* p, uint32_t experience) {
|
||||
export u8 CreatureLib_GrowthRate_CalculateLevel(level_int_t& out, const GrowthRate* p, u32 experience) {
|
||||
Try(out = p->CalculateLevel(experience);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_GrowthRate_CalculateExperience(uint32_t& out, const GrowthRate* p, level_int_t level) {
|
||||
export u8 CreatureLib_GrowthRate_CalculateExperience(u32& out, const GrowthRate* p, level_int_t level) {
|
||||
Try(out = p->CalculateExperience(level);)
|
||||
}
|
|
@ -8,30 +8,30 @@ export GrowthRateLibrary* CreatureLib_GrowthRateLibrary_Construct(size_t initial
|
|||
|
||||
export void CreatureLib_GrowthRateLibrary_Destruct(GrowthRateLibrary* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevel(level_int_t& out, GrowthRateLibrary* library,
|
||||
const char* growthRate, uint32_t experience) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_CalculateLevel(level_int_t& out, GrowthRateLibrary* library,
|
||||
const char* growthRate, u32 experience) {
|
||||
Try(out = library->CalculateLevel(ArbUt::StringView::CalculateHash(growthRate), experience);)
|
||||
}
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(level_int_t& out, GrowthRateLibrary* library,
|
||||
uint32_t growthRateHash, uint32_t experience) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(level_int_t& out, GrowthRateLibrary* library,
|
||||
u32 growthRateHash, u32 experience) {
|
||||
Try(out = library->CalculateLevel(growthRateHash, experience);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperience(uint32_t& out, GrowthRateLibrary* library,
|
||||
const char* growthRate, level_int_t level) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_CalculateExperience(u32& out, GrowthRateLibrary* library,
|
||||
const char* growthRate, level_int_t level) {
|
||||
Try(out = library->CalculateExperience(ArbUt::StringView::CalculateHash(growthRate), level);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(uint32_t& out, GrowthRateLibrary* library,
|
||||
uint32_t growthRateHash, level_int_t level) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(u32& out, GrowthRateLibrary* library,
|
||||
u32 growthRateHash, level_int_t level) {
|
||||
Try(out = library->CalculateExperience(growthRateHash, level);)
|
||||
}
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
|
||||
GrowthRate* growthRate) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
|
||||
GrowthRate* growthRate) {
|
||||
Try(library->AddGrowthRate(ArbUt::StringView::CalculateHash(growthRateName), growthRate);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, uint32_t growthRateHash,
|
||||
GrowthRate* growthRate) {
|
||||
export u8 CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, u32 growthRateHash,
|
||||
GrowthRate* growthRate) {
|
||||
Try(library->AddGrowthRate(growthRateHash, growthRate);)
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
using namespace CreatureLib::Library;
|
||||
|
||||
export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
|
||||
int32_t price, const char* effectName, EffectParameter* effectParameters[],
|
||||
i32 price, const char* effectName, EffectParameter* effectParameters[],
|
||||
size_t effectParameterCount, const char* battleTriggerEffectName,
|
||||
EffectParameter* battleTriggerEffectParameters[],
|
||||
size_t battleTriggerEffectParameterCount, const char* flags[],
|
||||
size_t flagsCount) {
|
||||
std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
||||
std::unordered_set<u32> conversedFlags(flagsCount);
|
||||
for (size_t i = 0; i < flagsCount; i++) {
|
||||
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export void CreatureLib_Item_Destruct(const Item* p) { delete p; }
|
|||
export const char* CreatureLib_Item_GetName(const Item* p) { return p->GetName().c_str(); }
|
||||
SIMPLE_GET_FUNC(Item, GetCategory, ItemCategory);
|
||||
SIMPLE_GET_FUNC(Item, GetBattleCategory, BattleItemCategory);
|
||||
SIMPLE_GET_FUNC(Item, GetPrice, int32_t);
|
||||
SIMPLE_GET_FUNC(Item, GetPrice, i32);
|
||||
|
||||
export bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
|
||||
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export uint8_t CreatureLib_LearnableAttacks_Construct(LearnableAttacks*& out, size_t levelAttackCapacity) {
|
||||
export u8 CreatureLib_LearnableAttacks_Construct(LearnableAttacks*& out, size_t levelAttackCapacity) {
|
||||
Try(out = new LearnableAttacks(levelAttackCapacity);)
|
||||
};
|
||||
|
||||
|
@ -13,13 +13,13 @@ export void CreatureLib_LearnableAttacks_AddLevelAttack(LearnableAttacks* p, lev
|
|||
p->AddLevelAttack(level, attack);
|
||||
}
|
||||
|
||||
export const AttackData* const* CreatureLib_LearnableAttacks_GetAttacksForLevel(LearnableAttacks* p, uint8_t level) {
|
||||
export const AttackData* const* CreatureLib_LearnableAttacks_GetAttacksForLevel(LearnableAttacks* p, u8 level) {
|
||||
return reinterpret_cast<const AttackData* const*>(p->GetAttacksForLevel(level).RawData());
|
||||
}
|
||||
export bool CreatureLib_LearnableAttacks_HasAttacksForLevel(LearnableAttacks* p, uint8_t level) {
|
||||
export bool CreatureLib_LearnableAttacks_HasAttacksForLevel(LearnableAttacks* p, u8 level) {
|
||||
return p->HasAttacksForLevel(level);
|
||||
}
|
||||
export size_t CreatureLib_LearnableAttacks_GetAttacksForLevelCount(LearnableAttacks* p, uint8_t level) {
|
||||
export size_t CreatureLib_LearnableAttacks_GetAttacksForLevelCount(LearnableAttacks* p, u8 level) {
|
||||
return p->GetAttacksForLevel(level).Count();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#include "../Core.hpp"
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export const LibrarySettings* CreatureLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves) {
|
||||
export const LibrarySettings* CreatureLib_LibrarySettings_Construct(u8 maximalLevel, u8 maximalMoves) {
|
||||
return new LibrarySettings(maximalLevel, maximalMoves);
|
||||
}
|
||||
|
||||
export void CreatureLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; }
|
||||
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalLevel, level_int_t);
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalAttacks, uint8_t);
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalAttacks, u8);
|
|
@ -11,6 +11,6 @@ export void CreatureLib_SpeciesLibrary_Destruct(const SpeciesLibrary* p) { delet
|
|||
|
||||
BASELIBRARY(CreatureLib_SpeciesLibrary, SpeciesLibrary, CreatureSpecies);
|
||||
|
||||
export const CreatureSpecies* CreatureLib_SpeciesLibrary_GetById(const SpeciesLibrary* p, uint16_t id) {
|
||||
export const CreatureSpecies* CreatureLib_SpeciesLibrary_GetById(const SpeciesLibrary* p, u16 id) {
|
||||
return p->GetById(id).GetRaw();
|
||||
}
|
|
@ -3,15 +3,13 @@
|
|||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export SpeciesVariant*
|
||||
CreatureLib_SpeciesVariant_Construct(const char* name, float height, float weight, uint32_t baseExperience,
|
||||
uint8_t types[], size_t typeLength, uint16_t baseHealth, uint16_t baseAttack,
|
||||
uint16_t baseDefense, uint16_t baseMagicalAttack, uint16_t baseMagicalDefense,
|
||||
uint16_t baseSpeed, const Talent* talents[], size_t talentsLength,
|
||||
const Talent* secretTalents[], size_t secretTalentsLength,
|
||||
const LearnableAttacks* attacks, const char* flags[], size_t flagsCount) {
|
||||
export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
|
||||
const char* name, float height, float weight, u32 baseExperience, u8 types[], size_t typeLength, u16 baseHealth,
|
||||
u16 baseAttack, u16 baseDefense, u16 baseMagicalAttack, u16 baseMagicalDefense, u16 baseSpeed,
|
||||
const Talent* talents[], size_t talentsLength, const Talent* secretTalents[], size_t secretTalentsLength,
|
||||
const LearnableAttacks* attacks, const char* flags[], size_t flagsCount) {
|
||||
|
||||
std::unordered_set<uint32_t> conversedFlags(flagsCount);
|
||||
std::unordered_set<u32> conversedFlags(flagsCount);
|
||||
for (size_t i = 0; i < flagsCount; i++) {
|
||||
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
|
||||
}
|
||||
|
@ -25,11 +23,11 @@ CreatureLib_SpeciesVariant_Construct(const char* name, float height, float weigh
|
|||
secretTalentsWrapped.Append(secretTalents[i]);
|
||||
}
|
||||
|
||||
return new SpeciesVariant(
|
||||
ArbUt::StringView(name), height, weight, baseExperience, ArbUt::List<uint8_t>(types, types + typeLength),
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(baseHealth, baseAttack, baseDefense, baseMagicalAttack,
|
||||
baseMagicalDefense, baseSpeed),
|
||||
talentsWrapped, secretTalentsWrapped, attacks, conversedFlags);
|
||||
return new SpeciesVariant(ArbUt::StringView(name), height, weight, baseExperience,
|
||||
ArbUt::List<u8>(types, types + typeLength),
|
||||
CreatureLib::Library::StatisticSet<u16>(baseHealth, baseAttack, baseDefense,
|
||||
baseMagicalAttack, baseMagicalDefense, baseSpeed),
|
||||
talentsWrapped, secretTalentsWrapped, attacks, conversedFlags);
|
||||
}
|
||||
|
||||
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
|
||||
|
@ -37,21 +35,21 @@ export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
|
|||
export const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetHeight, float);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetWeight, float);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetBaseExperience, uint32_t);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetBaseExperience, u32);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetTypeCount, size_t);
|
||||
export uint8_t CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
|
||||
export uint16_t CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
|
||||
export u8 CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
|
||||
export u16 CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
|
||||
return p->GetStatistic(stat);
|
||||
}
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetTalentCount, size_t);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetSecretTalentCount, size_t);
|
||||
export uint8_t CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, uint8_t index, const Talent*& out) {
|
||||
export u8 CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, u8 index, const Talent*& out) {
|
||||
Try(out = p->GetTalent(TalentIndex(secret, index)).GetRaw();)
|
||||
}
|
||||
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
|
||||
return p->GetLearnableAttacks().GetRaw();
|
||||
}
|
||||
export uint8_t CreatureLib_SpeciesVariant_GetRandomTalent(SpeciesVariant* p, ArbUt::Random* rand) {
|
||||
export u8 CreatureLib_SpeciesVariant_GetRandomTalent(SpeciesVariant* p, ArbUt::Random* rand) {
|
||||
return p->GetRandomTalent(*rand).GetIndex();
|
||||
}
|
||||
export bool CreatureLib_SpeciesVariant_HasFlag(const SpeciesVariant* p, const char* key) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
export uint8_t CreatureLib_TalentLibrary_Construct(TalentLibrary*& library, size_t initialCapacity = 32) {
|
||||
export u8 CreatureLib_TalentLibrary_Construct(TalentLibrary*& library, size_t initialCapacity = 32) {
|
||||
Try(library = new TalentLibrary(initialCapacity);)
|
||||
};
|
||||
|
||||
|
|
|
@ -8,27 +8,25 @@ export TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
|
|||
|
||||
export void CreatureLib_TypeLibrary_Destruct(const TypeLibrary* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_TypeLibrary_GetTypeId(uint8_t& out, const TypeLibrary* p, const char* type) {
|
||||
export u8 CreatureLib_TypeLibrary_GetTypeId(u8& out, const TypeLibrary* p, const char* type) {
|
||||
Try(out = p->GetTypeId(ArbUt::StringView(type));)
|
||||
}
|
||||
export uint8_t CreatureLib_TypeLibrary_RegisterType(uint8_t& out, TypeLibrary* p, const char* type) {
|
||||
export u8 CreatureLib_TypeLibrary_RegisterType(u8& out, TypeLibrary* p, const char* type) {
|
||||
Try(out = p->RegisterType(ArbUt::StringView(type));)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_TypeLibrary_SetEffectiveness(TypeLibrary* p, uint8_t attacking, uint8_t defensive,
|
||||
float effectiveness) {
|
||||
export u8 CreatureLib_TypeLibrary_SetEffectiveness(TypeLibrary* p, u8 attacking, u8 defensive, float effectiveness) {
|
||||
Try(p->SetEffectiveness(attacking, defensive, effectiveness);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLibrary* p, uint8_t attacking,
|
||||
uint8_t defensive) {
|
||||
export u8 CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive) {
|
||||
Try(out = p->GetSingleEffectiveness(attacking, defensive);)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, uint8_t attacking,
|
||||
uint8_t defensive[], size_t defensiveCount) {
|
||||
Try(out = p->GetEffectiveness(attacking, std::vector<uint8_t>(defensive, defensive + defensiveCount));)
|
||||
export u8 CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive[],
|
||||
size_t defensiveCount) {
|
||||
Try(out = p->GetEffectiveness(attacking, std::vector<u8>(defensive, defensive + defensiveCount));)
|
||||
}
|
||||
export uint8_t CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, uint8_t type) {
|
||||
export u8 CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, u8 type) {
|
||||
Try(out = p->GetTypeName(type).c_str();)
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ if (CREATURELIB_TESTS)
|
|||
# Add a definition for the test library
|
||||
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|
||||
if (SANITIZER_TESTS AND NOT WINDOWS)
|
||||
target_compile_options(CreatureLibTests PRIVATE -fsanitize=address)
|
||||
target_link_options(CreatureLibTests PRIVATE -fsanitize=address)
|
||||
target_compile_options(CreatureLibTests PRIVATE -fsanitize=address,undefined,leak,integer,nullability -fno-sanitize-recover=all)
|
||||
target_link_options(CreatureLibTests PRIVATE -fsanitize=address,undefined,leak,integer,nullability -fno-sanitize-recover=all)
|
||||
endif ()
|
||||
endif ()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText,
|
||||
ENUM(EventDataKind, u8, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText,
|
||||
ChangeSpecies, ChangeVariant, AttackUse, ChangeStatBoost, Fail, Swap, StatusChange)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace CreatureLib::Battling {
|
|||
std::vector<EventHookFunc> _listeners;
|
||||
size_t _offset;
|
||||
size_t _capacity;
|
||||
uint8_t* _memory = nullptr;
|
||||
u8* _memory = nullptr;
|
||||
|
||||
static constexpr size_t initialSize = 2048;
|
||||
static constexpr size_t stepSize = 1024;
|
||||
|
@ -32,7 +32,7 @@ namespace CreatureLib::Battling {
|
|||
if (ptr == nullptr) {
|
||||
THROW("Out of memory.");
|
||||
}
|
||||
_memory = static_cast<uint8_t*>(ptr);
|
||||
_memory = static_cast<u8*>(ptr);
|
||||
}
|
||||
EventHook(const EventHook&) = delete;
|
||||
EventHook& operator=(const EventHook&) = delete;
|
||||
|
@ -52,9 +52,9 @@ namespace CreatureLib::Battling {
|
|||
if (newPtr == nullptr) {
|
||||
THROW("Out of memory.");
|
||||
}
|
||||
_memory = static_cast<uint8_t*>(newPtr);
|
||||
_memory = static_cast<u8*>(newPtr);
|
||||
}
|
||||
uint8_t* ptr = _memory + _offset;
|
||||
u8* ptr = _memory + _offset;
|
||||
T* event = new (ptr) T(args...);
|
||||
_offset += sizeof(T);
|
||||
for (const auto& listener : _listeners) {
|
||||
|
|
|
@ -7,19 +7,19 @@ namespace CreatureLib::Battling {
|
|||
class ChangeStatBoostEvent final : public EventData {
|
||||
const ArbUt::BorrowedPtr<Creature> _creature;
|
||||
const CreatureLib::Library::Statistic _statistic;
|
||||
const int8_t _oldValue;
|
||||
const int8_t _newValue;
|
||||
const i8 _oldValue;
|
||||
const i8 _newValue;
|
||||
|
||||
public:
|
||||
ChangeStatBoostEvent(const ArbUt::BorrowedPtr<Creature>& creature, CreatureLib::Library::Statistic statistic,
|
||||
int8_t oldValue, int8_t newValue) noexcept
|
||||
i8 oldValue, i8 newValue) noexcept
|
||||
: _creature(creature), _statistic(statistic), _oldValue(oldValue), _newValue(newValue) {}
|
||||
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::ChangeStatBoost; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
CreatureLib::Library::Statistic GetStatistic() const noexcept { return _statistic; }
|
||||
int8_t GetOldValue() const noexcept { return _oldValue; }
|
||||
int8_t GetNewValue() const noexcept { return _newValue; }
|
||||
i8 GetOldValue() const noexcept { return _oldValue; }
|
||||
i8 GetNewValue() const noexcept { return _newValue; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@ namespace CreatureLib::Battling {
|
|||
class DamageEvent final : public EventData {
|
||||
ArbUt::BorrowedPtr<Creature> _creature;
|
||||
DamageSource _damageSource;
|
||||
uint32_t _originalHealth;
|
||||
uint32_t _newHealth;
|
||||
u32 _originalHealth;
|
||||
u32 _newHealth;
|
||||
|
||||
public:
|
||||
DamageEvent(Creature* c, DamageSource s, uint32_t oHealth, uint32_t newHealth) noexcept
|
||||
DamageEvent(Creature* c, DamageSource s, u32 oHealth, u32 newHealth) noexcept
|
||||
: _creature(c), _damageSource(s), _originalHealth(oHealth), _newHealth(newHealth) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Damage; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
DamageSource GetDamageSource() const noexcept { return _damageSource; }
|
||||
uint32_t GetOriginalHealth() const noexcept { return _originalHealth; }
|
||||
uint32_t GetNewHealth() const noexcept { return _newHealth; }
|
||||
u32 GetOriginalHealth() const noexcept { return _originalHealth; }
|
||||
u32 GetNewHealth() const noexcept { return _newHealth; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
namespace CreatureLib::Battling {
|
||||
class ExperienceGainEvent final : public EventData {
|
||||
ArbUt::BorrowedPtr<Creature> _creature;
|
||||
uint32_t _previousExperience;
|
||||
uint32_t _newExperience;
|
||||
u32 _previousExperience;
|
||||
u32 _newExperience;
|
||||
|
||||
public:
|
||||
ExperienceGainEvent(const ArbUt::BorrowedPtr<Creature>& creature, uint32_t previousExp, uint32_t newExp)
|
||||
ExperienceGainEvent(const ArbUt::BorrowedPtr<Creature>& creature, u32 previousExp, u32 newExp)
|
||||
: _creature(creature), _previousExperience(previousExp), _newExperience(newExp) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::ExperienceGain; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
uint32_t GetPreviousExperience() const noexcept { return _previousExperience; }
|
||||
uint32_t GetNewExperience() const noexcept { return _newExperience; }
|
||||
u32 GetPreviousExperience() const noexcept { return _previousExperience; }
|
||||
u32 GetNewExperience() const noexcept { return _newExperience; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
namespace CreatureLib::Battling {
|
||||
class HealEvent final : public EventData {
|
||||
ArbUt::BorrowedPtr<Creature> _creature;
|
||||
uint32_t _originalHealth;
|
||||
uint32_t _newHealth;
|
||||
u32 _originalHealth;
|
||||
u32 _newHealth;
|
||||
|
||||
public:
|
||||
HealEvent(ArbUt::BorrowedPtr<Creature> c, uint32_t oHealth, uint32_t newHealth) noexcept
|
||||
HealEvent(ArbUt::BorrowedPtr<Creature> c, u32 oHealth, u32 newHealth) noexcept
|
||||
: _creature(c), _originalHealth(oHealth), _newHealth(newHealth) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Heal; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
uint32_t GetOriginalHealth() const noexcept { return _originalHealth; }
|
||||
uint32_t GetNewHealth() const noexcept { return _newHealth; }
|
||||
u32 GetOriginalHealth() const noexcept { return _originalHealth; }
|
||||
u32 GetNewHealth() const noexcept { return _newHealth; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ using namespace CreatureLib::Battling;
|
|||
|
||||
using TargetList = List<OptionalBorrowedPtr<Creature>>;
|
||||
|
||||
static inline constexpr uint8_t GetOppositeSide(uint8_t v) {
|
||||
static inline constexpr u8 GetOppositeSide(u8 v) {
|
||||
if (v == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
|
|||
}
|
||||
HOOK(OnBeforeAttack, attack, attack);
|
||||
|
||||
for (uint8_t i = 0; i < attack->GetTargetCount(); i++) {
|
||||
for (u8 i = 0; i < attack->GetTargetCount(); i++) {
|
||||
auto target = attack->GetTargets()[i];
|
||||
if (target.HasValue()) {
|
||||
try_creature(HandleAttackForTarget(attack, target.GetValue()), "Exception occurred during handling attack "
|
||||
|
@ -200,7 +200,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
EnsureNotNull(miscLibrary)
|
||||
|
||||
auto* hitIterator = attack->GetTargetIteratorBegin(target);
|
||||
for (uint8_t hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
|
||||
for (u8 hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
|
||||
if (battle.GetValue()->HasEnded()) {
|
||||
return;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
break;
|
||||
}
|
||||
auto& hit = hitIterator[hitIndex];
|
||||
uint8_t hitType = attackData->GetType();
|
||||
u8 hitType = attackData->GetType();
|
||||
HOOK(ChangeAttackType, target, attack, target.GetRaw(), hitIndex, &hitType);
|
||||
hit.SetType(hitType);
|
||||
auto effectiveness = typeLibrary->GetEffectiveness(hitType, target->GetTypes());
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
ENUM(HistoryElementKind, uint8_t, AttackUse, Damage)
|
||||
ENUM(HistoryElementKind, u8, AttackUse, Damage)
|
||||
#endif // CREATURELIB_HISTORYELEMENTKIND_HPP
|
||||
|
|
|
@ -3,47 +3,44 @@
|
|||
|
||||
using namespace CreatureLib;
|
||||
|
||||
Library::StatisticSet<uint32_t> Battling::BattleStatCalculator::CalculateFlatStats(Battling::Creature* creature) const {
|
||||
return Library::StatisticSet<uint32_t>(CalculateFlatStat(creature, Library::Statistic::Health),
|
||||
CalculateFlatStat(creature, Library::Statistic::PhysicalAttack),
|
||||
CalculateFlatStat(creature, Library::Statistic::PhysicalDefense),
|
||||
CalculateFlatStat(creature, Library::Statistic::MagicalAttack),
|
||||
CalculateFlatStat(creature, Library::Statistic::MagicalDefense),
|
||||
CalculateFlatStat(creature, Library::Statistic::Speed));
|
||||
Library::StatisticSet<u32> Battling::BattleStatCalculator::CalculateFlatStats(Battling::Creature* creature) const {
|
||||
return Library::StatisticSet<u32>(CalculateFlatStat(creature, Library::Statistic::Health),
|
||||
CalculateFlatStat(creature, Library::Statistic::PhysicalAttack),
|
||||
CalculateFlatStat(creature, Library::Statistic::PhysicalDefense),
|
||||
CalculateFlatStat(creature, Library::Statistic::MagicalAttack),
|
||||
CalculateFlatStat(creature, Library::Statistic::MagicalDefense),
|
||||
CalculateFlatStat(creature, Library::Statistic::Speed));
|
||||
}
|
||||
|
||||
Library::StatisticSet<uint32_t>
|
||||
Battling::BattleStatCalculator::CalculateBoostedStats(Battling::Creature* creature) const {
|
||||
return Library::StatisticSet<uint32_t>(CalculateBoostedStat(creature, Library::Statistic::Health),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::MagicalAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::MagicalDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::Speed));
|
||||
Library::StatisticSet<u32> Battling::BattleStatCalculator::CalculateBoostedStats(Battling::Creature* creature) const {
|
||||
return Library::StatisticSet<u32>(CalculateBoostedStat(creature, Library::Statistic::Health),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::MagicalAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::MagicalDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::Speed));
|
||||
}
|
||||
|
||||
uint32_t CalculateHealthStat(Battling::Creature* creature) {
|
||||
u32 CalculateHealthStat(Battling::Creature* creature) {
|
||||
EnsureNotNull(creature)
|
||||
auto level = creature->GetLevel();
|
||||
float a = (creature->GetBaseStat(Library::Statistic::Health)) * 2.0 * level;
|
||||
return static_cast<uint32_t>(floor(a / 100.0) + level + 10);
|
||||
return static_cast<u32>(floor(a / 100.0) + level + 10);
|
||||
}
|
||||
|
||||
uint32_t CalculateOtherStat(Battling::Creature* creature, Library::Statistic stat) {
|
||||
u32 CalculateOtherStat(Battling::Creature* creature, Library::Statistic stat) {
|
||||
EnsureNotNull(creature)
|
||||
auto level = creature->GetLevel();
|
||||
float a = (creature->GetBaseStat(stat)) * 2.0 * level;
|
||||
return static_cast<uint32_t>(floor(a / 100.0) + 5);
|
||||
return static_cast<u32>(floor(a / 100.0) + 5);
|
||||
}
|
||||
|
||||
uint32_t Battling::BattleStatCalculator::CalculateFlatStat(Battling::Creature* creature,
|
||||
Library::Statistic stat) const {
|
||||
u32 Battling::BattleStatCalculator::CalculateFlatStat(Battling::Creature* creature, Library::Statistic stat) const {
|
||||
if (stat == Library::Statistic::Health)
|
||||
return CalculateHealthStat(creature);
|
||||
return CalculateOtherStat(creature, stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::BattleStatCalculator::CalculateBoostedStat(Battling::Creature* creature,
|
||||
Library::Statistic stat) const {
|
||||
u32 Battling::BattleStatCalculator::CalculateBoostedStat(Battling::Creature* creature, Library::Statistic stat) const {
|
||||
return creature->GetFlatStat(stat) + (creature->GetBoostedStat(stat));
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace CreatureLib::Battling {
|
|||
public:
|
||||
virtual ~BattleStatCalculator() = default;
|
||||
|
||||
virtual Library::StatisticSet<uint32_t> CalculateFlatStats(Creature* creature) const;
|
||||
virtual Library::StatisticSet<uint32_t> CalculateBoostedStats(Creature* creature) const;
|
||||
virtual uint32_t CalculateFlatStat(Creature* creature, Library::Statistic stat) const;
|
||||
virtual uint32_t CalculateBoostedStat(Creature* creature, Library::Statistic stat) const;
|
||||
virtual Library::StatisticSet<u32> CalculateFlatStats(Creature* creature) const;
|
||||
virtual Library::StatisticSet<u32> CalculateBoostedStats(Creature* creature) const;
|
||||
virtual u32 CalculateFlatStat(Creature* creature, Library::Statistic stat) const;
|
||||
virtual u32 CalculateBoostedStat(Creature* creature, Library::Statistic stat) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,23 +2,23 @@
|
|||
#include "../ScriptHandling/ScriptMacros.hpp"
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
uint32_t DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const {
|
||||
u32 DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const {
|
||||
EnsureNotNull(attack)
|
||||
EnsureNotNull(target)
|
||||
auto levelMod = static_cast<float>(2 * attack->GetUser()->GetLevel()) / 5 + 2;
|
||||
auto bp = hitData.GetBasePower();
|
||||
auto statMod = GetStatModifier(attack, target, hitIndex, hitData);
|
||||
HOOK(ModifyStatModifier, attack, attack, target, hitIndex, &statMod);
|
||||
uint32_t damage = static_cast<uint32_t>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||
GetDamageModifier(attack, target, hitIndex, hitData));
|
||||
u32 damage = static_cast<u32>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||
GetDamageModifier(attack, target, hitIndex, hitData));
|
||||
HOOK(OverrideDamage, attack, attack, target, hitIndex, &damage);
|
||||
HOOK(OverrideIncomingDamage, target, attack, target, hitIndex, &damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
uint8_t DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
[[maybe_unused]] const ExecutingAttack::HitData& hitData) const {
|
||||
u8 DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
[[maybe_unused]] const ExecutingAttack::HitData& hitData) const {
|
||||
EnsureNotNull(attack)
|
||||
EnsureNotNull(target)
|
||||
auto bp = attack->GetUseAttack()->GetBasePower();
|
||||
|
@ -26,7 +26,7 @@ uint8_t DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, u
|
|||
return bp;
|
||||
}
|
||||
|
||||
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const {
|
||||
EnsureNotNull(attack)
|
||||
EnsureNotNull(target)
|
||||
|
@ -65,7 +65,7 @@ float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target,
|
|||
return offensiveValue / defensiveValue;
|
||||
}
|
||||
|
||||
float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const {
|
||||
EnsureNotNull(attack)
|
||||
EnsureNotNull(target)
|
||||
|
|
|
@ -8,14 +8,14 @@ namespace CreatureLib::Battling {
|
|||
class DamageLibrary {
|
||||
public:
|
||||
virtual ~DamageLibrary() = default;
|
||||
virtual uint32_t GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
virtual u32 GetDamage(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
|
||||
virtual uint8_t GetBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
virtual float GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
virtual u8 GetBasePower(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
virtual float GetStatModifier(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
virtual float GetDamageModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
virtual float GetDamageModifier(ExecutingAttack* attack, Creature* target, u8 hitIndex,
|
||||
const ExecutingAttack::HitData& hitData) const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ void CreatureLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
|||
if (levelDiff <= 0)
|
||||
continue;
|
||||
auto experienceGain = levelDiff * 10;
|
||||
opponent->AddExperience(static_cast<uint32_t>(experienceGain));
|
||||
opponent->AddExperience(static_cast<u32>(experienceGain));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
bool CreatureLib::Battling::MiscLibrary::IsCritical([[maybe_unused]] CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target,
|
||||
[[maybe_unused]] uint8_t hit) const {
|
||||
[[maybe_unused]] u8 hit) const {
|
||||
EnsureNotNull(target)
|
||||
Ensure(target->GetBattle().HasValue())
|
||||
auto rand = target->GetBattle().GetValue()->GetRandom();
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace CreatureLib::Battling {
|
|||
class MiscLibrary {
|
||||
public:
|
||||
virtual ~MiscLibrary() = default;
|
||||
virtual bool IsCritical(ExecutingAttack* attack, Creature* target, uint8_t hit) const;
|
||||
virtual bool IsCritical(ExecutingAttack* attack, Creature* target, u8 hit) const;
|
||||
virtual bool CanFlee(FleeTurnChoice* switchChoice) const;
|
||||
virtual BaseTurnChoice* ReplacementAttack(Creature* user, CreatureIndex target) const;
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ void Battle::CheckChoicesSetAndRun() {
|
|||
EnsureNotNull(choice)
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = std::static_pointer_cast<AttackTurnChoice>(choice);
|
||||
uint8_t uses = 1;
|
||||
u8 uses = 1;
|
||||
// HOOK: change number of uses needed.
|
||||
if (attack->GetAttack()->GetRemainingUses() < uses) {
|
||||
choice = std::shared_ptr<BaseTurnChoice>(_library->GetMiscLibrary()->ReplacementAttack(
|
||||
|
@ -110,19 +110,19 @@ bool Battle::CreatureInField(ArbUt::BorrowedPtr<Creature> creature) const {
|
|||
return std::any_of(_sides.begin(), _sides.end(), [creature](auto c) { return c->CreatureOnSide(creature); });
|
||||
}
|
||||
|
||||
void Battle::ForceRecall(uint8_t side, uint8_t index) { _sides[side]->SetCreature(nullptr, index); }
|
||||
void Battle::ForceRecall(u8 side, u8 index) { _sides[side]->SetCreature(nullptr, index); }
|
||||
|
||||
size_t Battle::ScriptCount() const { return 1; }
|
||||
void Battle::GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) { GetOwnScripts(scripts); }
|
||||
|
||||
void Battle::GetOwnScripts(ArbUt::List<ScriptWrapper>& scripts) { scripts.Append(ScriptWrapper::FromSet(&_volatile)); }
|
||||
|
||||
void Battle::SwitchCreature(uint8_t sideIndex, uint8_t index, Creature* c) {
|
||||
void Battle::SwitchCreature(u8 sideIndex, u8 index, Creature* c) {
|
||||
auto side = this->_sides[sideIndex];
|
||||
side->SetCreature(c, index);
|
||||
}
|
||||
|
||||
bool Battle::CanSlotBeFilled(uint8_t side, uint8_t index) const {
|
||||
bool Battle::CanSlotBeFilled(u8 side, u8 index) const {
|
||||
for (const auto& party : _parties) {
|
||||
if (party->IsResponsibleForIndex(side, index)) {
|
||||
if (party->HasCreaturesNotInField())
|
||||
|
@ -137,8 +137,8 @@ void Battle::ValidateBattleState() {
|
|||
return;
|
||||
}
|
||||
bool survivingSideExists = false;
|
||||
uint8_t winningSide = 255;
|
||||
for (uint8_t i = 0; i < _sides.Count(); i++) {
|
||||
u8 winningSide = 255;
|
||||
for (u8 i = 0; i < _sides.Count(); i++) {
|
||||
auto side = _sides[i];
|
||||
if (side->HasFled()) {
|
||||
this->_battleResult = BattleResult::Inconclusive();
|
||||
|
@ -200,8 +200,8 @@ Battle* Battle::Clone() const {
|
|||
continue;
|
||||
}
|
||||
auto partyIndex = party->GetParty()->GetParty().IndexOf(creature.GetValue());
|
||||
if (partyIndex != -1U) {
|
||||
auto c = battle->_parties.At(j)->GetParty()->GetParty()[partyIndex];
|
||||
if (partyIndex.has_value()) {
|
||||
auto c = battle->_parties.At(j)->GetParty()->GetParty()[partyIndex.value()];
|
||||
battle->_sides.At(i)->SetCreature(c, creatureIndex);
|
||||
j = _parties.Count();
|
||||
break;
|
||||
|
|
|
@ -18,8 +18,8 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::BorrowedPtr<const BattleLibrary> _library;
|
||||
ArbUt::UniquePtrList<BattleParty> _parties;
|
||||
bool _canFlee;
|
||||
uint8_t _numberOfSides;
|
||||
uint8_t _creaturesPerSide;
|
||||
u8 _numberOfSides;
|
||||
u8 _creaturesPerSide;
|
||||
ArbUt::UniquePtrList<BattleSide> _sides;
|
||||
BattleRandom _random;
|
||||
std::unique_ptr<ChoiceQueue> _currentTurnQueue = nullptr;
|
||||
|
@ -28,14 +28,14 @@ namespace CreatureLib::Battling {
|
|||
EventHook _eventHook;
|
||||
ArbUt::UniquePtr<HistoryHolder> _historyHolder = new HistoryHolder([this]() { return GetCurrentTurn(); });
|
||||
|
||||
uint32_t _currentTurn = 0;
|
||||
u32 _currentTurn = 0;
|
||||
|
||||
ScriptSet _volatile;
|
||||
long _lastTurnTime;
|
||||
|
||||
public:
|
||||
Battle(const BattleLibrary* library, ArbUt::List<BattleParty*> parties, bool canFlee = true,
|
||||
uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1,
|
||||
u8 numberOfSides = 2, u8 creaturesPerSide = 1,
|
||||
uint_fast32_t randomSeed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count())
|
||||
|
@ -51,8 +51,8 @@ namespace CreatureLib::Battling {
|
|||
virtual ~Battle() { ClearBattle(); }
|
||||
|
||||
[[nodiscard]] const ArbUt::BorrowedPtr<const BattleLibrary>& GetLibrary() const noexcept;
|
||||
[[nodiscard]] uint32_t GetCurrentTurn() const noexcept { return _currentTurn; }
|
||||
inline uint8_t GetCreaturesPerSide() const noexcept { return _creaturesPerSide; }
|
||||
[[nodiscard]] u32 GetCurrentTurn() const noexcept { return _currentTurn; }
|
||||
inline u8 GetCreaturesPerSide() const noexcept { return _creaturesPerSide; }
|
||||
|
||||
virtual bool CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice);
|
||||
virtual bool TrySetChoice(BaseTurnChoice* choice);
|
||||
|
@ -69,13 +69,13 @@ namespace CreatureLib::Battling {
|
|||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(const CreatureIndex& target) const {
|
||||
return _sides[target.GetSideIndex()]->GetCreature(target.GetCreatureIndex());
|
||||
}
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(uint8_t side, uint8_t target) const {
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(u8 side, u8 target) const {
|
||||
return _sides[side]->GetCreature(target);
|
||||
}
|
||||
|
||||
void ForceRecall(uint8_t side, uint8_t index);
|
||||
void SwitchCreature(uint8_t side, uint8_t index, Creature* c);
|
||||
bool CanSlotBeFilled(uint8_t side, uint8_t index) const;
|
||||
void ForceRecall(u8 side, u8 index);
|
||||
void SwitchCreature(u8 side, u8 index, Creature* c);
|
||||
bool CanSlotBeFilled(u8 side, u8 index) const;
|
||||
|
||||
size_t ScriptCount() const override;
|
||||
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override;
|
||||
|
@ -93,16 +93,16 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(const ArbUt::StringView& key) const {
|
||||
return _volatile.Get(key);
|
||||
}
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(uint32_t keyHash) const noexcept {
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(u32 keyHash) const noexcept {
|
||||
return _volatile.Get(keyHash);
|
||||
}
|
||||
BattleScript* AddVolatileScript(const ArbUt::StringView& key);
|
||||
BattleScript* AddVolatileScript(BattleScript* script);
|
||||
void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
|
||||
void RemoveVolatileScript(uint32_t keyHash) { _volatile.Remove(keyHash); }
|
||||
void RemoveVolatileScript(u32 keyHash) { _volatile.Remove(keyHash); }
|
||||
void RemoveVolatileScript(BattleScript* script);
|
||||
bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
|
||||
bool HasVolatileScript(uint32_t keyHash) const { return _volatile.Has(keyHash); }
|
||||
bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); }
|
||||
|
||||
void DisplayText(const ArbUt::StringView& text);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace CreatureLib::Battling {
|
|||
return _responsibleIndices.Contains(index);
|
||||
}
|
||||
|
||||
inline bool IsResponsibleForIndex(uint8_t side, uint8_t index) const {
|
||||
inline bool IsResponsibleForIndex(u8 side, u8 index) const {
|
||||
return std::any_of(_responsibleIndices.begin(), _responsibleIndices.end(),
|
||||
[side, index](const CreatureIndex& ci) {
|
||||
return ci.GetSideIndex() == side && ci.GetCreatureIndex() == index;
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace CreatureLib::Battling {
|
|||
explicit BattleRandom(uint_fast32_t seed) noexcept : _random(seed) {}
|
||||
|
||||
bool EffectChance(float chance, ExecutingAttack* attack, Creature* target);
|
||||
int32_t Get() noexcept { return _random.Get(); }
|
||||
int32_t Get(int32_t max) noexcept { return _random.Get(max); }
|
||||
int32_t Get(int32_t min, int32_t max) noexcept { return _random.Get(min, max); }
|
||||
i32 Get() noexcept { return _random.Get(); }
|
||||
i32 Get(i32 max) noexcept { return _random.Get(max); }
|
||||
i32 Get(i32 min, i32 max) noexcept { return _random.Get(min, max); }
|
||||
ArbUt::Random& GetRNG() noexcept { return _random; }
|
||||
uint_fast32_t GetSeed() const noexcept { return _random.GetSeed(); }
|
||||
};
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
namespace CreatureLib::Battling {
|
||||
class BattleResult {
|
||||
bool _conclusiveResult;
|
||||
uint8_t _winningSide;
|
||||
u8 _winningSide;
|
||||
|
||||
BattleResult(bool conclusiveResult, uint8_t winningSide)
|
||||
BattleResult(bool conclusiveResult, u8 winningSide)
|
||||
: _conclusiveResult(conclusiveResult), _winningSide(winningSide) {}
|
||||
|
||||
public:
|
||||
static BattleResult Inconclusive() { return BattleResult(false, 0); }
|
||||
static BattleResult Conclusive(uint8_t winner) { return BattleResult(true, winner); }
|
||||
static BattleResult Conclusive(u8 winner) { return BattleResult(true, winner); }
|
||||
static BattleResult Empty() { return BattleResult(false, 0); }
|
||||
|
||||
/// Whether or not the battle has ended with a conclusive result.
|
||||
bool IsConclusiveResult() const noexcept { return _conclusiveResult; }
|
||||
/// Get the index of the side that has won the battle. Only valid if the battle has a conclusive result.
|
||||
uint8_t GetWinningSide() const noexcept { return _winningSide; }
|
||||
u8 GetWinningSide() const noexcept { return _winningSide; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ bool BattleSide::AllPossibleSlotsFilled() const {
|
|||
|
||||
void BattleSide::ResetChoices() noexcept {
|
||||
_choicesSet = 0;
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
|
||||
for (u8 i = 0; i < _creaturesPerSide; i++) {
|
||||
_choices[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void BattleSide::SetChoice(BaseTurnChoice* choice) {
|
|||
THROW("User not found");
|
||||
}
|
||||
|
||||
void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint8_t index) {
|
||||
void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, u8 index) {
|
||||
auto old = _creatures[index];
|
||||
if (old.HasValue()) {
|
||||
HOOK(OnRemove, old.GetValue());
|
||||
|
@ -82,7 +82,7 @@ bool BattleSide::CreatureOnSide(const ArbUt::BorrowedPtr<Creature>& creature) co
|
|||
return std::find(_creatures.begin(), _creatures.end(), creature.GetRaw()) != _creatures.end();
|
||||
}
|
||||
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& BattleSide::GetCreature(uint8_t index) const { return _creatures[index]; }
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& BattleSide::GetCreature(u8 index) const { return _creatures[index]; }
|
||||
|
||||
void BattleSide::GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) {
|
||||
GetOwnScripts(scripts);
|
||||
|
@ -93,7 +93,7 @@ void BattleSide::GetOwnScripts(ArbUt::List<ScriptWrapper>& scripts) {
|
|||
}
|
||||
size_t BattleSide::ScriptCount() const { return _battle->ScriptCount() + 1; }
|
||||
|
||||
uint8_t BattleSide::GetRandomCreatureIndex() {
|
||||
u8 BattleSide::GetRandomCreatureIndex() {
|
||||
// TODO: Consider adding parameter to only get index for available creatures.
|
||||
return _battle->GetRandom()->Get(_creaturesPerSide);
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
|
||||
namespace CreatureLib::Battling {
|
||||
class BattleSide : public ScriptSource {
|
||||
uint8_t _index;
|
||||
uint8_t _creaturesPerSide;
|
||||
u8 _index;
|
||||
u8 _creaturesPerSide;
|
||||
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _creatures;
|
||||
ArbUt::List<std::shared_ptr<BaseTurnChoice>> _choices;
|
||||
ArbUt::List<bool> _fillableSlots;
|
||||
uint8_t _choicesSet = 0;
|
||||
u8 _choicesSet = 0;
|
||||
ScriptSet _volatile;
|
||||
ArbUt::BorrowedPtr<Battle> _battle;
|
||||
bool _hasFled = false;
|
||||
|
||||
public:
|
||||
BattleSide(uint8_t index, ArbUt::BorrowedPtr<Battle> battle, uint8_t creaturesPerSide) noexcept
|
||||
BattleSide(u8 index, ArbUt::BorrowedPtr<Battle> battle, u8 creaturesPerSide) noexcept
|
||||
: _index(index), _creaturesPerSide(creaturesPerSide), _creatures(creaturesPerSide),
|
||||
_choices(creaturesPerSide), _fillableSlots(creaturesPerSide), _battle(battle) {
|
||||
for (size_t i = 0; i < creaturesPerSide; i++) {
|
||||
|
@ -42,10 +42,10 @@ namespace CreatureLib::Battling {
|
|||
void SetChoice(BaseTurnChoice* choice);
|
||||
void ResetChoices() noexcept;
|
||||
|
||||
void ForceClearCreature(uint8_t index) { _creatures[index] = {}; }
|
||||
void SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, uint8_t index);
|
||||
void ForceClearCreature(u8 index) { _creatures[index] = {}; }
|
||||
void SetCreature(ArbUt::OptionalBorrowedPtr<Creature> creature, u8 index);
|
||||
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(uint8_t index) const;
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(u8 index) const;
|
||||
bool CreatureOnSide(const ArbUt::BorrowedPtr<Creature>& creature) const;
|
||||
|
||||
size_t ScriptCount() const override;
|
||||
|
@ -56,8 +56,8 @@ namespace CreatureLib::Battling {
|
|||
|
||||
const ArbUt::OptionalBorrowedPtr<Creature>& GetCreature(u8 index) { return _creatures[index]; }
|
||||
|
||||
uint8_t GetSideIndex() noexcept { return _index; }
|
||||
uint8_t GetCreatureIndex(const ArbUt::BorrowedPtr<Creature>& c) {
|
||||
u8 GetSideIndex() noexcept { return _index; }
|
||||
u8 GetCreatureIndex(const ArbUt::BorrowedPtr<Creature>& c) {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
if (!_creatures[i].HasValue())
|
||||
continue;
|
||||
|
@ -68,7 +68,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
|
||||
void MarkSlotAsUnfillable(const ArbUt::BorrowedPtr<Creature>& creature) noexcept {
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
|
||||
for (u8 i = 0; i < _creaturesPerSide; i++) {
|
||||
if (!_creatures[i].HasValue())
|
||||
continue;
|
||||
if (_creatures[i].GetValue() == creature) {
|
||||
|
@ -90,7 +90,7 @@ namespace CreatureLib::Battling {
|
|||
|
||||
void MarkAsFled() noexcept { _hasFled = true; }
|
||||
|
||||
uint8_t GetRandomCreatureIndex();
|
||||
u8 GetRandomCreatureIndex();
|
||||
|
||||
bool SwapPositions(u8 a, u8 b);
|
||||
|
||||
|
@ -99,16 +99,16 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(const ArbUt::StringView& key) const {
|
||||
return _volatile.Get(key);
|
||||
}
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(uint32_t keyHash) const noexcept {
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> GetVolatileScript(u32 keyHash) const noexcept {
|
||||
return _volatile.Get(keyHash);
|
||||
}
|
||||
BattleScript* AddVolatileScript(const ArbUt::StringView& key);
|
||||
BattleScript* AddVolatileScript(BattleScript* script);
|
||||
void RemoveVolatileScript(const ArbUt::BasicStringView& name) { _volatile.Remove(name); }
|
||||
void RemoveVolatileScript(uint32_t keyHash) { _volatile.Remove(keyHash); }
|
||||
void RemoveVolatileScript(u32 keyHash) { _volatile.Remove(keyHash); }
|
||||
void RemoveVolatileScript(BattleScript* script);
|
||||
bool HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
|
||||
bool HasVolatileScript(uint32_t keyHash) const { return _volatile.Has(keyHash); }
|
||||
bool HasVolatileScript(u32 keyHash) const { return _volatile.Has(keyHash); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::BorrowedPtr<const BattleLibrary> _library;
|
||||
ArbUt::StringView _species;
|
||||
ArbUt::StringView _variant = "default"_cnc;
|
||||
uint8_t _level;
|
||||
u8 _level;
|
||||
std::optional<std::string> _nickname = "";
|
||||
|
||||
ArbUt::StringView _talent = ""_cnc;
|
||||
Library::Gender _gender = static_cast<Library::Gender>(-1);
|
||||
uint8_t _coloring = 0;
|
||||
u8 _coloring = 0;
|
||||
ArbUt::StringView _heldItem = ""_cnc;
|
||||
uint32_t _identifier = 0;
|
||||
u32 _identifier = 0;
|
||||
ArbUt::List<std::tuple<ArbUt::BorrowedPtr<const Library::AttackData>, AttackLearnMethod>> _attacks;
|
||||
|
||||
public:
|
||||
CreateCreature(ArbUt::BorrowedPtr<const BattleLibrary> library, const ArbUt::StringView& species, uint8_t level)
|
||||
CreateCreature(ArbUt::BorrowedPtr<const BattleLibrary> library, const ArbUt::StringView& species, u8 level)
|
||||
: _library(library), _species(species), _level(level),
|
||||
_attacks(library->GetSettings()->GetMaximalAttacks()) {}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace CreatureLib::Battling {
|
|||
Creature::Creature(const ArbUt::BorrowedPtr<const BattleLibrary>& library,
|
||||
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
||||
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
||||
u32 experience, u32 uid, Library::Gender gender, u8 coloring,
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::optional<std::string> nickname,
|
||||
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
||||
bool allowedExperienceGain)
|
||||
|
@ -91,8 +91,8 @@ namespace CreatureLib::Battling {
|
|||
// We modify the health of the creature by the change in its max health.
|
||||
auto prevHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health);
|
||||
RecalculateFlatStats();
|
||||
int32_t diffHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health) - prevHealth;
|
||||
if (_currentHealth < static_cast<uint32_t>(INT32_MAX) && static_cast<int32_t>(_currentHealth) < -diffHealth) {
|
||||
i32 diffHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health) - prevHealth;
|
||||
if (_currentHealth < static_cast<u32>(INT32_MAX) && static_cast<i32>(_currentHealth) < -diffHealth) {
|
||||
_currentHealth = 0;
|
||||
} else {
|
||||
_currentHealth += diffHealth;
|
||||
|
@ -105,7 +105,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::ChangeLevelBy(int8_t amount) {
|
||||
void Creature::ChangeLevelBy(i8 amount) {
|
||||
auto level = _level + amount;
|
||||
if (level > _library->GetSettings()->GetMaximalLevel())
|
||||
level = _library->GetSettings()->GetMaximalLevel();
|
||||
|
@ -149,7 +149,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
}
|
||||
|
||||
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount, bool selfInflicted) {
|
||||
bool Creature::ChangeStatBoost(Library::Statistic stat, i8 diffAmount, bool selfInflicted) {
|
||||
bool preventStatChange = false;
|
||||
HOOK(PreventStatBoostChange, this, this, stat, diffAmount, selfInflicted, &preventStatChange);
|
||||
if (preventStatChange) {
|
||||
|
@ -218,7 +218,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::Damage(uint32_t damage, DamageSource source) {
|
||||
void Creature::Damage(u32 damage, DamageSource source) {
|
||||
if (damage > _currentHealth) {
|
||||
damage = _currentHealth;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::Heal(uint32_t amount, bool canRevive) {
|
||||
void Creature::Heal(u32 amount, bool canRevive) {
|
||||
if (_currentHealth == 0 && !canRevive) {
|
||||
return;
|
||||
}
|
||||
|
@ -271,9 +271,9 @@ namespace CreatureLib::Battling {
|
|||
_overridenTalent = _library->GetStaticLib()->GetTalentLibrary()->Get(talent);
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& Creature::GetTypes() const noexcept { return _types; }
|
||||
const std::vector<u8>& Creature::GetTypes() const noexcept { return _types; }
|
||||
|
||||
bool Creature::HasType(uint8_t type) const noexcept {
|
||||
bool Creature::HasType(u8 type) const noexcept {
|
||||
return std::find(_types.begin(), _types.end(), type) != _types.end();
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
|
||||
void Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
||||
void Creature::AddExperience(uint32_t amount) {
|
||||
void Creature::AddExperience(u32 amount) {
|
||||
auto maxLevel = _library->GetSettings()->GetMaximalLevel();
|
||||
if (_level >= maxLevel) {
|
||||
return;
|
||||
|
@ -347,7 +347,7 @@ namespace CreatureLib::Battling {
|
|||
_heldItem = v.value();
|
||||
}
|
||||
}
|
||||
void Creature::SetHeldItem(uint32_t itemNameHash) {
|
||||
void Creature::SetHeldItem(u32 itemNameHash) {
|
||||
if (itemNameHash == ArbUt::StringView::CalculateHash("")) {
|
||||
_heldItem = {};
|
||||
_heldItemTriggerScript = {};
|
||||
|
@ -415,8 +415,8 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
THROW("Can't add attack. The creature already has the maximum amount of attacks.");
|
||||
}
|
||||
uint8_t Creature::GetAvailableAttackSlot() const noexcept {
|
||||
for (uint8_t i = 0; i < (uint8_t)_attacks.Count(); i++) {
|
||||
u8 Creature::GetAvailableAttackSlot() const noexcept {
|
||||
for (u8 i = 0; i < (u8)_attacks.Count(); i++) {
|
||||
if (_attacks[i] == nullptr) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -29,19 +29,19 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::OptionalBorrowedPtr<const Library::SpeciesVariant> _displayVariant = nullptr;
|
||||
|
||||
level_int_t _level;
|
||||
uint32_t _experience;
|
||||
uint32_t _uniqueIdentifier;
|
||||
u32 _experience;
|
||||
u32 _uniqueIdentifier;
|
||||
Library::Gender _gender;
|
||||
uint8_t _coloring;
|
||||
u8 _coloring;
|
||||
|
||||
uint32_t _currentHealth = -1;
|
||||
u32 _currentHealth = -1;
|
||||
|
||||
f32 _weight;
|
||||
f32 _height;
|
||||
|
||||
Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost;
|
||||
Library::StatisticSet<uint32_t> _flatStats;
|
||||
Library::StatisticSet<uint32_t> _boostedStats;
|
||||
Library::ClampedStatisticSet<i8, -6, 6> _statBoost;
|
||||
Library::StatisticSet<u32> _flatStats;
|
||||
Library::StatisticSet<u32> _boostedStats;
|
||||
|
||||
struct BattleData {
|
||||
bool OnBattleField = false;
|
||||
|
@ -75,11 +75,10 @@ namespace CreatureLib::Battling {
|
|||
public:
|
||||
Creature(const ArbUt::BorrowedPtr<const BattleLibrary>& library,
|
||||
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
|
||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level,
|
||||
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
|
||||
ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem, std::optional<std::string> nickname,
|
||||
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
|
||||
bool allowedExperienceGain = true);
|
||||
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, level_int_t level, u32 experience,
|
||||
u32 uid, Library::Gender gender, u8 coloring, ArbUt::OptionalBorrowedPtr<const Library::Item> heldItem,
|
||||
std::optional<std::string> nickname, const Library::TalentIndex& talent,
|
||||
const std::vector<LearnedAttack*>& attacks, bool allowedExperienceGain = true);
|
||||
|
||||
virtual ~Creature();
|
||||
|
||||
|
@ -98,23 +97,23 @@ namespace CreatureLib::Battling {
|
|||
virtual void ChangeVariant(const ArbUt::StringView& variantName);
|
||||
virtual void ChangeVariant(const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant);
|
||||
inline level_int_t GetLevel() const noexcept { return _level; }
|
||||
inline uint32_t GetExperience() const noexcept { return _experience; }
|
||||
inline uint32_t GetUniqueIdentifier() const noexcept { return _uniqueIdentifier; }
|
||||
inline u32 GetExperience() const noexcept { return _experience; }
|
||||
inline u32 GetUniqueIdentifier() const noexcept { return _uniqueIdentifier; }
|
||||
inline Library::Gender GetGender() const noexcept { return _gender; }
|
||||
inline uint8_t GetColoring() const noexcept { return _coloring; }
|
||||
inline u8 GetColoring() const noexcept { return _coloring; }
|
||||
inline bool HasHeldItem(const ArbUt::BasicStringView& name) const noexcept {
|
||||
return _heldItem.HasValue() && _heldItem.GetValue()->GetName() == name;
|
||||
}
|
||||
inline bool HasHeldItem(uint32_t nameHash) const noexcept {
|
||||
inline bool HasHeldItem(u32 nameHash) const noexcept {
|
||||
return _heldItem.HasValue() && _heldItem.GetValue()->GetName() == nameHash;
|
||||
}
|
||||
inline const ArbUt::OptionalBorrowedPtr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
|
||||
void SetHeldItem(const ArbUt::BasicStringView& itemName);
|
||||
void SetHeldItem(uint32_t itemNameHash);
|
||||
void SetHeldItem(u32 itemNameHash);
|
||||
inline void SetHeldItem(const ArbUt::BorrowedPtr<const Library::Item>& item) noexcept { _heldItem = item; };
|
||||
bool ConsumeHeldItem();
|
||||
|
||||
inline uint32_t GetCurrentHealth() const noexcept { return _currentHealth; }
|
||||
inline u32 GetCurrentHealth() const noexcept { return _currentHealth; }
|
||||
|
||||
inline f32 GetWeight() const noexcept { return _weight; }
|
||||
inline void SetWeight(f32 weight) noexcept {
|
||||
|
@ -154,17 +153,17 @@ namespace CreatureLib::Battling {
|
|||
/// Are we allowed to use this creature in a battle?
|
||||
[[nodiscard]] virtual bool IsUsable() const noexcept;
|
||||
[[nodiscard]] bool IsFainted() const noexcept;
|
||||
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const noexcept;
|
||||
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
|
||||
[[nodiscard]] const std::vector<u8>& GetTypes() const noexcept;
|
||||
[[nodiscard]] bool HasType(u8 type) const noexcept;
|
||||
void SetType(u8 index, u8 type) noexcept;
|
||||
|
||||
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
||||
void ChangeLevelBy(int8_t amount);
|
||||
void Damage(uint32_t damage, DamageSource source);
|
||||
void Heal(uint32_t amount, bool canRevive = false);
|
||||
u32 GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
|
||||
void ChangeLevelBy(i8 amount);
|
||||
void Damage(u32 damage, DamageSource source);
|
||||
void Heal(u32 amount, bool canRevive = false);
|
||||
void RestoreAllAttackUses() noexcept;
|
||||
void OverrideActiveTalent(const ArbUt::StringView& talent);
|
||||
void AddExperience(uint32_t amount);
|
||||
void AddExperience(u32 amount);
|
||||
|
||||
void MarkOpponentAsSeen(ArbUt::BorrowedPtr<Creature> creature) { _battleData.SeenOpponents.insert(creature); }
|
||||
const std::unordered_set<ArbUt::BorrowedPtr<Creature>>& GetSeenOpponents() const {
|
||||
|
@ -205,7 +204,7 @@ namespace CreatureLib::Battling {
|
|||
inline bool AllowedExperienceGain() const noexcept { return _allowedExperienceGain; }
|
||||
inline void SetAllowedExperienceGain(bool allowed) noexcept { _allowedExperienceGain = allowed; }
|
||||
|
||||
uint8_t GetAvailableAttackSlot() const noexcept;
|
||||
u8 GetAvailableAttackSlot() const noexcept;
|
||||
void AddAttack(LearnedAttack* attack);
|
||||
void ReplaceAttack(size_t index, LearnedAttack* attack);
|
||||
void SwapAttacks(size_t a, size_t b) { _attacks.Swap(a, b); }
|
||||
|
@ -220,15 +219,11 @@ namespace CreatureLib::Battling {
|
|||
|
||||
// region Stat APIs
|
||||
|
||||
bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount, bool selfInflicted = false);
|
||||
[[nodiscard]] inline uint32_t GetFlatStat(Library::Statistic stat) const { return _flatStats.GetStat(stat); }
|
||||
[[nodiscard]] inline uint32_t GetBoostedStat(Library::Statistic stat) const {
|
||||
return _boostedStats.GetStat(stat);
|
||||
}
|
||||
[[nodiscard]] inline uint32_t GetBaseStat(Library::Statistic stat) const {
|
||||
return _variant->GetStatistic(stat);
|
||||
}
|
||||
[[nodiscard]] inline int8_t GetStatBoost(Library::Statistic stat) const { return _statBoost.GetStat(stat); }
|
||||
bool ChangeStatBoost(Library::Statistic stat, i8 diffAmount, bool selfInflicted = false);
|
||||
[[nodiscard]] inline u32 GetFlatStat(Library::Statistic stat) const { return _flatStats.GetStat(stat); }
|
||||
[[nodiscard]] inline u32 GetBoostedStat(Library::Statistic stat) const { return _boostedStats.GetStat(stat); }
|
||||
[[nodiscard]] inline u32 GetBaseStat(Library::Statistic stat) const { return _variant->GetStatistic(stat); }
|
||||
[[nodiscard]] inline i8 GetStatBoost(Library::Statistic stat) const { return _statBoost.GetStat(stat); }
|
||||
void RecalculateFlatStats();
|
||||
void RecalculateBoostedStats();
|
||||
void RecalculateFlatStat(Library::Statistic);
|
||||
|
|
|
@ -9,11 +9,11 @@ namespace CreatureLib::Battling {
|
|||
|
||||
public:
|
||||
CreatureIndex() noexcept : _side(0), _creature(0) {}
|
||||
CreatureIndex(uint8_t side, u8 creature) noexcept : _side(side), _creature(creature) {}
|
||||
CreatureIndex(u8 side, u8 creature) noexcept : _side(side), _creature(creature) {}
|
||||
|
||||
uint8_t GetSideIndex() const noexcept { return _side; }
|
||||
u8 GetSideIndex() const noexcept { return _side; }
|
||||
|
||||
uint8_t GetCreatureIndex() const noexcept { return _creature; }
|
||||
u8 GetCreatureIndex() const noexcept { return _creature; }
|
||||
|
||||
bool operator==(const CreatureIndex& rhs) const noexcept {
|
||||
return (_side == rhs._side) && (_creature == rhs._creature);
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace CreatureLib::Battling {
|
|||
size_t GetLength() const noexcept { return _party.Count(); }
|
||||
|
||||
void PackParty() {
|
||||
int32_t firstNil = -1;
|
||||
i32 firstNil = -1;
|
||||
for (size_t i = 0; i < _party.Count(); i++) {
|
||||
if (_party[i] == nullptr) {
|
||||
if (firstNil == -1) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CREATURELIB_DAMAGESOURCE_HPP
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(DamageSource, uint8_t, AttackDamage, Misc);
|
||||
ENUM(DamageSource, u8, AttackDamage, Misc);
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_DAMAGESOURCE_HPP
|
||||
|
|
|
@ -8,32 +8,32 @@ namespace CreatureLib::Battling {
|
|||
public:
|
||||
class HitData {
|
||||
bool _critical = false;
|
||||
uint8_t _basePower = 0;
|
||||
u8 _basePower = 0;
|
||||
float _effectiveness = 1;
|
||||
uint32_t _damage = 0;
|
||||
uint8_t _type = 0;
|
||||
u32 _damage = 0;
|
||||
u8 _type = 0;
|
||||
bool _hasFailed = false;
|
||||
|
||||
public:
|
||||
HitData() noexcept {}
|
||||
|
||||
[[nodiscard]] inline bool IsCritical() const noexcept { return _critical; }
|
||||
[[nodiscard]] inline uint8_t GetBasePower() const noexcept { return _basePower; }
|
||||
[[nodiscard]] inline u8 GetBasePower() const noexcept { return _basePower; }
|
||||
[[nodiscard]] inline float GetEffectiveness() const noexcept { return _effectiveness; }
|
||||
[[nodiscard]] inline uint32_t GetDamage() const noexcept { return _damage; }
|
||||
[[nodiscard]] inline uint8_t GetType() const noexcept { return _type; }
|
||||
[[nodiscard]] inline u32 GetDamage() const noexcept { return _damage; }
|
||||
[[nodiscard]] inline u8 GetType() const noexcept { return _type; }
|
||||
[[nodiscard]] inline bool HasFailed() const noexcept { return _hasFailed; }
|
||||
|
||||
inline void SetCritical(bool value) noexcept { _critical = value; }
|
||||
inline void SetBasePower(uint8_t value) noexcept { _basePower = value; }
|
||||
inline void SetBasePower(u8 value) noexcept { _basePower = value; }
|
||||
inline void SetEffectiveness(float value) noexcept { _effectiveness = value; }
|
||||
inline void SetDamage(uint32_t value) noexcept { _damage = value; }
|
||||
inline void SetType(uint8_t value) noexcept { _type = value; }
|
||||
inline void SetDamage(u32 value) noexcept { _damage = value; }
|
||||
inline void SetType(u8 value) noexcept { _type = value; }
|
||||
inline void Fail() noexcept { _hasFailed = true; }
|
||||
};
|
||||
|
||||
private:
|
||||
uint8_t _numberHits;
|
||||
u8 _numberHits;
|
||||
std::unique_ptr<HitData[]> _hits;
|
||||
ArbUt::BorrowedPtr<Creature> _user;
|
||||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||
|
@ -42,7 +42,7 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _targets;
|
||||
|
||||
public:
|
||||
ExecutingAttack(const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
||||
ExecutingAttack(const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& targets, u8 numberHits,
|
||||
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
|
||||
const ArbUt::BorrowedPtr<const Library::AttackData>& useAttack,
|
||||
const std::unique_ptr<BattleScript>& script)
|
||||
|
@ -56,8 +56,8 @@ namespace CreatureLib::Battling {
|
|||
|
||||
virtual ~ExecutingAttack() noexcept = default;
|
||||
|
||||
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, uint8_t hit) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, u8 hit) {
|
||||
for (u8 i = 0; i < _targets.Count(); i++) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
|
||||
HitData* GetTargetIteratorBegin(ArbUt::BorrowedPtr<Creature> creature) {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
for (u8 i = 0; i < _targets.Count(); i++) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace CreatureLib::Battling {
|
|||
}
|
||||
|
||||
bool IsCreatureTarget(ArbUt::BorrowedPtr<Creature> creature) noexcept {
|
||||
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||
for (u8 i = 0; i < _targets.Count(); i++) {
|
||||
if (!_targets[i].HasValue()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,10 +92,10 @@ namespace CreatureLib::Battling {
|
|||
return false;
|
||||
}
|
||||
|
||||
inline uint8_t GetTargetCount() const noexcept { return _targets.Count(); }
|
||||
inline u8 GetTargetCount() const noexcept { return _targets.Count(); }
|
||||
|
||||
inline const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& GetTargets() const noexcept { return _targets; }
|
||||
inline uint8_t GetNumberOfHits() const noexcept { return _numberHits; }
|
||||
inline u8 GetNumberOfHits() const noexcept { return _numberHits; }
|
||||
|
||||
inline const ArbUt::BorrowedPtr<Creature>& GetUser() noexcept { return _user; }
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include "LearnedAttack.hpp"
|
||||
|
||||
CreatureLib::Battling::LearnedAttack::LearnedAttack(
|
||||
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
|
||||
AttackLearnMethod learnMethod)
|
||||
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, u8 maxUses, AttackLearnMethod learnMethod)
|
||||
: _attack(attack), _maxUses(maxUses), _remainingUses(maxUses), _learnMethod(learnMethod) {}
|
||||
|
||||
CreatureLib::Battling::LearnedAttack::LearnedAttack(
|
||||
|
@ -14,23 +13,23 @@ CreatureLib::Battling::LearnedAttack::GetAttack() const noexcept {
|
|||
return _attack;
|
||||
}
|
||||
|
||||
uint8_t CreatureLib::Battling::LearnedAttack::GetMaxUses() const noexcept { return _maxUses; }
|
||||
u8 CreatureLib::Battling::LearnedAttack::GetMaxUses() const noexcept { return _maxUses; }
|
||||
|
||||
uint8_t CreatureLib::Battling::LearnedAttack::GetRemainingUses() const noexcept { return _remainingUses; }
|
||||
u8 CreatureLib::Battling::LearnedAttack::GetRemainingUses() const noexcept { return _remainingUses; }
|
||||
|
||||
CreatureLib::Battling::AttackLearnMethod CreatureLib::Battling::LearnedAttack::GetLearnMethod() const noexcept {
|
||||
return _learnMethod;
|
||||
}
|
||||
|
||||
bool CreatureLib::Battling::LearnedAttack::TryUse(uint8_t uses) noexcept {
|
||||
bool CreatureLib::Battling::LearnedAttack::TryUse(u8 uses) noexcept {
|
||||
if (uses > _remainingUses)
|
||||
return false;
|
||||
_remainingUses -= uses;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreatureLib::Battling::LearnedAttack::DecreaseUses(uint8_t amount) noexcept { _remainingUses -= amount; }
|
||||
void CreatureLib::Battling::LearnedAttack::DecreaseUses(u8 amount) noexcept { _remainingUses -= amount; }
|
||||
|
||||
void CreatureLib::Battling::LearnedAttack::RestoreUses(uint8_t amount) noexcept { _remainingUses += amount; }
|
||||
void CreatureLib::Battling::LearnedAttack::RestoreUses(u8 amount) noexcept { _remainingUses += amount; }
|
||||
|
||||
void CreatureLib::Battling::LearnedAttack::RestoreAllUses() noexcept { _remainingUses = _maxUses; }
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
namespace CreatureLib::Battling {
|
||||
class LearnedAttack {
|
||||
ArbUt::BorrowedPtr<const Library::AttackData> _attack;
|
||||
uint8_t _maxUses;
|
||||
uint8_t _remainingUses;
|
||||
u8 _maxUses;
|
||||
u8 _remainingUses;
|
||||
AttackLearnMethod _learnMethod;
|
||||
|
||||
public:
|
||||
LearnedAttack(const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
|
||||
LearnedAttack(const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, u8 maxUses,
|
||||
AttackLearnMethod learnMethod);
|
||||
LearnedAttack(const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack,
|
||||
AttackLearnMethod learnMethod);
|
||||
|
@ -21,13 +21,13 @@ namespace CreatureLib::Battling {
|
|||
virtual ~LearnedAttack() = default;
|
||||
|
||||
const ArbUt::BorrowedPtr<const Library::AttackData>& GetAttack() const noexcept;
|
||||
uint8_t GetMaxUses() const noexcept;
|
||||
uint8_t GetRemainingUses() const noexcept;
|
||||
u8 GetMaxUses() const noexcept;
|
||||
u8 GetRemainingUses() const noexcept;
|
||||
AttackLearnMethod GetLearnMethod() const noexcept;
|
||||
|
||||
virtual bool TryUse(uint8_t uses) noexcept;
|
||||
virtual void DecreaseUses(uint8_t amount) noexcept;
|
||||
virtual void RestoreUses(uint8_t amount) noexcept;
|
||||
virtual bool TryUse(u8 uses) noexcept;
|
||||
virtual void DecreaseUses(u8 amount) noexcept;
|
||||
virtual void RestoreUses(u8 amount) noexcept;
|
||||
virtual void RestoreAllUses() noexcept;
|
||||
|
||||
virtual LearnedAttack* Clone() const {
|
||||
|
|
|
@ -49,8 +49,8 @@ namespace CreatureLib::Battling {
|
|||
_par_ const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
|
||||
virtual void OnBeforeTurn(_par_ const BaseTurnChoice* choice){};
|
||||
|
||||
virtual void ChangeSpeed(_par_ BaseTurnChoice* choice, _par_ uint32_t* speed){};
|
||||
virtual void ChangePriority(_par_ AttackTurnChoice* choice, _par_ int8_t* priority){};
|
||||
virtual void ChangeSpeed(_par_ BaseTurnChoice* choice, _par_ u32* speed){};
|
||||
virtual void ChangePriority(_par_ AttackTurnChoice* choice, _par_ i8* priority){};
|
||||
virtual void ChangeAttack(_par_ AttackTurnChoice* choice, _par_ ArbUt::StringView* outAttack){};
|
||||
virtual void ModifyNumberOfHits(_par_ AttackTurnChoice* choice, _par_ u8* numberOfHits){};
|
||||
virtual void PreventAttack(_par_ ExecutingAttack* attack, _par_ bool* outResult){};
|
||||
|
@ -90,10 +90,10 @@ namespace CreatureLib::Battling {
|
|||
virtual void OnFaintingOpponent(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||
_par_ u8 hitNumber){};
|
||||
|
||||
virtual void PreventStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat,
|
||||
_par_ int8_t diffAmount, _par_ bool selfInflicted, _par_ bool* prevent){};
|
||||
virtual void PreventStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat, _par_ i8 diffAmount,
|
||||
_par_ bool selfInflicted, _par_ bool* prevent){};
|
||||
virtual void ModifyStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat,
|
||||
_par_ int8_t* diffAmount){};
|
||||
_par_ i8* diffAmount){};
|
||||
virtual void PreventSecondaryEffects(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||
_par_ u8 hitNumber, _par_ bool* outResult){};
|
||||
virtual void OnSecondaryEffect(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace CreatureLib::Battling {
|
||||
class ScriptAggregator {
|
||||
const ScriptWrapper* _scripts;
|
||||
const ScriptWrapper* nullable _scripts;
|
||||
i32 _size;
|
||||
i32 _index = -1;
|
||||
i32 _setIndex = -1;
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
#define CREATURELIB_SCRIPTCATEGORY_HPP
|
||||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
ENUM(ScriptCategory, uint8_t, Attack, Talent, Status, Creature, Battle, Side, ItemBattleTrigger)
|
||||
ENUM(ScriptCategory, u8, Attack, Talent, Status, Creature, Battle, Side, ItemBattleTrigger)
|
||||
|
||||
#endif // CREATURELIB_SCRIPTCATEGORY_HPP
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace CreatureLib::Battling {
|
||||
class ScriptSet {
|
||||
ArbUt::UniquePtrList<BattleScript> _scripts;
|
||||
ArbUt::Dictionary<uint32_t, size_t> _lookup;
|
||||
ArbUt::Dictionary<u32, size_t> _lookup;
|
||||
|
||||
public:
|
||||
~ScriptSet() = default;
|
||||
|
@ -39,7 +39,7 @@ namespace CreatureLib::Battling {
|
|||
return Get(key.GetHash());
|
||||
}
|
||||
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> Get(uint32_t keyHash) const noexcept {
|
||||
ArbUt::OptionalBorrowedPtr<BattleScript> Get(u32 keyHash) const noexcept {
|
||||
auto v = _lookup.TryGet(keyHash);
|
||||
if (v.has_value()) {
|
||||
return _scripts[v.value()].GetRaw();
|
||||
|
@ -49,7 +49,7 @@ namespace CreatureLib::Battling {
|
|||
|
||||
void Remove(const ArbUt::BasicStringView& key) { Remove(key.GetHash()); }
|
||||
|
||||
void Remove(uint32_t keyHash) {
|
||||
void Remove(u32 keyHash) {
|
||||
auto v = _lookup.TryGet(keyHash);
|
||||
if (v.has_value()) {
|
||||
auto script = _scripts[v.value()];
|
||||
|
@ -69,7 +69,7 @@ namespace CreatureLib::Battling {
|
|||
|
||||
bool Has(const ArbUt::BasicStringView& key) const { return _lookup.Has(key); }
|
||||
|
||||
bool Has(uint32_t keyHash) const { return _lookup.Has(keyHash); }
|
||||
bool Has(u32 keyHash) const { return _lookup.Has(keyHash); }
|
||||
|
||||
inline size_t Count() const { return _scripts.Count(); }
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace CreatureLib::Battling {
|
|||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||
CreatureIndex _target;
|
||||
std::unique_ptr<BattleScript> _attackScript = nullptr;
|
||||
int8_t _priority = 0;
|
||||
i8 _priority = 0;
|
||||
bool _hasFailed = false;
|
||||
|
||||
void ResolveScript(ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData> attack) {
|
||||
|
@ -59,8 +59,8 @@ namespace CreatureLib::Battling {
|
|||
|
||||
TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Attack; }
|
||||
|
||||
inline int8_t GetPriority() const noexcept { return _priority; }
|
||||
inline void SetPriority(int8_t priority) noexcept { _priority = priority; }
|
||||
inline i8 GetPriority() const noexcept { return _priority; }
|
||||
inline void SetPriority(i8 priority) noexcept { _priority = priority; }
|
||||
|
||||
const CreatureIndex& GetTarget() const noexcept { return _target; }
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace CreatureLib::Battling {
|
|||
class Creature;
|
||||
|
||||
class BaseTurnChoice : public ScriptSource {
|
||||
int32_t _randomValue;
|
||||
uint32_t _speed;
|
||||
i32 _randomValue;
|
||||
u32 _speed;
|
||||
|
||||
protected:
|
||||
ArbUt::BorrowedPtr<Creature> _user;
|
||||
|
@ -20,11 +20,11 @@ namespace CreatureLib::Battling {
|
|||
[[nodiscard]] virtual TurnChoiceKind GetKind() const noexcept = 0;
|
||||
[[nodiscard]] inline const ArbUt::BorrowedPtr<Creature>& GetUser() const noexcept { return _user; }
|
||||
|
||||
inline void __SetRandomValue(int32_t val) noexcept { _randomValue = val; }
|
||||
inline int32_t __GetRandomValue() const noexcept { return _randomValue; }
|
||||
inline void __SetRandomValue(i32 val) noexcept { _randomValue = val; }
|
||||
inline i32 __GetRandomValue() const noexcept { return _randomValue; }
|
||||
|
||||
inline void __SetSpeed(uint32_t val) noexcept { _speed = val; }
|
||||
inline uint32_t __GetSpeed() const noexcept { return _speed; }
|
||||
inline void __SetSpeed(u32 val) noexcept { _speed = val; }
|
||||
inline u32 __GetSpeed() const noexcept { return _speed; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
#define CREATURELIB_TURNCHOICEKIND_HPP
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(TurnChoiceKind, uint8_t, Pass, Attack, Item, Switch, Flee);
|
||||
ENUM(TurnChoiceKind, u8, Pass, Attack, Item, Switch, Flee);
|
||||
}
|
||||
#endif // CREATURELIB_TURNCHOICEKIND_HPP
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef CREATURELIB_DEFINES_HPP
|
||||
#define CREATURELIB_DEFINES_HPP
|
||||
#include <cstdint>
|
||||
#include <Arbutils/Defines.hpp>
|
||||
|
||||
#if LEVEL_U8
|
||||
using level_int_t = uint8_t;
|
||||
|
@ -15,17 +15,14 @@ using level_int_t = uint64_t;
|
|||
using level_int_t = uint8_t;
|
||||
#endif
|
||||
|
||||
using u8 = uint8_t;
|
||||
using u16 = uint16_t;
|
||||
using u32 = uint32_t;
|
||||
using u64 = uint64_t;
|
||||
[[deprecated]] typedef uint8_t uint8_t;
|
||||
[[deprecated]] typedef uint16_t uint16_t;
|
||||
[[deprecated]] typedef uint32_t uint32_t;
|
||||
[[deprecated]] typedef uint64_t uint64_t;
|
||||
|
||||
using i8 = int8_t;
|
||||
using i16 = int16_t;
|
||||
using i32 = int32_t;
|
||||
using i64 = int64_t;
|
||||
|
||||
using f32 = float;
|
||||
using f64 = double;
|
||||
[[deprecated]] typedef int8_t int8_t;
|
||||
[[deprecated]] typedef int16_t int16_t;
|
||||
[[deprecated]] typedef int32_t int32_t;
|
||||
[[deprecated]] typedef int64_t int64_t;
|
||||
|
||||
#endif // CREATURELIB_DEFINES_HPP
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
ENUM(AttackCategory, uint8_t, Physical, Magical, Status)
|
||||
ENUM(AttackCategory, u8, Physical, Magical, Status)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_ATTACKCATEGORY_HPP
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "AttackData.hpp"
|
||||
|
||||
CreatureLib::Library::AttackData::AttackData(const ArbUt::StringView& name, uint8_t type,
|
||||
CreatureLib::Library::AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage,
|
||||
CreatureLib::Library::AttackTarget target, int8_t priority,
|
||||
const SecondaryEffect* effect, std::unordered_set<uint32_t> flags)
|
||||
CreatureLib::Library::AttackData::AttackData(const ArbUt::StringView& name, u8 type,
|
||||
CreatureLib::Library::AttackCategory category, u8 power, u8 accuracy,
|
||||
u8 baseUsage, CreatureLib::Library::AttackTarget target, i8 priority,
|
||||
const SecondaryEffect* effect, std::unordered_set<u32> flags)
|
||||
: _name(name), _type(type), _category(category), _basePower(power), _accuracy(accuracy), _baseUsages(baseUsage),
|
||||
_target(target), _priority(priority), _effect(effect), _flags(std::move(flags)) {}
|
||||
|
|
|
@ -10,30 +10,29 @@ namespace CreatureLib::Library {
|
|||
class AttackData {
|
||||
protected:
|
||||
ArbUt::StringView _name;
|
||||
uint8_t _type;
|
||||
u8 _type;
|
||||
AttackCategory _category;
|
||||
uint8_t _basePower;
|
||||
uint8_t _accuracy;
|
||||
uint8_t _baseUsages;
|
||||
u8 _basePower;
|
||||
u8 _accuracy;
|
||||
u8 _baseUsages;
|
||||
AttackTarget _target;
|
||||
int8_t _priority;
|
||||
i8 _priority;
|
||||
std::unique_ptr<const SecondaryEffect> _effect = nullptr;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
std::unordered_set<u32> _flags;
|
||||
|
||||
public:
|
||||
AttackData(const ArbUt::StringView& name, uint8_t type, AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage, AttackTarget target, int8_t priority,
|
||||
const SecondaryEffect* effect, std::unordered_set<uint32_t> flags);
|
||||
AttackData(const ArbUt::StringView& name, u8 type, AttackCategory category, u8 power, u8 accuracy, u8 baseUsage,
|
||||
AttackTarget target, i8 priority, const SecondaryEffect* effect, std::unordered_set<u32> flags);
|
||||
virtual ~AttackData() = default;
|
||||
|
||||
inline const ArbUt::StringView& GetName() const noexcept { return _name; }
|
||||
inline uint8_t GetType() const noexcept { return _type; }
|
||||
inline u8 GetType() const noexcept { return _type; }
|
||||
inline AttackCategory GetCategory() const noexcept { return _category; }
|
||||
inline uint8_t GetBasePower() const noexcept { return _basePower; }
|
||||
inline uint8_t GetAccuracy() const noexcept { return _accuracy; }
|
||||
inline uint8_t GetBaseUsages() const noexcept { return _baseUsages; }
|
||||
inline u8 GetBasePower() const noexcept { return _basePower; }
|
||||
inline u8 GetAccuracy() const noexcept { return _accuracy; }
|
||||
inline u8 GetBaseUsages() const noexcept { return _baseUsages; }
|
||||
inline AttackTarget GetTarget() const noexcept { return _target; }
|
||||
inline int8_t GetPriority() const noexcept { return _priority; }
|
||||
inline i8 GetPriority() const noexcept { return _priority; }
|
||||
inline bool HasSecondaryEffect() const noexcept {
|
||||
return _effect != nullptr && !_effect->GetEffectName().IsEmpty();
|
||||
}
|
||||
|
@ -42,9 +41,7 @@ namespace CreatureLib::Library {
|
|||
inline bool HasFlag(const ArbUt::StringView& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
}
|
||||
inline bool HasFlag(uint32_t keyHash) const noexcept {
|
||||
return this->_flags.find(keyHash) != this->_flags.end();
|
||||
}
|
||||
inline bool HasFlag(u32 keyHash) const noexcept { return this->_flags.find(keyHash) != this->_flags.end(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
ENUM(AttackTarget, uint8_t, Adjacent, AdjacentAlly, AdjacentAllySelf, AdjacentOpponent,
|
||||
ENUM(AttackTarget, u8, Adjacent, AdjacentAlly, AdjacentAllySelf, AdjacentOpponent,
|
||||
|
||||
All, AllAdjacent, AllAdjacentOpponent, AllAlly, AllOpponent,
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
namespace CreatureLib::Library {
|
||||
template <class T> class BaseLibrary {
|
||||
protected:
|
||||
ArbUt::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
|
||||
ArbUt::List<uint32_t> _listValues;
|
||||
ArbUt::Dictionary<u32, std::unique_ptr<const T>> _values;
|
||||
ArbUt::List<u32> _listValues;
|
||||
|
||||
public:
|
||||
BaseLibrary(size_t initialCapacity = 32) : _values(initialCapacity), _listValues(initialCapacity) {}
|
||||
|
@ -23,7 +23,7 @@ namespace CreatureLib::Library {
|
|||
_values.GetStdMap().insert({key.GetHash(), std::unique_ptr<const T>(value)});
|
||||
_listValues.Append(key);
|
||||
}
|
||||
inline virtual void Insert(uint32_t hashedKey, const T* value) {
|
||||
inline virtual void Insert(u32 hashedKey, const T* value) {
|
||||
EnsureNotNull(value)
|
||||
_values.GetStdMap().insert({hashedKey, std::unique_ptr<const T>(value)});
|
||||
_listValues.Append(hashedKey);
|
||||
|
@ -32,18 +32,22 @@ namespace CreatureLib::Library {
|
|||
inline void Delete(const ArbUt::StringView& key) noexcept {
|
||||
_values.erase(key.GetHash());
|
||||
auto k = _listValues.IndexOf(key);
|
||||
_listValues.Remove(k);
|
||||
if (k.has_value()) {
|
||||
_listValues.Remove(k.value());
|
||||
}
|
||||
}
|
||||
inline void Delete(uint32_t hashedKey) noexcept {
|
||||
inline void Delete(u32 hashedKey) noexcept {
|
||||
_values.Remove(hashedKey);
|
||||
auto k = _listValues.IndexOf(hashedKey);
|
||||
_listValues.Remove(k);
|
||||
if (k.has_value()) {
|
||||
_listValues.Remove(k.value());
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<const T>> TryGet(const ArbUt::BasicStringView& name) const noexcept {
|
||||
return TryGet(name.GetHash());
|
||||
}
|
||||
std::optional<ArbUt::BorrowedPtr<const T>> TryGet(uint32_t hashedKey) const noexcept {
|
||||
std::optional<ArbUt::BorrowedPtr<const T>> TryGet(u32 hashedKey) const noexcept {
|
||||
auto find = _values.GetStdMap().find(hashedKey);
|
||||
if (find == _values.GetStdMap().end())
|
||||
return {};
|
||||
|
@ -53,29 +57,25 @@ namespace CreatureLib::Library {
|
|||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(const ArbUt::BasicStringView& name) const {
|
||||
return _values.Get(name.GetHash());
|
||||
}
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(uint32_t hashedKey) const {
|
||||
return _values.Get(hashedKey);
|
||||
}
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(u32 hashedKey) const { return _values.Get(hashedKey); }
|
||||
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](const ArbUt::BasicStringView& name) const {
|
||||
return Get(name);
|
||||
}
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
|
||||
[[nodiscard]] inline const ArbUt::Dictionary<uint32_t, const std::unique_ptr<const T>>&
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](u32 hashedKey) const { return Get(hashedKey); }
|
||||
[[nodiscard]] inline const ArbUt::Dictionary<u32, const std::unique_ptr<const T>>&
|
||||
GetIterator() const noexcept {
|
||||
return _values;
|
||||
}
|
||||
|
||||
using const_iterator = typename std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>::const_iterator;
|
||||
using const_iterator = typename std::unordered_map<u32, ArbUt::BorrowedPtr<const T>>::const_iterator;
|
||||
|
||||
inline const_iterator begin() const {
|
||||
return reinterpret_cast<const std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>&>(
|
||||
_values.GetStdMap())
|
||||
return reinterpret_cast<const std::unordered_map<u32, ArbUt::BorrowedPtr<const T>>&>(_values.GetStdMap())
|
||||
.begin();
|
||||
}
|
||||
inline const_iterator end() const {
|
||||
return reinterpret_cast<const std::unordered_map<uint32_t, ArbUt::BorrowedPtr<const T>>&>(
|
||||
_values.GetStdMap())
|
||||
return reinterpret_cast<const std::unordered_map<u32, ArbUt::BorrowedPtr<const T>>&>(_values.GetStdMap())
|
||||
.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@ using namespace CreatureLib::Library;
|
|||
|
||||
struct CreatureSpecies::impl {
|
||||
const ArbUt::StringView _name;
|
||||
uint16_t _id;
|
||||
u16 _id;
|
||||
float _genderRate;
|
||||
const ArbUt::StringView _growthRate;
|
||||
uint8_t _captureRate;
|
||||
u8 _captureRate;
|
||||
|
||||
ArbUt::Dictionary<uint32_t, ArbUt::UniquePtr<const SpeciesVariant>> _variantsLookup;
|
||||
ArbUt::Dictionary<u32, ArbUt::UniquePtr<const SpeciesVariant>> _variantsLookup;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const SpeciesVariant>> _variantsList;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
std::unordered_set<u32> _flags;
|
||||
|
||||
impl(uint16_t id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ArbUt::StringView& growthRate, uint8_t captureRate, std::unordered_set<uint32_t> flags)
|
||||
impl(u16 id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ArbUt::StringView& growthRate, u8 captureRate, std::unordered_set<u32> flags)
|
||||
: _name(name), _id(id), _genderRate(genderRatio), _growthRate(growthRate), _captureRate(captureRate),
|
||||
_variantsLookup(1), _variantsList(1), _flags(std::move(flags)) {
|
||||
EnsureNotNull(defaultVariant)
|
||||
|
@ -24,20 +24,20 @@ struct CreatureSpecies::impl {
|
|||
|
||||
~impl() { _variantsLookup.Clear(); }
|
||||
|
||||
inline uint16_t GetId() const noexcept { return _id; }
|
||||
inline u16 GetId() const noexcept { return _id; }
|
||||
inline float GetGenderRate() const noexcept { return _genderRate; }
|
||||
inline const ArbUt::StringView& GetGrowthRate() const noexcept { return _growthRate; }
|
||||
inline uint8_t GetCaptureRate() const noexcept { return _captureRate; }
|
||||
inline u8 GetCaptureRate() const noexcept { return _captureRate; }
|
||||
|
||||
[[nodiscard]] inline bool HasVariant(const ArbUt::BasicStringView& key) const noexcept {
|
||||
return _variantsLookup.Has(key);
|
||||
}
|
||||
[[nodiscard]] inline bool HasVariant(uint32_t hash) const noexcept { return _variantsLookup.Has(hash); }
|
||||
[[nodiscard]] inline bool HasVariant(u32 hash) const noexcept { return _variantsLookup.Has(hash); }
|
||||
[[nodiscard]] inline std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>>
|
||||
TryGetVariant(const ArbUt::BasicStringView& name) const noexcept {
|
||||
return TryGetVariant(name.GetHash());
|
||||
}
|
||||
[[nodiscard]] std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>> TryGetVariant(uint32_t hash) const noexcept {
|
||||
[[nodiscard]] std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>> TryGetVariant(u32 hash) const noexcept {
|
||||
auto find = _variantsLookup.GetStdMap().find(hash);
|
||||
if (find == _variantsLookup.end())
|
||||
return {};
|
||||
|
@ -46,7 +46,7 @@ struct CreatureSpecies::impl {
|
|||
[[nodiscard]] inline ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(const ArbUt::BasicStringView& key) const {
|
||||
return _variantsLookup.Get(key).GetRaw();
|
||||
}
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(uint32_t key) const {
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(u32 key) const {
|
||||
return _variantsLookup.Get(key).GetRaw();
|
||||
}
|
||||
[[nodiscard]] Gender GetRandomGender(ArbUt::Random& rand) const noexcept {
|
||||
|
@ -73,40 +73,38 @@ struct CreatureSpecies::impl {
|
|||
inline bool HasFlag(const ArbUt::StringView& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
}
|
||||
inline bool HasFlag(uint32_t keyHash) const noexcept { return this->_flags.find(keyHash) != this->_flags.end(); }
|
||||
inline bool HasFlag(u32 keyHash) const noexcept { return this->_flags.find(keyHash) != this->_flags.end(); }
|
||||
};
|
||||
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, const ArbUt::StringView& growthRate, uint8_t captureRate,
|
||||
std::unordered_set<uint32_t> flags)
|
||||
CreatureSpecies::CreatureSpecies(u16 id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, const ArbUt::StringView& growthRate, u8 captureRate,
|
||||
std::unordered_set<u32> flags)
|
||||
: _impl(new impl(id, name, defaultVariant, genderRatio, growthRate, captureRate, flags)) {}
|
||||
|
||||
#define ImplGetter(type, func) \
|
||||
type CreatureSpecies::func() const noexcept { return _impl->func(); }
|
||||
|
||||
CreatureSpecies::~CreatureSpecies() = default;
|
||||
ImplGetter(uint16_t, GetId);
|
||||
ImplGetter(u16, GetId);
|
||||
ImplGetter(float, GetGenderRate);
|
||||
ImplGetter(const ArbUt::StringView&, GetGrowthRate);
|
||||
ImplGetter(uint8_t, GetCaptureRate);
|
||||
ImplGetter(u8, GetCaptureRate);
|
||||
ImplGetter(const ArbUt::StringView&, GetName);
|
||||
|
||||
bool CreatureSpecies::HasVariant(const ArbUt::BasicStringView& key) const noexcept { return _impl->HasVariant(key); }
|
||||
bool CreatureSpecies::HasVariant(uint32_t hash) const noexcept { return _impl->HasVariant(hash); }
|
||||
bool CreatureSpecies::HasVariant(u32 hash) const noexcept { return _impl->HasVariant(hash); }
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>>
|
||||
CreatureSpecies::TryGetVariant(const ArbUt::BasicStringView& name) const noexcept {
|
||||
return _impl->TryGetVariant(name);
|
||||
}
|
||||
std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>> CreatureSpecies::TryGetVariant(uint32_t hash) const noexcept {
|
||||
std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>> CreatureSpecies::TryGetVariant(u32 hash) const noexcept {
|
||||
return _impl->TryGetVariant(hash);
|
||||
}
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant> CreatureSpecies::GetVariant(const ArbUt::BasicStringView& key) const {
|
||||
return _impl->GetVariant(key);
|
||||
}
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant> CreatureSpecies::GetVariant(uint32_t key) const {
|
||||
return _impl->GetVariant(key);
|
||||
}
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant> CreatureSpecies::GetVariant(u32 key) const { return _impl->GetVariant(key); }
|
||||
Gender CreatureSpecies::GetRandomGender(ArbUt::Random& rand) const noexcept { return _impl->GetRandomGender(rand); }
|
||||
void CreatureSpecies::SetVariant(const ArbUt::StringView& name, const SpeciesVariant* variant) {
|
||||
_impl->SetVariant(name, variant);
|
||||
|
@ -116,4 +114,4 @@ const ArbUt::List<ArbUt::BorrowedPtr<const SpeciesVariant>>& CreatureSpecies::Ge
|
|||
}
|
||||
|
||||
bool CreatureSpecies::HasFlag(const ArbUt::StringView& key) const noexcept { return _impl->HasFlag(key); }
|
||||
bool CreatureSpecies::HasFlag(uint32_t keyHash) const noexcept { return _impl->HasFlag(keyHash); }
|
||||
bool CreatureSpecies::HasFlag(u32 keyHash) const noexcept { return _impl->HasFlag(keyHash); }
|
||||
|
|
|
@ -23,15 +23,14 @@ namespace CreatureLib::Library {
|
|||
/// @param captureRate The chance to capture the creature species, between 0 and 255. 255 means instant capture,
|
||||
/// 0 means impossible to capture.
|
||||
/// @param flags A set of flags for use by the developer. These can be used for easy grouping.
|
||||
CreatureSpecies(uint16_t id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, const ArbUt::StringView& growthRate, uint8_t captureRate,
|
||||
std::unordered_set<uint32_t> flags = {});
|
||||
CreatureSpecies(u16 id, const ArbUt::StringView& name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ArbUt::StringView& growthRate, u8 captureRate, std::unordered_set<u32> flags = {});
|
||||
|
||||
virtual ~CreatureSpecies();
|
||||
|
||||
/// @brief Returns the unique id of the creature species.
|
||||
/// @return The unique id of the creature species
|
||||
uint16_t GetId() const noexcept;
|
||||
u16 GetId() const noexcept;
|
||||
/// @brief Returns the name of the species.
|
||||
/// @return The name of the species.
|
||||
[[nodiscard]] const ArbUt::StringView& GetName() const noexcept;
|
||||
|
@ -45,7 +44,7 @@ namespace CreatureLib::Library {
|
|||
/// @brief Returns the capture rate of the creature species.
|
||||
/// @return The base capture rate of the creature species. 255 means instant capture, 0 means impossible to
|
||||
/// capture.
|
||||
uint8_t GetCaptureRate() const noexcept;
|
||||
u8 GetCaptureRate() const noexcept;
|
||||
|
||||
/// @brief Checks whether the species contains a variant with a specific name.
|
||||
/// @param key The name of the variant that's being looked for.
|
||||
|
@ -55,7 +54,7 @@ namespace CreatureLib::Library {
|
|||
/// @param hash The string hash of the variant that's being looked for. This hash can be retrieved from the
|
||||
/// StringView class.
|
||||
/// @return True if the species contains the variant, false otherwise.
|
||||
[[nodiscard]] bool HasVariant(uint32_t hash) const noexcept;
|
||||
[[nodiscard]] bool HasVariant(u32 hash) const noexcept;
|
||||
/// @brief Try to get a variant of the species with a specific name.
|
||||
/// @param name The name of the variant that's being looked for.
|
||||
/// @param out If a variant is found, it will be put in this variable. If not, this will remain unchanged.
|
||||
|
@ -67,8 +66,7 @@ namespace CreatureLib::Library {
|
|||
/// StringView class.
|
||||
/// @param out If a variant is found, it will be put in this variable. If not, this will remain unchanged.
|
||||
/// @return True if the species contains the variant, false otherwise.
|
||||
[[nodiscard]] std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>>
|
||||
TryGetVariant(uint32_t hash) const noexcept;
|
||||
[[nodiscard]] std::optional<ArbUt::BorrowedPtr<const SpeciesVariant>> TryGetVariant(u32 hash) const noexcept;
|
||||
/// @brief Returns a variant with a specific name. Throws if no variant with the name exists.
|
||||
/// @param key The name of the variant that's being looked for.
|
||||
/// @return The specified variant.
|
||||
|
@ -76,7 +74,7 @@ namespace CreatureLib::Library {
|
|||
/// @brief Returns a variant with a specific name. Throws if no variant with the name exists.
|
||||
/// @param key The string hash of the variant that's being looked for.
|
||||
/// @return The specified variant.
|
||||
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(uint32_t key) const;
|
||||
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(u32 key) const;
|
||||
/// @brief Returns a random gender based on the gender ratio of the species.
|
||||
/// @param rand A random number generator class.
|
||||
/// @return A random gender. If gender ratio is -1 this will return Genderless, otherwise it will be either male
|
||||
|
@ -99,7 +97,7 @@ namespace CreatureLib::Library {
|
|||
/// @brief Checks whether the species has a specific flag.
|
||||
/// @param keyHash The flag to check for.
|
||||
/// @return True if the species has the flag, false otherwise.
|
||||
bool HasFlag(uint32_t keyHash) const noexcept;
|
||||
bool HasFlag(u32 keyHash) const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace CreatureLib::Library {
|
|||
inline bool HasAttacksForLevel(level_int_t level) const noexcept { return _learnedByLevel.Has(level); }
|
||||
inline const ArbUt::List<ArbUt::BorrowedPtr<const AttackData>>& GetAttacksForLevel(level_int_t level) const {
|
||||
if (!_learnedByLevel.Has(level)) {
|
||||
THROW("No attacks found for level ", (uint32_t)level, ".");
|
||||
THROW("No attacks found for level ", (u32)level, ".");
|
||||
}
|
||||
return _learnedByLevel.Get(level);
|
||||
}
|
||||
|
|
|
@ -6,20 +6,19 @@ namespace CreatureLib::Library {
|
|||
ArbUt::StringView _name;
|
||||
float _height;
|
||||
float _weight;
|
||||
uint32_t _baseExperience;
|
||||
ArbUt::List<uint8_t> _types;
|
||||
Library::StatisticSet<uint16_t> _baseStatistics;
|
||||
u32 _baseExperience;
|
||||
ArbUt::List<u8> _types;
|
||||
Library::StatisticSet<u16> _baseStatistics;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> _talents;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> _secretTalents;
|
||||
std::unique_ptr<const LearnableAttacks> _attacks;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
std::unordered_set<u32> _flags;
|
||||
|
||||
public:
|
||||
impl(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
|
||||
ArbUt::List<uint8_t> types, Library::StatisticSet<uint16_t> baseStats,
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> talents,
|
||||
impl(const ArbUt::StringView& name, float height, float weight, u32 baseExperience, ArbUt::List<u8> types,
|
||||
Library::StatisticSet<u16> baseStats, ArbUt::List<ArbUt::BorrowedPtr<const Talent>> talents,
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> secretTalents, const LearnableAttacks* attacks,
|
||||
std::unordered_set<uint32_t> flags)
|
||||
std::unordered_set<u32> flags)
|
||||
: _name(name), _height(height), _weight(weight), _baseExperience(baseExperience),
|
||||
_types(std::move((types))), _baseStatistics(baseStats), _talents(std::move(talents)),
|
||||
_secretTalents(std::move(secretTalents)), _attacks(attacks), _flags(std::move(flags)){};
|
||||
|
@ -27,14 +26,12 @@ namespace CreatureLib::Library {
|
|||
inline const ArbUt::StringView& GetName() const { return _name; }
|
||||
inline float GetHeight() const { return _height; }
|
||||
inline float GetWeight() const { return _weight; }
|
||||
inline uint32_t GetBaseExperience() const { return _baseExperience; }
|
||||
inline u32 GetBaseExperience() const { return _baseExperience; }
|
||||
|
||||
[[nodiscard]] inline size_t GetTypeCount() const { return _types.Count(); }
|
||||
[[nodiscard]] inline uint8_t GetType(size_t index) const { return _types[index]; }
|
||||
[[nodiscard]] inline const ArbUt::List<uint8_t>& GetTypes() const { return _types; }
|
||||
[[nodiscard]] inline uint16_t GetStatistic(Library::Statistic stat) const {
|
||||
return _baseStatistics.GetStat(stat);
|
||||
}
|
||||
[[nodiscard]] inline u8 GetType(size_t index) const { return _types[index]; }
|
||||
[[nodiscard]] inline const ArbUt::List<u8>& GetTypes() const { return _types; }
|
||||
[[nodiscard]] inline u16 GetStatistic(Library::Statistic stat) const { return _baseStatistics.GetStat(stat); }
|
||||
[[nodiscard]] inline size_t GetTalentCount() const noexcept { return _talents.Count(); }
|
||||
[[nodiscard]] inline size_t GetSecretTalentCount() const noexcept { return _secretTalents.Count(); }
|
||||
[[nodiscard]] const ArbUt::BorrowedPtr<const Talent>& GetTalent(const TalentIndex& index) const {
|
||||
|
@ -95,16 +92,14 @@ namespace CreatureLib::Library {
|
|||
inline bool HasFlag(const ArbUt::StringView& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
}
|
||||
inline bool HasFlag(uint32_t keyHash) const noexcept {
|
||||
return this->_flags.find(keyHash) != this->_flags.end();
|
||||
}
|
||||
inline bool HasFlag(u32 keyHash) const noexcept { return this->_flags.find(keyHash) != this->_flags.end(); }
|
||||
};
|
||||
|
||||
SpeciesVariant::SpeciesVariant(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
|
||||
const ArbUt::List<uint8_t>& types, StatisticSet<uint16_t> baseStats,
|
||||
SpeciesVariant::SpeciesVariant(const ArbUt::StringView& name, float height, float weight, u32 baseExperience,
|
||||
const ArbUt::List<u8>& types, StatisticSet<u16> baseStats,
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& talents,
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& secretTalents,
|
||||
const LearnableAttacks* attacks, const std::unordered_set<uint32_t>& flags)
|
||||
const LearnableAttacks* attacks, const std::unordered_set<u32>& flags)
|
||||
: _impl(new impl(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks,
|
||||
flags)) {}
|
||||
SpeciesVariant::~SpeciesVariant() = default;
|
||||
|
@ -115,11 +110,11 @@ namespace CreatureLib::Library {
|
|||
ImplGetter(const ArbUt::StringView&, GetName);
|
||||
ImplGetter(float, GetHeight);
|
||||
ImplGetter(float, GetWeight);
|
||||
ImplGetter(uint32_t, GetBaseExperience);
|
||||
ImplGetter(u32, GetBaseExperience);
|
||||
ImplGetter(size_t, GetTypeCount);
|
||||
uint8_t SpeciesVariant::GetType(size_t index) const { return _impl->GetType(index); }
|
||||
ImplGetter(const ArbUt::List<uint8_t>&, GetTypes);
|
||||
uint16_t SpeciesVariant::GetStatistic(Library::Statistic stat) const noexcept { return _impl->GetStatistic(stat); }
|
||||
u8 SpeciesVariant::GetType(size_t index) const { return _impl->GetType(index); }
|
||||
ImplGetter(const ArbUt::List<u8>&, GetTypes);
|
||||
u16 SpeciesVariant::GetStatistic(Library::Statistic stat) const noexcept { return _impl->GetStatistic(stat); }
|
||||
|
||||
ImplGetter(size_t, GetTalentCount);
|
||||
ImplGetter(size_t, GetSecretTalentCount);
|
||||
|
@ -140,5 +135,5 @@ namespace CreatureLib::Library {
|
|||
ImplGetter(const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>&, GetSecretTalents);
|
||||
|
||||
bool SpeciesVariant::HasFlag(const ArbUt::StringView& key) const noexcept { return _impl->HasFlag(key); }
|
||||
bool SpeciesVariant::HasFlag(uint32_t keyHash) const noexcept { return _impl->HasFlag(keyHash); }
|
||||
bool SpeciesVariant::HasFlag(u32 keyHash) const noexcept { return _impl->HasFlag(keyHash); }
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@ namespace CreatureLib::Library {
|
|||
/// scripts when battling.
|
||||
/// @param attacks The attacks that this variant can learn.
|
||||
/// @param flags A set of flags for use by the developer. These can be used for easy grouping.
|
||||
SpeciesVariant(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
|
||||
const ArbUt::List<uint8_t>& types, Library::StatisticSet<uint16_t> baseStats,
|
||||
SpeciesVariant(const ArbUt::StringView& name, float height, float weight, u32 baseExperience,
|
||||
const ArbUt::List<u8>& types, Library::StatisticSet<u16> baseStats,
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& talents,
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& secretTalents,
|
||||
const LearnableAttacks* attacks, const std::unordered_set<uint32_t>& flags = {});
|
||||
const LearnableAttacks* attacks, const std::unordered_set<u32>& flags = {});
|
||||
virtual ~SpeciesVariant();
|
||||
|
||||
/// @brief Returns the unique name of the variant.
|
||||
|
@ -45,7 +45,7 @@ namespace CreatureLib::Library {
|
|||
float GetWeight() const noexcept;
|
||||
/// @brief Returns the amount of base experience gained when defeating a creature with this variant.
|
||||
/// @return The amount of base experience gained when defeating a creature with this variant.
|
||||
uint32_t GetBaseExperience() const noexcept;
|
||||
u32 GetBaseExperience() const noexcept;
|
||||
|
||||
/// @brief Returns the amount of types this variant has.
|
||||
/// @return The amount of types this variant has.
|
||||
|
@ -53,14 +53,14 @@ namespace CreatureLib::Library {
|
|||
/// @brief Returns a type index at a specified index.
|
||||
/// @param index The index of the type requested.
|
||||
/// @return A type index, as defined in TypeLibrary.
|
||||
[[nodiscard]] uint8_t GetType(size_t index) const;
|
||||
[[nodiscard]] u8 GetType(size_t index) const;
|
||||
/// @brief Returns a list of the types on this variant.
|
||||
/// @return A list of types on the variant,
|
||||
[[nodiscard]] const ArbUt::List<uint8_t>& GetTypes() const noexcept;
|
||||
[[nodiscard]] const ArbUt::List<u8>& GetTypes() const noexcept;
|
||||
/// @brief Returns the value of a base statistic.
|
||||
/// @param stat The desired statistic.
|
||||
/// @return The base statistic value.
|
||||
[[nodiscard]] uint16_t GetStatistic(Library::Statistic stat) const noexcept;
|
||||
[[nodiscard]] u16 GetStatistic(Library::Statistic stat) const noexcept;
|
||||
|
||||
/// @brief Returns the amount of talents this variant has.
|
||||
/// @return The amount of talents this variant has.
|
||||
|
@ -102,7 +102,7 @@ namespace CreatureLib::Library {
|
|||
/// @brief Checks whether the species has a specific flag.
|
||||
/// @param keyHash The flag to check for.
|
||||
/// @return True if the species has the flag, false otherwise.
|
||||
bool HasFlag(uint32_t keyHash) const noexcept;
|
||||
bool HasFlag(u32 keyHash) const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,17 @@ namespace CreatureLib::Library {
|
|||
/// @brief Initialises a Talent Index from whether or not this is a secret talent, and it's index.
|
||||
/// @param secret Whether or not this is a secret talent.
|
||||
/// @param index The index of the talent on the species variant.
|
||||
inline TalentIndex(bool secret, uint8_t index) noexcept : _secret(secret), _index(index) {}
|
||||
inline TalentIndex(bool secret, u8 index) noexcept : _secret(secret), _index(index) {}
|
||||
/// @brief Returns whether or not this is a secret talent.
|
||||
/// @return Whether or not this is a secret talent.
|
||||
[[nodiscard]] constexpr inline bool IsSecret() const noexcept { return _secret; }
|
||||
/// @brief Returns the index of the talent on the species variant.
|
||||
/// @return The index of the talent on the species variant.
|
||||
[[nodiscard]] constexpr inline uint8_t GetIndex() const noexcept { return _index; }
|
||||
[[nodiscard]] constexpr inline u8 GetIndex() const noexcept { return _index; }
|
||||
|
||||
private:
|
||||
bool _secret = false;
|
||||
uint8_t _index;
|
||||
u8 _index;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace CreatureLib::Library {
|
|||
class EffectParameter {
|
||||
private:
|
||||
EffectParameterType _type = EffectParameterType::None;
|
||||
std::variant<bool, int64_t, float, ArbUt::StringView> _value;
|
||||
std::variant<bool, i64, float, ArbUt::StringView> _value;
|
||||
|
||||
public:
|
||||
inline EffectParameter() : _type(EffectParameterType::None){};
|
||||
inline explicit EffectParameter(bool b) : _type(EffectParameterType::Bool), _value(b){};
|
||||
inline explicit EffectParameter(int64_t i) : _type(EffectParameterType::Int), _value(i){};
|
||||
inline explicit EffectParameter(i64 i) : _type(EffectParameterType::Int), _value(i){};
|
||||
inline explicit EffectParameter(float f) : _type(EffectParameterType::Float), _value(f){};
|
||||
inline explicit EffectParameter(const ArbUt::StringView& s) : _type(EffectParameterType::String), _value(s){};
|
||||
EffectParameter(const EffectParameter& other) = delete;
|
||||
|
@ -30,19 +30,19 @@ namespace CreatureLib::Library {
|
|||
}
|
||||
return std::get<bool>(_value);
|
||||
}
|
||||
int64_t AsInt() const {
|
||||
i64 AsInt() const {
|
||||
if (_type != EffectParameterType::Int) {
|
||||
if (_type == EffectParameterType::Float) {
|
||||
return static_cast<int64_t>(std::get<float>(_value));
|
||||
return static_cast<i64>(std::get<float>(_value));
|
||||
}
|
||||
THROW("Cast effect parameter to int, but was ", EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
return std::get<int64_t>(_value);
|
||||
return std::get<i64>(_value);
|
||||
}
|
||||
float AsFloat() const {
|
||||
if (_type != EffectParameterType::Float) {
|
||||
if (_type == EffectParameterType::Int) {
|
||||
return static_cast<float>(std::get<int64_t>(_value));
|
||||
return static_cast<float>(std::get<i64>(_value));
|
||||
}
|
||||
THROW("Cast effect parameter to float, but was ", EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace CreatureLib::Library {
|
|||
\brief Might be somewhat controversial nowadays, but as many creature battling games only have two genders, we'll
|
||||
hardcode those.
|
||||
*/
|
||||
ENUM(Gender, uint8_t, Male, Female, Genderless)
|
||||
ENUM(Gender, u8, Male, Female, Genderless)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_GENDER_HPP
|
||||
|
|
|
@ -7,18 +7,18 @@
|
|||
|
||||
namespace CreatureLib::Library {
|
||||
class ExternGrowthRate : public GrowthRate {
|
||||
level_int_t (*_calcLevel)(uint32_t experience);
|
||||
uint32_t (*_calcExperience)(level_int_t level);
|
||||
level_int_t (*_calcLevel)(u32 experience);
|
||||
u32 (*_calcExperience)(level_int_t level);
|
||||
|
||||
public:
|
||||
inline ExternGrowthRate(level_int_t (*calcLevel)(uint32_t), uint32_t (*calcExperience)(level_int_t level))
|
||||
inline ExternGrowthRate(level_int_t (*calcLevel)(u32), u32 (*calcExperience)(level_int_t level))
|
||||
: _calcLevel(calcLevel), _calcExperience(calcExperience) {
|
||||
EnsureNotNull(calcLevel)
|
||||
EnsureNotNull(calcExperience)
|
||||
}
|
||||
|
||||
level_int_t CalculateLevel(uint32_t experience) const override { return _calcLevel(experience); }
|
||||
uint32_t CalculateExperience(level_int_t level) const override { return _calcExperience(level); }
|
||||
level_int_t CalculateLevel(u32 experience) const override { return _calcLevel(experience); }
|
||||
u32 CalculateExperience(level_int_t level) const override { return _calcExperience(level); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace CreatureLib::Library {
|
|||
public:
|
||||
virtual ~GrowthRate() = default;
|
||||
|
||||
[[nodiscard]] virtual level_int_t CalculateLevel(uint32_t experience) const = 0;
|
||||
[[nodiscard]] virtual uint32_t CalculateExperience(level_int_t level) const = 0;
|
||||
[[nodiscard]] virtual level_int_t CalculateLevel(u32 experience) const = 0;
|
||||
[[nodiscard]] virtual u32 CalculateExperience(level_int_t level) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include <Arbutils/Exception.hpp>
|
||||
#include "../Exceptions/CreatureException.hpp"
|
||||
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::BasicStringView& growthRate,
|
||||
uint32_t experience) const {
|
||||
u8 CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::BasicStringView& growthRate,
|
||||
u32 experience) const {
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
THROW("Invalid growth rate was requested.");
|
||||
|
@ -11,7 +11,7 @@ uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::Bas
|
|||
return find->second->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(uint32_t hash, uint32_t experience) const {
|
||||
u8 CreatureLib::Library::GrowthRateLibrary::CalculateLevel(u32 hash, u32 experience) const {
|
||||
auto find = _growthRates.find(hash);
|
||||
if (find == _growthRates.end()) {
|
||||
THROW("Invalid growth rate was requested.");
|
||||
|
@ -19,8 +19,8 @@ uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(uint32_t hash, u
|
|||
return find->second->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbUt::BasicStringView& growthRate,
|
||||
level_int_t level) const {
|
||||
u32 CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbUt::BasicStringView& growthRate,
|
||||
level_int_t level) const {
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
THROW("Invalid growth rate was requested.");
|
||||
|
@ -28,7 +28,7 @@ uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbU
|
|||
return find->second->CalculateExperience(level);
|
||||
}
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(uint32_t hash, level_int_t level) const {
|
||||
u32 CreatureLib::Library::GrowthRateLibrary::CalculateExperience(u32 hash, level_int_t level) const {
|
||||
auto find = _growthRates.find(hash);
|
||||
if (find == _growthRates.end()) {
|
||||
THROW("Invalid growth rate was requested.");
|
||||
|
@ -41,6 +41,6 @@ void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ArbUt::StringV
|
|||
_growthRates.insert({name, std::unique_ptr<const GrowthRate>(rate)});
|
||||
}
|
||||
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(uint32_t hash, CreatureLib::Library::GrowthRate* rate) {
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(u32 hash, CreatureLib::Library::GrowthRate* rate) {
|
||||
_growthRates.insert({hash, std::unique_ptr<const GrowthRate>(rate)});
|
||||
}
|
||||
|
|
|
@ -8,20 +8,20 @@
|
|||
namespace CreatureLib::Library {
|
||||
class GrowthRateLibrary {
|
||||
private:
|
||||
std::unordered_map<uint32_t, std::unique_ptr<const GrowthRate>> _growthRates;
|
||||
std::unordered_map<u32, std::unique_ptr<const GrowthRate>> _growthRates;
|
||||
|
||||
public:
|
||||
GrowthRateLibrary(size_t initialCapacity = 10)
|
||||
: _growthRates(std::unordered_map<uint32_t, std::unique_ptr<const GrowthRate>>(initialCapacity)) {}
|
||||
: _growthRates(std::unordered_map<u32, std::unique_ptr<const GrowthRate>>(initialCapacity)) {}
|
||||
|
||||
virtual ~GrowthRateLibrary() = default;
|
||||
|
||||
[[nodiscard]] level_int_t CalculateLevel(const ArbUt::BasicStringView& growthRate, uint32_t experience) const;
|
||||
[[nodiscard]] level_int_t CalculateLevel(uint32_t hash, uint32_t experience) const;
|
||||
[[nodiscard]] uint32_t CalculateExperience(const ArbUt::BasicStringView& growthRate, level_int_t level) const;
|
||||
[[nodiscard]] uint32_t CalculateExperience(uint32_t hash, level_int_t level) const;
|
||||
[[nodiscard]] level_int_t CalculateLevel(const ArbUt::BasicStringView& growthRate, u32 experience) const;
|
||||
[[nodiscard]] level_int_t CalculateLevel(u32 hash, u32 experience) const;
|
||||
[[nodiscard]] u32 CalculateExperience(const ArbUt::BasicStringView& growthRate, level_int_t level) const;
|
||||
[[nodiscard]] u32 CalculateExperience(u32 hash, level_int_t level) const;
|
||||
|
||||
void AddGrowthRate(uint32_t hash, GrowthRate* rate);
|
||||
void AddGrowthRate(u32 hash, GrowthRate* rate);
|
||||
void AddGrowthRate(const ArbUt::StringView& name, GrowthRate* rate);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
namespace CreatureLib::Library {
|
||||
class LookupGrowthRate : public GrowthRate {
|
||||
protected:
|
||||
ArbUt::List<uint32_t> _experience;
|
||||
ArbUt::List<u32> _experience;
|
||||
|
||||
public:
|
||||
LookupGrowthRate(const ArbUt::List<uint32_t>& experience) : _experience(experience) {}
|
||||
LookupGrowthRate(const ArbUt::List<u32>& experience) : _experience(experience) {}
|
||||
|
||||
level_int_t CalculateLevel(uint32_t experience) const override {
|
||||
level_int_t CalculateLevel(u32 experience) const override {
|
||||
for (level_int_t i = 0; i < (level_int_t)_experience.Count(); i++) {
|
||||
if (_experience[i] > experience) {
|
||||
return i;
|
||||
|
@ -21,7 +21,7 @@ namespace CreatureLib::Library {
|
|||
return _experience.Count() - 1;
|
||||
}
|
||||
|
||||
uint32_t CalculateExperience(level_int_t level) const override { return _experience[level - 1]; }
|
||||
u32 CalculateExperience(level_int_t level) const override { return _experience[level - 1]; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CREATURELIB_BATTLEITEMCATEGORY_HPP
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
ENUM(BattleItemCategory, uint8_t, None, Healing, StatusHealing, CaptureDevice, MiscBattleItem)
|
||||
ENUM(BattleItemCategory, u8, None, Healing, StatusHealing, CaptureDevice, MiscBattleItem)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_BATTLEITEMCATEGORY_HPP
|
||||
|
|
|
@ -5,41 +5,41 @@ namespace CreatureLib::Library {
|
|||
ArbUt::StringView _name;
|
||||
ItemCategory _category;
|
||||
BattleItemCategory _battleCategory;
|
||||
int32_t _price;
|
||||
i32 _price;
|
||||
|
||||
ArbUt::OptionalUniquePtr<const SecondaryEffect> _effect = nullptr;
|
||||
ArbUt::OptionalUniquePtr<const SecondaryEffect> _battleTriggerEffect = nullptr;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
std::unordered_set<u32> _flags;
|
||||
|
||||
public:
|
||||
inline impl(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory,
|
||||
int32_t price, const SecondaryEffect* effect, const SecondaryEffect* battleTriggerEffect,
|
||||
const std::unordered_set<uint32_t>& flags) noexcept
|
||||
inline impl(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory, i32 price,
|
||||
const SecondaryEffect* effect, const SecondaryEffect* battleTriggerEffect,
|
||||
const std::unordered_set<u32>& flags) noexcept
|
||||
: _name(name), _category(category), _battleCategory(battleCategory), _price(price), _effect(effect),
|
||||
_battleTriggerEffect(battleTriggerEffect), _flags(flags) {}
|
||||
|
||||
inline const ArbUt::StringView& GetName() const noexcept { return _name; }
|
||||
inline ItemCategory GetCategory() const noexcept { return _category; }
|
||||
inline BattleItemCategory GetBattleCategory() const noexcept { return _battleCategory; }
|
||||
inline int32_t GetPrice() const noexcept { return _price; }
|
||||
inline i32 GetPrice() const noexcept { return _price; }
|
||||
inline const ArbUt::OptionalUniquePtr<const SecondaryEffect>& GetEffect() const noexcept { return _effect; }
|
||||
inline const ArbUt::OptionalUniquePtr<const SecondaryEffect>& GetBattleTriggerEffect() const noexcept {
|
||||
return _battleTriggerEffect;
|
||||
}
|
||||
|
||||
inline bool HasFlag(const ArbUt::BasicStringView& flag) const noexcept { return this->_flags.contains(flag); }
|
||||
inline bool HasFlag(uint32_t flag) const noexcept { return this->_flags.contains(flag); }
|
||||
inline bool HasFlag(u32 flag) const noexcept { return this->_flags.contains(flag); }
|
||||
};
|
||||
Item::Item(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
||||
Item::Item(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory, i32 price,
|
||||
const SecondaryEffect* effect, const SecondaryEffect* battleTriggerEffect,
|
||||
const std::unordered_set<uint32_t>& flags) noexcept
|
||||
const std::unordered_set<u32>& flags) noexcept
|
||||
: _impl(new impl(name, category, battleCategory, price, effect, battleTriggerEffect, flags)) {}
|
||||
|
||||
Item::~Item() = default;
|
||||
const ArbUt::StringView& Item::GetName() const noexcept { return _impl->GetName(); }
|
||||
ItemCategory Item::GetCategory() const noexcept { return _impl->GetCategory(); }
|
||||
BattleItemCategory Item::GetBattleCategory() const noexcept { return _impl->GetBattleCategory(); }
|
||||
int32_t Item::GetPrice() const noexcept { return _impl->GetPrice(); }
|
||||
i32 Item::GetPrice() const noexcept { return _impl->GetPrice(); }
|
||||
const ArbUt::OptionalUniquePtr<const SecondaryEffect>& Item::GetEffect() const noexcept {
|
||||
return _impl->GetEffect();
|
||||
}
|
||||
|
@ -48,6 +48,6 @@ namespace CreatureLib::Library {
|
|||
}
|
||||
|
||||
bool Item::HasFlag(const ArbUt::BasicStringView& flag) const noexcept { return _impl->HasFlag(flag); }
|
||||
bool Item::HasFlag(uint32_t flag) const noexcept { return _impl->HasFlag(flag); }
|
||||
bool Item::HasFlag(u32 flag) const noexcept { return _impl->HasFlag(flag); }
|
||||
|
||||
}
|
|
@ -15,9 +15,9 @@ namespace CreatureLib::Library {
|
|||
std::unique_ptr<impl> _impl;
|
||||
|
||||
public:
|
||||
Item(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
||||
Item(const ArbUt::StringView& name, ItemCategory category, BattleItemCategory battleCategory, i32 price,
|
||||
const SecondaryEffect* effect, const SecondaryEffect* battleTriggerEffect,
|
||||
const std::unordered_set<uint32_t>& flags) noexcept;
|
||||
const std::unordered_set<u32>& flags) noexcept;
|
||||
NO_COPY_OR_MOVE(Item)
|
||||
|
||||
virtual ~Item();
|
||||
|
@ -25,12 +25,12 @@ namespace CreatureLib::Library {
|
|||
const ArbUt::StringView& GetName() const noexcept;
|
||||
ItemCategory GetCategory() const noexcept;
|
||||
BattleItemCategory GetBattleCategory() const noexcept;
|
||||
int32_t GetPrice() const noexcept;
|
||||
i32 GetPrice() const noexcept;
|
||||
|
||||
const ArbUt::OptionalUniquePtr<const SecondaryEffect>& GetEffect() const noexcept;
|
||||
const ArbUt::OptionalUniquePtr<const SecondaryEffect>& GetBattleTriggerEffect() const noexcept;
|
||||
bool HasFlag(const ArbUt::BasicStringView& flag) const noexcept;
|
||||
bool HasFlag(uint32_t flag) const noexcept;
|
||||
bool HasFlag(u32 flag) const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CREATURELIB_ITEMCATEGORY_HPP
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
ENUM(ItemCategory, uint8_t, MiscItem, CaptureDevice, Medicine, Berry, MoveLearner, VariantChanger, KeyItem, Mail)
|
||||
ENUM(ItemCategory, u8, MiscItem, CaptureDevice, Medicine, Berry, MoveLearner, VariantChanger, KeyItem, Mail)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_ITEMCATEGORY_HPP
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
namespace CreatureLib::Library {
|
||||
struct LibrarySettings::impl {
|
||||
level_int_t _maximalLevel;
|
||||
uint8_t _maximalAttacks;
|
||||
u8 _maximalAttacks;
|
||||
|
||||
public:
|
||||
impl(level_int_t maximalLevel, uint8_t maximalAttacks)
|
||||
impl(level_int_t maximalLevel, u8 maximalAttacks)
|
||||
: _maximalLevel(maximalLevel), _maximalAttacks(maximalAttacks) {}
|
||||
|
||||
[[nodiscard]] inline level_int_t GetMaximalLevel() const noexcept { return _maximalLevel; }
|
||||
|
||||
[[nodiscard]] inline uint8_t GetMaximalAttacks() const noexcept { return _maximalAttacks; }
|
||||
[[nodiscard]] inline u8 GetMaximalAttacks() const noexcept { return _maximalAttacks; }
|
||||
};
|
||||
LibrarySettings::LibrarySettings(level_int_t maximalLevel, uint8_t maximalAttacks)
|
||||
LibrarySettings::LibrarySettings(level_int_t maximalLevel, u8 maximalAttacks)
|
||||
: _impl(new impl(maximalLevel, maximalAttacks)) {}
|
||||
LibrarySettings::~LibrarySettings() = default;
|
||||
|
||||
level_int_t LibrarySettings::GetMaximalLevel() const noexcept { return _impl->GetMaximalLevel(); }
|
||||
uint8_t LibrarySettings::GetMaximalAttacks() const noexcept { return _impl->GetMaximalAttacks(); }
|
||||
u8 LibrarySettings::GetMaximalAttacks() const noexcept { return _impl->GetMaximalAttacks(); }
|
||||
}
|
|
@ -14,7 +14,7 @@ namespace CreatureLib::Library {
|
|||
/// @brief Initialises LibrarySettings.
|
||||
/// @param maximalLevel The maximal level a creature can be.
|
||||
/// @param maximalAttacks The maximal number of attacks a creature can have.
|
||||
LibrarySettings(level_int_t maximalLevel, uint8_t maximalAttacks);
|
||||
LibrarySettings(level_int_t maximalLevel, u8 maximalAttacks);
|
||||
virtual ~LibrarySettings();
|
||||
|
||||
/// @brief Returns the maximal level a creature can be in the current library.
|
||||
|
@ -22,7 +22,7 @@ namespace CreatureLib::Library {
|
|||
[[nodiscard]] level_int_t GetMaximalLevel() const noexcept;
|
||||
/// @brief Returns the maximal number of attacks a creature can have.
|
||||
/// @return The maximal number of attacks a creature can have.
|
||||
[[nodiscard]] uint8_t GetMaximalAttacks() const noexcept;
|
||||
[[nodiscard]] u8 GetMaximalAttacks() const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
namespace CreatureLib::Library {
|
||||
class SpeciesLibrary : public BaseLibrary<CreatureSpecies> {
|
||||
private:
|
||||
ArbUt::Dictionary<uint16_t, ArbUt::BorrowedPtr<const CreatureSpecies>> _valuesById;
|
||||
ArbUt::Dictionary<u16, ArbUt::BorrowedPtr<const CreatureSpecies>> _valuesById;
|
||||
|
||||
public:
|
||||
SpeciesLibrary(size_t initialCapacity = 32) : BaseLibrary(initialCapacity){};
|
||||
|
@ -16,12 +16,12 @@ namespace CreatureLib::Library {
|
|||
BaseLibrary::Insert(key, value);
|
||||
_valuesById.Insert(value->GetId(), value);
|
||||
}
|
||||
void Insert(uint32_t hashedKey, const CreatureSpecies* value) override {
|
||||
void Insert(u32 hashedKey, const CreatureSpecies* value) override {
|
||||
BaseLibrary::Insert(hashedKey, value);
|
||||
_valuesById.Insert(value->GetId(), value);
|
||||
}
|
||||
|
||||
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(uint16_t id) const { return _valuesById[id]; }
|
||||
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(u16 id) const { return _valuesById[id]; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
ENUM(Statistic, uint8_t, Health, PhysicalAttack, PhysicalDefense, MagicalAttack, MagicalDefense, Speed)
|
||||
ENUM(Statistic, u8, Health, PhysicalAttack, PhysicalDefense, MagicalAttack, MagicalDefense, Speed)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_STATISTIC_HPP
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
uint8_t TypeLibrary::RegisterType(const ArbUt::StringView& key) {
|
||||
u8 TypeLibrary::RegisterType(const ArbUt::StringView& key) {
|
||||
_types.Insert(key, _types.Count());
|
||||
_effectiveness.Resize(_types.Count());
|
||||
for (auto& eff : _effectiveness) {
|
||||
|
@ -11,14 +11,14 @@ uint8_t TypeLibrary::RegisterType(const ArbUt::StringView& key) {
|
|||
return _types.Count() - 1;
|
||||
}
|
||||
|
||||
void TypeLibrary::SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness) {
|
||||
void TypeLibrary::SetEffectiveness(u8 attacking, u8 defensive, float effectiveness) {
|
||||
_effectiveness[attacking][defensive] = effectiveness;
|
||||
}
|
||||
const ArbUt::StringView& TypeLibrary::GetTypeName(uint8_t type) const {
|
||||
const ArbUt::StringView& TypeLibrary::GetTypeName(u8 type) const {
|
||||
for (auto& kv : _types) {
|
||||
if (kv.second == type) {
|
||||
return kv.first;
|
||||
}
|
||||
}
|
||||
THROW("Name requested for unknown type: ", (uint32_t)type);
|
||||
THROW("Name requested for unknown type: ", (u32)type);
|
||||
}
|
||||
|
|
|
@ -16,25 +16,25 @@ namespace CreatureLib::Library {
|
|||
public:
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(ArbUt::Dictionary<ArbUt::StringView, u8>(initialCapacity)) {}
|
||||
|
||||
inline uint8_t GetTypeId(const ArbUt::StringView& key) const { return _types.Get(key); }
|
||||
inline u8 GetTypeId(const ArbUt::StringView& key) const { return _types.Get(key); }
|
||||
[[nodiscard]] inline float GetSingleEffectiveness(u8 attacking, u8 defensive) const {
|
||||
try {
|
||||
return _effectiveness[attacking][defensive];
|
||||
} catch (const std::exception& e) {
|
||||
THROW("Unknown type indices were requested for effectiveness: ", (uint32_t)attacking, " and ",
|
||||
(uint32_t)defensive);
|
||||
THROW("Unknown type indices were requested for effectiveness: ", (u32)attacking, " and ",
|
||||
(u32)defensive);
|
||||
}
|
||||
}
|
||||
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking, const std::vector<u8>& defensive) const {
|
||||
[[nodiscard]] inline float GetEffectiveness(u8 attacking, const std::vector<u8>& defensive) const {
|
||||
return std::accumulate(defensive.begin(), defensive.end(), (float)1,
|
||||
[this, attacking](float init, uint8_t defense) {
|
||||
[this, attacking](float init, u8 defense) {
|
||||
return init * GetSingleEffectiveness(attacking, defense);
|
||||
});
|
||||
}
|
||||
const ArbUt::StringView& GetTypeName(u8 type) const;
|
||||
|
||||
uint8_t RegisterType(const ArbUt::StringView& typeName);
|
||||
void SetEffectiveness(uint8_t attacking, u8 defensive, float effectiveness);
|
||||
u8 RegisterType(const ArbUt::StringView& typeName);
|
||||
void SetEffectiveness(u8 attacking, u8 defensive, float effectiveness);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ TEST_CASE("Bool EffectParameter") {
|
|||
}
|
||||
|
||||
TEST_CASE("Int EffectParameter") {
|
||||
auto p = EffectParameter((int64_t)684);
|
||||
auto p = EffectParameter((i64)684);
|
||||
REQUIRE(p.AsInt() == 684);
|
||||
REQUIRE(p.AsFloat() == 684);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue