mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	- trade windows work with new creatures\artifacts
- removed some duplicated code in creature loading
This commit is contained in:
		| @@ -1938,16 +1938,17 @@ void CObjectListWindow::keyPressed (const SDL_KeyboardEvent & key) | |||||||
| 	changeSelection(sel); | 	changeSelection(sel); | ||||||
| } | } | ||||||
|  |  | ||||||
| CTradeWindow::CTradeableItem::CTradeableItem( EType Type, int ID, bool Left, int Serial): | CTradeWindow::CTradeableItem::CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial): | ||||||
|     type(Type), |     CIntObject(LCLICK | HOVER | RCLICK, pos), | ||||||
|  |     type(EType(-1)),// set to invalid, will be corrected in setType | ||||||
|     id(ID), |     id(ID), | ||||||
|     serial(Serial), |     serial(Serial), | ||||||
|     left(Left) |     left(Left) | ||||||
| { | { | ||||||
| 	addUsedEvents(LCLICK | HOVER | RCLICK); |  | ||||||
| 	downSelection = false; | 	downSelection = false; | ||||||
| 	hlp = NULL; | 	hlp = NULL; | ||||||
| 	image = nullptr; | 	image = nullptr; | ||||||
|  | 	setType(Type); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CTradeWindow::CTradeableItem::setType(EType newType) | void CTradeWindow::CTradeableItem::setType(EType newType) | ||||||
| @@ -1992,13 +1993,13 @@ std::string CTradeWindow::CTradeableItem::getFilename() | |||||||
| 	switch(type) | 	switch(type) | ||||||
| 	{ | 	{ | ||||||
| 	case RESOURCE: | 	case RESOURCE: | ||||||
| 		return "resource 32"; | 		return "RESOURCE"; | ||||||
| 	case PLAYER: | 	case PLAYER: | ||||||
| 		return "flags"; | 		return "CREST58"; | ||||||
| 	case ARTIFACT_TYPE: | 	case ARTIFACT_TYPE: | ||||||
| 	case ARTIFACT_PLACEHOLDER: | 	case ARTIFACT_PLACEHOLDER: | ||||||
| 	case ARTIFACT_INSTANCE: | 	case ARTIFACT_INSTANCE: | ||||||
| 		return "artdefs"; | 		return "artifact"; | ||||||
| 	case CREATURE: | 	case CREATURE: | ||||||
| 		return "crtport"; | 		return "crtport"; | ||||||
| 	default: | 	default: | ||||||
| @@ -2057,7 +2058,7 @@ void CTradeWindow::CTradeableItem::showAll(SDL_Surface * to) | |||||||
|  |  | ||||||
| 	if (image) | 	if (image) | ||||||
| 	{ | 	{ | ||||||
| 		image->moveTo(posToBitmap); | 		image->moveTo(pos.topLeft() + posToBitmap); | ||||||
| 		image->showAll(to); | 		image->showAll(to); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -2121,12 +2122,12 @@ void CTradeWindow::CTradeableItem::showAllAt(const Point &dstPos, const std::str | |||||||
| 	std::string oldSub = subtitle; | 	std::string oldSub = subtitle; | ||||||
| 	downSelection = true; | 	downSelection = true; | ||||||
|  |  | ||||||
| 	pos = dstPos; | 	moveTo(dstPos); | ||||||
| 	subtitle = customSub; | 	subtitle = customSub; | ||||||
| 	showAll(to); | 	showAll(to); | ||||||
|  |  | ||||||
| 	downSelection = false; | 	downSelection = false; | ||||||
| 	pos = oldPos; | 	moveTo(oldPos.topLeft()); | ||||||
| 	subtitle = oldSub; | 	subtitle = oldSub; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -2274,9 +2275,8 @@ void CTradeWindow::initItems(bool Left) | |||||||
| 			xOffset = -361; | 			xOffset = -361; | ||||||
| 			yOffset = +46; | 			yOffset = +46; | ||||||
|  |  | ||||||
| 			CTradeableItem *hlp = new CTradeableItem(itemsType[Left], -1, 1, 0); | 			CTradeableItem *hlp = new CTradeableItem(Point(137, 469), itemsType[Left], -1, 1, 0); | ||||||
| 			hlp->recActions &= ~(UPDATE | SHOWALL); | 			hlp->recActions &= ~(UPDATE | SHOWALL); | ||||||
| 			hlp->pos += Rect(137, 469, 42, 42); |  | ||||||
| 			items[Left].push_back(hlp); | 			items[Left].push_back(hlp); | ||||||
| 		} | 		} | ||||||
| 		else //ARTIFACT_EXP | 		else //ARTIFACT_EXP | ||||||
| @@ -2320,8 +2320,8 @@ void CTradeWindow::initItems(bool Left) | |||||||
| 		if(id < 0 && mode != EMarketMode::ARTIFACT_EXP)  //when sacrificing artifacts we need to prepare empty slots | 		if(id < 0 && mode != EMarketMode::ARTIFACT_EXP)  //when sacrificing artifacts we need to prepare empty slots | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		CTradeableItem *hlp = new CTradeableItem(itemsType[Left], id, Left, j); | 		CTradeableItem *hlp = new CTradeableItem(pos[j].topLeft(), itemsType[Left], id, Left, j); | ||||||
| 		hlp->pos = pos[j] + hlp->pos; | 		hlp->pos = pos[j] + this->pos.topLeft(); | ||||||
| 		items[Left].push_back(hlp); | 		items[Left].push_back(hlp); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -3017,6 +3017,7 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= | |||||||
|  |  | ||||||
| 		initItems(true); | 		initItems(true); | ||||||
| 		mimicCres(); | 		mimicCres(); | ||||||
|  | 		artIcon = nullptr; | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| @@ -3035,6 +3036,8 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*= | |||||||
|  |  | ||||||
| 		initItems(true); | 		initItems(true); | ||||||
| 		initItems(false); | 		initItems(false); | ||||||
|  | 		artIcon = new CAnimImage("ARTIFACT", 0, 0, 281, 442); | ||||||
|  | 		artIcon->disable(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	//Experience needed to reach next level | 	//Experience needed to reach next level | ||||||
| @@ -3198,8 +3201,8 @@ void CAltarWindow::mimicCres() | |||||||
|  |  | ||||||
| 	BOOST_FOREACH(CTradeableItem *t, items[1]) | 	BOOST_FOREACH(CTradeableItem *t, items[1]) | ||||||
| 	{ | 	{ | ||||||
| 		CTradeableItem *hlp = new CTradeableItem(CREATURE_PLACEHOLDER, t->id, false, t->serial); | 		CTradeableItem *hlp = new CTradeableItem(positions[t->serial].topLeft(), CREATURE_PLACEHOLDER, t->id, false, t->serial); | ||||||
| 		hlp->pos = positions[t->serial] + hlp->pos; | 		hlp->pos = positions[t->serial] + this->pos.topLeft(); | ||||||
| 		items[0].push_back(hlp); | 		items[0].push_back(hlp); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -3337,7 +3340,8 @@ void CAltarWindow::showAll(SDL_Surface * to) | |||||||
| 	CTradeWindow::showAll(to); | 	CTradeWindow::showAll(to); | ||||||
| 	if(mode == EMarketMode::ARTIFACT_EXP && arts && arts->commonInfo->src.art) | 	if(mode == EMarketMode::ARTIFACT_EXP && arts && arts->commonInfo->src.art) | ||||||
| 	{ | 	{ | ||||||
| 		blitAtLoc(graphics->artDefs->ourImages[arts->commonInfo->src.art->artType->id].bitmap, 281, 442, to); | 		artIcon->setFrame(arts->commonInfo->src.art->artType->id); | ||||||
|  | 		artIcon->showAll(to); | ||||||
|  |  | ||||||
| 		int dmp, val; | 		int dmp, val; | ||||||
| 		market->getOffer(arts->commonInfo->src.art->artType->id, 0, dmp, val, EMarketMode::ARTIFACT_EXP); | 		market->getOffer(arts->commonInfo->src.art->artType->id, 0, dmp, val, EMarketMode::ARTIFACT_EXP); | ||||||
|   | |||||||
| @@ -615,7 +615,7 @@ public: | |||||||
| 		void showAll(SDL_Surface * to); | 		void showAll(SDL_Surface * to); | ||||||
| 		void clickLeft(tribool down, bool previousState); | 		void clickLeft(tribool down, bool previousState); | ||||||
| 		std::string getName(int number = -1) const; | 		std::string getName(int number = -1) const; | ||||||
| 		CTradeableItem(EType Type, int ID, bool Left, int Serial); | 		CTradeableItem(Point pos, EType Type, int ID, bool Left, int Serial); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	const IMarket *market; | 	const IMarket *market; | ||||||
| @@ -687,6 +687,7 @@ public: | |||||||
|  |  | ||||||
| class CAltarWindow : public CTradeWindow | class CAltarWindow : public CTradeWindow | ||||||
| { | { | ||||||
|  | 	CAnimImage * artIcon; | ||||||
| public: | public: | ||||||
| 	CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode); //c-tor | 	CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode); //c-tor | ||||||
|  |  | ||||||
|   | |||||||
| @@ -120,18 +120,13 @@ void Graphics::initializeBattleGraphics() | |||||||
| } | } | ||||||
| Graphics::Graphics() | Graphics::Graphics() | ||||||
| { | { | ||||||
| 	CDefHandler *smi2; |  | ||||||
|  |  | ||||||
| 	std::vector<Task> tasks; //preparing list of graphics to load | 	std::vector<Task> tasks; //preparing list of graphics to load | ||||||
| 	tasks += boost::bind(&Graphics::loadFonts,this); | 	tasks += boost::bind(&Graphics::loadFonts,this); | ||||||
| 	tasks += boost::bind(&Graphics::loadPaletteAndColors,this); | 	tasks += boost::bind(&Graphics::loadPaletteAndColors,this); | ||||||
| 	tasks += boost::bind(&Graphics::loadHeroFlags,this); | 	tasks += boost::bind(&Graphics::loadHeroFlags,this); | ||||||
| 	tasks += boost::bind(&Graphics::initializeBattleGraphics,this); | 	tasks += boost::bind(&Graphics::initializeBattleGraphics,this); | ||||||
| 	tasks += boost::bind(&Graphics::loadErmuToPicture,this); | 	tasks += boost::bind(&Graphics::loadErmuToPicture,this); | ||||||
| 	tasks += GET_DEF_ESS(artDefs,"ARTIFACT.DEF"); |  | ||||||
| 	tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF"); | 	tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF"); | ||||||
| 	tasks += GET_DEF(smi2,"TWCRPORT.DEF"); |  | ||||||
| 	tasks += GET_DEF_ESS(flags,"CREST58.DEF"); |  | ||||||
| 	tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF"); | 	tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF"); | ||||||
| 	tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF"); | 	tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF"); | ||||||
|  |  | ||||||
| @@ -142,16 +137,6 @@ Graphics::Graphics() | |||||||
| 	{ | 	{ | ||||||
| 		CSDL_Ext::alphaTransform(heroMoveArrows->ourImages[y].bitmap); | 		CSDL_Ext::alphaTransform(heroMoveArrows->ourImages[y].bitmap); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	smi2->notFreeImgs = true; |  | ||||||
| 	for (size_t i=0; i<smi2->ourImages.size(); ++i) |  | ||||||
| 	{ |  | ||||||
| 		bigImgs[i-2] = smi2->ourImages[i].bitmap; |  | ||||||
| 	} |  | ||||||
| 	//hack for green color on big infernal troglodite image - Mantis #758 |  | ||||||
| 	SDL_Color green = {0x30, 0x5c, 0x20, SDL_ALPHA_OPAQUE}; |  | ||||||
| 	bigImgs[71]->format->palette->colors[7] = green; |  | ||||||
| 	delete smi2; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void Graphics::loadHeroAnims() | void Graphics::loadHeroAnims() | ||||||
|   | |||||||
| @@ -46,10 +46,8 @@ public: | |||||||
| 	SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256] | 	SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256] | ||||||
| 	SDL_Color * neutralColorPalette;  | 	SDL_Color * neutralColorPalette;  | ||||||
|  |  | ||||||
| 	CDefEssential * artDefs; //artifacts //TODO: move to CArtifact class |  | ||||||
| 	std::vector<CDefEssential *> flags1, flags2, flags3, flags4; //flags blitted on heroes when , | 	std::vector<CDefEssential *> flags1, flags2, flags3, flags4; //flags blitted on heroes when , | ||||||
| 	CDefEssential * resources32; //resources 32x32 | 	CDefEssential * resources32; //resources 32x32 | ||||||
| 	CDefEssential * flags; |  | ||||||
| 	CDefEssential * heroMoveArrows; | 	CDefEssential * heroMoveArrows; | ||||||
| 	std::map<std::string, CDefEssential *> heroAnims; // [hero class def name]  //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing | 	std::map<std::string, CDefEssential *> heroAnims; // [hero class def name]  //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing | ||||||
| 	std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3]  //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing | 	std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3]  //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing | ||||||
| @@ -59,8 +57,6 @@ public: | |||||||
| 	std::map<std::string, CDefEssential *> advmapobjGraphics; | 	std::map<std::string, CDefEssential *> advmapobjGraphics; | ||||||
| 	CDefEssential * getDef(const CGObjectInstance * obj); | 	CDefEssential * getDef(const CGObjectInstance * obj); | ||||||
| 	CDefEssential * getDef(const CGDefInfo * info); | 	CDefEssential * getDef(const CGDefInfo * info); | ||||||
| 	//creatures |  | ||||||
| 	std::map<int,SDL_Surface*> bigImgs; //creature ID -> big 58x64 img of creature; //ID=-2 is for blank (black) img; -1 for the border |  | ||||||
| 	//towns | 	//towns | ||||||
| 	std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type | 	std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type | ||||||
| 	//for battles | 	//for battles | ||||||
|   | |||||||
| @@ -317,80 +317,26 @@ void CCreatureHandler::loadCreatures() | |||||||
|  |  | ||||||
| 	BOOST_FOREACH(auto & node, config.Struct()) | 	BOOST_FOREACH(auto & node, config.Struct()) | ||||||
| 	{ | 	{ | ||||||
| 		const JsonNode &creature = node.second; | 		int creatureID = node.second["id"].Float(); | ||||||
| 		int creatureID = creature["id"].Float(); |  | ||||||
| 		const JsonNode *value; |  | ||||||
|  |  | ||||||
| 		// Set various creature properties |  | ||||||
| 		CCreature *c = creatures[creatureID]; | 		CCreature *c = creatures[creatureID]; | ||||||
| 		c->level = creature["level"].Float(); |  | ||||||
|  |  | ||||||
| 		c->animDefName = creature["defname"].String(); | 		BOOST_FOREACH(const JsonNode &ability, node.second["ability_remove"].Vector()) | ||||||
|  |  | ||||||
| 		VLC->modh->identifiers.requestIdentifier(std::string("faction.") + creature["faction"].String(), [=](si32 faction) |  | ||||||
| 		{ | 		{ | ||||||
| 			c->faction = faction; | 			RemoveAbility(c, ability); | ||||||
| 		}); | 		} | ||||||
|  | 		BOOST_FOREACH(const JsonNode &ability, node.second["abilities"].Vector()) | ||||||
| 		BOOST_FOREACH(const JsonNode &value, creature["upgrades"].Vector()) |  | ||||||
| 		{ | 		{ | ||||||
| 			VLC->modh->identifiers.requestIdentifier(std::string("creature.") + value.String(), [=](si32 identifier) | 			AddAbility(c, ability.Vector()); | ||||||
| 			{ |  | ||||||
| 				c->upgrades.insert(identifier); |  | ||||||
| 			}); |  | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		value = &creature["projectile_defname"]; | 		loadCreatureJson(c, node.second); | ||||||
| 		if (!value->isNull()) |  | ||||||
| 		{ |  | ||||||
| 			c->projectile = value->String(); |  | ||||||
|  |  | ||||||
| 			value = &creature["projectile_spin"]; |  | ||||||
| 			c->projectileSpin = value->Bool(); |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		value = &creature["ability_remove"];//remove first - arch devil |  | ||||||
| 		if (!value->isNull()) |  | ||||||
| 		{ |  | ||||||
| 			BOOST_FOREACH(const JsonNode &ability, value->Vector()) |  | ||||||
| 			{ |  | ||||||
| 				RemoveAbility(c, ability); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		value = &creature["abilities"]; |  | ||||||
| 		if (!value->isNull()) { |  | ||||||
| 			BOOST_FOREACH(const JsonNode &ability, value->Vector()) |  | ||||||
| 			{ |  | ||||||
| 				AddAbility(c, ability.Vector()); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		c->special = creature["special"].Bool(); |  | ||||||
| 		if ( c->special ) |  | ||||||
| 			notUsedMonsters.insert(c->idNumber); |  | ||||||
|  |  | ||||||
| 		const JsonNode & sounds = creature["sound"]; |  | ||||||
|  |  | ||||||
| #define GET_SOUND_VALUE(value_name) c->sounds.value_name = sounds[#value_name].String() |  | ||||||
| 		GET_SOUND_VALUE(attack); |  | ||||||
| 		GET_SOUND_VALUE(defend); |  | ||||||
| 		GET_SOUND_VALUE(killed); |  | ||||||
| 		GET_SOUND_VALUE(move); |  | ||||||
| 		GET_SOUND_VALUE(shoot); |  | ||||||
| 		GET_SOUND_VALUE(wince); |  | ||||||
| 		GET_SOUND_VALUE(ext1); |  | ||||||
| 		GET_SOUND_VALUE(ext2); |  | ||||||
| 		GET_SOUND_VALUE(startMoving); |  | ||||||
| 		GET_SOUND_VALUE(endMoving); |  | ||||||
| #undef GET_SOUND_VALUE |  | ||||||
|  |  | ||||||
| 		// Main reference name, e.g. royalGriffin | 		// Main reference name, e.g. royalGriffin | ||||||
| 		c->nameRef = node.first; | 		c->nameRef = node.first; | ||||||
| 		VLC->modh->identifiers.registerObject("creature." + node.first, c->idNumber); | 		VLC->modh->identifiers.registerObject("creature." + node.first, c->idNumber); | ||||||
|  |  | ||||||
| 		// Alternative names, if any | 		// Alternative names, if any | ||||||
| 		BOOST_FOREACH(const JsonNode &name, creature["extraNames"].Vector()) | 		BOOST_FOREACH(const JsonNode &name, node.second["extraNames"].Vector()) | ||||||
| 		{ | 		{ | ||||||
| 			VLC->modh->identifiers.registerObject("creature." + name.String(), c->idNumber); | 			VLC->modh->identifiers.registerObject("creature." + name.String(), c->idNumber); | ||||||
| 		} | 		} | ||||||
| @@ -618,7 +564,6 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
|  |  | ||||||
| 	cre->cost = Res::ResourceSet(node["cost"]); | 	cre->cost = Res::ResourceSet(node["cost"]); | ||||||
|  |  | ||||||
| 	cre->level = node["level"].Float(); |  | ||||||
| 	cre->fightValue = node["fightValue"].Float(); | 	cre->fightValue = node["fightValue"].Float(); | ||||||
| 	cre->AIValue = node["aiValue"].Float(); | 	cre->AIValue = node["aiValue"].Float(); | ||||||
| 	cre->growth = node["growth"].Float(); | 	cre->growth = node["growth"].Float(); | ||||||
| @@ -636,24 +581,6 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
| 	cre->ammMin = amounts["min"].Float(); | 	cre->ammMin = amounts["min"].Float(); | ||||||
| 	cre->ammMax = amounts["max"].Float(); | 	cre->ammMax = amounts["max"].Float(); | ||||||
|  |  | ||||||
| 	std::string factionStr = node["faction"].String(); |  | ||||||
| 	if (factionStr.empty()) |  | ||||||
| 		factionStr = "neutral"; //TODO: should be done in schema |  | ||||||
|  |  | ||||||
| 	VLC->modh->identifiers.requestIdentifier(std::string("faction.") + factionStr, [=](si32 faction) |  | ||||||
| 	{ |  | ||||||
| 		cre->faction = faction; |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	//optional |  | ||||||
| 	BOOST_FOREACH (auto & str, node["upgrades"].Vector()) |  | ||||||
| 	{ |  | ||||||
| 		VLC->modh->identifiers.requestIdentifier(std::string("creature.") + str.String(), [=](si32 identifier) |  | ||||||
| 		{ |  | ||||||
| 			cre->upgrades.insert(identifier); |  | ||||||
| 		}); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if (!node["shots"].isNull()) | 	if (!node["shots"].isNull()) | ||||||
| 		cre->addBonus(node["shots"].Float(), Bonus::SHOTS); | 		cre->addBonus(node["shots"].Float(), Bonus::SHOTS); | ||||||
|  |  | ||||||
| @@ -709,7 +636,6 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
| 	//graphics | 	//graphics | ||||||
|  |  | ||||||
| 	const JsonNode & graphics = node["graphics"]; | 	const JsonNode & graphics = node["graphics"]; | ||||||
| 	cre->animDefName = graphics["animation"].String(); |  | ||||||
| 	cre->timeBetweenFidgets = graphics["timeBetweenFidgets"].Float(); | 	cre->timeBetweenFidgets = graphics["timeBetweenFidgets"].Float(); | ||||||
| 	cre->troopCountLocationOffset = graphics["troopCountLocationOffset"].Float(); | 	cre->troopCountLocationOffset = graphics["troopCountLocationOffset"].Float(); | ||||||
| 	cre->attackClimaxFrame = graphics["attackClimaxFrame"].Float(); | 	cre->attackClimaxFrame = graphics["attackClimaxFrame"].Float(); | ||||||
| @@ -718,12 +644,8 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
| 	cre->walkAnimationTime = animationTime["walk"].Float(); | 	cre->walkAnimationTime = animationTime["walk"].Float(); | ||||||
| 	cre->attackAnimationTime = animationTime["attack"].Float(); | 	cre->attackAnimationTime = animationTime["attack"].Float(); | ||||||
| 	cre->flightAnimationDistance = animationTime["flight"].Float(); //? | 	cre->flightAnimationDistance = animationTime["flight"].Float(); //? | ||||||
| 	//TODO: background? |  | ||||||
| 	const JsonNode & missile = graphics["missile"]; |  | ||||||
| 	//TODO: parse |  | ||||||
| 	cre->projectile = missile["projectile"].String(); |  | ||||||
| 	cre->projectileSpin = missile["spinning"].Bool(); |  | ||||||
|  |  | ||||||
|  | 	const JsonNode & missile = graphics["missile"]; | ||||||
| 	const JsonNode & offsets = missile["offset"]; | 	const JsonNode & offsets = missile["offset"]; | ||||||
| 	cre->upperRightMissleOffsetX = offsets["upperX"].Float(); | 	cre->upperRightMissleOffsetX = offsets["upperX"].Float(); | ||||||
| 	cre->upperRightMissleOffsetY = offsets["upperY"].Float(); | 	cre->upperRightMissleOffsetY = offsets["upperY"].Float(); | ||||||
| @@ -739,9 +661,38 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
| 	cre->advMapDef = graphics["map"].String(); | 	cre->advMapDef = graphics["map"].String(); | ||||||
| 	cre->iconIndex = graphics["iconIndex"].Float(); | 	cre->iconIndex = graphics["iconIndex"].Float(); | ||||||
|  |  | ||||||
| 	const JsonNode & sounds = node["sound"]; | 	loadCreatureJson(cre, node); | ||||||
|  | 	return cre; | ||||||
|  | } | ||||||
|  |  | ||||||
| #define GET_SOUND_VALUE(value_name) do { cre->sounds.value_name = sounds[#value_name].String(); } while(0) | void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & config) | ||||||
|  | { | ||||||
|  | 	creature->level = config["level"].Float(); | ||||||
|  | 	creature->animDefName = config["graphics"]["animation"].String(); | ||||||
|  |  | ||||||
|  | 	VLC->modh->identifiers.requestIdentifier(std::string("faction.") + config["faction"].String(), [=](si32 faction) | ||||||
|  | 	{ | ||||||
|  | 		creature->faction = faction; | ||||||
|  | 	}); | ||||||
|  |  | ||||||
|  | 	BOOST_FOREACH(const JsonNode &value, config["upgrades"].Vector()) | ||||||
|  | 	{ | ||||||
|  | 		VLC->modh->identifiers.requestIdentifier(std::string("creature.") + value.String(), [=](si32 identifier) | ||||||
|  | 		{ | ||||||
|  | 			creature->upgrades.insert(identifier); | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	creature->projectile = config["graphics"]["missile"]["projectile"].String(); | ||||||
|  | 	creature->projectileSpin = config["graphics"]["missile"]["spinning"].Bool(); | ||||||
|  |  | ||||||
|  | 	creature->special = config["special"].Bool(); | ||||||
|  | 	if ( creature->special ) | ||||||
|  | 		notUsedMonsters.insert(creature->idNumber); | ||||||
|  |  | ||||||
|  | 	const JsonNode & sounds = config["sound"]; | ||||||
|  |  | ||||||
|  | #define GET_SOUND_VALUE(value_name) creature->sounds.value_name = sounds[#value_name].String() | ||||||
| 	GET_SOUND_VALUE(attack); | 	GET_SOUND_VALUE(attack); | ||||||
| 	GET_SOUND_VALUE(defend); | 	GET_SOUND_VALUE(defend); | ||||||
| 	GET_SOUND_VALUE(killed); | 	GET_SOUND_VALUE(killed); | ||||||
| @@ -753,8 +704,6 @@ CCreature * CCreatureHandler::loadCreature(const JsonNode & node) | |||||||
| 	GET_SOUND_VALUE(startMoving); | 	GET_SOUND_VALUE(startMoving); | ||||||
| 	GET_SOUND_VALUE(endMoving); | 	GET_SOUND_VALUE(endMoving); | ||||||
| #undef GET_SOUND_VALUE | #undef GET_SOUND_VALUE | ||||||
|  |  | ||||||
| 	return cre; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigParser & parser) //help function for parsing CREXPBON.txt | void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigParser & parser) //help function for parsing CREXPBON.txt | ||||||
|   | |||||||
| @@ -125,9 +125,11 @@ public: | |||||||
|  |  | ||||||
| class DLL_LINKAGE CCreatureHandler | class DLL_LINKAGE CCreatureHandler | ||||||
| { | { | ||||||
| private: //? | private: | ||||||
| 	CBonusSystemNode allCreatures; | 	CBonusSystemNode allCreatures; | ||||||
| 	CBonusSystemNode creaturesOfLevel[GameConstants::CREATURES_PER_TOWN + 1];//index 0 is used for creatures of unknown tier or outside <1-7> range | 	CBonusSystemNode creaturesOfLevel[GameConstants::CREATURES_PER_TOWN + 1];//index 0 is used for creatures of unknown tier or outside <1-7> range | ||||||
|  |  | ||||||
|  | 	void loadCreatureJson(CCreature * creature, const JsonNode & config); | ||||||
| public: | public: | ||||||
| 	std::set<int> notUsedMonsters; | 	std::set<int> notUsedMonsters; | ||||||
| 	std::set<TCreature> doubledCreatures; //they get double week | 	std::set<TCreature> doubledCreatures; //they get double week | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user