Implement held item scripts
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:
@@ -9,9 +9,10 @@ namespace PkmnLib::Library {
|
||||
public:
|
||||
Item(const ArbUt::StringView& name, CreatureLib::Library::ItemCategory category,
|
||||
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
|
||||
const CreatureLib::Library::SecondaryEffect* effect, const std::unordered_set<uint32_t>& flags,
|
||||
uint8_t flingPower) noexcept
|
||||
: CreatureLib::Library::Item(name, category, battleCategory, price, effect, flags),
|
||||
const CreatureLib::Library::SecondaryEffect* effect,
|
||||
const CreatureLib::Library::SecondaryEffect* battleTriggerEffect,
|
||||
const std::unordered_set<uint32_t>& flags, uint8_t flingPower) noexcept
|
||||
: CreatureLib::Library::Item(name, category, battleCategory, price, battleTriggerEffect, effect, flags),
|
||||
_flingPower(flingPower) {}
|
||||
|
||||
inline uint8_t GetFlingPower() const noexcept { return _flingPower; }
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <scriptdictionary/scriptdictionary.h>
|
||||
#include <scripthandle/scripthandle.h>
|
||||
#include <scripthelper/scripthelper.h>
|
||||
#include <scriptstdstring/scriptstdstring.h>
|
||||
#include <scriptmath/scriptmath.h>
|
||||
#include <scriptstdstring/scriptstdstring.h>
|
||||
#include "AngelScriptMetadata.hpp"
|
||||
#include "AngelscriptUserdata.hpp"
|
||||
#include "ByteCodeHandling/FileByteCodeStream.hpp"
|
||||
@@ -309,6 +309,10 @@ void AngelScriptResolver::RegisterScriptType(asITypeInfo* typeInfo, const ArbUt:
|
||||
case "Side"_cnc:
|
||||
_typeDatabase[ScriptCategory::Side].Insert(effectName, new AngelScriptTypeInfo(effectName, typeInfo));
|
||||
break;
|
||||
case "ItemBattleTrigger"_cnc:
|
||||
_typeDatabase[ScriptCategory::ItemBattleTrigger].Insert(effectName,
|
||||
new AngelScriptTypeInfo(effectName, typeInfo));
|
||||
break;
|
||||
case "Weather"_cnc:
|
||||
_typeDatabase[static_cast<ScriptCategory>(PkmnScriptCategory::Weather)].Insert(
|
||||
effectName, new AngelScriptTypeInfo(effectName, typeInfo));
|
||||
|
||||
@@ -136,6 +136,7 @@ public:
|
||||
case ScriptCategory::Creature: t = _engine->GetTypeInfoByName("Pokemon"); break;
|
||||
case ScriptCategory::Battle: t = _engine->GetTypeInfoByName("Battle"); break;
|
||||
case ScriptCategory::Side: t = _engine->GetTypeInfoByName("BattleSide"); break;
|
||||
case ScriptCategory::ItemBattleTrigger: t = _engine->GetTypeInfoByName("Pokemon"); break;
|
||||
}
|
||||
switch (static_cast<PkmnScriptCategory>(category)) {
|
||||
case PkmnScriptCategory::Weather: t = _engine->GetTypeInfoByName("Battle"); break;
|
||||
|
||||
@@ -433,3 +433,10 @@ void AngelScriptScript::ModifyDefensiveStatValue(CreatureLib::Battling::Executin
|
||||
ctx->SetArgAddress(3, modifier);
|
||||
})
|
||||
}
|
||||
void AngelScriptScript::OnAfterHeldItemConsume(CreatureLib::Battling::Creature* creature,
|
||||
const CreatureLib::Library::Item* item) {
|
||||
CALL_HOOK(OnAfterHeldItemConsume, {
|
||||
ctx->SetArgObject(0, (void*)creature);
|
||||
ctx->SetArgObject(1, (void*)item);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ public:
|
||||
[[maybe_unused]] u32 oldHealth, [[maybe_unused]] u32 newHealth) override;
|
||||
void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override;
|
||||
void OnSwitchIn(CreatureLib::Battling::Creature* creature) override;
|
||||
void OnAfterHeldItemConsume(CreatureLib::Battling::Creature* creature,
|
||||
const CreatureLib::Library::Item* item) override;
|
||||
|
||||
////////////////////
|
||||
// PkmnLib methods//
|
||||
|
||||
@@ -190,6 +190,9 @@ public:
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
ModifyDefensiveStatValue,
|
||||
"void ModifyDefensiveStatValue(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& defensiveStatValue)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
OnAfterHeldItemConsume,
|
||||
"void OnAfterHeldItemConsume(Pokemon@ target, const Item@ item)");
|
||||
};
|
||||
|
||||
#undef SCRIPT_HOOK_FUNCTION
|
||||
|
||||
@@ -58,6 +58,7 @@ shared abstract class PkmnScript {
|
||||
void OnEndTurn(){};
|
||||
void OnDamage(Pokemon@ pokemon, DamageSource damageSource, uint oldHealth, uint newHealth){};
|
||||
void OnFaint(Pokemon@ pokemon, DamageSource damageSource){};
|
||||
void OnAfterHeldItemConsume(Pokemon@ target, const Item@ item){};
|
||||
|
||||
// PkmnLib methods
|
||||
void PreventIncomingCritical(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& preventCrit){};
|
||||
|
||||
Reference in New Issue
Block a user