mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
* added native terrain bonuses in battles
* number of units in stack in battle should now fit the box * non-living and undead creatures have now always 0 morale
This commit is contained in:
parent
97287bb7d1
commit
1cac083239
@ -585,10 +585,8 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
}
|
||||
SDL_BlitSurface(amountBG, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[curStackID]->pos.x + xAdd + pos.x, creAnims[curStackID]->pos.y + 260 + pos.y));
|
||||
//blitting amount
|
||||
std::ostringstream ss;
|
||||
ss<<curStack.amount;
|
||||
CSDL_Ext::printAtMiddleWB(
|
||||
ss.str(),
|
||||
makeNumberShort(curStack.amount),
|
||||
creAnims[curStackID]->pos.x + xAdd + 14 + pos.x,
|
||||
creAnims[curStackID]->pos.y + 260 + 4 + pos.y,
|
||||
GEOR13,
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "../int3.h"
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
|
||||
/*
|
||||
* SDL_Extensions.h, part of VCMI engine
|
||||
@ -32,10 +30,6 @@ bool isItIn(const SDL_Rect * rect, int x, int y);
|
||||
template<typename IntType>
|
||||
std::string makeNumberShort(IntType number) //the output is a string containing at most 5 characters [4 if positive] (eg. intead 10000 it gives 10k)
|
||||
{
|
||||
#if BOOST_VERSION >= 103800
|
||||
BOOST_MPL_ASSERT_MSG( boost::is_integral<IntType>::value, NON_INTEGRAL_TYPES_ARE_NOT_ALLOWED, (IntType) ); //it should make noise if IntType is not integral type
|
||||
#endif
|
||||
|
||||
int initialLength;
|
||||
bool negative = (number < 0);
|
||||
std::ostringstream ost, rets;
|
||||
|
11
config/native_terrains.txt
Normal file
11
config/native_terrains.txt
Normal file
@ -0,0 +1,11 @@
|
||||
//list of native terrains of different factions
|
||||
//[faction ID] [terrain ID]
|
||||
0 2
|
||||
1 2
|
||||
2 3
|
||||
3 7
|
||||
4 0
|
||||
5 6
|
||||
6 5
|
||||
7 4
|
||||
8 2
|
@ -437,6 +437,7 @@ void CHeroHandler::initHeroClasses()
|
||||
heroes[gg]->heroClass = heroClasses[heroes[gg]->heroType];
|
||||
}
|
||||
initTerrainCosts();
|
||||
loadNativeTerrains();
|
||||
}
|
||||
|
||||
unsigned int CHeroHandler::level(unsigned int experience)
|
||||
@ -478,6 +479,12 @@ void CHeroHandler::initTerrainCosts()
|
||||
{
|
||||
std::ifstream inp;
|
||||
inp.open("config" PATHSEPARATOR "TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
|
||||
|
||||
if(!inp.is_open())
|
||||
{
|
||||
tlog1 << "Error while opening config/TERCOSTS.TXT file!" << std::endl;
|
||||
}
|
||||
|
||||
int tynum;
|
||||
inp>>tynum;
|
||||
for(int i=0; i<2*tynum; i+=2)
|
||||
@ -495,3 +502,27 @@ void CHeroHandler::initTerrainCosts()
|
||||
inp.close();
|
||||
}
|
||||
|
||||
void CHeroHandler::loadNativeTerrains()
|
||||
{
|
||||
std::ifstream inp;
|
||||
inp.open("config" PATHSEPARATOR "native_terrains.txt", std::ios_base::in|std::ios_base::binary);
|
||||
|
||||
if(!inp.is_open())
|
||||
{
|
||||
tlog1 << "Error while opening config/native_terrains.txt file!" << std::endl;
|
||||
}
|
||||
const int MAX_ELEM = 1000;
|
||||
char buf[MAX_ELEM+1];
|
||||
inp.getline(buf, MAX_ELEM);
|
||||
inp.getline(buf, MAX_ELEM);
|
||||
|
||||
nativeTerrains.resize(F_NUMBER);
|
||||
for(int i=0; i<F_NUMBER; ++i)
|
||||
{
|
||||
int faction, terrain;
|
||||
inp >> faction;
|
||||
inp >> terrain;
|
||||
nativeTerrains[faction] = terrain;
|
||||
}
|
||||
inp.close();
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
std::vector<SBallisticsLevelInfo> ballistics; //info about ballistics ability per level; [0] - none; [1] - basic; [2] - adv; [3] - expert
|
||||
|
||||
std::map<int, CObstacleInfo> obstacles; //info about obstacles that may be placed on battlefield
|
||||
std::vector<int> nativeTerrains; //info about native terrains of different factions
|
||||
|
||||
void loadObstacles(); //loads info about obstacles
|
||||
|
||||
@ -115,6 +116,7 @@ public:
|
||||
void loadHeroClasses();
|
||||
void initHeroClasses();
|
||||
void initTerrainCosts();
|
||||
void loadNativeTerrains();
|
||||
CHeroHandler(); //c-tor
|
||||
~CHeroHandler(); //d-tor
|
||||
|
||||
|
@ -541,6 +541,9 @@ si8 CStack::Morale() const
|
||||
{
|
||||
si8 ret = morale;
|
||||
|
||||
if(hasFeatureOfType(StackFeature::NON_LIVING) || hasFeatureOfType(StackFeature::UNDEAD))
|
||||
return 0;
|
||||
|
||||
ret += valOfFeatures(StackFeature::MORALE_BONUS); //mirth & sorrow & other
|
||||
|
||||
if(hasFeatureOfType(StackFeature::SELF_MORALE)) //eg. minotaur
|
||||
@ -578,7 +581,7 @@ si32 CStack::Attack() const
|
||||
ret += (VLC->spellh->spells[56].powers[getEffect(56)->level]/100.0) * Defense(false);
|
||||
}
|
||||
|
||||
ret += valOfFeatures(StackFeature::ATTACK_BONUS, -1);
|
||||
ret += valOfFeatures(StackFeature::ATTACK_BONUS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -592,7 +595,7 @@ si32 CStack::Defense(bool withFrenzy /*= true*/) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret += valOfFeatures(StackFeature::DEFENCE_BONUS, -1);
|
||||
ret += valOfFeatures(StackFeature::DEFENCE_BONUS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ struct StackFeature
|
||||
{
|
||||
CREATURE_ABILITY,
|
||||
BONUS_FROM_HERO,
|
||||
SPELL_EFFECT
|
||||
SPELL_EFFECT,
|
||||
OTHER_SOURCE /*eg. bonus from terrain if native*/
|
||||
};
|
||||
|
||||
ui8 type;//ECombatFeatures
|
||||
|
@ -934,6 +934,18 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, CCreatureSet &army
|
||||
stacks[g]->position -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//adding native terrain bonuses
|
||||
for(int g=0; g<stacks.size(); ++g)
|
||||
{
|
||||
if( VLC->heroh->nativeTerrains[stacks[g]->creature->faction] == gs->map->terrain[tile.x][tile.y][tile.z].tertype )
|
||||
{
|
||||
stacks[g]->features.push_back(makeFeature(StackFeature::SPEED_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
|
||||
stacks[g]->features.push_back(makeFeature(StackFeature::ATTACK_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
|
||||
stacks[g]->features.push_back(makeFeature(StackFeature::DEFENCE_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
|
||||
}
|
||||
}
|
||||
|
||||
//adding war machines
|
||||
if(hero1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user