mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* creature window prints morale/luck for actual stack in battle (CStack), not stack as seen in hero screen (CStackInstance), fixes #1264
* creature abilities bonus properties are updated when the creature id is assigned * removed decrease morale ability from config file (it was duplicating the one from ZCRTRAIT.TXT
This commit is contained in:
		| @@ -336,9 +336,9 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode * | ||||
|  | ||||
| 	//Stats | ||||
| 	morale = new MoraleLuckBox(true, genRect(42, 42, 335, 100)); | ||||
| 	morale->set(stack); | ||||
| 	morale->set(stackNode); | ||||
| 	luck = new MoraleLuckBox(false, genRect(42, 42, 387, 100)); | ||||
| 	luck->set(stack); | ||||
| 	luck->set(stackNode); | ||||
|  | ||||
| 	new CAnimImage("PSKIL42", 4, 0, 387, 51); //exp icon - Print it always? | ||||
| 	if (type) //not in fort window | ||||
|   | ||||
| @@ -362,12 +362,13 @@ | ||||
| 			{ | ||||
| 				"type" : "DRAGON_NATURE", | ||||
| 			}, | ||||
| 			"descreaseMorale" : | ||||
| 			{ | ||||
| 				"type" : "MORALE", | ||||
| 				"effectRange" : "ONLY_ENEMY_ARMY", | ||||
| 				"val" : -1 | ||||
| 			}, | ||||
| //		morale decrease is already set in ZCRTRAIT TXT  | ||||
| //			"descreaseMorale" : | ||||
| //			{ | ||||
| //				"type" : "MORALE", | ||||
| //				"effectRange" : "ONLY_ENEMY_ARMY", | ||||
| //				"val" : -1 | ||||
| //			}, | ||||
| 			"age" : | ||||
| 			{ | ||||
| 				"type" : "SPELL_AFTER_ATTACK", | ||||
|   | ||||
| @@ -132,6 +132,16 @@ bool CCreature::isItNativeTerrain(int terrain) const | ||||
| 	return VLC->townh->factions[faction]->nativeTerrain == terrain; | ||||
| } | ||||
|  | ||||
| void CCreature::setId(CreatureID ID) | ||||
| { | ||||
| 	idNumber = ID; | ||||
| 	BOOST_FOREACH(auto bonus, getExportedBonusList()) | ||||
| 	{ | ||||
| 		if(bonus->source == Bonus::CREATURE_ABILITY) | ||||
| 			bonus->sid = ID; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void AddAbility(CCreature *cre, const JsonVector &ability_vec) | ||||
| { | ||||
| 	Bonus *nsf = new Bonus(); | ||||
| @@ -260,7 +270,7 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses) | ||||
| 	if(hasAbility("const_lowers_morale")) | ||||
| 	{ | ||||
| 		JsonNode node = makeBonusNode("MORALE"); | ||||
| 		node["val"].Float() = 1; | ||||
| 		node["val"].Float() = -1; | ||||
| 		node["effectRange"].String() = "ONLY_ENEMY_ARMY"; | ||||
| 		creature["abilities"]["const_lowers_morale"] = node; | ||||
| 	} | ||||
| @@ -326,7 +336,7 @@ std::vector<JsonNode> CCreatureHandler::loadLegacyData(size_t dataSize) | ||||
| void CCreatureHandler::loadObject(std::string scope, std::string name, const JsonNode & data) | ||||
| { | ||||
| 	auto object = loadFromJson(data); | ||||
| 	object->idNumber = CreatureID(creatures.size()); | ||||
| 	object->setId(CreatureID(creatures.size())); | ||||
| 	object->iconIndex = object->idNumber + 2; | ||||
|  | ||||
| 	creatures.push_back(object); | ||||
| @@ -342,7 +352,7 @@ void CCreatureHandler::loadObject(std::string scope, std::string name, const Jso | ||||
| void CCreatureHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) | ||||
| { | ||||
| 	auto object = loadFromJson(data); | ||||
| 	object->idNumber = CreatureID(index); | ||||
| 	object->setId(CreatureID(index)); | ||||
| 	object->iconIndex = object->idNumber + 2; | ||||
|  | ||||
| 	if(data["hasDoubleWeek"].Bool()) // | ||||
|   | ||||
| @@ -107,6 +107,7 @@ public: | ||||
|  | ||||
| 	bool valid() const; | ||||
|  | ||||
| 	void setId(CreatureID ID); //assigns idNumber and updates bonuses to reference it | ||||
| 	void addBonus(int val, Bonus::BonusType type, int subtype = -1); | ||||
| 	std::string nodeName() const override; | ||||
|  | ||||
|   | ||||
| @@ -1347,6 +1347,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs ) | ||||
| 			{ | ||||
| 				BOOST_FOREACH(Bonus &fromEffect, effect) | ||||
| 				{ | ||||
| 					logBonus->traceStream() << s->nodeName() << " receives a new bonus: " << fromEffect.Description(); | ||||
| 					s->addNewBonus( new Bonus(fromEffect)); | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user