mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Added workaround for loading spellbook existance status
This commit is contained in:
@@ -1223,6 +1223,7 @@ class SpellID
|
|||||||
public:
|
public:
|
||||||
enum ESpellID
|
enum ESpellID
|
||||||
{
|
{
|
||||||
|
SPELLBOOK_PRESET = -3,
|
||||||
PRESET = -2,
|
PRESET = -2,
|
||||||
NONE = -1,
|
NONE = -1,
|
||||||
SUMMON_BOAT=0, SCUTTLE_BOAT=1, VISIONS=2, VIEW_EARTH=3, DISGUISE=4, VIEW_AIR=5,
|
SUMMON_BOAT=0, SCUTTLE_BOAT=1, VISIONS=2, VIEW_EARTH=3, DISGUISE=4, VIEW_AIR=5,
|
||||||
|
@@ -287,16 +287,23 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
|||||||
if (ID == Obj::HERO)
|
if (ID == Obj::HERO)
|
||||||
appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, type->heroClass->getIndex())->getTemplates().front();
|
appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, type->heroClass->getIndex())->getTemplates().front();
|
||||||
|
|
||||||
if(!vstd::contains(spells, SpellID::PRESET)) //hero starts with a spell
|
if(!vstd::contains(spells, SpellID::PRESET))
|
||||||
{
|
{
|
||||||
|
// hero starts with default spells
|
||||||
for(const auto & spellID : type->spells)
|
for(const auto & spellID : type->spells)
|
||||||
spells.insert(spellID);
|
spells.insert(spellID);
|
||||||
}
|
}
|
||||||
else //remove placeholder
|
else //remove placeholder
|
||||||
spells -= SpellID::PRESET;
|
spells -= SpellID::PRESET;
|
||||||
|
|
||||||
if(!getArt(ArtifactPosition::MACH4) && !getArt(ArtifactPosition::SPELLBOOK) && type->haveSpellBook) //no catapult means we haven't read pre-existent set -> use default rules for spellbook
|
if(!vstd::contains(spells, SpellID::SPELLBOOK_PRESET))
|
||||||
putArtifact(ArtifactPosition::SPELLBOOK, ArtifactUtils::createNewArtifactInstance(ArtifactID::SPELLBOOK));
|
{
|
||||||
|
// hero starts with default spellbook presence status
|
||||||
|
if(!getArt(ArtifactPosition::SPELLBOOK) && type->haveSpellBook)
|
||||||
|
putArtifact(ArtifactPosition::SPELLBOOK, ArtifactUtils::createNewArtifactInstance(ArtifactID::SPELLBOOK));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
spells -= SpellID::SPELLBOOK_PRESET;
|
||||||
|
|
||||||
if(!getArt(ArtifactPosition::MACH4))
|
if(!getArt(ArtifactPosition::MACH4))
|
||||||
putArtifact(ArtifactPosition::MACH4, ArtifactUtils::createNewArtifactInstance(ArtifactID::CATAPULT)); //everyone has a catapult
|
putArtifact(ArtifactPosition::MACH4, ArtifactUtils::createNewArtifactInstance(ArtifactID::CATAPULT)); //everyone has a catapult
|
||||||
|
@@ -878,6 +878,9 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
|||||||
if(!hasArtSet)
|
if(!hasArtSet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Workaround - if hero has customized artifacts game should not attempt to add spellbook based on hero type
|
||||||
|
hero->spells.insert(SpellID::SPELLBOOK_PRESET);
|
||||||
|
|
||||||
if(!hero->artifactsWorn.empty() || !hero->artifactsInBackpack.empty())
|
if(!hero->artifactsWorn.empty() || !hero->artifactsInBackpack.empty())
|
||||||
{
|
{
|
||||||
logGlobal->warn("Hero %s at %s has set artifacts twice (in map properties and on adventure map instance). Using the latter set...", hero->getNameTranslated(), hero->pos.toString());
|
logGlobal->warn("Hero %s at %s has set artifacts twice (in map properties and on adventure map instance). Using the latter set...", hero->getNameTranslated(), hero->pos.toString());
|
||||||
|
Reference in New Issue
Block a user