Implements new Effect Parameters in AngelScript/
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:
@@ -13,6 +13,7 @@
|
||||
#include "TypeRegistry/Battling/RegisterPokemonClass.hpp"
|
||||
#include "TypeRegistry/Battling/RegisterTurnChoices.hpp"
|
||||
#include "TypeRegistry/ConstString.hpp"
|
||||
#include "TypeRegistry/Library/RegisterEffectParameter.hpp"
|
||||
#include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp"
|
||||
#include "TypeRegistry/Library/RegisterItemTypes.hpp"
|
||||
#include "TypeRegistry/Library/RegisterMoveTypes.hpp"
|
||||
@@ -24,6 +25,26 @@ CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateS
|
||||
return new AngelScripResolver();
|
||||
}
|
||||
|
||||
static void TranslateException(asIScriptContext *ctx, void* /*userParam*/)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrow the original exception so we can catch it again
|
||||
throw;
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
// Tell the VM the type of exception that occurred
|
||||
ctx->SetException(e.what());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// The callback must not allow any exception to be thrown, but it is not necessary
|
||||
// to explicitly set an exception string if the default exception string is sufficient
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) {
|
||||
for (auto scriptCategory : ScriptCategoryHelper::GetValues()) {
|
||||
_typeDatabase.Insert(scriptCategory, {});
|
||||
@@ -31,6 +52,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) {
|
||||
|
||||
auto library = (PkmnLib::Battling::BattleLibrary*)arg;
|
||||
_engine = asCreateScriptEngine();
|
||||
_engine->SetTranslateAppExceptionCallback(asFUNCTION(TranslateException), 0, asCALL_CDECL);
|
||||
|
||||
int32_t r = _engine->SetMessageCallback(asFUNCTION(MessageCallback), nullptr, asCALL_CDECL);
|
||||
if (r < 0)
|
||||
@@ -76,6 +98,7 @@ void AngelScripResolver::RegisterTypes() {
|
||||
RegisterGrowthRateTypes::Register(_engine);
|
||||
RegisterTypeLibrary::Register(_engine);
|
||||
RegisterStaticLibraryTypes::Register(_engine);
|
||||
RegisterEffectParameter::Register(_engine);
|
||||
|
||||
// Register battle types
|
||||
RegisterPokemonClass::Register(_engine);
|
||||
|
||||
Reference in New Issue
Block a user