1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-25 12:14:46 +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:
Michał W. Urbańczyk 2013-05-19 19:53:03 +00:00
parent fc6e72dc75
commit c85829a00c
5 changed files with 24 additions and 11 deletions

View File

@ -336,9 +336,9 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
//Stats //Stats
morale = new MoraleLuckBox(true, genRect(42, 42, 335, 100)); 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 = 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? new CAnimImage("PSKIL42", 4, 0, 387, 51); //exp icon - Print it always?
if (type) //not in fort window if (type) //not in fort window

View File

@ -362,12 +362,13 @@
{ {
"type" : "DRAGON_NATURE", "type" : "DRAGON_NATURE",
}, },
"descreaseMorale" : // morale decrease is already set in ZCRTRAIT TXT
{ // "descreaseMorale" :
"type" : "MORALE", // {
"effectRange" : "ONLY_ENEMY_ARMY", // "type" : "MORALE",
"val" : -1 // "effectRange" : "ONLY_ENEMY_ARMY",
}, // "val" : -1
// },
"age" : "age" :
{ {
"type" : "SPELL_AFTER_ATTACK", "type" : "SPELL_AFTER_ATTACK",

View File

@ -132,6 +132,16 @@ bool CCreature::isItNativeTerrain(int terrain) const
return VLC->townh->factions[faction]->nativeTerrain == terrain; 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) static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
{ {
Bonus *nsf = new Bonus(); Bonus *nsf = new Bonus();
@ -260,7 +270,7 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
if(hasAbility("const_lowers_morale")) if(hasAbility("const_lowers_morale"))
{ {
JsonNode node = makeBonusNode("MORALE"); JsonNode node = makeBonusNode("MORALE");
node["val"].Float() = 1; node["val"].Float() = -1;
node["effectRange"].String() = "ONLY_ENEMY_ARMY"; node["effectRange"].String() = "ONLY_ENEMY_ARMY";
creature["abilities"]["const_lowers_morale"] = node; 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) void CCreatureHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{ {
auto object = loadFromJson(data); auto object = loadFromJson(data);
object->idNumber = CreatureID(creatures.size()); object->setId(CreatureID(creatures.size()));
object->iconIndex = object->idNumber + 2; object->iconIndex = object->idNumber + 2;
creatures.push_back(object); 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) void CCreatureHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{ {
auto object = loadFromJson(data); auto object = loadFromJson(data);
object->idNumber = CreatureID(index); object->setId(CreatureID(index));
object->iconIndex = object->idNumber + 2; object->iconIndex = object->idNumber + 2;
if(data["hasDoubleWeek"].Bool()) // if(data["hasDoubleWeek"].Bool()) //

View File

@ -107,6 +107,7 @@ public:
bool valid() const; 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); void addBonus(int val, Bonus::BonusType type, int subtype = -1);
std::string nodeName() const override; std::string nodeName() const override;

View File

@ -1347,6 +1347,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
{ {
BOOST_FOREACH(Bonus &fromEffect, effect) BOOST_FOREACH(Bonus &fromEffect, effect)
{ {
logBonus->traceStream() << s->nodeName() << " receives a new bonus: " << fromEffect.Description();
s->addNewBonus( new Bonus(fromEffect)); s->addNewBonus( new Bonus(fromEffect));
} }
} }