From f01e30a3b1d6bd8a0ae5754eb6dbfa881776ee98 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 27 Jun 2014 19:08:36 +0300 Subject: [PATCH] Added random objects to configs. For now as separate "random handlers", should be merged into main handlers later --- config/objects/generic.json | 34 ++++++++++++------------ config/objects/moddables.json | 29 ++++++++++++++++++-- lib/mapObjects/CObjectClassesHandler.cpp | 8 ++++++ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/config/objects/generic.json b/config/objects/generic.json index f916b5be0..54e6132b1 100644 --- a/config/objects/generic.json +++ b/config/objects/generic.json @@ -64,26 +64,26 @@ }, /// Random objects - "randomResource" : { "index" :76, "handler": "resource" }, - "randomTown" : { "index" :77, "handler": "town" }, - "randomHero" : { "index" :70, "handler": "hero" }, + "randomResource" : { "index" :76, "handler": "randomResource", "types" : { "object" : { "index" : 0} } }, + "randomTown" : { "index" :77, "handler": "randomTown", "types" : { "object" : { "index" : 0} } }, + "randomHero" : { "index" :70, "handler": "randomHero", "types" : { "object" : { "index" : 0} } }, - "randomDwelling" : { "index" :216, "handler": "dwelling" }, + "randomDwelling" : { "index" :216, "handler": "randomDwelling", "types" : { "object" : { "index" : 0} } }, - "randomArtifact" : { "index" :65, "handler": "artifact" }, - "randomArtifactTreasure" : { "index" :66, "handler": "artifact" }, - "randomArtifactMinor" : { "index" :67, "handler": "artifact" }, - "randomArtifactMajor" : { "index" :68, "handler": "artifact" }, - "randomArtifactRelic" : { "index" :69, "handler": "artifact" }, + "randomArtifact" : { "index" :65, "handler": "randomArtifact", "types" : { "object" : { "index" : 0} } }, + "randomArtifactTreasure" : { "index" :66, "handler": "randomArtifact", "types" : { "object" : { "index" : 0} } }, + "randomArtifactMinor" : { "index" :67, "handler": "randomArtifact", "types" : { "object" : { "index" : 0} } }, + "randomArtifactMajor" : { "index" :68, "handler": "randomArtifact", "types" : { "object" : { "index" : 0} } }, + "randomArtifactRelic" : { "index" :69, "handler": "randomArtifact", "types" : { "object" : { "index" : 0} } }, - "randomMonster" : { "index" :71, "handler": "monster" }, - "randomMonsterLevel1" : { "index" :72, "handler": "monster" }, - "randomMonsterLevel2" : { "index" :73, "handler": "monster" }, - "randomMonsterLevel3" : { "index" :74, "handler": "monster" }, - "randomMonsterLevel4" : { "index" :75, "handler": "monster" }, - "randomMonsterLevel5" : { "index" :162, "handler": "monster" }, - "randomMonsterLevel6" : { "index" :163, "handler": "monster" }, - "randomMonsterLevel7" : { "index" :164, "handler": "monster" }, + "randomMonster" : { "index" :71, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel1" : { "index" :72, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel2" : { "index" :73, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel3" : { "index" :74, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel4" : { "index" :75, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel5" : { "index" :162, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel6" : { "index" :163, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, + "randomMonsterLevel7" : { "index" :164, "handler": "randomMonster", "types" : { "object" : { "index" : 0} } }, /// Classes without dedicated object "hillFort" : { "index" :35, "handler": "generic", "types" : { "object" : { "index" : 0} } }, diff --git a/config/objects/moddables.json b/config/objects/moddables.json index 51268b93c..a93481eb5 100644 --- a/config/objects/moddables.json +++ b/config/objects/moddables.json @@ -236,10 +236,35 @@ "seerHut" : { "index" :83, "handler": "seerHut" }, // subtype: level - "randomDwellingLvl" : { "index" :217, "handler": "dwelling" }, + "randomDwellingLvl" : { + "index" :217, "handler": "randomDwelling", + "types" : { + "objectLvl1" : { "index" : 0}, + "objectLvl2" : { "index" : 1}, + "objectLvl3" : { "index" : 2}, + "objectLvl4" : { "index" : 3}, + "objectLvl5" : { "index" : 4}, + "objectLvl6" : { "index" : 5}, + "objectLvl7" : { "index" : 6} + } + }, // subtype: faction ID - "randomDwellingFaction" : { "index" :218, "handler": "dwelling" }, + "randomDwellingFaction" : { + "index" :218, + "handler": "randomDwelling", + "types" : { + "objectCastle" : { "index" : 0}, + "objectRampart" : { "index" : 1}, + "objectTower" : { "index" : 2}, + "objectInferno" : { "index" : 3}, + "objectNecropolis" : { "index" : 4}, + "objectDungeon" : { "index" : 5}, + "objectStronghold" : { "index" : 6}, + "objectFortress" : { "index" : 7}, + "objectCastle" : { "index" : 8}, + } + }, // don't have subtypes (at least now), but closely connected to this objects "spellScroll" : { "index" :93, "handler": "artifact" }, diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index e543a70ee..ed74a8933 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -40,6 +40,13 @@ CObjectClassesHandler::CObjectClassesHandler() SET_HANDLER_CLASS("static", CObstacleConstructor); SET_HANDLER_CLASS("", CObstacleConstructor); + SET_HANDLER("randomArtifact", CGArtifact); + SET_HANDLER("randomHero", CGHeroInstance); + SET_HANDLER("randomResource", CGResource); + SET_HANDLER("randomTown", CGTownInstance); + SET_HANDLER("randomMonster", CGCreature); + SET_HANDLER("randomDwelling", CGDwelling); + SET_HANDLER("generic", CGObjectInstance); SET_HANDLER("market", CGMarket); SET_HANDLER("cartographer", CCartographer); @@ -67,6 +74,7 @@ CObjectClassesHandler::CObjectClassesHandler() SET_HANDLER("pandora", CGPandoraBox); SET_HANDLER("pickable", CGPickable); SET_HANDLER("prison", CGHeroInstance); + SET_HANDLER("prison", CGHeroInstance); SET_HANDLER("questGuard", CGQuestGuard); SET_HANDLER("resource", CGResource); SET_HANDLER("scholar", CGScholar);