mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-17 11:56:46 +02:00
Partial solution to #2206
TODO: add serialized field that contains custom guard config
This commit is contained in:
parent
3f1bc7e21c
commit
9e7b459882
@ -10,58 +10,58 @@
|
|||||||
},
|
},
|
||||||
"types" : {
|
"types" : {
|
||||||
"basiliskPit" : { "index" : 0, "creatures" : [ [ "basilisk" ] ] },
|
"basiliskPit" : { "index" : 0, "creatures" : [ [ "basilisk" ] ] },
|
||||||
"behemothCrag" : { "index" : 1, "creatures" : [ [ "behemoth" ] ], "guards" : true },
|
"behemothCrag" : { "index" : 1, "creatures" : [ [ "behemoth" ] ]},
|
||||||
"pillarOfEyes" : { "index" : 2, "creatures" : [ [ "beholder" ] ] },
|
"pillarOfEyes" : { "index" : 2, "creatures" : [ [ "beholder" ] ] },
|
||||||
"hallOfDarkness" : { "index" : 3, "creatures" : [ [ "blackKnight" ] ], "guards" : true },
|
"hallOfDarkness" : { "index" : 3, "creatures" : [ [ "blackKnight" ] ]},
|
||||||
"dragonVault" : { "index" : 4, "creatures" : [ [ "boneDragon" ] ], "guards" : true },
|
"dragonVault" : { "index" : 4, "creatures" : [ [ "boneDragon" ] ]},
|
||||||
"trainingGrounds" : { "index" : 5, "creatures" : [ [ "cavalier" ] ], "guards" : true },
|
"trainingGrounds" : { "index" : 5, "creatures" : [ [ "cavalier" ] ]},
|
||||||
"centaurStables" : { "index" : 6, "creatures" : [ [ "centaur" ] ] },
|
"centaurStables" : { "index" : 6, "creatures" : [ [ "centaur" ] ] },
|
||||||
"airConflux" : { "index" : 7, "creatures" : [ [ "airElemental" ] ] },
|
"airConflux" : { "index" : 7, "creatures" : [ [ "airElemental" ] ] },
|
||||||
"portalOfGlory" : { "index" : 8, "creatures" : [ [ "angel" ] ], "guards" : true },
|
"portalOfGlory" : { "index" : 8, "creatures" : [ [ "angel" ] ]},
|
||||||
"cyclopsCave" : { "index" : 9, "creatures" : [ [ "cyclop" ] ], "guards" : true },
|
"cyclopsCave" : { "index" : 9, "creatures" : [ [ "cyclop" ] ]},
|
||||||
"forsakenPalace" : { "index" : 10, "creatures" : [ [ "devil" ] ], "guards" : true },
|
"forsakenPalace" : { "index" : 10, "creatures" : [ [ "devil" ] ]},
|
||||||
"serpentFlyHive" : { "index" : 11, "creatures" : [ [ "serpentFly" ] ] },
|
"serpentFlyHive" : { "index" : 11, "creatures" : [ [ "serpentFly" ] ] },
|
||||||
"dwarfCottage" : { "index" : 12, "creatures" : [ [ "dwarf" ] ] },
|
"dwarfCottage" : { "index" : 12, "creatures" : [ [ "dwarf" ] ] },
|
||||||
"earthConflux" : { "index" : 13, "creatures" : [ [ "earthElemental" ] ], "guards" : true },
|
"earthConflux" : { "index" : 13, "creatures" : [ [ "earthElemental" ] ]},
|
||||||
"fireLake" : { "index" : 14, "creatures" : [ [ "efreet" ] ], "guards" : true },
|
"fireLake" : { "index" : 14, "creatures" : [ [ "efreet" ] ]},
|
||||||
"homestead" : { "index" : 15, "creatures" : [ [ "woodElf" ] ] },
|
"homestead" : { "index" : 15, "creatures" : [ [ "woodElf" ] ] },
|
||||||
"fireConflux" : { "index" : 16, "creatures" : [ [ "fireElemental" ] ] },
|
"fireConflux" : { "index" : 16, "creatures" : [ [ "fireElemental" ] ] },
|
||||||
"parapet" : { "index" : 17, "creatures" : [ [ "stoneGargoyle" ] ] },
|
"parapet" : { "index" : 17, "creatures" : [ [ "stoneGargoyle" ] ] },
|
||||||
"altarOfWishes" : { "index" : 18, "creatures" : [ [ "genie" ] ], "guards" : true },
|
"altarOfWishes" : { "index" : 18, "creatures" : [ [ "genie" ] ]},
|
||||||
"wolfPen" : { "index" : 19, "creatures" : [ [ "goblinWolfRider" ] ] },
|
"wolfPen" : { "index" : 19, "creatures" : [ [ "goblinWolfRider" ] ] },
|
||||||
"gnollHut" : { "index" : 20, "creatures" : [ [ "gnoll" ] ] },
|
"gnollHut" : { "index" : 20, "creatures" : [ [ "gnoll" ] ] },
|
||||||
"goblinBarracks" : { "index" : 21, "creatures" : [ [ "goblin" ] ] },
|
"goblinBarracks" : { "index" : 21, "creatures" : [ [ "goblin" ] ] },
|
||||||
"hallOfSins" : { "index" : 22, "creatures" : [ [ "gog" ] ] },
|
"hallOfSins" : { "index" : 22, "creatures" : [ [ "gog" ] ] },
|
||||||
"gorgonLair" : { "index" : 23, "creatures" : [ [ "gorgon" ] ], "guards" : true },
|
"gorgonLair" : { "index" : 23, "creatures" : [ [ "gorgon" ] ]},
|
||||||
"dragonCliffs" : { "index" : 24, "creatures" : [ [ "greenDragon" ] ], "guards" : true },
|
"dragonCliffs" : { "index" : 24, "creatures" : [ [ "greenDragon" ] ]},
|
||||||
"griffinTower" : { "index" : 25, "creatures" : [ [ "griffin" ] ] },
|
"griffinTower" : { "index" : 25, "creatures" : [ [ "griffin" ] ] },
|
||||||
"harpyLoft" : { "index" : 26, "creatures" : [ [ "harpy" ] ] },
|
"harpyLoft" : { "index" : 26, "creatures" : [ [ "harpy" ] ] },
|
||||||
"kennels" : { "index" : 27, "creatures" : [ [ "hellHound" ] ] },
|
"kennels" : { "index" : 27, "creatures" : [ [ "hellHound" ] ] },
|
||||||
"hydraPond" : { "index" : 28, "creatures" : [ [ "hydra" ] ], "guards" : true },
|
"hydraPond" : { "index" : 28, "creatures" : [ [ "hydra" ] ]},
|
||||||
"impCrucible" : { "index" : 29, "creatures" : [ [ "imp" ] ] },
|
"impCrucible" : { "index" : 29, "creatures" : [ [ "imp" ] ] },
|
||||||
"lizardDen" : { "index" : 30, "creatures" : [ [ "lizardman" ] ] },
|
"lizardDen" : { "index" : 30, "creatures" : [ [ "lizardman" ] ] },
|
||||||
"mageTower" : { "index" : 31, "creatures" : [ [ "mage" ] ] },
|
"mageTower" : { "index" : 31, "creatures" : [ [ "mage" ] ] },
|
||||||
"manticoreLair" : { "index" : 32, "creatures" : [ [ "manticore" ] ], "guards" : true },
|
"manticoreLair" : { "index" : 32, "creatures" : [ [ "manticore" ] ]},
|
||||||
"medusaChapel" : { "index" : 33, "creatures" : [ [ "medusa" ] ] },
|
"medusaChapel" : { "index" : 33, "creatures" : [ [ "medusa" ] ] },
|
||||||
"labyrinth" : { "index" : 34, "creatures" : [ [ "minotaur" ] ], "guards" : true },
|
"labyrinth" : { "index" : 34, "creatures" : [ [ "minotaur" ] ]},
|
||||||
"monastery" : { "index" : 35, "creatures" : [ [ "monk" ] ], "guards" : true },
|
"monastery" : { "index" : 35, "creatures" : [ [ "monk" ] ]},
|
||||||
"goldenPavilion" : { "index" : 36, "creatures" : [ [ "naga" ] ], "guards" : true },
|
"goldenPavilion" : { "index" : 36, "creatures" : [ [ "naga" ] ]},
|
||||||
"demonGate" : { "index" : 37, "creatures" : [ [ "demon" ] ] },
|
"demonGate" : { "index" : 37, "creatures" : [ [ "demon" ] ] },
|
||||||
"ogreFort" : { "index" : 38, "creatures" : [ [ "ogre" ] ] },
|
"ogreFort" : { "index" : 38, "creatures" : [ [ "ogre" ] ] },
|
||||||
"orcTower" : { "index" : 39, "creatures" : [ [ "orc" ] ] },
|
"orcTower" : { "index" : 39, "creatures" : [ [ "orc" ] ] },
|
||||||
"hellHole" : { "index" : 40, "creatures" : [ [ "pitFiend" ] ], "guards" : true },
|
"hellHole" : { "index" : 40, "creatures" : [ [ "pitFiend" ] ]},
|
||||||
"dragonCave" : { "index" : 41, "creatures" : [ [ "redDragon" ] ], "guards" : true },
|
"dragonCave" : { "index" : 41, "creatures" : [ [ "redDragon" ] ]},
|
||||||
"cliffNest" : { "index" : 42, "creatures" : [ [ "roc" ] ], "guards" : true },
|
"cliffNest" : { "index" : 42, "creatures" : [ [ "roc" ] ]},
|
||||||
"workshop" : { "index" : 43, "creatures" : [ [ "gremlin" ] ] },
|
"workshop" : { "index" : 43, "creatures" : [ [ "gremlin" ] ] },
|
||||||
"cloudTemple" : { "index" : 44, "creatures" : [ [ "giant" ] ], "guards" : true },
|
"cloudTemple" : { "index" : 44, "creatures" : [ [ "giant" ] ]},
|
||||||
"dendroidArches" : { "index" : 45, "creatures" : [ [ "dendroidGuard" ] ], "guards" : true },
|
"dendroidArches" : { "index" : 45, "creatures" : [ [ "dendroidGuard" ] ]},
|
||||||
"warren" : { "index" : 46, "creatures" : [ [ "troglodyte" ] ] },
|
"warren" : { "index" : 46, "creatures" : [ [ "troglodyte" ] ] },
|
||||||
"waterConflux" : { "index" : 47, "creatures" : [ [ "waterElemental" ] ] },
|
"waterConflux" : { "index" : 47, "creatures" : [ [ "waterElemental" ] ] },
|
||||||
"tombOfSouls" : { "index" : 48, "creatures" : [ [ "wight" ] ] },
|
"tombOfSouls" : { "index" : 48, "creatures" : [ [ "wight" ] ] },
|
||||||
"wyvernNest" : { "index" : 49, "creatures" : [ [ "wyvern" ] ], "guards" : true },
|
"wyvernNest" : { "index" : 49, "creatures" : [ [ "wyvern" ] ]},
|
||||||
"enchantedSpring" : { "index" : 50, "creatures" : [ [ "pegasus" ] ] },
|
"enchantedSpring" : { "index" : 50, "creatures" : [ [ "pegasus" ] ] },
|
||||||
"unicornGladeBig" : { "index" : 51, "creatures" : [ [ "unicorn" ] ], "guards" : true },
|
"unicornGladeBig" : { "index" : 51, "creatures" : [ [ "unicorn" ] ]},
|
||||||
"mausoleum" : { "index" : 52, "creatures" : [ [ "lich" ] ], "guards" : true },
|
"mausoleum" : { "index" : 52, "creatures" : [ [ "lich" ] ]},
|
||||||
"estate" : { "index" : 53, "creatures" : [ [ "vampire" ] ] },
|
"estate" : { "index" : 53, "creatures" : [ [ "vampire" ] ] },
|
||||||
"cursedTemple" : { "index" : 54, "creatures" : [ [ "skeleton" ] ] },
|
"cursedTemple" : { "index" : 54, "creatures" : [ [ "skeleton" ] ] },
|
||||||
"graveyard" : { "index" : 55, "creatures" : [ [ "walkingDead" ] ] },
|
"graveyard" : { "index" : 55, "creatures" : [ [ "walkingDead" ] ] },
|
||||||
@ -69,17 +69,17 @@
|
|||||||
"archersTower" : { "index" : 57, "creatures" : [ [ "archer" ] ] },
|
"archersTower" : { "index" : 57, "creatures" : [ [ "archer" ] ] },
|
||||||
"barracks" : { "index" : 58, "creatures" : [ [ "swordsman" ] ] },
|
"barracks" : { "index" : 58, "creatures" : [ [ "swordsman" ] ] },
|
||||||
"magicLantern" : { "index" : 59, "creatures" : [ [ "pixie" ] ] },
|
"magicLantern" : { "index" : 59, "creatures" : [ [ "pixie" ] ] },
|
||||||
"altarOfThought" : { "index" : 60, "creatures" : [ [ "psychicElemental" ] ], "guards" : true },
|
"altarOfThought" : { "index" : 60, "creatures" : [ [ "psychicElemental" ] ]},
|
||||||
"pyre" : { "index" : 61, "creatures" : [ [ "firebird" ] ], "guards" : true },
|
"pyre" : { "index" : 61, "creatures" : [ [ "firebird" ] ]},
|
||||||
"frozenCliffs" : { "index" : 62, "creatures" : [ [ "azureDragon" ] ], "guards" : true },
|
"frozenCliffs" : { "index" : 62, "creatures" : [ [ "azureDragon" ] ]},
|
||||||
"crystalCavern" : { "index" : 63, "creatures" : [ [ "crystalDragon" ] ], "guards" : true },
|
"crystalCavern" : { "index" : 63, "creatures" : [ [ "crystalDragon" ] ]},
|
||||||
"magicForest" : { "index" : 64, "creatures" : [ [ "fairieDragon" ] ], "guards" : true },
|
"magicForest" : { "index" : 64, "creatures" : [ [ "fairieDragon" ] ]},
|
||||||
"sulfurousLair" : { "index" : 65, "creatures" : [ [ "rustDragon" ] ], "guards" : true },
|
"sulfurousLair" : { "index" : 65, "creatures" : [ [ "rustDragon" ] ]},
|
||||||
"enchantersHollow" : { "index" : 66, "creatures" : [ [ "enchanter" ] ], "guards" : true },
|
"enchantersHollow" : { "index" : 66, "creatures" : [ [ "enchanter" ] ]},
|
||||||
"treetopTower" : { "index" : 67, "creatures" : [ [ "sharpshooter" ] ], "guards" : true },
|
"treetopTower" : { "index" : 67, "creatures" : [ [ "sharpshooter" ] ]},
|
||||||
"unicornGlade" : { "index" : 68, "creatures" : [ [ "unicorn" ] ], "guards" : true },
|
"unicornGlade" : { "index" : 68, "creatures" : [ [ "unicorn" ] ]},
|
||||||
"altarOfAir" : { "index" : 69, "creatures" : [ [ "airElemental" ] ] },
|
"altarOfAir" : { "index" : 69, "creatures" : [ [ "airElemental" ] ] },
|
||||||
"altarOfEarth" : { "index" : 70, "creatures" : [ [ "earthElemental" ] ], "guards" : true },
|
"altarOfEarth" : { "index" : 70, "creatures" : [ [ "earthElemental" ] ]},
|
||||||
"altarOfFire" : { "index" : 71, "creatures" : [ [ "fireElemental" ] ] },
|
"altarOfFire" : { "index" : 71, "creatures" : [ [ "fireElemental" ] ] },
|
||||||
"altarOfWater" : { "index" : 72, "creatures" : [ [ "waterElemental" ] ] },
|
"altarOfWater" : { "index" : 72, "creatures" : [ [ "waterElemental" ] ] },
|
||||||
"thatchedHut" : { "index" : 73, "creatures" : [ [ "halfling" ] ] },
|
"thatchedHut" : { "index" : 73, "creatures" : [ [ "halfling" ] ] },
|
||||||
@ -88,7 +88,7 @@
|
|||||||
"tombOfCurses" : { "index" : 76, "creatures" : [ [ "mummy" ] ] },
|
"tombOfCurses" : { "index" : 76, "creatures" : [ [ "mummy" ] ] },
|
||||||
"nomadTent" : { "index" : 77, "creatures" : [ [ "nomad" ] ] },
|
"nomadTent" : { "index" : 77, "creatures" : [ [ "nomad" ] ] },
|
||||||
"rogueCavern" : { "index" : 78, "creatures" : [ [ "rogue" ] ] },
|
"rogueCavern" : { "index" : 78, "creatures" : [ [ "rogue" ] ] },
|
||||||
"trollBridge" : { "index" : 79, "creatures" : [ [ "troll" ] ], "guards" : true }
|
"trollBridge" : { "index" : 79, "creatures" : [ [ "troll" ] ] }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// subtype: unique special dwellings - golem factory and elemental conflux
|
// subtype: unique special dwellings - golem factory and elemental conflux
|
||||||
|
@ -171,6 +171,51 @@ void CGDwelling::newTurn() const
|
|||||||
|
|
||||||
if(change)
|
if(change)
|
||||||
cb->sendAndApply(&sac);
|
cb->sendAndApply(&sac);
|
||||||
|
|
||||||
|
updateGuards();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGDwelling::updateGuards() const
|
||||||
|
{
|
||||||
|
//TODO: store custom guard config and use it
|
||||||
|
//TODO: store boolean flag for guards
|
||||||
|
|
||||||
|
bool guarded = false;
|
||||||
|
//default condition - creatures are of level 5 or higher
|
||||||
|
for (auto creatureEntry : creatures)
|
||||||
|
{
|
||||||
|
if (VLC->creh->creatures[creatureEntry.second.at(0)]->level >= 5)
|
||||||
|
{
|
||||||
|
guarded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (guarded)
|
||||||
|
{
|
||||||
|
for (auto creatureEntry : creatures)
|
||||||
|
{
|
||||||
|
const CCreature * crea = VLC->creh->creatures[creatureEntry.second.at(0)];
|
||||||
|
|
||||||
|
SlotID slot = getSlotFor(crea->idNumber);
|
||||||
|
StackLocation stackLocation = StackLocation(this, slot);;
|
||||||
|
if (hasStackAtSlot(slot)) //stack already exists, overwrite it
|
||||||
|
{
|
||||||
|
ChangeStackCount csc;
|
||||||
|
csc.sl = stackLocation;
|
||||||
|
csc.count = crea->growth * 3;
|
||||||
|
csc.absoluteValue = true;
|
||||||
|
cb->sendAndApply(&csc);
|
||||||
|
}
|
||||||
|
else //slot is empty, create whole new stack
|
||||||
|
{
|
||||||
|
InsertNewStack ns;
|
||||||
|
ns.sl = stackLocation;
|
||||||
|
ns.stack = CStackBasicDescriptor(crea->idNumber, crea->growth * 3);
|
||||||
|
cb->sendAndApply(&ns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h) const
|
void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h) const
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
|
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateGuards() const;
|
||||||
void heroAcceptsCreatures(const CGHeroInstance *h) const;
|
void heroAcceptsCreatures(const CGHeroInstance *h) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,18 +196,42 @@ void CDwellingInstanceConstructor::configureObject(CGObjectInstance * object, CR
|
|||||||
dwelling->creatures.back().second.push_back(cre->idNumber);
|
dwelling->creatures.back().second.push_back(cre->idNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guards.getType() == JsonNode::DATA_BOOL)
|
bool guarded = false; //TODO: serialize for sanity
|
||||||
|
|
||||||
|
if (guards.getType() == JsonNode::DATA_BOOL) //simple switch
|
||||||
{
|
{
|
||||||
if (guards.Bool())
|
if (guards.Bool())
|
||||||
{
|
{
|
||||||
const CCreature * crea = availableCreatures.at(0).at(0);
|
guarded = true;
|
||||||
dwelling->putStack(SlotID(0), new CStackInstance(crea->idNumber, crea->growth * 3 ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else for (auto & stack : JsonRandom::loadCreatures(guards, rng))
|
else if (guards.getType() == JsonNode::DATA_VECTOR) //custom guards (eg. Elemental Conflux)
|
||||||
|
{
|
||||||
|
for (auto & stack : JsonRandom::loadCreatures(guards, rng))
|
||||||
{
|
{
|
||||||
dwelling->putStack(SlotID(dwelling->stacksCount()), new CStackInstance(stack.type->idNumber, stack.count));
|
dwelling->putStack(SlotID(dwelling->stacksCount()), new CStackInstance(stack.type->idNumber, stack.count));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else //default condition - creatures are of level 5 or higher
|
||||||
|
{
|
||||||
|
for (auto creatureEntry : availableCreatures)
|
||||||
|
{
|
||||||
|
if (creatureEntry.at(0)->level >= 5)
|
||||||
|
{
|
||||||
|
guarded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (guarded)
|
||||||
|
{
|
||||||
|
for (auto creatureEntry : availableCreatures)
|
||||||
|
{
|
||||||
|
const CCreature * crea = creatureEntry.at(0);
|
||||||
|
dwelling->putStack (SlotID(dwelling->stacksCount()), new CStackInstance(crea->idNumber, crea->growth * 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDwellingInstanceConstructor::producesCreature(const CCreature * crea) const
|
bool CDwellingInstanceConstructor::producesCreature(const CCreature * crea) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user