1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Added hacks fot spell scroll support.

This commit is contained in:
AlexVinS
2016-02-13 19:43:05 +03:00
parent 7106c5d1af
commit e0af4a665a
8 changed files with 85 additions and 48 deletions

View File

@@ -23,6 +23,7 @@
#include "CRandomGenerator.h"
#include "mapObjects/CObjectClassesHandler.h"
#include "mapping/CMap.h"
// Note: list must match entries in ArtTraits.txt
#define ART_POS_LIST \
@@ -963,6 +964,40 @@ CArtifactInstance * CArtifactInstance::createNewArtifactInstance(int aid)
return createNewArtifactInstance(VLC->arth->artifacts[aid]);
}
CArtifactInstance * CArtifactInstance::createArtifact(CMap * map, int aid, int spellID)
{
CArtifactInstance * a = nullptr;
if(aid >= 0)
{
if(spellID < 0)
{
a = CArtifactInstance::createNewArtifactInstance(aid);
}
else
{
a = CArtifactInstance::createScroll(SpellID(spellID).toSpell());
}
}
else //FIXME: create combined artifact instance for random combined artifacts, just in case
{
a = new CArtifactInstance(); //random, empty
}
map->addNewArtifactInstance(a);
//TODO make it nicer
if(a->artType && (!!a->artType->constituents))
{
CCombinedArtifactInstance * comb = dynamic_cast<CCombinedArtifactInstance *>(a);
for(CCombinedArtifactInstance::ConstituentInfo & ci : comb->constituentsInfo)
{
map->addNewArtifactInstance(ci.art);
}
}
return a;
}
void CArtifactInstance::deserializationFix()
{
setType(artType);