diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index c39b2b5..a4c5373 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -19,7 +19,10 @@ AngelScriptScript::AngelScriptScript(const ArbUt::OptionalBorrowedPtr& own AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj, ContextPool* ctxPool) : PkmnLib::Battling::PkmnScript(owner), _resolver(resolver), _type(type), _ctxPool(ctxPool), _obj(obj) { - if (_type->GetGetOwner().Exists) { + if (_type->GetGetOwner().Exists && owner.HasValue()) { + if (ownerType == nullptr){ + THROW("Script was created with owner value, but with unknown owner type.") + } CScriptHandle* handle = nullptr; AngelScriptUtils::AngelscriptFunctionCall( _type->GetGetOwner().Function, _ctxPool, _obj, _resolver, GetName(), [&](asIScriptContext*) {},