diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index c767aee..c478c55 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -80,10 +80,10 @@ shared abstract class PkmnScript { Ensure(r >= 0); r = engine->GetModuleByIndex(0)->AddScriptSection("ItemUseScript", R"( shared abstract class ItemUseScript { - private Item@ __owner; + private const Item@ __owner; protected const Item@ GetOwner() { return __owner; }; - protected void SetOwner(Item@ o) { @__owner = @o; }; + protected void SetOwner(const Item@ o) { @__owner = @o; }; void OnInitialize(const narray@ parameters){}; bool IsItemUsable() { return false; }; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 5fff52c..aea17ec 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -74,10 +74,12 @@ static size_t GetTypesLengthWrapper(PkmnLib::Battling::Pokemon* p) { return p->G static uint8_t GetTypeWrapper(PkmnLib::Battling::Pokemon* p, size_t index) { return p->GetTypes()[index]; } #if defined(__clang__) -// Angelscript aligns this wrong (aligned on 4 bytes, wants 8). While this is a slight performance hit, we can ignore it for now. +// Angelscript aligns this wrong (aligned on 4 bytes, wants 8). While this is a slight performance hit, we can ignore it +// for now. [[clang::no_sanitize("alignment")]] #endif -static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& name) { +static CScriptHandle +AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& name) { auto* resolver = static_cast(obj->GetLibrary()->GetScriptResolver().get()); auto* script = static_cast(obj->AddVolatileScript(name))->GetRawAngelscriptObject(); @@ -213,6 +215,9 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { "Pokemon", "void ChangeForme(const constString &in name)", asMETHODPR(PkmnLib::Battling::Pokemon, ChangeVariant, (const ArbUt::StringView&), void), asCALL_THISCALL); Ensure(r >= 0); + r = engine->RegisterObjectMethod("Pokemon", "void AttemptCapture(const Item@ item)", + asMETHOD(PkmnLib::Battling::Pokemon, AttemptCapture), asCALL_THISCALL); + Ensure(r >= 0); r = engine->RegisterObjectMethod("TypeLibrary", "float GetEffectiveness(uint8 attackingType, Pokemon@ defender) const",