|
|
|
@ -168,7 +168,7 @@ void CMapLoaderH3M::readHeader()
|
|
|
|
|
features = MapFormatFeaturesH3M::find(mapHeader->version, hotaVersion);
|
|
|
|
|
reader->setFormatLevel(features);
|
|
|
|
|
|
|
|
|
|
if(hotaVersion > 0)
|
|
|
|
|
if(features.levelHOTA1)
|
|
|
|
|
{
|
|
|
|
|
bool isMirrorMap = reader->readBool();
|
|
|
|
|
bool isArenaMap = reader->readBool();
|
|
|
|
@ -181,10 +181,35 @@ void CMapLoaderH3M::readHeader()
|
|
|
|
|
logGlobal->warn("Map '%s': Arena maps are not supported!", mapName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(hotaVersion > 1)
|
|
|
|
|
if(features.levelHOTA2)
|
|
|
|
|
{
|
|
|
|
|
[[maybe_unused]] uint8_t unknown = reader->readUInt32();
|
|
|
|
|
assert(unknown == 12);
|
|
|
|
|
int32_t terrainTypesCount = reader->readUInt32();
|
|
|
|
|
assert(features.terrainsCount == terrainTypesCount);
|
|
|
|
|
|
|
|
|
|
if (features.terrainsCount != terrainTypesCount)
|
|
|
|
|
logGlobal->warn("Map '%s': Expected %d terrains, but %d found!", mapName, features.terrainsCount, terrainTypesCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
int32_t townTypesCount = reader->readUInt32();
|
|
|
|
|
int8_t allowedDifficultiesMask = reader->readInt8Checked(0, 31);
|
|
|
|
|
|
|
|
|
|
assert(features.factionsCount == townTypesCount);
|
|
|
|
|
|
|
|
|
|
if (features.factionsCount != townTypesCount)
|
|
|
|
|
logGlobal->warn("Map '%s': Expected %d factions, but %d found!", mapName, features.factionsCount, townTypesCount);
|
|
|
|
|
|
|
|
|
|
if (allowedDifficultiesMask != 0)
|
|
|
|
|
logGlobal->warn("Map '%s': List of allowed difficulties (%d) is not implemented!", mapName, static_cast<int>(allowedDifficultiesMask));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA7)
|
|
|
|
|
{
|
|
|
|
|
bool canHireDefeatedHeroes = reader->readBool();
|
|
|
|
|
|
|
|
|
|
if (!canHireDefeatedHeroes)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to block hiring of defeated heroes is not implemented!", mapName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -249,14 +274,14 @@ void CMapLoaderH3M::readPlayerInfo()
|
|
|
|
|
playerInfo.aiTactic = static_cast<EAiTactic>(reader->readInt8Checked(-1, 3));
|
|
|
|
|
|
|
|
|
|
if(features.levelSOD)
|
|
|
|
|
reader->skipUnused(1); //TODO: check meaning?
|
|
|
|
|
reader->skipUnused(1); //faction is selectable
|
|
|
|
|
|
|
|
|
|
std::set<FactionID> allowedFactions;
|
|
|
|
|
|
|
|
|
|
reader->readBitmaskFactions(allowedFactions, false);
|
|
|
|
|
|
|
|
|
|
const bool isFactionRandom = playerInfo.isFactionRandom = reader->readBool();
|
|
|
|
|
const bool allFactionsAllowed = isFactionRandom && allowedFactions.size() == features.factionsCount;
|
|
|
|
|
playerInfo.isFactionRandom = reader->readBool();
|
|
|
|
|
const bool allFactionsAllowed = playerInfo.isFactionRandom && allowedFactions.size() == features.factionsCount;
|
|
|
|
|
|
|
|
|
|
if(!allFactionsAllowed)
|
|
|
|
|
playerInfo.allowedFactions = allowedFactions;
|
|
|
|
@ -267,7 +292,7 @@ void CMapLoaderH3M::readPlayerInfo()
|
|
|
|
|
if(features.levelAB)
|
|
|
|
|
{
|
|
|
|
|
playerInfo.generateHeroAtMainTown = reader->readBool();
|
|
|
|
|
reader->skipUnused(1); //TODO: check meaning?
|
|
|
|
|
reader->skipUnused(1); // starting town type, unused
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -721,7 +746,6 @@ void CMapLoaderH3M::readMapOptions()
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA0)
|
|
|
|
|
{
|
|
|
|
|
//TODO: HotA
|
|
|
|
|
bool allowSpecialMonths = reader->readBool();
|
|
|
|
|
map->overrideGameSetting(EGameSettings::CREATURES_ALLOW_RANDOM_SPECIAL_WEEKS, JsonNode(allowSpecialMonths));
|
|
|
|
|
reader->skipZero(3);
|
|
|
|
@ -729,12 +753,15 @@ void CMapLoaderH3M::readMapOptions()
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA1)
|
|
|
|
|
{
|
|
|
|
|
// Unknown, may be another "sized bitmap", e.g
|
|
|
|
|
// 4 bytes - size of bitmap (16)
|
|
|
|
|
// 2 bytes - bitmap data (16 bits / 2 bytes)
|
|
|
|
|
[[maybe_unused]] uint8_t unknownConstant = reader->readUInt8();
|
|
|
|
|
assert(unknownConstant == 16);
|
|
|
|
|
reader->skipZero(5);
|
|
|
|
|
int32_t combinedArtifactsCount = reader->readInt32();
|
|
|
|
|
int32_t combinedArtifactsBytes = (combinedArtifactsCount + 7) / 8;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < combinedArtifactsBytes; ++i)
|
|
|
|
|
{
|
|
|
|
|
uint8_t mask = reader->readUInt8();
|
|
|
|
|
if (mask != 0)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to ban specific combined artifacts is not implemented!", mapName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA3)
|
|
|
|
@ -744,6 +771,17 @@ void CMapLoaderH3M::readMapOptions()
|
|
|
|
|
if(roundLimit != -1)
|
|
|
|
|
logGlobal->warn("Map '%s': roundLimit of %d is not implemented!", mapName, roundLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
|
|
|
|
|
{
|
|
|
|
|
// unconfirmed, but only remainig option according to changelog
|
|
|
|
|
bool heroRecruitmentBlocked = reader->readBool();
|
|
|
|
|
if (heroRecruitmentBlocked)
|
|
|
|
|
logGlobal->warn("Map '%s': option to ban hero recruitment for %s is not implemented!!", mapName, PlayerColor(i).toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMapLoaderH3M::readAllowedArtifacts()
|
|
|
|
@ -884,6 +922,26 @@ void CMapLoaderH3M::readPredefinedHeroes()
|
|
|
|
|
|
|
|
|
|
logGlobal->debug("Map '%s': Hero predefined in map: %s", mapName, hero->getHeroType()->getJsonKey());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
for(int heroID = 0; heroID < heroesCount; heroID++)
|
|
|
|
|
{
|
|
|
|
|
bool alwaysAddSkills = reader->readBool(); // prevent heroes from receiving additional random secondary skills at the start of the map if they are not of the first level
|
|
|
|
|
bool cannotGainXP = reader->readBool();
|
|
|
|
|
int32_t level = reader->readInt32(); // Needs investigation how this interacts with usual setting of level via experience
|
|
|
|
|
assert(level > 0);
|
|
|
|
|
|
|
|
|
|
if (!alwaysAddSkills)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to prevent hero %d from gaining skills on map start is not implemented!", mapName, heroID);
|
|
|
|
|
|
|
|
|
|
if (cannotGainXP)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to prevent hero %d from receiveing experience is not implemented!", mapName, heroID);
|
|
|
|
|
|
|
|
|
|
if (level > 1)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to set level of hero %d to %d is not implemented!", mapName, heroID, level);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
|
|
|
@ -921,6 +979,9 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
|
|
|
|
|
bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
|
|
|
|
{
|
|
|
|
|
ArtifactID artifactID = reader->readArtifact();
|
|
|
|
|
SpellID scrollSpell = SpellID::NONE;
|
|
|
|
|
if (features.levelHOTA5)
|
|
|
|
|
scrollSpell = reader->readSpell16();
|
|
|
|
|
|
|
|
|
|
if(artifactID == ArtifactID::NONE)
|
|
|
|
|
return false;
|
|
|
|
@ -944,7 +1005,7 @@ bool CMapLoaderH3M::loadArtifactToSlot(CGHeroInstance * hero, int slot)
|
|
|
|
|
// Artifact seems to be missing in game, so skip artifacts that don't fit target slot
|
|
|
|
|
if(ArtifactID(artifactID).toArtifact()->canBePutAt(hero, ArtifactPosition(slot)))
|
|
|
|
|
{
|
|
|
|
|
auto * artifact = ArtifactUtils::createArtifact(artifactID);
|
|
|
|
|
auto * artifact = ArtifactUtils::createArtifact(artifactID, scrollSpell);
|
|
|
|
|
map->putArtifactInstance(*hero, artifact, slot);
|
|
|
|
|
map->addNewArtifactInstance(artifact);
|
|
|
|
|
}
|
|
|
|
@ -988,16 +1049,21 @@ void CMapLoaderH3M::readObjectTemplates()
|
|
|
|
|
{
|
|
|
|
|
uint32_t defAmount = reader->readUInt32();
|
|
|
|
|
|
|
|
|
|
templates.reserve(defAmount);
|
|
|
|
|
originalTemplates.reserve(defAmount);
|
|
|
|
|
remappedTemplates.reserve(defAmount);
|
|
|
|
|
|
|
|
|
|
// Read custom defs
|
|
|
|
|
for(int defID = 0; defID < defAmount; ++defID)
|
|
|
|
|
{
|
|
|
|
|
auto tmpl = reader->readObjectTemplate();
|
|
|
|
|
templates.push_back(tmpl);
|
|
|
|
|
originalTemplates.push_back(tmpl);
|
|
|
|
|
|
|
|
|
|
if (!CResourceHandler::get()->existsResource(tmpl->animationFile.addPrefix("SPRITES/")))
|
|
|
|
|
logMod->warn("Template animation %s of type (%d %d) is missing!", tmpl->animationFile.getOriginalName(), tmpl->id, tmpl->subid );
|
|
|
|
|
auto remapped = std::make_shared<ObjectTemplate>(*tmpl);
|
|
|
|
|
reader->remapTemplate(*remapped);
|
|
|
|
|
remappedTemplates.push_back(remapped);
|
|
|
|
|
|
|
|
|
|
if (!CResourceHandler::get()->existsResource(remapped->animationFile.addPrefix("SPRITES/")))
|
|
|
|
|
logMod->warn("Template animation %s of type (%d %d) is missing!", remapped->animationFile.getOriginalName(), remapped->id, remapped->subid );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1018,6 +1084,8 @@ CGObjectInstance * CMapLoaderH3M::readEvent(const int3 & mapPosition, const Obje
|
|
|
|
|
else
|
|
|
|
|
object->humanActivate = true;
|
|
|
|
|
|
|
|
|
|
readBoxHotaContent(object, mapPosition, idToBeGiven);
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1025,6 +1093,12 @@ CGObjectInstance * CMapLoaderH3M::readPandora(const int3 & mapPosition, const Ob
|
|
|
|
|
{
|
|
|
|
|
auto * object = new CGPandoraBox(map->cb);
|
|
|
|
|
readBoxContent(object, mapPosition, idToBeGiven);
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
reader->skipZero(1); // Unknown value, always 0 so far
|
|
|
|
|
|
|
|
|
|
readBoxHotaContent(object, mapPosition, idToBeGiven);
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1055,7 +1129,15 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
|
|
|
|
}
|
|
|
|
|
size_t gart = reader->readUInt8(); //number of gained artifacts
|
|
|
|
|
for(size_t oo = 0; oo < gart; ++oo)
|
|
|
|
|
{
|
|
|
|
|
reward.artifacts.push_back(reader->readArtifact());
|
|
|
|
|
if (features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
SpellID scrollSpell = reader->readSpell16();
|
|
|
|
|
if (reward.artifacts.back() == ArtifactID::SPELL_SCROLL)
|
|
|
|
|
logGlobal->warn("Map '%s': Pandora/Event at %s Option to give spell scroll (%s) via event or pandora is not implemented!", mapName, mapPosition.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t gspel = reader->readUInt8(); //number of gained spells
|
|
|
|
|
for(size_t oo = 0; oo < gspel; ++oo)
|
|
|
|
@ -1076,6 +1158,27 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
|
|
|
|
reader->skipZero(8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMapLoaderH3M::readBoxHotaContent(CGPandoraBox * object, const int3 & mapPosition, const ObjectInstanceID & idToBeGiven)
|
|
|
|
|
{
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
int32_t movementMode = reader->readInt32(); // Give, Take, Nullify, Set, Replenish
|
|
|
|
|
int32_t movementAmount = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
assert(movementMode >= 0 && movementMode <= 4);
|
|
|
|
|
if (movementMode != 0 || movementAmount != 0)
|
|
|
|
|
logGlobal->warn("Map '%s': Event/Pandora %s option to modify (mode %d) movement points by %d is not implemented!", mapName, mapPosition.toString(), movementMode, movementAmount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA6)
|
|
|
|
|
{
|
|
|
|
|
int32_t allowedDifficultiesMask = reader->readInt32();
|
|
|
|
|
assert(allowedDifficultiesMask > 0 && allowedDifficultiesMask < 32);
|
|
|
|
|
if (allowedDifficultiesMask != 31)
|
|
|
|
|
logGlobal->warn("Map '%s': Event/Pandora %s availability by difficulty (mode %d) is not implemented!", mapName, mapPosition.toString(), allowedDifficultiesMask);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
|
|
|
|
{
|
|
|
|
|
auto * object = new CGCreature(map->cb);
|
|
|
|
@ -1092,7 +1195,8 @@ CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const Ob
|
|
|
|
|
//type will be set during initialization
|
|
|
|
|
object->putStack(SlotID(0), hlp);
|
|
|
|
|
|
|
|
|
|
object->character = reader->readInt8Checked(0, 4);
|
|
|
|
|
//TODO: 0-4 is h3 range. 5 is hota extension for exact aggression?
|
|
|
|
|
object->character = reader->readInt8Checked(0, 5);
|
|
|
|
|
|
|
|
|
|
bool hasMessage = reader->readBool();
|
|
|
|
|
if(hasMessage)
|
|
|
|
@ -1127,6 +1231,15 @@ CGObjectInstance * CMapLoaderH3M::readMonster(const int3 & mapPosition, const Ob
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
bool sizeByValue = reader->readBool();//FIXME: double-check this flag effect
|
|
|
|
|
int32_t targetValue = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
if (sizeByValue || targetValue)
|
|
|
|
|
logGlobal->warn( "Map '%s': Wandering monsters %s option to set unit size to %d (%d) AI value is not implemented!", mapName, mapPosition.toString(), targetValue, sizeByValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1274,23 +1387,37 @@ CGObjectInstance * CMapLoaderH3M::readGarrison(const int3 & mapPosition)
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readArtifact(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
ArtifactID artID = ArtifactID::NONE; //random, set later
|
|
|
|
|
SpellID spellID = SpellID::NONE;
|
|
|
|
|
auto * object = new CGArtifact(map->cb);
|
|
|
|
|
|
|
|
|
|
readMessageAndGuards(object->message, object, mapPosition);
|
|
|
|
|
|
|
|
|
|
if(objectTemplate->id == Obj::SPELL_SCROLL)
|
|
|
|
|
{
|
|
|
|
|
spellID = reader->readSpell32();
|
|
|
|
|
artID = ArtifactID::SPELL_SCROLL;
|
|
|
|
|
}
|
|
|
|
|
else if(objectTemplate->id == Obj::ARTIFACT)
|
|
|
|
|
{
|
|
|
|
|
//specific artifact
|
|
|
|
|
//specific artifact
|
|
|
|
|
if(objectTemplate->id == Obj::ARTIFACT)
|
|
|
|
|
artID = ArtifactID(objectTemplate->subid);
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
uint32_t pickupMode = reader->readUInt32();
|
|
|
|
|
uint8_t pickupFlags = reader->readUInt8();
|
|
|
|
|
|
|
|
|
|
assert(pickupMode == 0 || pickupMode == 1 || pickupMode == 2); // DISABLED, RANDOM, CUSTOM
|
|
|
|
|
|
|
|
|
|
if (pickupMode != 0)
|
|
|
|
|
logGlobal->warn("Map '%s': Artifact %s: not implemented pickup mode %d (flags: %d)", mapName, mapPosition.toString(), pickupMode, static_cast<int>(pickupFlags));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object->storedArtifact = ArtifactUtils::createArtifact(artID, spellID.getNum());
|
|
|
|
|
object->storedArtifact = ArtifactUtils::createArtifact(artID, SpellID::NONE);
|
|
|
|
|
map->addNewArtifactInstance(object->storedArtifact);
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readScroll(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
auto * object = new CGArtifact(map->cb);
|
|
|
|
|
readMessageAndGuards(object->message, object, mapPosition);
|
|
|
|
|
SpellID spellID = reader->readSpell32();
|
|
|
|
|
|
|
|
|
|
object->storedArtifact = ArtifactUtils::createArtifact(ArtifactID::SPELL_SCROLL, spellID.getNum());
|
|
|
|
|
map->addNewArtifactInstance(object->storedArtifact);
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
@ -1315,17 +1442,32 @@ CGObjectInstance * CMapLoaderH3M::readResource(const int3 & mapPosition, std::sh
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readMine(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readMine(const int3 & mapPosition)
|
|
|
|
|
{
|
|
|
|
|
auto * object = new CGMine(map->cb);
|
|
|
|
|
if(objectTemplate->subid < 7)
|
|
|
|
|
setOwnerAndValidate(mapPosition, object, reader->readPlayer32());
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readAbandonedMine(const int3 & mapPosition)
|
|
|
|
|
{
|
|
|
|
|
auto * object = new CGMine(map->cb);
|
|
|
|
|
object->setOwner(PlayerColor::NEUTRAL);
|
|
|
|
|
reader->readBitmaskResources(object->abandonedMineResources, false);
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
setOwnerAndValidate(mapPosition, object, reader->readPlayer32());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
object->setOwner(PlayerColor::NEUTRAL);
|
|
|
|
|
reader->readBitmaskResources(object->abandonedMineResources, false);
|
|
|
|
|
bool customGuards = reader->readBool();
|
|
|
|
|
CreatureID guardsUnit = reader->readCreature32();
|
|
|
|
|
int32_t guardsMin = reader->readInt32();
|
|
|
|
|
int32_t guardsMax = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
if (customGuards)
|
|
|
|
|
{
|
|
|
|
|
assert(guardsMin <= guardsMax);
|
|
|
|
|
assert(guardsUnit.hasValue());
|
|
|
|
|
logGlobal->warn("Map '%s': Abandoned Mine %s: not implemented guards of %d-%d %s", mapName, mapPosition.toString(), guardsMin, guardsMax, guardsUnit.toEntity(VLC)->getJsonKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
@ -1415,21 +1557,48 @@ CGObjectInstance * CMapLoaderH3M::readHeroPlaceholder(const int3 & mapPosition)
|
|
|
|
|
logGlobal->debug("Map '%s': Hero placeholder: %s at %s, owned by %s", mapName, VLC->heroh->getById(htid)->getJsonKey(), mapPosition.toString(), object->getOwner().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
bool customizedStatingUnits = reader->readBool();
|
|
|
|
|
|
|
|
|
|
if (customizedStatingUnits)
|
|
|
|
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to customize starting units", mapName);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; ++i)
|
|
|
|
|
{
|
|
|
|
|
int32_t unitAmount = reader->readInt32();
|
|
|
|
|
CreatureID unitToGive = reader->readCreature32();
|
|
|
|
|
|
|
|
|
|
if (unitToGive.hasValue())
|
|
|
|
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to give %d units of type %d on map start to slot %d is not implemented!", mapName, unitAmount, unitToGive.toEntity(VLC)->getJsonKey(), i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t artifactsToGive = reader->readInt32();
|
|
|
|
|
assert(artifactsToGive >= 0);
|
|
|
|
|
assert(artifactsToGive < 100); // technically legal, but not possible in h3
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < artifactsToGive; ++i)
|
|
|
|
|
{
|
|
|
|
|
// NOTE: this might actually be 2 bytes for artifact ID + 2 bytes for spell scroll
|
|
|
|
|
ArtifactID startingArtifact = reader->readArtifact32();
|
|
|
|
|
logGlobal->warn("Map '%s': Hero placeholder: not implemented option to give hero artifact %d", mapName, startingArtifact.toEntity(VLC)->getJsonKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readGrail(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readGrail(const int3 & mapPosition)
|
|
|
|
|
{
|
|
|
|
|
if (objectTemplate->subid < 1000)
|
|
|
|
|
{
|
|
|
|
|
map->grailPos = mapPosition;
|
|
|
|
|
map->grailRadius = reader->readInt32();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Battle location for arena mode in HotA
|
|
|
|
|
logGlobal->warn("Map '%s': Arena mode is not supported!", mapName);
|
|
|
|
|
}
|
|
|
|
|
map->grailPos = mapPosition;
|
|
|
|
|
map->grailRadius = reader->readInt32();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readHotaBattleLocation(const int3 & mapPosition)
|
|
|
|
|
{
|
|
|
|
|
// Battle location for arena mode in HotA
|
|
|
|
|
logGlobal->warn("Map '%s': Arena mode is not supported!", mapName);
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1442,14 +1611,6 @@ CGObjectInstance * CMapLoaderH3M::readGeneric(const int3 & mapPosition, std::sha
|
|
|
|
|
return new CGObjectInstance(map->cb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readPyramid(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
if(objectTemplate->subid == 0)
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
return new CGObjectInstance(map->cb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readQuestGuard(const int3 & mapPosition)
|
|
|
|
|
{
|
|
|
|
|
auto * guard = new CGQuestGuard(map->cb);
|
|
|
|
@ -1498,7 +1659,7 @@ CGObjectInstance * CMapLoaderH3M::readBank(const int3 & mapPosition, std::shared
|
|
|
|
|
|
|
|
|
|
if(guardsPresetIndex != -1 || upgradedStackPresence != -1 || !artifacts.empty())
|
|
|
|
|
logGlobal->warn(
|
|
|
|
|
"Map '%s: creature bank at %s settings %d %d %d are not implemented!",
|
|
|
|
|
"Map '%s': creature bank at %s settings %d %d %d are not implemented!",
|
|
|
|
|
mapName,
|
|
|
|
|
mapPosition.toString(),
|
|
|
|
|
guardsPresetIndex,
|
|
|
|
@ -1510,9 +1671,101 @@ CGObjectInstance * CMapLoaderH3M::readBank(const int3 & mapPosition, std::shared
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readRewardWithArtifact(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
switch(objectTemplate->id.toEnum())
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
// TREASURE_CHEST - rewards index, if 3 - then 2nd value is artifact
|
|
|
|
|
// CORPSE - rewards index, if 1 - then 2nd value is artifact
|
|
|
|
|
// SHIPWRECK_SURVIVOR - if content = 0 then 2nd value is granted artifact
|
|
|
|
|
// SEA_CHEST - rewards index, if 2 - then 2nd value is artifact
|
|
|
|
|
// FLOTSAM - rewards index (0-3) + -1
|
|
|
|
|
// TREE_OF_KNOWLEDGE - rewards index (0-2) + -1
|
|
|
|
|
// PYRAMID - if content = 0 then 2nd value is granted spell
|
|
|
|
|
// WARRIORS_TOMB - if content = 0 then 2nd value is granted artifact
|
|
|
|
|
// HOTA_JETSAM - rewards index (0-3) + -1
|
|
|
|
|
// HOTA_VIAL_OF_MANA - rewards index (0-3) + -1
|
|
|
|
|
|
|
|
|
|
int32_t content = reader->readInt32();
|
|
|
|
|
ArtifactID artifact;
|
|
|
|
|
if (content != -1)
|
|
|
|
|
{
|
|
|
|
|
artifact = reader->readArtifact32(); // NOTE: might be 2 byte artifact + 2 bytes scroll spell
|
|
|
|
|
logGlobal->warn("Map '%s': Object (%d) %s settings %d %d are not implemented!", mapName, objectTemplate->id, mapPosition.toString(), content, artifact);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
reader->skipUnused(4); // garbage data, usually -1, but sometimes uninitialized
|
|
|
|
|
}
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readBlackMarket(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 7; ++i)
|
|
|
|
|
{
|
|
|
|
|
ArtifactID artifact = reader->readArtifact();
|
|
|
|
|
SpellID spellID = reader->readSpell16();
|
|
|
|
|
|
|
|
|
|
if (artifact.hasValue())
|
|
|
|
|
{
|
|
|
|
|
if (artifact != ArtifactID::SPELL_SCROLL)
|
|
|
|
|
logGlobal->warn("Map '%s': Black Market at %s: option to sell artifact %s is not implemented", mapName, mapPosition.toString(), artifact.toEntity(VLC)->getJsonKey());
|
|
|
|
|
else
|
|
|
|
|
logGlobal->warn("Map '%s': Black Market at %s: option to sell scroll %s is not implemented", mapName, mapPosition.toString(), spellID.toEntity(VLC)->getJsonKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readUniversity(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
int32_t customized = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
std::set<SecondarySkill> allowedSkills;
|
|
|
|
|
reader->readBitmaskSkills(allowedSkills, false);
|
|
|
|
|
|
|
|
|
|
// NOTE: check how this interacts with hota Seafaring Academy that is guaranteed to give Navigation
|
|
|
|
|
assert(customized == -1 || customized == 0);
|
|
|
|
|
if (customized != -1)
|
|
|
|
|
logGlobal->warn("Map '%s': University at %s: option to give specific skills out of %d is not implemented", mapName, mapPosition.toString(), allowedSkills.size());
|
|
|
|
|
}
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readRewardWithArtifactAndResources(const int3 & mapPosition, std::shared_ptr<const ObjectTemplate> objectTemplate)
|
|
|
|
|
{
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
// Sea Barrel / 0 -> aID = -1, aA = resource amount, rA = resource type, aB = garbage, rB = 0
|
|
|
|
|
// Sea Barrel / 1 -> aID = -1, aA = 1, rA = 1, aB = garbage, rB = 0
|
|
|
|
|
// Ancient Lamp / 0 -> aID = -1, aA = amount to recruit, rA = 0, aB = 1, rB = 0
|
|
|
|
|
// Grave / 0 -> aID = artifact to give, aA = resource amount, rA = resource type, aB = 1, rB = garbage
|
|
|
|
|
// CAMPFIRE 12 / 0 -> aID = -1, aA = gold amount, rA = gold type, aB = resource amount, rB = resource type
|
|
|
|
|
// WAGON 105 / 0 -> aID = -1 or artifact, aA = resource amount, rA = resource type, aB = 1, rB = garbage?
|
|
|
|
|
// WAGON 105 / 1 -> empty / garbage?
|
|
|
|
|
// LEAN_TO / 39 / 0 -> aID = -1, aA = resource amount, rA = resource type, aB = garbage, rB = 0
|
|
|
|
|
|
|
|
|
|
int32_t content = reader->readInt32();
|
|
|
|
|
int32_t artifact = reader->readInt32();
|
|
|
|
|
int32_t amountA = reader->readInt32();
|
|
|
|
|
int8_t resourceA = reader->readInt8();
|
|
|
|
|
int32_t amountB = reader->readInt32();
|
|
|
|
|
int8_t resourceB = reader->readInt8();
|
|
|
|
|
|
|
|
|
|
if (content != -1)
|
|
|
|
|
logGlobal->warn("Map '%s': Object (%d) %s settings %d %d %d %d %d %d are not implemented!", mapName, objectTemplate->id, mapPosition.toString(), content, artifact, amountA, static_cast<int>(resourceA), amountB, static_cast<int>(resourceB));
|
|
|
|
|
}
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * CMapLoaderH3M::readObject(MapObjectID id, MapObjectSubID subid, std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
|
|
|
|
|
{
|
|
|
|
|
switch(id.toEnum())
|
|
|
|
|
{
|
|
|
|
|
case Obj::EVENT:
|
|
|
|
|
return readEvent(mapPosition, objectInstanceID);
|
|
|
|
@ -1555,8 +1808,9 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|
|
|
|
case Obj::RANDOM_MINOR_ART:
|
|
|
|
|
case Obj::RANDOM_MAJOR_ART:
|
|
|
|
|
case Obj::RANDOM_RELIC_ART:
|
|
|
|
|
case Obj::SPELL_SCROLL:
|
|
|
|
|
return readArtifact(mapPosition, objectTemplate);
|
|
|
|
|
case Obj::SPELL_SCROLL:
|
|
|
|
|
return readScroll(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::RANDOM_RESOURCE:
|
|
|
|
|
case Obj::RESOURCE:
|
|
|
|
@ -1567,7 +1821,10 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|
|
|
|
|
|
|
|
|
case Obj::MINE:
|
|
|
|
|
case Obj::ABANDONED_MINE:
|
|
|
|
|
return readMine(mapPosition, objectTemplate);
|
|
|
|
|
if (subid < 7)
|
|
|
|
|
return readMine(mapPosition);
|
|
|
|
|
else
|
|
|
|
|
return readAbandonedMine(mapPosition);
|
|
|
|
|
|
|
|
|
|
case Obj::CREATURE_GENERATOR1:
|
|
|
|
|
case Obj::CREATURE_GENERATOR2:
|
|
|
|
@ -1584,7 +1841,10 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|
|
|
|
return readPandora(mapPosition, objectInstanceID);
|
|
|
|
|
|
|
|
|
|
case Obj::GRAIL:
|
|
|
|
|
return readGrail(mapPosition, objectTemplate);
|
|
|
|
|
if (subid < 1000)
|
|
|
|
|
return readGrail(mapPosition);
|
|
|
|
|
else
|
|
|
|
|
return readHotaBattleLocation(mapPosition);
|
|
|
|
|
|
|
|
|
|
case Obj::RANDOM_DWELLING:
|
|
|
|
|
case Obj::RANDOM_DWELLING_LVL:
|
|
|
|
@ -1600,9 +1860,6 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|
|
|
|
case Obj::HERO_PLACEHOLDER:
|
|
|
|
|
return readHeroPlaceholder(mapPosition);
|
|
|
|
|
|
|
|
|
|
case Obj::PYRAMID:
|
|
|
|
|
return readPyramid(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::LIGHTHOUSE:
|
|
|
|
|
return readLighthouse(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
@ -1613,6 +1870,50 @@ CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplat
|
|
|
|
|
case Obj::SHIPWRECK:
|
|
|
|
|
return readBank(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::TREASURE_CHEST:
|
|
|
|
|
case Obj::CORPSE:
|
|
|
|
|
case Obj::SHIPWRECK_SURVIVOR:
|
|
|
|
|
case Obj::SEA_CHEST:
|
|
|
|
|
case Obj::FLOTSAM:
|
|
|
|
|
case Obj::TREE_OF_KNOWLEDGE:
|
|
|
|
|
case Obj::PYRAMID:
|
|
|
|
|
case Obj::WARRIORS_TOMB:
|
|
|
|
|
return readRewardWithArtifact(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::CAMPFIRE:
|
|
|
|
|
case Obj::WAGON:
|
|
|
|
|
case Obj::LEAN_TO:
|
|
|
|
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::BORDER_GATE:
|
|
|
|
|
if (subid == 1000) // HotA hacks - Quest Gate
|
|
|
|
|
return readQuestGuard(mapPosition);
|
|
|
|
|
if (subid == 1001) // HotA hacks - Grave
|
|
|
|
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::HOTA_CUSTOM_OBJECT_1:
|
|
|
|
|
// 0 -> Ancient Lamp
|
|
|
|
|
// 1 -> Sea Barrel
|
|
|
|
|
// 2 -> Jetsam
|
|
|
|
|
// 3 -> Vial of Mana
|
|
|
|
|
if (subid == 0 || subid == 1)
|
|
|
|
|
return readRewardWithArtifactAndResources(mapPosition, objectTemplate);
|
|
|
|
|
else
|
|
|
|
|
return readRewardWithArtifact(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::HOTA_CUSTOM_OBJECT_2:
|
|
|
|
|
if (subid == 0) // Seafaring Academy
|
|
|
|
|
return readUniversity(mapPosition, objectTemplate);
|
|
|
|
|
else
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::BLACK_MARKET:
|
|
|
|
|
return readBlackMarket(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
case Obj::UNIVERSITY:
|
|
|
|
|
return readUniversity(mapPosition, objectTemplate);
|
|
|
|
|
|
|
|
|
|
default: //any other object
|
|
|
|
|
return readGeneric(mapPosition, objectTemplate);
|
|
|
|
|
}
|
|
|
|
@ -1625,26 +1926,30 @@ void CMapLoaderH3M::readObjects()
|
|
|
|
|
for(uint32_t i = 0; i < objectsCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
int3 mapPosition = reader->readInt3();
|
|
|
|
|
assert(map->isInTheMap(mapPosition) || map->isInTheMap(mapPosition - int3(0,8,0)) || map->isInTheMap(mapPosition - int3(8,0,0)) || map->isInTheMap(mapPosition - int3(8,8,0)));
|
|
|
|
|
|
|
|
|
|
uint32_t defIndex = reader->readUInt32();
|
|
|
|
|
ObjectInstanceID objectInstanceID = ObjectInstanceID(static_cast<si32>(map->objects.size()));
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const ObjectTemplate> objectTemplate = templates.at(defIndex);
|
|
|
|
|
std::shared_ptr<ObjectTemplate> originalTemplate = originalTemplates.at(defIndex);
|
|
|
|
|
std::shared_ptr<ObjectTemplate> remappedTemplate = remappedTemplates.at(defIndex);
|
|
|
|
|
auto originalID = originalTemplate->id;
|
|
|
|
|
auto originalSubID = originalTemplate->subid;
|
|
|
|
|
reader->skipZero(5);
|
|
|
|
|
|
|
|
|
|
CGObjectInstance * newObject = readObject(objectTemplate, mapPosition, objectInstanceID);
|
|
|
|
|
CGObjectInstance * newObject = readObject(originalID, originalSubID, remappedTemplate, mapPosition, objectInstanceID);
|
|
|
|
|
|
|
|
|
|
if(!newObject)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
newObject->setAnchorPos(mapPosition);
|
|
|
|
|
newObject->ID = objectTemplate->id;
|
|
|
|
|
newObject->ID = remappedTemplate->id;
|
|
|
|
|
newObject->id = objectInstanceID;
|
|
|
|
|
if(newObject->ID != Obj::HERO && newObject->ID != Obj::HERO_PLACEHOLDER && newObject->ID != Obj::PRISON)
|
|
|
|
|
{
|
|
|
|
|
newObject->subID = objectTemplate->subid;
|
|
|
|
|
newObject->subID = remappedTemplate->subid;
|
|
|
|
|
}
|
|
|
|
|
newObject->appearance = objectTemplate;
|
|
|
|
|
newObject->appearance = remappedTemplate;
|
|
|
|
|
assert(objectInstanceID == ObjectInstanceID((si32)map->objects.size()));
|
|
|
|
|
|
|
|
|
|
if (newObject->isVisitable() && !map->isInTheMap(newObject->visitablePos()))
|
|
|
|
@ -1895,6 +2200,23 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
|
|
|
|
logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString());
|
|
|
|
|
|
|
|
|
|
reader->skipZero(16);
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
bool alwaysAddSkills = reader->readBool(); // prevent heroes from receiving additional random secondary skills at the start of the map if they are not of the first level
|
|
|
|
|
bool cannotGainXP = reader->readBool();
|
|
|
|
|
int32_t level = reader->readInt32(); // Needs investigation how this interacts with usual setting of level via experience
|
|
|
|
|
assert(level > 0);
|
|
|
|
|
|
|
|
|
|
if (!alwaysAddSkills)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to prevent hero %d from gaining skills on map start is not implemented!", mapName, object->subID.num);
|
|
|
|
|
|
|
|
|
|
if (cannotGainXP)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to prevent hero %d from receiveing experience is not implemented!", mapName, object->subID.num);
|
|
|
|
|
|
|
|
|
|
if (level > 1)
|
|
|
|
|
logGlobal->warn("Map '%s': Option to set level of hero %d to %d is not implemented!", mapName, object->subID.num, level);
|
|
|
|
|
}
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2028,6 +2350,14 @@ void CMapLoaderH3M::readSeerHutQuest(CGSeerHut * hut, const int3 & position, con
|
|
|
|
|
case ESeerHutRewardType::ARTIFACT:
|
|
|
|
|
{
|
|
|
|
|
reward.artifacts.push_back(reader->readArtifact());
|
|
|
|
|
if (features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
SpellID scrollSpell = reader->readSpell16();
|
|
|
|
|
if (reward.artifacts.back() == ArtifactID::SPELL_SCROLL)
|
|
|
|
|
logGlobal->warn("Map '%s': Seer Hut at %s: Option to give spell scroll (%s) as a reward is not implemented!", mapName, position.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ESeerHutRewardType::SPELL:
|
|
|
|
@ -2092,6 +2422,13 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|
|
|
|
for(size_t yy = 0; yy < artNumber; ++yy)
|
|
|
|
|
{
|
|
|
|
|
auto artid = reader->readArtifact();
|
|
|
|
|
if (features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
SpellID scrollSpell = reader->readSpell16();
|
|
|
|
|
if (artid == ArtifactID::SPELL_SCROLL)
|
|
|
|
|
logGlobal->warn("Map '%s': Seer Hut at %s: Quest to find scroll '%s' is not implemented!", mapName, position.toString(), scrollSpell.toEntity(VLC)->getJsonKey());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
guard->quest->mission.artifacts.push_back(artid);
|
|
|
|
|
map->allowedArtifact.erase(artid); //these are unavailable for random generation
|
|
|
|
|
}
|
|
|
|
@ -2128,6 +2465,7 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|
|
|
|
case EQuestMission::HOTA_MULTI:
|
|
|
|
|
{
|
|
|
|
|
uint32_t missionSubID = reader->readUInt32();
|
|
|
|
|
assert(missionSubID < 3);
|
|
|
|
|
|
|
|
|
|
if(missionSubID == 0)
|
|
|
|
|
{
|
|
|
|
@ -2144,6 +2482,14 @@ EQuestMission CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & positi
|
|
|
|
|
guard->quest->mission.daysPassed = reader->readUInt32() + 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(missionSubID == 2)
|
|
|
|
|
{
|
|
|
|
|
missionId = EQuestMission::HOTA_GAME_DIFFICULTY;
|
|
|
|
|
int32_t difficultyMask = reader->readUInt32();
|
|
|
|
|
assert(difficultyMask > 0 && difficultyMask < 32);
|
|
|
|
|
logGlobal->warn("Map '%s': Seer Hut at %s: Difficulty-specific quest (%d) is not implemented!", mapName, position.toString(), difficultyMask);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
@ -2223,33 +2569,63 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|
|
|
|
if(features.levelHOTA1)
|
|
|
|
|
object->spellResearchAllowed = reader->readBool();
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
// Most likely customization of special buildings per faction -> 4x11 table
|
|
|
|
|
// presumably:
|
|
|
|
|
// 0 -> default / allowed
|
|
|
|
|
// 1 -> built?
|
|
|
|
|
// 2 -> banned?
|
|
|
|
|
uint32_t specialBuildingsSize = reader->readUInt32();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < specialBuildingsSize; ++i)
|
|
|
|
|
{
|
|
|
|
|
int factionID = i / 4;
|
|
|
|
|
int buildingID = i % 4;
|
|
|
|
|
|
|
|
|
|
int8_t specialBuildingBuilt = reader->readInt8Checked(0, 2);
|
|
|
|
|
if (specialBuildingBuilt != 0)
|
|
|
|
|
logGlobal->warn("Map '%s': Town at %s: Constructing / banning town-specific special building %d in faction %d on start is not implemented!", mapName, position.toString(), buildingID, factionID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read castle events
|
|
|
|
|
uint32_t eventsCount = reader->readUInt32();
|
|
|
|
|
|
|
|
|
|
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
|
|
|
|
{
|
|
|
|
|
// TODO: a lot of copy-pasted code with map event
|
|
|
|
|
CCastleEvent event;
|
|
|
|
|
event.name = readBasicString();
|
|
|
|
|
event.message.appendTextID(readLocalizedString(TextIdentifier("town", position.x, position.y, position.z, "event", eventID, "description")));
|
|
|
|
|
event.creatures.resize(7);
|
|
|
|
|
|
|
|
|
|
reader->readResources(event.resources);
|
|
|
|
|
readEventCommon(event, TextIdentifier("town", position.x, position.y, position.z, "event", eventID, "description"));
|
|
|
|
|
|
|
|
|
|
reader->readBitmaskPlayers(event.players, false);
|
|
|
|
|
if(features.levelSOD)
|
|
|
|
|
event.humanAffected = reader->readBool();
|
|
|
|
|
else
|
|
|
|
|
event.humanAffected = true;
|
|
|
|
|
if(features.levelHOTA5)
|
|
|
|
|
{
|
|
|
|
|
int32_t creatureGrowth8 = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
event.computerAffected = reader->readBool();
|
|
|
|
|
event.firstOccurrence = reader->readUInt16();
|
|
|
|
|
event.nextOccurrence = reader->readUInt8();
|
|
|
|
|
// always 44
|
|
|
|
|
int32_t hotaAmount = reader->readInt32();
|
|
|
|
|
|
|
|
|
|
reader->skipZero(17);
|
|
|
|
|
// contains bitmask on which town-specific buildings to build
|
|
|
|
|
// 4 bits / town, for each of special building in town (special 1 - special 4)
|
|
|
|
|
int32_t hotaSpecialA = reader->readInt32();
|
|
|
|
|
int16_t hotaSpecialB = reader->readInt16();
|
|
|
|
|
|
|
|
|
|
if (hotaSpecialA != 0 || hotaSpecialB != 0 || hotaAmount != 44)
|
|
|
|
|
logGlobal->warn("Map '%s': Town at %s: Constructing town-specific special buildings in event is not implemented!", mapName, position.toString());;
|
|
|
|
|
|
|
|
|
|
event.creatures.push_back(creatureGrowth8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(features.levelHOTA7)
|
|
|
|
|
{
|
|
|
|
|
[[maybe_unused]] bool neutralAffected = reader->readBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// New buildings
|
|
|
|
|
reader->readBitmaskBuildings(event.buildings, faction);
|
|
|
|
|
|
|
|
|
|
event.creatures.resize(7);
|
|
|
|
|
for(int i = 0; i < 7; ++i)
|
|
|
|
|
event.creatures[i] = reader->readUInt16();
|
|
|
|
|
|
|
|
|
@ -2270,7 +2646,7 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|
|
|
|
if (mapHeader->players[alignment].canAnyonePlay())
|
|
|
|
|
object->alignmentToPlayer = PlayerColor(alignment);
|
|
|
|
|
else
|
|
|
|
|
logGlobal->warn("%s - Alignment of town at %s is invalid! Player %d is not present on map!", mapName, position.toString(), int(alignment));
|
|
|
|
|
logGlobal->warn("Map '%s': Alignment of town at %s is invalid! Player %d is not present on map!", mapName, position.toString(), int(alignment));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -2279,11 +2655,11 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|
|
|
|
|
|
|
|
|
if(invertedAlignment < PlayerColor::PLAYER_LIMIT.getNum())
|
|
|
|
|
{
|
|
|
|
|
logGlobal->warn("%s - Alignment of town at %s 'not as player %d' is not implemented!", mapName, position.toString(), alignment - PlayerColor::PLAYER_LIMIT.getNum());
|
|
|
|
|
logGlobal->warn("Map '%s': Alignment of town at %s 'not as player %d' is not implemented!", mapName, position.toString(), alignment - PlayerColor::PLAYER_LIMIT.getNum());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
logGlobal->warn("%s - Alignment of town at %s is corrupted!!", mapName, position.toString());
|
|
|
|
|
logGlobal->warn("Map '%s': Alignment of town at %s is corrupted!!", mapName, position.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2293,30 +2669,45 @@ CGObjectInstance * CMapLoaderH3M::readTown(const int3 & position, std::shared_pt
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMapLoaderH3M::readEventCommon(CMapEvent & event, const TextIdentifier & messageID)
|
|
|
|
|
{
|
|
|
|
|
event.name = readBasicString();
|
|
|
|
|
event.message.appendTextID(readLocalizedString(messageID));
|
|
|
|
|
|
|
|
|
|
reader->readResources(event.resources);
|
|
|
|
|
|
|
|
|
|
reader->readBitmaskPlayers(event.players, false);
|
|
|
|
|
if(features.levelSOD)
|
|
|
|
|
event.humanAffected = reader->readBool();
|
|
|
|
|
else
|
|
|
|
|
event.humanAffected = true;
|
|
|
|
|
|
|
|
|
|
event.computerAffected = reader->readBool();
|
|
|
|
|
event.firstOccurrence = reader->readUInt16();
|
|
|
|
|
event.nextOccurrence = reader->readUInt16();
|
|
|
|
|
|
|
|
|
|
reader->skipZero(16);
|
|
|
|
|
|
|
|
|
|
if (features.levelHOTA7)
|
|
|
|
|
{
|
|
|
|
|
int32_t allowedDifficultiesMask = reader->readInt32();
|
|
|
|
|
assert(allowedDifficultiesMask > 0 && allowedDifficultiesMask < 32);
|
|
|
|
|
if (allowedDifficultiesMask != 31)
|
|
|
|
|
logGlobal->warn("Map '%s': Map event: availability by difficulty (mode %d) is not implemented!", mapName, allowedDifficultiesMask);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMapLoaderH3M::readEvents()
|
|
|
|
|
{
|
|
|
|
|
uint32_t eventsCount = reader->readUInt32();
|
|
|
|
|
for(int eventID = 0; eventID < eventsCount; ++eventID)
|
|
|
|
|
{
|
|
|
|
|
CMapEvent event;
|
|
|
|
|
event.name = readBasicString();
|
|
|
|
|
event.message.appendTextID(readLocalizedString(TextIdentifier("event", eventID, "description")));
|
|
|
|
|
readEventCommon(event, TextIdentifier("event", eventID, "description"));
|
|
|
|
|
|
|
|
|
|
reader->readResources(event.resources);
|
|
|
|
|
reader->readBitmaskPlayers(event.players, false);
|
|
|
|
|
if(features.levelSOD)
|
|
|
|
|
{
|
|
|
|
|
event.humanAffected = reader->readBool();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
event.humanAffected = true;
|
|
|
|
|
}
|
|
|
|
|
event.computerAffected = reader->readBool();
|
|
|
|
|
event.firstOccurrence = reader->readUInt16();
|
|
|
|
|
event.nextOccurrence = reader->readUInt8();
|
|
|
|
|
|
|
|
|
|
reader->skipZero(17);
|
|
|
|
|
// garbage bytes that were present in HOTA5 & HOTA6
|
|
|
|
|
if (features.levelHOTA5 && !features.levelHOTA7)
|
|
|
|
|
reader->skipUnused(14);
|
|
|
|
|
|
|
|
|
|
map->events.push_back(event);
|
|
|
|
|
}
|
|
|
|
|