diff --git a/TemplePlus/gamesystems/legacysystems.cpp b/TemplePlus/gamesystems/legacysystems.cpp index 678f91e15..70b6f637c 100644 --- a/TemplePlus/gamesystems/legacysystems.cpp +++ b/TemplePlus/gamesystems/legacysystems.cpp @@ -317,14 +317,15 @@ const std::string &FeatSystem::GetName() const { SpellSystem::SpellSystem(const GameSystemConf &config) { auto startup = temple::GetPointer(0x1007b740); - mesFuncs.Open("tprules\\spell_enums_ext.mes", &spellSys.spellEnumsExt); if (!startup(&config)) { throw TempleException("Unable to initialize game system Spell"); } + spellSys.Init(config); } SpellSystem::~SpellSystem() { auto shutdown = temple::GetPointer(0x100791d0); mesFuncs.Close(spellSys.spellEnumsExt); + mesFuncs.Close(spellSys.spellMesExt); shutdown(); } diff --git a/TemplePlus/spell.cpp b/TemplePlus/spell.cpp index b163595db..3b0345a71 100644 --- a/TemplePlus/spell.cpp +++ b/TemplePlus/spell.cpp @@ -115,6 +115,12 @@ class SpellFuncReplacements : public TempleFix { replaceFunction(0x10077970, [](uint32_t spellEnum){ return spellSys.GetSpellEnumTAG(spellEnum); }); + // GetSpellMesline + replaceFunction(0x1007AD80, [](uint32_t spellEnum) { + return spellSys.GetSpellMesline(spellEnum); + }); + + // SpellPacketSetCasterLevel replaceFunction(0x10079B70, [](SpellPacketBody* spellPkt){ @@ -398,6 +404,11 @@ SpellMapTransferInfo::SpellMapTransferInfo() } +void LegacySpellSystem::Init(const GameSystemConf& conf){ + mesFuncs.Open("tprules\\spell_enums_ext.mes", &spellSys.spellEnumsExt); + mesFuncs.Open("mes\\spell_ext.mes", &spellMesExt); +} + uint32_t LegacySpellSystem::spellRegistryCopy(uint32_t spellEnum, SpellEntry* spellEntry) { return spellEntryRegistry.copy(spellEnum, spellEntry); @@ -418,10 +429,11 @@ int LegacySpellSystem::ParseSpellSpecString(SpellStoreData* spell, char* spellSt return addresses.ParseSpellSpecString(spell, spellString); } -const char* LegacySpellSystem::GetSpellMesline(uint32_t lineNumber) const -{ - MesLine mesLine; - mesLine.key = lineNumber; +const char* LegacySpellSystem::GetSpellMesline(uint32_t lineNumber) const{ + + MesLine mesLine(lineNumber); + if (mesFuncs.GetLine(spellMesExt, &mesLine)) + return mesLine.value; mesFuncs.GetLine_Safe(*spellMes, &mesLine); return mesLine.value; } @@ -725,7 +737,7 @@ SpellMapTransferInfo LegacySpellSystem::SaveSpellForTeleport(const SpellPacket& auto spellEnum = data.spellPktBody.spellEnum; Expects(spellEnum > 0 && spellEnum < 10000); // keeping a margin for now because co8 has messed with this a bit - if (spellEnum > SPELL_ENUM_MAX) { + if (spellEnum > SPELL_ENUM_MAX_EXPANDED) { logger->warn("Spell enum beyond expected range encountered: {}", spellEnum); } diff --git a/TemplePlus/spell.h b/TemplePlus/spell.h index 468db9b49..20d408640 100644 --- a/TemplePlus/spell.h +++ b/TemplePlus/spell.h @@ -5,8 +5,10 @@ #include "tig\tig_mes.h" #include "spell_structs.h" #include "tio/tio.h" + //#include "ui/ui_picker.h" +struct GameSystemConf; class TioOutputStream; struct PickerArgs; @@ -152,8 +154,10 @@ struct LegacySpellSystem : temple::AddressTable MesHandle * spellEnumMesHandle; MesHandle spellEnumsExt; MesHandle * spellMes; + MesHandle spellMesExt; MesHandle * spellsRadialMenuOptionsMes; std::vector spellMapTransInfo; + void Init(const GameSystemConf& conf); uint32_t spellRegistryCopy(uint32_t spellEnum, SpellEntry* spellEntry); uint32_t ConfigSpellTargetting(PickerArgs* pickerArgs, SpellPacketBody* spellPacketBody); @@ -162,6 +166,7 @@ struct LegacySpellSystem : temple::AddressTable const char* GetSpellMesline(uint32_t line) const; bool CheckAbilityScoreReqForSpell(objHndl handle, uint32_t spellEnum, int statBeingRaised) const; + static const char* GetSpellEnumTAG(uint32_t spellEnum); const char* GetSpellName(uint32_t spellEnum) const; diff --git a/tpdata/co8fixes.dat b/tpdata/co8fixes.dat index 0928545ad..2b853fcf7 100644 Binary files a/tpdata/co8fixes.dat and b/tpdata/co8fixes.dat differ diff --git a/tpdata/tpgamefiles.dat b/tpdata/tpgamefiles.dat index a44ce054b..30187040c 100644 Binary files a/tpdata/tpgamefiles.dat and b/tpdata/tpgamefiles.dat differ diff --git a/tpdata/tprules/spell_enums_ext.mes b/tpdata/tprules/spell_enums_ext.mes index 09f6ea6f7..62876256e 100644 --- a/tpdata/tprules/spell_enums_ext.mes +++ b/tpdata/tprules/spell_enums_ext.mes @@ -1 +1,6 @@ +{3000}{class_ability_bardic_suggestion} + +{8000}{Bardic Suggestion} + {20735}{TAG_HEZROU_STENCH} +{23000}{}//class_ability_bardic_suggestion \ No newline at end of file