Support for specific PkmnLib functions in Scripts, added ModifyCriticalStage function.
This commit is contained in:
@@ -4,10 +4,11 @@
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <CreatureLib/Core/Exceptions/NotImplementedException.hpp>
|
||||
#include <angelscript.h>
|
||||
#include "../../Battling/PkmnScript.hpp"
|
||||
#include "AngelScriptTypeInfo.hpp"
|
||||
#include "ContextPool.hpp"
|
||||
|
||||
class AngelScriptScript : public CreatureLib::Battling::Script {
|
||||
class AngelScriptScript : public PkmnLib::Battling::PkmnScript {
|
||||
private:
|
||||
AngelScriptTypeInfo* _type = nullptr;
|
||||
ContextPool* _ctxPool = nullptr;
|
||||
@@ -16,7 +17,7 @@ private:
|
||||
|
||||
public:
|
||||
AngelScriptScript(const std::string& name, AngelScriptTypeInfo* type, asIScriptObject* obj, ContextPool* ctxPool)
|
||||
: CreatureLib::Battling::Script(name), _type(type), _ctxPool(ctxPool), _obj(obj) {}
|
||||
: PkmnLib::Battling::PkmnScript(name), _type(type), _ctxPool(ctxPool), _obj(obj) {}
|
||||
|
||||
~AngelScriptScript() override { _obj->Release(); }
|
||||
|
||||
@@ -251,6 +252,20 @@ public:
|
||||
ctx->SetArgAddress(3, damage);
|
||||
})
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// PkmnLib methods//
|
||||
////////////////////
|
||||
|
||||
void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
|
||||
uint8_t hit, uint8_t* critStage) override {
|
||||
CALL_HOOK(ModifyCriticalStage, {
|
||||
ctx->SetArgObject(0, (void*)attack);
|
||||
ctx->SetArgObject(1, (void*)target);
|
||||
ctx->SetArgByte(2, hit);
|
||||
ctx->SetArgAddress(3, critStage);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
#undef CALL_HOOK
|
||||
|
||||
@@ -90,24 +90,29 @@ public:
|
||||
SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyEffectChance,
|
||||
"void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
|
||||
"void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
|
||||
"void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
|
||||
|
||||
SCRIPT_HOOK_FUNCTION(OverrideBasePower,
|
||||
"void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance)");
|
||||
SCRIPT_HOOK_FUNCTION(ChangeDamageStatsUser,
|
||||
"void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user)");
|
||||
SCRIPT_HOOK_FUNCTION(BypassDefensiveStat,
|
||||
"void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
|
||||
SCRIPT_HOOK_FUNCTION(BypassOffensiveStat,
|
||||
"void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyStatModifier,
|
||||
"void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyDamageModifier,
|
||||
"void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
|
||||
SCRIPT_HOOK_FUNCTION(OverrideDamage,
|
||||
"void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
|
||||
SCRIPT_HOOK_FUNCTION(OverrideBasePower,
|
||||
"void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
ChangeDamageStatsUser,
|
||||
"void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user)");
|
||||
SCRIPT_HOOK_FUNCTION(BypassDefensiveStat,
|
||||
"void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
|
||||
SCRIPT_HOOK_FUNCTION(BypassOffensiveStat,
|
||||
"void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyStatModifier,
|
||||
"void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
ModifyDamageModifier,
|
||||
"void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
|
||||
SCRIPT_HOOK_FUNCTION(OverrideDamage,
|
||||
"void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
|
||||
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
ModifyCriticalStage,
|
||||
"void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage)");
|
||||
};
|
||||
|
||||
#undef SCRIPT_HOOK_FUNCTION
|
||||
|
||||
@@ -6,6 +6,7 @@ void BasicScriptClass::Register(asIScriptEngine* engine) {
|
||||
// registry interface. As such, we just create it from string.
|
||||
[[maybe_unused]] int r = engine->GetModuleByIndex(0)->AddScriptSection("PkmnScript", R"(
|
||||
shared abstract class PkmnScript {
|
||||
// CreatureLib methods
|
||||
void Stack(){};
|
||||
void OnRemove(){};
|
||||
void PreventAttack(ExecutingMove@ attack, bool& result){};
|
||||
@@ -31,6 +32,9 @@ shared abstract class PkmnScript {
|
||||
void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
|
||||
void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
|
||||
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage){};
|
||||
|
||||
// PkmnLib methods
|
||||
void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};
|
||||
}
|
||||
)");
|
||||
assert(r >= 0);
|
||||
|
||||
Reference in New Issue
Block a user