mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fixed #1042. Tweaks for Commander bonuses.
This commit is contained in:
parent
deb22b3674
commit
9e0c9b4f49
@ -129,13 +129,21 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
}
|
||||
}
|
||||
|
||||
CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander):
|
||||
CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander, const CStack * stack):
|
||||
CWindowObject(PLAYER_COLORED),
|
||||
type(COMMANDER),
|
||||
commander (Commander)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
init(commander, commander, dynamic_cast<const CGHeroInstance*>(commander->armyObj));
|
||||
if (stack)
|
||||
{
|
||||
type = COMMANDER_BATTLE;
|
||||
init(commander, stack, dynamic_cast<const CGHeroInstance*>(commander->armyObj));
|
||||
}
|
||||
else
|
||||
{
|
||||
type = COMMANDER;
|
||||
init(commander, commander, dynamic_cast<const CGHeroInstance*>(commander->armyObj));
|
||||
}
|
||||
|
||||
boost::function<void()> Dsm;
|
||||
CFunctionList<void()> fs[2];
|
||||
@ -144,7 +152,8 @@ CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander):
|
||||
fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
|
||||
if (type < COMMANDER_LEVEL_UP) //can dismiss only in regular window
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
|
||||
}
|
||||
|
||||
CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, boost::function<void(ui32)> callback):
|
||||
@ -166,7 +175,8 @@ CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderIns
|
||||
fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
|
||||
if (type < COMMANDER_LEVEL_UP) //can dismiss only in regular window
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
|
||||
}
|
||||
|
||||
void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *StackNode, const CGHeroInstance *HeroOwner)
|
||||
@ -389,7 +399,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
if (creArt) //stack or commander artifacts
|
||||
{
|
||||
setArt (stack->getArt(ArtifactPosition::CREATURE_SLOT));
|
||||
if (type > BATTLE) //artifact buttons inactive in battle
|
||||
if (type > BATTLE && type < COMMANDER_BATTLE) //artifact buttons inactive in battle
|
||||
{
|
||||
//TODO: disable buttons if no artifact is equipped
|
||||
leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||
@ -877,10 +887,18 @@ void CCreInfoWindow::init(const CCreature *creature, const CBonusSystemNode *sta
|
||||
CIntObject * createCreWindow(
|
||||
const CStack *s, bool lclick/* = false*/)
|
||||
{
|
||||
if(settings["general"]["classicCreatureWindow"].Bool())
|
||||
return new CCreInfoWindow(*s, lclick);
|
||||
auto c = dynamic_cast<const CCommanderInstance *>(s->base);
|
||||
if (c)
|
||||
{
|
||||
return new CCreatureWindow (c, s);
|
||||
}
|
||||
else
|
||||
return new CCreatureWindow(*s, CCreatureWindow::BATTLE);
|
||||
{
|
||||
if(settings["general"]["classicCreatureWindow"].Bool())
|
||||
return new CCreInfoWindow(*s, lclick);
|
||||
else
|
||||
return new CCreatureWindow(*s, CCreatureWindow::BATTLE);
|
||||
}
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(int Cid, int Type, int creatureCount)
|
||||
|
@ -41,7 +41,7 @@ class CSelectableSkill;
|
||||
class CCreatureWindow : public CWindowObject, public CArtifactHolder
|
||||
{
|
||||
public:
|
||||
enum CreWinType {OTHER = 0, BATTLE = 1, ARMY = 2, HERO = 3, COMMANDER = 4, COMMANDER_LEVEL_UP = 5}; // > 3 are opened permanently
|
||||
enum CreWinType {OTHER = 0, BATTLE = 1, ARMY = 2, HERO = 3, COMMANDER = 4, COMMANDER_LEVEL_UP = 5, COMMANDER_BATTLE = 6}; // > 3 are opened permanently
|
||||
//bool active; //TODO: comment me
|
||||
int type;//0 - rclick popup; 1 - normal window
|
||||
int bonusRows; //height of skill window
|
||||
@ -89,7 +89,7 @@ public:
|
||||
CCreatureWindow(const CStack & stack, int type); //battle c-tor
|
||||
CCreatureWindow (const CStackInstance &stack, int Type); //pop-up c-tor
|
||||
CCreatureWindow(const CStackInstance &st, int Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
|
||||
CCreatureWindow(const CCommanderInstance * commander); //commander window
|
||||
CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = NULL); //commander window
|
||||
CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, boost::function<void(ui32)> callback);
|
||||
CCreatureWindow(int Cid, int Type, int creatureCount); //c-tor
|
||||
|
||||
|
@ -1885,7 +1885,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int battlefieldTyp
|
||||
{
|
||||
if (heroes[i] && heroes[i]->commander)
|
||||
{
|
||||
CStack * stack = curB->generateNewStack (*heroes[i]->commander, !i, 255,
|
||||
CStack * stack = curB->generateNewStack (*heroes[i]->commander, !i, -2, //TODO: use COMMANDER_SLOT_PLACEHOLDER
|
||||
creatureBank ? commanderBank[i] : commanderField[i]);
|
||||
stacks.push_back(stack);
|
||||
}
|
||||
@ -2720,7 +2720,7 @@ ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
|
||||
speed = ((100 + percentBonus) * speed)/100;
|
||||
|
||||
//bind effect check - doesn't influence stack initiative
|
||||
if (useBind && getEffect(72))
|
||||
if (useBind && getEffect (Spells::BIND))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -240,8 +240,9 @@ public:
|
||||
h & ID & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks
|
||||
& shots & casts & count;
|
||||
|
||||
TSlot slot = (base ? base->armyObj->findStack(base) : -1);
|
||||
const CArmedInstance *army = (base ? base->armyObj : NULL);
|
||||
TSlot slot = (base ? base->armyObj->findStack(base) : -1);
|
||||
|
||||
if(h.saving)
|
||||
{
|
||||
h & army & slot;
|
||||
@ -249,7 +250,13 @@ public:
|
||||
else
|
||||
{
|
||||
h & army & slot;
|
||||
if(!army || slot == -1 || !army->hasStackAtSlot(slot))
|
||||
if (slot == -2) //TODO
|
||||
{
|
||||
auto hero = dynamic_cast<const CGHeroInstance *>(army);
|
||||
assert (hero);
|
||||
base = hero->commander;
|
||||
}
|
||||
else if(!army || slot == -1 || !army->hasStackAtSlot(slot))
|
||||
{
|
||||
base = NULL;
|
||||
tlog3 << type->nameSing << " doesn't have a base stack!\n";
|
||||
|
@ -300,6 +300,10 @@ bool CCreatureSet::contains(const CStackInstance *stack) const
|
||||
|
||||
TSlot CCreatureSet::findStack(const CStackInstance *stack) const
|
||||
{
|
||||
auto h = dynamic_cast<const CGHeroInstance *>(this);
|
||||
if (h && h->commander == stack)
|
||||
return -2;
|
||||
|
||||
if(!stack)
|
||||
return -1;
|
||||
|
||||
|
@ -1361,7 +1361,11 @@ int RankRangeLimiter::limit(const BonusLimitationContext &context) const
|
||||
{
|
||||
const CStackInstance *csi = retreiveStackInstance(&context.node);
|
||||
if(csi)
|
||||
{
|
||||
if (csi->getNodeType() == Bonus::COMMANDER) //no stack exp bonuses for commander creatures
|
||||
return true;
|
||||
return csi->getExpRank() < minRank || csi->getExpRank() > maxRank;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user