From ceaa51d07d7200732baf8c4c518d9bdbc7c1e131 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sun, 28 Sep 2008 13:29:37 +0000 Subject: [PATCH] * 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 --- CGameState.cpp | 4 +-- CHeroWindow.cpp | 4 +-- CPlayerInterface.cpp | 8 +++--- hch/CObjectHandler.cpp | 43 +++++++++++++++++++++++++++++--- hch/CObjectHandler.h | 4 +-- server/CGameHandler.cpp | 54 ++++++++++++++++++++++++++++++++++++++--- 6 files changed, 100 insertions(+), 17 deletions(-) diff --git a/CGameState.cpp b/CGameState.cpp index 18d9951d5..02debc674 100644 --- a/CGameState.cpp +++ b/CGameState.cpp @@ -319,9 +319,9 @@ void CGameState::applyNL(IPack * pack) { SetSecSkill *sr = static_cast(pack); CGHeroInstance *hero = getHero(sr->id); - if(hero->getSecSkillLevel(sr->which) < 0) + if(hero->getSecSkillLevel(sr->which) == 0) { - hero->secSkills.push_back(std::pair(sr->which, (sr->abs)? (sr->val) : (sr->val-1))); + hero->secSkills.push_back(std::pair(sr->which, sr->val)); } else { diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index cf1d70ce7..7f7ffea82 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -228,7 +228,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero) for(int g=0; gsecSkills.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 { diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 0b7909233..1124f706e 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -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; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index ec44b20b9..e58790243 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -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=0) diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 00916c7b8..4cd08c7fb 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -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(); }; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index d48af6ee0..ad836c2ad 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -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::iterator j=i->second.towns.begin();j!=i->second.towns.end();j++)//handle towns {