Anonymous | Login | 2024-12-03 17:11 UTC |
My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
0002781 | VCMI | Mods | public | 2017-08-31 01:33 | 2017-09-06 12:29 | ||||||||
Reporter | hkoehler | ||||||||||||
Assigned To | hkoehler | ||||||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||||||
Status | resolved | Resolution | fixed | ||||||||||
Platform | OS | OS Version | |||||||||||
Product Version | 0.99 | ||||||||||||
Target Version | Fixed in Version | 1.next | |||||||||||
Summary | 0002781: Granting bonuses to war machines | ||||||||||||
Description | It seems that bonuses granted to a hero do not propagate to war machines. E.g. granting the bonus below to a hero has no effect on the health of his ammo cart during combat (but works fine for normal creatures). "type" : "STACK_HEALTH", "val" : 150, "valueType" : "BASE_NUMBER", "limiters": [{ "type" : "CREATURE_TYPE_LIMITER", "parameters" : [ "ammoCart" ] }] | ||||||||||||
Additional Information | Seems related to the limiter - without it the bonus applies to war machines as well. | ||||||||||||
Tags | No tags attached. | ||||||||||||
Attached Files | |||||||||||||
Notes | |
(0007247) hkoehler (developer) 2017-09-02 02:28 |
BattleInfo * BattleInfo::setupBattle( ... auto handleWarMachine= [&](int side, ArtifactPosition artslot, BattleHex hex) { const CArtifactInstance * warMachineArt = heroes[side]->getArt(artslot); if(nullptr != warMachineArt) { CreatureID cre = warMachineArt->artType->warMachine; if(cre != CreatureID::NONE) stacks.push_back(curB->generateNewStack(CStackBasicDescriptor(cre, 1), side, SlotID::WAR_MACHINES_SLOT, hex)); } }; ... } CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor & base, ui8 side, SlotID slot, BattleHex position) const { int stackID = getIdForNewStack(); PlayerColor owner = sides[side].color; auto ret = new CStack(&base, owner, stackID, side, slot); ret->position = position; ret->state.insert(EBattleStackState::ALIVE); //alive state indication return ret; } --- In CCreatureSet.cpp: CStackBasicDescriptor::CStackBasicDescriptor(CreatureID id, TQuantity Count) : type (VLC->creh->creatures[id]), count(Count) { } --- CStack::CStack(const CStackBasicDescriptor * stack, PlayerColor O, int I, ui8 Side, SlotID S): base(nullptr), ID(I), owner(O), slot(S), side(Side), counterAttacks(this), shots(this), casts(this), health(this), cloneID(-1), position() { type = stack->type; baseAmount = stack->count; health.init(); //??? setNodeType(STACK_BATTLE); } --- In HeroBonus.cpp: int CCreatureTypeLimiter::limit(const BonusLimitationContext &context) const { const CCreature *c = retrieveCreature(&context.node); if(!c) return true; return c != creature && (!includeUpgrades || !creature->isMyUpgrade(c)); //drop bonus if it's not our creature and (we don`t check upgrades or its not our upgrade) } const CCreature * retrieveCreature(const CBonusSystemNode *node) { switch(node->getNodeType()) { case CBonusSystemNode::CREATURE: return (static_cast<const CCreature *>(node)); default: const CStackInstance *csi = retreiveStackInstance(node); if(csi) return csi->type; return nullptr; } } const CStackInstance * retreiveStackInstance(const CBonusSystemNode *node) { switch(node->getNodeType()) { case CBonusSystemNode::STACK_INSTANCE: return (static_cast<const CStackInstance *>(node)); case CBonusSystemNode::STACK_BATTLE: return (static_cast<const CStack*>(node))->base; default: return nullptr; } } |
(0007248) hkoehler (developer) 2017-09-02 02:31 |
Looks like war machines stacks are created with base = nullptr, which is what retrieveStackInstance returns, and hence retrieveCreature as well. As a result, CCreatureTypeLimiter::limit will return true, stopping propagation. |
(0007249) hkoehler (developer) 2017-09-02 02:46 edited on: 2017-09-02 06:32 |
Problem is that retrieveCreature shouldn't depend on retrieveStackInstance, as it only requires creature type, not creature instance, and there are stacks without instances (e.g. war machines). Creature type is stored in type, so no need to use base->type. Fix: const CCreature * retrieveCreature(const CBonusSystemNode *node) { switch(node->getNodeType()) { case CBonusSystemNode::CREATURE: return (static_cast<const CCreature *>(node)); case CBonusSystemNode::STACK_BATTLE: return (static_cast<const CStack*>(node))->type; default: const CStackInstance *csi = retreiveStackInstance(node); if(csi) return csi->type; return nullptr; } } |
(0007264) AVS (administrator) 2017-09-06 12:29 |
Fixed in https://github.com/vcmi/vcmi/pull/374 [^] |
Issue History | |||
Date Modified | Username | Field | Change |
2017-08-31 01:33 | hkoehler | New Issue | |
2017-08-31 02:39 | hkoehler | Note Added: 0007245 | |
2017-09-01 22:52 | hkoehler | Note Edited: 0007245 | View Revisions |
2017-09-02 00:23 | SXX | Summary | Granting bonuses to war machines => Granting bonuses to war machines1 |
2017-09-02 00:24 | SXX | Summary | Granting bonuses to war machines1 => Granting bonuses to war machines |
2017-09-02 02:27 | hkoehler | Assigned To | => hkoehler |
2017-09-02 02:27 | hkoehler | Status | new => assigned |
2017-09-02 02:27 | hkoehler | Additional Information Updated | View Revisions |
2017-09-02 02:28 | hkoehler | Note Deleted: 0007245 | |
2017-09-02 02:28 | hkoehler | Note Added: 0007247 | |
2017-09-02 02:31 | hkoehler | Note Added: 0007248 | |
2017-09-02 02:46 | hkoehler | Note Added: 0007249 | |
2017-09-02 03:02 | hkoehler | Note Edited: 0007249 | View Revisions |
2017-09-02 06:32 | SXX | Note Edited: 0007249 | View Revisions |
2017-09-02 06:32 | SXX | Note Added: 0007250 | |
2017-09-02 06:32 | SXX | Note Edited: 0007250 | View Revisions |
2017-09-02 06:33 | SXX | Note Deleted: 0007250 | |
2017-09-02 06:36 | SXX | Note Added: 0007251 | |
2017-09-02 07:07 | SXX | Note Edited: 0007251 | View Revisions |
2017-09-02 07:07 | SXX | Note Added: 0007252 | |
2017-09-02 07:08 | SXX | Note Added: 0007253 | |
2017-09-02 07:08 | SXX | Note Deleted: 0007252 | |
2017-09-02 07:08 | SXX | Note Deleted: 0007251 | |
2017-09-02 07:08 | SXX | Note Deleted: 0007253 | |
2017-09-06 12:29 | AVS | Note Added: 0007264 | |
2017-09-06 12:29 | AVS | Status | assigned => resolved |
2017-09-06 12:29 | AVS | Fixed in Version | => 1.next |
2017-09-06 12:29 | AVS | Resolution | open => fixed |
Copyright © 2000 - 2024 MantisBT Team |