mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
* minor refactoring
This commit is contained in:
@ -564,7 +564,7 @@ bool CMovementStartAnimation::init()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if(!stack || myAnim()->getType() == 5)
|
if(!stack || myAnim()->getType() == CCreatureAnim::DEATH)
|
||||||
{
|
{
|
||||||
CMovementStartAnimation::endAnim();
|
CMovementStartAnimation::endAnim();
|
||||||
return false;
|
return false;
|
||||||
@ -602,7 +602,7 @@ CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * s
|
|||||||
|
|
||||||
bool CReverseAnimation::init()
|
bool CReverseAnimation::init()
|
||||||
{
|
{
|
||||||
if(myAnim() == NULL || myAnim()->getType() == 5)
|
if(myAnim() == NULL || myAnim()->getType() == CCreatureAnim::DEATH)
|
||||||
{
|
{
|
||||||
endAnim();
|
endAnim();
|
||||||
|
|
||||||
@ -699,7 +699,7 @@ bool CShootingAnimation::init()
|
|||||||
|
|
||||||
const CStack * shooter = attackingStack;
|
const CStack * shooter = attackingStack;
|
||||||
|
|
||||||
if(!shooter || myAnim()->getType() == 5)
|
if(!shooter || myAnim()->getType() == CCreatureAnim::DEATH)
|
||||||
{
|
{
|
||||||
endAnim();
|
endAnim();
|
||||||
return false;
|
return false;
|
||||||
|
@ -581,7 +581,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
|||||||
SDL_SetClipRect(to, &pos);
|
SDL_SetClipRect(to, &pos);
|
||||||
|
|
||||||
//printing background and hexes
|
//printing background and hexes
|
||||||
if(activeStack != NULL && creAnims[activeStack->ID]->getType() != 0) //show everything with range
|
if(activeStack != NULL && creAnims[activeStack->ID]->getType() != CCreatureAnim::MOVING) //show everything with range
|
||||||
{
|
{
|
||||||
blitAt(backgroundWithHexes, pos.x, pos.y, to);
|
blitAt(backgroundWithHexes, pos.x, pos.y, to);
|
||||||
}
|
}
|
||||||
@ -711,7 +711,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
|||||||
const CStack *s = stacks[i];
|
const CStack *s = stacks[i];
|
||||||
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
|
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
|
||||||
continue;
|
continue;
|
||||||
if(creAnims[s->ID]->getType() != 5 && s->position >= 0) //don't show turrets here
|
if(creAnims[s->ID]->getType() != CCreatureAnim::DEATH && s->position >= 0) //don't show turrets here
|
||||||
stackAliveByHex[s->position].push_back(s);
|
stackAliveByHex[s->position].push_back(s);
|
||||||
}
|
}
|
||||||
std::vector<const CStack *> stackDeadByHex[GameConstants::BFIELD_SIZE];
|
std::vector<const CStack *> stackDeadByHex[GameConstants::BFIELD_SIZE];
|
||||||
@ -720,7 +720,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
|||||||
const CStack *s = stacks[i];
|
const CStack *s = stacks[i];
|
||||||
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
|
if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
|
||||||
continue;
|
continue;
|
||||||
if(creAnims[s->ID]->getType() == 5)
|
if(creAnims[s->ID]->getType() == CCreatureAnim::DEATH)
|
||||||
stackDeadByHex[s->position].push_back(s);
|
stackDeadByHex[s->position].push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,7 +956,7 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
|
|||||||
{
|
{
|
||||||
const CStack *s = aliveStacks[hex][v];
|
const CStack *s = aliveStacks[hex][v];
|
||||||
|
|
||||||
if(!s->hasBonusOfType(Bonus::FLYING) || creAnims[s->ID]->getType() != 0)
|
if(!s->hasBonusOfType(Bonus::FLYING) || creAnims[s->ID]->getType() != CCreatureAnim::DEATH)
|
||||||
showAliveStack(s, to);
|
showAliveStack(s, to);
|
||||||
else
|
else
|
||||||
flyingStacks->push_back(s);
|
flyingStacks->push_back(s);
|
||||||
@ -2171,12 +2171,13 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
|||||||
const CCreature *creature = stack->getCreature();
|
const CCreature *creature = stack->getCreature();
|
||||||
SDL_Rect unitRect = {creAnims[ID]->pos.x, creAnims[ID]->pos.y, uint16_t(creAnims[ID]->fullWidth), uint16_t(creAnims[ID]->fullHeight)};
|
SDL_Rect unitRect = {creAnims[ID]->pos.x, creAnims[ID]->pos.y, uint16_t(creAnims[ID]->fullWidth), uint16_t(creAnims[ID]->fullHeight)};
|
||||||
|
|
||||||
int animType = creAnims[ID]->getType();
|
CCreatureAnim::EAnimType animType = creAnims[ID]->getType();
|
||||||
|
|
||||||
int affectingSpeed = getAnimSpeed();
|
int affectingSpeed = getAnimSpeed();
|
||||||
if(animType == 1 || animType == 2) //standing stacks should not stand faster :)
|
if(animType == CCreatureAnim::MOUSEON || animType == CCreatureAnim::HOLDING) //standing stacks should not stand faster :)
|
||||||
affectingSpeed = 2;
|
affectingSpeed = 2;
|
||||||
bool incrementFrame = (animCount%(4/affectingSpeed)==0) && animType!=5 && animType!=20 && animType!=2;
|
bool incrementFrame = (animCount%(4/affectingSpeed)==0) && animType!=CCreatureAnim::DEATH &&
|
||||||
|
animType!=CCreatureAnim::MOVE_START && animType!=CCreatureAnim::HOLDING;
|
||||||
|
|
||||||
if (creature->idNumber == 149)
|
if (creature->idNumber == 149)
|
||||||
{
|
{
|
||||||
@ -2186,7 +2187,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// standing animation
|
// standing animation
|
||||||
if(animType == 2)
|
if(animType == CCreatureAnim::HOLDING)
|
||||||
{
|
{
|
||||||
if(standingFrame.find(ID)!=standingFrame.end())
|
if(standingFrame.find(ID)!=standingFrame.end())
|
||||||
{
|
{
|
||||||
@ -2521,7 +2522,8 @@ void CBattleInterface::endAction(const BattleAction* action)
|
|||||||
attackingHero->setPhase(0);
|
attackingHero->setPhase(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stack && action->actionType == BattleAction::WALK && creAnims[action->stackNumber]->getType() != 2) //walk or walk & attack
|
if(stack && action->actionType == BattleAction::WALK &&
|
||||||
|
creAnims[action->stackNumber]->getType() != CCreatureAnim::HOLDING) //walk or walk & attack
|
||||||
{
|
{
|
||||||
pendingAnims.push_back(std::make_pair(new CMovementEndAnimation(this, stack, action->destinationTile), false));
|
pendingAnims.push_back(std::make_pair(new CMovementEndAnimation(this, stack, action->destinationTile), false));
|
||||||
}
|
}
|
||||||
|
@ -1141,7 +1141,7 @@ void CAdvMapInt::tileLClicked(const int3 &mapPos)
|
|||||||
switch(spellBeingCasted->id)
|
switch(spellBeingCasted->id)
|
||||||
{
|
{
|
||||||
case Spells::SCUTTLE_BOAT: //Scuttle Boat
|
case Spells::SCUTTLE_BOAT: //Scuttle Boat
|
||||||
if(topBlocking && topBlocking->ID == 8)
|
if(topBlocking && topBlocking->ID == Obj::BOAT)
|
||||||
leaveCastingMode(true, mapPos);
|
leaveCastingMode(true, mapPos);
|
||||||
break;
|
break;
|
||||||
case Spells::DIMENSION_DOOR:
|
case Spells::DIMENSION_DOOR:
|
||||||
|
@ -2586,9 +2586,9 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan
|
|||||||
{
|
{
|
||||||
switch (market->o->ID)
|
switch (market->o->ID)
|
||||||
{
|
{
|
||||||
break; case 7: title = CGI->generaltexth->allTexts[349];
|
break; case Obj::BLACK_MARKET: title = CGI->generaltexth->allTexts[349];
|
||||||
break; case 99: title = CGI->generaltexth->allTexts[159];
|
break; case Obj::TRADING_POST: title = CGI->generaltexth->allTexts[159];
|
||||||
break; case 221: title = CGI->generaltexth->allTexts[159];
|
break; case Obj::TRADING_POST_SNOW: title = CGI->generaltexth->allTexts[159];
|
||||||
break; default: title = market->o->getHoverText();
|
break; default: title = market->o->getHoverText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
|
|||||||
: static_cast<const CGHeroInstance*>(obj));
|
: static_cast<const CGHeroInstance*>(obj));
|
||||||
|
|
||||||
//print hero / boat and flag
|
//print hero / boat and flag
|
||||||
if((themp && themp->moveDir && themp->type) || (obj->ID == 8)) //it's hero or boat
|
if((themp && themp->moveDir && themp->type) || (obj->ID == Obj::BOAT)) //it's hero or boat
|
||||||
{
|
{
|
||||||
const int IMGVAL = 8; //frames per group of movement animation
|
const int IMGVAL = 8; //frames per group of movement animation
|
||||||
ui8 dir;
|
ui8 dir;
|
||||||
|
@ -1123,7 +1123,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
|
|||||||
|
|
||||||
//initialize bonuses
|
//initialize bonuses
|
||||||
BOOST_FOREACH(auto skill_info, secSkills)
|
BOOST_FOREACH(auto skill_info, secSkills)
|
||||||
updateSkill(skill_info.first, skill_info.second);
|
updateSkill(static_cast<CGHeroInstance::SecondarySkill>(skill_info.first), skill_info.second);
|
||||||
Updatespecialty();
|
Updatespecialty();
|
||||||
|
|
||||||
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
|
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
|
||||||
@ -1184,7 +1184,7 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CGHeroInstance::updateSkill(int which, int val)
|
void CGHeroInstance::updateSkill(SecondarySkill which, int val)
|
||||||
{
|
{
|
||||||
if(which == LEADERSHIP || which == LUCK)
|
if(which == LEADERSHIP || which == LUCK)
|
||||||
{ //luck-> VLC->generaltexth->arraytxt[73+luckSkill]; VLC->generaltexth->arraytxt[104+moraleSkill]
|
{ //luck-> VLC->generaltexth->arraytxt[73+luckSkill]; VLC->generaltexth->arraytxt[104+moraleSkill]
|
||||||
|
@ -417,7 +417,7 @@ public:
|
|||||||
void initHeroDefInfo();
|
void initHeroDefInfo();
|
||||||
void pushPrimSkill(int which, int val);
|
void pushPrimSkill(int which, int val);
|
||||||
void Updatespecialty();
|
void Updatespecialty();
|
||||||
void updateSkill(int which, int val);
|
void updateSkill(SecondarySkill which, int val);
|
||||||
|
|
||||||
CGHeroInstance();
|
CGHeroInstance();
|
||||||
virtual ~CGHeroInstance();
|
virtual ~CGHeroInstance();
|
||||||
|
@ -1669,7 +1669,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
|||||||
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
||||||
if(((t.terType == ETerrainType::ROCK || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) ))
|
if(((t.terType == ETerrainType::ROCK || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) ))
|
||||||
&& complain("Cannot move hero, destination tile is blocked!"))
|
&& complain("Cannot move hero, destination tile is blocked!"))
|
||||||
|| ((!h->boat && !h->canWalkOnSea() && t.terType == ETerrainType::WATER && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
|| ((!h->boat && !h->canWalkOnSea() && t.terType == ETerrainType::WATER && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != Obj::BOAT && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
||||||
&& complain("Cannot move hero, destination tile is on water!"))
|
&& complain("Cannot move hero, destination tile is on water!"))
|
||||||
|| ((h->boat && t.terType != ETerrainType::WATER && t.blocked)
|
|| ((h->boat && t.terType != ETerrainType::WATER && t.blocked)
|
||||||
&& complain("Cannot disembark hero, tile is blocked!"))
|
&& complain("Cannot disembark hero, tile is blocked!"))
|
||||||
|
Reference in New Issue
Block a user