mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Added workaround for loading spellbook existance status
This commit is contained in:
parent
88566cb1ef
commit
cc91be3518
@ -1223,6 +1223,7 @@ class SpellID
|
||||
public:
|
||||
enum ESpellID
|
||||
{
|
||||
SPELLBOOK_PRESET = -3,
|
||||
PRESET = -2,
|
||||
NONE = -1,
|
||||
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)
|
||||
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)
|
||||
spells.insert(spellID);
|
||||
}
|
||||
else //remove placeholder
|
||||
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
|
||||
putArtifact(ArtifactPosition::SPELLBOOK, ArtifactUtils::createNewArtifactInstance(ArtifactID::SPELLBOOK));
|
||||
if(!vstd::contains(spells, SpellID::SPELLBOOK_PRESET))
|
||||
{
|
||||
// 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))
|
||||
putArtifact(ArtifactPosition::MACH4, ArtifactUtils::createNewArtifactInstance(ArtifactID::CATAPULT)); //everyone has a catapult
|
||||
|
@ -878,6 +878,9 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
||||
if(!hasArtSet)
|
||||
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())
|
||||
{
|
||||
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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user