Updates to newer CreatureLib.

This commit is contained in:
Deukhoofd 2021-03-07 11:12:18 +01:00
parent f8427fa594
commit 18cebe842a
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
9 changed files with 18 additions and 15 deletions

View File

@ -13,7 +13,7 @@ export uint8_t PkmnLib_AngelScriptResolver_CreateScript(AngelScriptResolver* p,
Try(p->CreateScript(name, script);)
}
export uint8_t PkmnLib_AngelScriptResolver_FinalizeModule(AngelScriptResolver* p) { Try(p->FinalizeModule();) }
export uint8_t PkmnLib_AngelScriptResolver_LoadScript(CreatureLib::Battling::Script*& out, AngelScriptResolver* p,
export uint8_t PkmnLib_AngelScriptResolver_LoadScript(CreatureLib::Battling::BattleScript*& out, AngelScriptResolver* p,
ScriptCategory category, const char* scriptName) {
Try(out = p->LoadScript(category, ArbUt::StringView(scriptName));)
}

View File

@ -3,7 +3,7 @@ void PkmnLib::Battling::Battle::SetWeather(const ArbUt::StringView& name) {
if (_weatherScript != nullptr) {
_weatherScript->OnRemove();
}
_weatherScript = std::unique_ptr<CreatureLib::Battling::Script>(
_weatherScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(
_library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Weather), name));
_eventHook.Trigger<WeatherChangeEvent>(name);
}

View File

@ -4,12 +4,13 @@
#include <CreatureLib/Battling/Models/Battle.hpp>
#include "../EventHooks/WeatherChangeEvent.hpp"
#include "../Library/BattleLibrary.hpp"
#include "../PkmnScript.hpp"
#include "../PkmnScriptCategory.hpp"
namespace PkmnLib::Battling {
class Battle : public CreatureLib::Battling::Battle {
private:
std::unique_ptr<CreatureLib::Battling::Script> _weatherScript = nullptr;
std::unique_ptr<CreatureLib::Battling::BattleScript> _weatherScript = nullptr;
public:
Battle(const BattleLibrary* library, const ArbUt::List<CreatureLib::Battling::BattleParty*>& parties,

View File

@ -1,6 +1,6 @@
#ifndef PKMNLIB_PKMNSCRIPT_HPP
#define PKMNLIB_PKMNSCRIPT_HPP
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
#include <CreatureLib/Battling/ScriptHandling/BattleScript.hpp>
#ifdef __clang__
#pragma clang diagnostic push
@ -11,7 +11,7 @@
#endif
namespace PkmnLib::Battling {
class PkmnScript : public CreatureLib::Battling::Script {
class PkmnScript : public CreatureLib::Battling::BattleScript {
public:
virtual void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage){};

View File

@ -32,7 +32,7 @@ void PkmnLib::Battling::Pokemon::SetStatus(const ArbUt::StringView& name) {
if (_statusScript != nullptr) {
_statusScript->OnRemove();
}
_statusScript = std::unique_ptr<CreatureLib::Battling::Script>(
_statusScript = std::unique_ptr<CreatureLib::Battling::BattleScript>(
_library->LoadScript(static_cast<ScriptCategory>(PkmnScriptCategory::Status), name));
if (_battle.HasValue()) {
_battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, name);

View File

@ -4,6 +4,7 @@
#include <CreatureLib/Battling/Models/Creature.hpp>
#include "../../Library/Statistic.hpp"
#include "../Library/BattleLibrary.hpp"
#include "../PkmnScript.hpp"
#include "LearnedMove.hpp"
namespace PkmnLib::Battling {
@ -13,7 +14,7 @@ namespace PkmnLib::Battling {
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> _effortValues;
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> _nature;
std::unique_ptr<CreatureLib::Battling::Script> _statusScript = nullptr;
std::unique_ptr<CreatureLib::Battling::BattleScript> _statusScript = nullptr;
uint8_t _friendship = 0;
public:
@ -27,11 +28,11 @@ namespace PkmnLib::Battling {
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 31> individualValues,
CreatureLib::Library::ClampedStatisticSet<uint8_t, 0, 252> effortValues,
ArbUt::BorrowedPtr<const PkmnLib::Library::Nature> nature, bool allowedExperienceGain = true)
: CreatureLib::Battling::Creature(library.ForceAs<const CreatureLib::Battling::BattleLibrary>(),
species.ForceAs<const CreatureLib::Library::CreatureSpecies>(),
forme.ForceAs<const CreatureLib::Library::SpeciesVariant>(), level, experience,
uid, gender, coloring, heldItem.ForceAs<const CreatureLib::Library::Item>(),
nickname, talent, moves, allowedExperienceGain),
: CreatureLib::Battling::Creature(
library.ForceAs<const CreatureLib::Battling::BattleLibrary>(),
species.ForceAs<const CreatureLib::Library::CreatureSpecies>(),
forme.ForceAs<const CreatureLib::Library::SpeciesVariant>(), level, experience, uid, gender, coloring,
heldItem.ForceAs<const CreatureLib::Library::Item>(), nickname, talent, moves, allowedExperienceGain),
_individualValues(individualValues), _effortValues(effortValues), _nature(nature),
_friendship(species->GetBaseHappiness()) {}

View File

@ -126,7 +126,7 @@ void AngelScriptResolver::MessageCallback(const asSMessageInfo* msg, void*) {
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
}
CreatureLib::Battling::Script* AngelScriptResolver::LoadScript(ScriptCategory category,
CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(ScriptCategory category,
const ArbUt::StringView& scriptName) {
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> innerDb;
auto v = _typeDatabase.TryGet(category);

View File

@ -44,7 +44,8 @@ public:
void FinalizeModule();
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const ArbUt::StringView& scriptName) override;
CreatureLib::Battling::BattleScript* LoadScript(ScriptCategory category,
const ArbUt::StringView& scriptName) override;
void WriteByteCodeToFile(const char* file, bool stripDebugInfo = false);
void LoadByteCodeFromFile(const char* file);

View File

@ -1,6 +1,6 @@
#ifndef PKMNLIB_ANGELSCRIPTSCRIPT_HPP
#define PKMNLIB_ANGELSCRIPTSCRIPT_HPP
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
#include <CreatureLib/Battling/ScriptHandling/BattleScript.hpp>
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
#include <angelscript.h>
#include "../../../extern/angelscript_addons/scriptarray/scriptarray.h"