diff --git a/CInterface/Battling/Battle.cpp b/CInterface/Battling/Battle.cpp index 42682a0..e55e6c8 100644 --- a/CInterface/Battling/Battle.cpp +++ b/CInterface/Battling/Battle.cpp @@ -57,7 +57,7 @@ export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) { return reinterpret_cast(p->GetParties().RawData()); } -export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) { +export BattleScript* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) { auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key)); if (!v.has_value()) { return nullptr; @@ -67,12 +67,14 @@ export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) export uint8_t CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) { Try(p->AddVolatileScript(ArbUt::StringView(key));) } -export uint8_t CreatureLib_Battle_AddVolatileScript(Battle* p, Script* script) { Try(p->AddVolatileScript(script);) } +export uint8_t CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) { + Try(p->AddVolatileScript(script);) +} export uint8_t CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) { Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));) } -export uint8_t CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, Script* script) { +export uint8_t CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) { Try(p->RemoveVolatileScript(script);) } export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) { diff --git a/CInterface/Battling/BattleScript.cpp b/CInterface/Battling/BattleScript.cpp new file mode 100644 index 0000000..23d1518 --- /dev/null +++ b/CInterface/Battling/BattleScript.cpp @@ -0,0 +1,95 @@ +#include "../../src/Battling/ScriptHandling/BattleScript.hpp" +#include "../Core.hpp" +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 const char* CreatureLib_Script_GetName(BattleScript* p) { return p->GetName().c_str(); } + +export uint8_t 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) { + 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) { + Try(p->PreventAttack(attack, outResult)); +} +export uint8_t 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) { + Try(p->StopBeforeAttack(attack, outResult)); +} +export uint8_t 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) { + Try(p->FailIncomingAttack(attack, target, outResult)); +} + +export uint8_t 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) { + Try(p->OnAttackMiss(attack, target)); +} +export uint8_t CreatureLib_Script_ChangeAttackType(BattleScript* p, ExecutingAttack* attack, Creature* target, + uint8_t hitNumber, uint8_t* 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) { + Try(p->OverrideBasePower(attack, target, hitNumber, basePower)); +} +export uint8_t CreatureLib_Script_ChangeDamageStatsUser(BattleScript* p, ExecutingAttack* attack, Creature* target, + uint8_t 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) { + Try(p->BypassDefensiveStat(attack, target, hitNumber, bypass)); +} +export uint8_t CreatureLib_Script_BypassOffensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target, + uint8_t 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) { + Try(p->ModifyStatModifier(attack, target, hitNumber, modifier)); +} +export uint8_t CreatureLib_Script_ModifyDamageModifier(BattleScript* p, ExecutingAttack* attack, Creature* target, + uint8_t 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) { + Try(p->OverrideDamage(attack, target, hitNumber, damage)); +} +export uint8_t CreatureLib_Script_PreventSecondaryEffects(BattleScript* p, ExecutingAttack* attack, Creature* target, + uint8_t 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) { + Try(p->OnSecondaryEffect(attack, target, hitNumber)); +} +export uint8_t 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) { + Try(p->PreventSelfSwitch(choice, outResult)); +} +export uint8_t 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) { + Try(p->ModifyIncomingEffectChance(attack, target, chance)); +} diff --git a/CInterface/Battling/Creature.cpp b/CInterface/Battling/Creature.cpp index a1819fa..349c058 100644 --- a/CInterface/Battling/Creature.cpp +++ b/CInterface/Battling/Creature.cpp @@ -86,13 +86,13 @@ export uint8_t CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->C export uint8_t CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) { Try(p->AddVolatileScript(ArbUt::StringView(scriptName));) } -export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, Script* script) { +export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) { Try(p->AddVolatileScript(script);) } export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) { Try(p->RemoveVolatileScript(ArbUt::StringView(scriptName));) } -export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, Script* script) { +export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) { Try(p->RemoveVolatileScript(script);) } export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) { diff --git a/CInterface/Battling/ExecutingAttack.cpp b/CInterface/Battling/ExecutingAttack.cpp index aa816d4..70b96c8 100644 --- a/CInterface/Battling/ExecutingAttack.cpp +++ b/CInterface/Battling/ExecutingAttack.cpp @@ -4,9 +4,10 @@ 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, Script* script) { + LearnedAttack* attack, BattleScript* script) { Try(auto ls = ArbUt::List>(targetCount); - for (size_t i = 0; i < targetCount; i++) { ls.Append(targets[i]); } auto s = std::unique_ptr