Initial work on capturing of Pokemon
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -71,9 +71,8 @@ void AngelScriptItemUseScript::OnUse(CreatureLib::Battling::Battle* battle) cons
|
||||
}
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__OnUse.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {
|
||||
ctx->SetArgObject(0, battle);
|
||||
}, [&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) { ctx->SetArgObject(0, battle); },
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
}
|
||||
void AngelScriptItemUseScript::OnCreatureUse(CreatureLib::Battling::Creature* creature, bool isBattle) const {
|
||||
if (!__OnPokemonUse.Exists) {
|
||||
@@ -87,3 +86,15 @@ void AngelScriptItemUseScript::OnCreatureUse(CreatureLib::Battling::Creature* cr
|
||||
},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
}
|
||||
void AngelScriptItemUseScript::ModifyPokeballCatchBonus(PkmnLib::Battling::Pokemon* pokemon, u8* catchBonus) const {
|
||||
if (!__ModifyPokeballCatchBonus.Exists) {
|
||||
return;
|
||||
}
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__ModifyPokeballCatchBonus.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {
|
||||
ctx->SetArgObject(0, (void*)pokemon);
|
||||
ctx->SetArgAddress(1, catchBonus);
|
||||
},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
#include <CreatureLib/Battling/ScriptHandling/ItemUseScript.hpp>
|
||||
#include <scriptarray/scriptarray.h>
|
||||
#include "../../Battling/PkmnItemUseScript.hpp"
|
||||
#include "TypeRegistry/NativeArray.hpp"
|
||||
|
||||
class AngelScriptResolver;
|
||||
|
||||
class AngelScriptItemUseScript final : public CreatureLib::Battling::ItemUseScript {
|
||||
class AngelScriptItemUseScript final : public PkmnLib::Battling::PkmnItemUseScript {
|
||||
public:
|
||||
AngelScriptItemUseScript(asIScriptObject* scriptObject, AngelScriptResolver* resolver)
|
||||
: _scriptObject(scriptObject), _resolver(resolver) {}
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
|
||||
void OnUse(CreatureLib::Battling::Battle* battle) const override;
|
||||
void OnCreatureUse(CreatureLib::Battling::Creature* creature, bool isBattle) const override;
|
||||
void ModifyPokeballCatchBonus(PkmnLib::Battling::Pokemon* pokemon, u8* catchBonus) const override;
|
||||
|
||||
private:
|
||||
asIScriptObject* _scriptObject;
|
||||
@@ -50,13 +52,16 @@ private:
|
||||
|
||||
#define ITEM_USE_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl);
|
||||
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const BattleLibrary@ library, const narray<EffectParameter@>@ parameters)");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(
|
||||
OnInitialize, "void OnInitialize(const BattleLibrary@ library, const narray<EffectParameter@>@ parameters)");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsItemUsable, "bool IsItemUsable()");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsPokemonUseItem, "bool IsPokemonUseItem()");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsUseValidForPokemon, "bool IsUseValidForPokemon(Pokemon@ target)");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsHoldable, "bool IsHoldable()");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(OnUse, "void OnUse()");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(OnPokemonUse, "void OnPokemonUse(Pokemon@ target)");
|
||||
ITEM_USE_SCRIPT_HOOK_FUNCTION(ModifyPokeballCatchBonus,
|
||||
"void ModifyPokeballCatchBonus(Pokemon@ target, uint8& catchBonus)");
|
||||
};
|
||||
|
||||
#endif // PKMNLIB_ANGELSCRIPTITEMUSESCRIPT_HPP
|
||||
|
||||
@@ -193,7 +193,7 @@ CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt
|
||||
return new AngelScriptScript(owner, ownerType, this, t.value(), obj, _contextPool);
|
||||
}
|
||||
|
||||
CreatureLib::Battling::ItemUseScript* AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) {
|
||||
PkmnLib::Battling::PkmnItemUseScript* AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) {
|
||||
auto v = this->_itemUseScripts.TryGet(item);
|
||||
if (v.has_value()) {
|
||||
return v.value();
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) override;
|
||||
CreatureLib::Battling::ItemUseScript* LoadItemScript(const CreatureLib::Library::Item* item) override;
|
||||
PkmnLib::Battling::PkmnItemUseScript* LoadItemScript(const CreatureLib::Library::Item* item) override;
|
||||
|
||||
ArbUt::OptionalBorrowedPtr<const PkmnLib::Battling::EvolutionScript>
|
||||
LoadEvolutionScript(const ArbUt::StringView& view) override;
|
||||
|
||||
@@ -463,3 +463,11 @@ void AngelScriptScript::ChangeSpeed(CreatureLib::Battling::BaseTurnChoice* choic
|
||||
ctx->SetArgAddress(1, (void*)speed);
|
||||
});
|
||||
}
|
||||
void AngelScriptScript::ModifyCaptureRateBonus(CreatureLib::Battling::Creature* pokemon,
|
||||
CreatureLib::Library::Item* catchItem, u8* modifier) {
|
||||
CALL_HOOK(ModifyCaptureRateBonus, {
|
||||
ctx->SetArgObject(0, (void*)pokemon);
|
||||
ctx->SetArgObject(1, (void*)catchItem);
|
||||
ctx->SetArgAddress(2, (void*)modifier);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,6 +163,8 @@ public:
|
||||
CreatureLib::Battling::Creature* target, u8 hitIndex, float* modifier) override;
|
||||
void ModifyDefensiveStatValue(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, u8 hitIndex, float* modifier) override;
|
||||
void ModifyCaptureRateBonus(CreatureLib::Battling::Creature* pokemon, CreatureLib::Library::Item* catchItem,
|
||||
u8* modifier) override;
|
||||
};
|
||||
|
||||
#undef CALL_HOOK
|
||||
|
||||
@@ -206,6 +206,8 @@ public:
|
||||
ModifyDefensiveStatValue,
|
||||
"void ModifyDefensiveStatValue(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& defensiveStatValue)");
|
||||
SCRIPT_HOOK_FUNCTION(OnAfterHeldItemConsume, "void OnAfterHeldItemConsume(Pokemon@ target, const Item@ item)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyCaptureRateBonus,
|
||||
"void ModifyCaptureRateBonus(Pokemon@ target, const Item@ item, uint8& bonus)");
|
||||
};
|
||||
|
||||
#undef SCRIPT_HOOK_FUNCTION
|
||||
|
||||
@@ -89,6 +89,7 @@ shared abstract class ItemUseScript {
|
||||
|
||||
void OnUse(Battle@ battle) { };
|
||||
void OnPokemonUse(Pokemon@ target, bool isBattle) { };
|
||||
void ModifyPokeballCatchBonus(Pokemon@ target, uint8& catchBonus){};
|
||||
}
|
||||
)");
|
||||
Ensure(r >= 0);
|
||||
|
||||
Reference in New Issue
Block a user