1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* fixed bug with levelling up

* fixed pictures of secondary skills in hero window (in left - click popups)
* added handling of navigation, logistics, pathfinding, scouting end estates secondary skills
This commit is contained in:
mateuszb 2008-09-28 13:29:37 +00:00
parent a4afdc7145
commit ceaa51d07d
6 changed files with 100 additions and 17 deletions

View File

@ -319,9 +319,9 @@ void CGameState::applyNL(IPack * pack)
{
SetSecSkill *sr = static_cast<SetSecSkill*>(pack);
CGHeroInstance *hero = getHero(sr->id);
if(hero->getSecSkillLevel(sr->which) < 0)
if(hero->getSecSkillLevel(sr->which) == 0)
{
hero->secSkills.push_back(std::pair<int,int>(sr->which, (sr->abs)? (sr->val) : (sr->val-1)));
hero->secSkills.push_back(std::pair<int,int>(sr->which, sr->val));
}
else
{

View File

@ -228,7 +228,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
for(int g=0; g<hero->secSkills.size(); ++g)
{
secSkillAreas[g]->type = hero->secSkills[g].first;
secSkillAreas[g]->bonus = hero->secSkills[g].second-1;
secSkillAreas[g]->bonus = hero->secSkills[g].second;
std::string hlp = CGI->abilh->abilities[ hero->secSkills[g].first ]->infoTexts[hero->secSkills[g].second-1];
secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
@ -305,7 +305,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
dismissButton->block(hero->visitedTown);
leftArtRoll->block(hero->artifacts.size()<6);
rightArtRoll->block(hero->artifacts.size()<6);
if(hero->getSecSkillLevel(19)<0)
if(hero->getSecSkillLevel(19)==0)
gar2button->block(true);
else
{

View File

@ -596,8 +596,8 @@ void SComponent::init(Etype Type, int Subtype, int Val)
subtitle = oss.str();
break;
case secskill44:
subtitle += CGI->abilh->levels[Val] + " " + CGI->abilh->abilities[Subtype]->name;
description = CGI->abilh->abilities[Subtype]->infoTexts[Val];
subtitle += CGI->abilh->levels[Val-1] + " " + CGI->abilh->abilities[Subtype]->name;
description = CGI->abilh->abilities[Subtype]->infoTexts[Val-1];
break;
case resource:
description = CGI->generaltexth->allTexts[242];
@ -658,10 +658,10 @@ SDL_Surface * SComponent::getImg()
return graphics->pskillsb->ourImages[subtype].bitmap;
break;
case secskill44:
return CGI->abilh->abils44->ourImages[subtype*3 + 3 + val].bitmap;
return CGI->abilh->abils44->ourImages[subtype*3 + 3 + val - 1].bitmap;
break;
case secskill:
return CGI->abilh->abils82->ourImages[subtype*3 + 3 + val].bitmap;
return CGI->abilh->abils82->ourImages[subtype*3 + 3 + val - 1].bitmap;
break;
case resource:
return graphics->resources->ourImages[subtype].bitmap;

View File

@ -168,6 +168,43 @@ bool CGHeroInstance::isHero() const
unsigned int CGHeroInstance::getTileCost(const EterrainType & ttype, const Eroad & rdtype, const Eriver & rvtype) const
{
unsigned int ret = type->heroClass->terrCosts[ttype];
//applying pathfinding skill
switch(getSecSkillLevel(0))
{
case 1: //basic
switch(ttype)
{
case rough:
ret = 100;
break;
case sand: case snow:
if(ret>125)
ret = 125;
break;
case swamp:
if(ret>150)
ret = 150;
break;
}
break;
case 2: //advanced
switch(ttype)
{
case rough: case sand: case snow:
ret = 100;
break;
case swamp:
if(ret>125)
ret = 125;
break;
}
break;
case 3: //expert
ret = 100;
break;
}
//calculating road influence
switch(rdtype)
{
case dirtRoad:
@ -213,7 +250,7 @@ int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position o
}
int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
{
return 6;
return 6 + getSecSkillLevel(3); //default + scouting
}
void CGHeroInstance::setPosition(int3 Pos, bool h3m) //as above, but sets position
{
@ -243,7 +280,7 @@ int CGHeroInstance::getSecSkillLevel(const int & ID) const
for(int i=0;i<secSkills.size();i++)
if(secSkills[i].first==ID)
return secSkills[i].second;
return -1;
return 0;
}
ui32 CGHeroInstance::getArtAtPos(ui16 pos) const
{
@ -278,7 +315,7 @@ void CGHeroInstance::setArtAtPos(ui16 pos, int art)
artifacts.push_back(art);
}
}
const CArtifact * CGHeroInstance::getArt(int pos)
const CArtifact * CGHeroInstance::getArt(int pos) const
{
int id = getArtAtPos(pos);
if(id>=0)

View File

@ -125,10 +125,10 @@ public:
bool canWalkOnSea() const;
int getCurrentLuck() const;
int getCurrentMorale() const;
int getSecSkillLevel(const int & ID) const; //-1 - no skill
int getSecSkillLevel(const int & ID) const; //0 - no skill
ui32 getArtAtPos(ui16 pos) const; //-1 - no artifact
void setArtAtPos(ui16 pos, int art);
const CArtifact * getArt(int pos);
const CArtifact * getArt(int pos) const;
CGHeroInstance();
virtual ~CGHeroInstance();
};

View File

@ -269,8 +269,8 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile
//tactic round
{
NEW_ROUND;
if( (hero1 && hero1->getSecSkillLevel(19)>=0) ||
( hero2 && hero2->getSecSkillLevel(19)>=0) )//someone has tactics
if( (hero1 && hero1->getSecSkillLevel(19)>0) ||
( hero2 && hero2->getSecSkillLevel(19)>0) )//someone has tactics
{
//TODO: tactic round (round -1)
}
@ -1083,11 +1083,44 @@ int lowestSpeed(CGHeroInstance * chi)
}
return ret;
}
int valMovePoints(CGHeroInstance * chi)
int valMovePoints(CGHeroInstance * chi, bool onLand)
{
int ret = 1270+70*lowestSpeed(chi);
if (ret>2000)
ret=2000;
if(onLand)
{
//logistics:
switch(chi->getSecSkillLevel(2))
{
case 1:
ret *= 1.1f;
break;
case 2:
ret *= 1.2f;
break;
case 3:
ret *= 1.3f;
break;
}
}
else
{
//navigation:
switch(chi->getSecSkillLevel(2))
{
case 1:
ret *= 1.5f;
break;
case 2:
ret *= 2.0f;
break;
case 3:
ret *= 2.5f;
break;
}
}
//TODO: additional bonuses (but they aren't currently stored in chi)
@ -1111,9 +1144,22 @@ void CGameHandler::newTurn()
{
NewTurn::Hero h;
h.id = (*i).second.heroes[j]->id;
h.move = valMovePoints((*i).second.heroes[j]);
h.move = valMovePoints((*i).second.heroes[j], true); //TODO: check if hero is really on the land
h.mana = (*i).second.heroes[j]->mana;
n.heroes.insert(h);
//handle estates
switch((*i).second.heroes[j]->getSecSkillLevel(13))
{
case 1: //basic
r.res[6] += 125;
break;
case 2: //advanced
r.res[6] += 250;
break;
case 3: //expert
r.res[6] += 500;
break;
}
}
for(std::vector<CGTownInstance *>::iterator j=i->second.towns.begin();j!=i->second.towns.end();j++)//handle towns
{