mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* partial implementation of hero crossover
* minor fixes to resolution handling * other minor fixes and changes
This commit is contained in:
parent
4d171bd53c
commit
fc79b9b6cf
@ -383,6 +383,13 @@ void config::CConfigHandler::init()
|
||||
tlog1 << "Cannot parse config/settings.txt file!\n";
|
||||
else if(!info.full)
|
||||
tlog2 << "Not entire config/settings.txt parsed!\n";
|
||||
|
||||
//fixing screenx / screeny if set to 0x0
|
||||
if (cc.screenx == 0 && cc.screeny == 0)
|
||||
{
|
||||
cc.screenx = cc.resx;
|
||||
cc.screeny = cc.resy;
|
||||
}
|
||||
}
|
||||
|
||||
GUIOptions * config::CConfigHandler::go()
|
||||
|
@ -389,6 +389,8 @@ void processCommand(const std::string &message)
|
||||
for(j=conf.guiOptions.begin(); j!=conf.guiOptions.end() && hlp++<i; j++); //move j to the i-th resolution info
|
||||
conf.cc.resx = j->first.first;
|
||||
conf.cc.resy = j->first.second;
|
||||
conf.cc.screenx = j->first.first;
|
||||
conf.cc.screeny = j->first.second;
|
||||
tlog0 << "Screen resolution set to " << conf.cc.resx << " x " << conf.cc.resy <<". It will be aplied when the game starts.\n";
|
||||
}
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ void CPlayerInterface::gameOver(ui8 player, bool victory )
|
||||
{
|
||||
std::string txt = CGI->generaltexth->allTexts[5]; //%s has been vanquished!
|
||||
boost::algorithm::replace_first(txt, "%s", CGI->generaltexth->capColors[player]);
|
||||
showInfoDialog(txt,std::vector<SComponent*>(1, new SComponent(SComponent::flag, player, 0)));
|
||||
//showInfoDialog(txt,std::vector<SComponent*>(1, new SComponent(SComponent::flag, player, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2388,7 +2388,7 @@ void CBonusSelection::selectMap( int whichOne )
|
||||
// mapInfo->countPlayers();
|
||||
// mapInfo->mapHeader = NULL;
|
||||
CMapInfo dummyInfo(false);
|
||||
dummyInfo.filename = "lala";
|
||||
dummyInfo.filename = ourCampaign->camp->header.filename;
|
||||
|
||||
|
||||
CSelectionScreen::updateStartInfo(curMap ? curMap : &dummyInfo, sInfo, ourHeader);
|
||||
@ -2607,13 +2607,30 @@ void CBonusSelection::updateBonusSelection()
|
||||
boost::algorithm::replace_first(desc, "%s", replacement);
|
||||
}
|
||||
break;
|
||||
case 8: //player
|
||||
//TODO
|
||||
continue;
|
||||
case 8: //player aka hero crossover
|
||||
surfToDuplicate = graphics->flags->ourImages[bonDescs[i].info1].bitmap;
|
||||
desc = CGI->generaltexth->allTexts[718];
|
||||
|
||||
boost::algorithm::replace_first(desc, "%s", CGI->generaltexth->capColors[bonDescs[i].info1]); //player color
|
||||
boost::algorithm::replace_first(desc, "%s", ourCampaign->camp->scenarios[bonDescs[i].info2].mapName); //scenario
|
||||
|
||||
break;
|
||||
case 9: //hero
|
||||
//TODO
|
||||
continue;
|
||||
|
||||
desc = CGI->generaltexth->allTexts[718];
|
||||
boost::algorithm::replace_first(desc, "%s", CGI->generaltexth->capColors[bonDescs[i].info1]); //hero's color
|
||||
|
||||
if (bonDescs[i].info2 == 0xFFFF)
|
||||
{
|
||||
boost::algorithm::replace_first(desc, "%s", CGI->heroh->heroes[0]->name); //hero's name
|
||||
surfToDuplicate = graphics->portraitLarge[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
boost::algorithm::replace_first(desc, "%s", CGI->heroh->heroes[bonDescs[i].info2]->name); //hero's name
|
||||
surfToDuplicate = graphics->portraitLarge[bonDescs[i].info2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2650,8 +2667,14 @@ void CBonusSelection::updateBonusSelection()
|
||||
void CBonusSelection::startMap()
|
||||
{
|
||||
StartInfo *si = new StartInfo(sInfo);
|
||||
//don't pop - we should get back to this screen
|
||||
GH.popInts(3);
|
||||
if (ourCampaign->mapsConquered.size())
|
||||
{
|
||||
GH.popInts(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GH.popInts(3);
|
||||
}
|
||||
curOpts = NULL;
|
||||
::startGame(si);
|
||||
}
|
||||
|
@ -176,9 +176,7 @@ SDL_Surface * CSDL_Ext::copySurface(SDL_Surface * mod) //returns copy of given s
|
||||
|
||||
bool isItIn(const SDL_Rect * rect, int x, int y)
|
||||
{
|
||||
if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h))
|
||||
return true;
|
||||
else return false;
|
||||
return (x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h);
|
||||
}
|
||||
|
||||
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
||||
|
@ -5,7 +5,7 @@ clientSettings
|
||||
port=3030;
|
||||
resolution=800x600; // format: WxH
|
||||
pregameRes=800x600; //WxH
|
||||
screenSize=800x600; //WxH
|
||||
screenSize=0x0; //WxH, if 0x0 will be set to he same value as resolution
|
||||
bpp=24; // bits per pixels: 16, 24 or 32
|
||||
fullscreen=0; //0 - windowed mode, 1 - fullscreen
|
||||
server=127.0.0.1; //use 127.0.0.1 for localhost
|
||||
|
@ -8,6 +8,10 @@
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "../StartInfo.h"
|
||||
#include "CArtHandler.h" //for hero crossover
|
||||
#include "CObjectHandler.h" //for hero crossover
|
||||
#include "CHeroHandler.h"
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
@ -463,6 +467,82 @@ bool CCampaignScenario::isNotVoid() const
|
||||
return mapName.size() > 0;
|
||||
}
|
||||
|
||||
void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> heroes )
|
||||
{
|
||||
crossoverHeroes = heroes;
|
||||
|
||||
if (!(travelOptions.whatHeroKeeps & 1))
|
||||
{
|
||||
//trimming experience
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
cgh->initExp();
|
||||
}
|
||||
}
|
||||
if (!(travelOptions.whatHeroKeeps & 2))
|
||||
{
|
||||
//trimming prim skills
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
#define RESET_PRIM_SKILL(NAME, VALNAME) \
|
||||
cgh->getBonus(Selector::type(Bonus::PRIMARY_SKILL) && \
|
||||
Selector::subtype(PrimarySkill::NAME) && \
|
||||
Selector::sourceType(Bonus::HERO_BASE_SKILL) )->val = cgh->type->heroClass->VALNAME;
|
||||
|
||||
RESET_PRIM_SKILL(ATTACK, initialAttack);
|
||||
RESET_PRIM_SKILL(DEFENSE, initialDefence);
|
||||
RESET_PRIM_SKILL(SPELL_POWER, initialPower);
|
||||
RESET_PRIM_SKILL(KNOWLEDGE, initialKnowledge);
|
||||
#undef RESET_PRIM_SKILL
|
||||
}
|
||||
}
|
||||
if (!(travelOptions.whatHeroKeeps & 4))
|
||||
{
|
||||
//trimming sec skills
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
cgh->secSkills = cgh->type->secSkillsInit;
|
||||
}
|
||||
}
|
||||
if (!(travelOptions.whatHeroKeeps & 8))
|
||||
{
|
||||
//trimming spells
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
cgh->spells.clear();
|
||||
}
|
||||
}
|
||||
if (!(travelOptions.whatHeroKeeps & 16))
|
||||
{
|
||||
//trimming artifacts
|
||||
for (int g=0; g<VLC->arth->artifacts.size(); ++g)
|
||||
{
|
||||
bool takeable = travelOptions.artifsKeptByHero[g / 8] & ( 1 << (g%8) ) ;
|
||||
if (!takeable)
|
||||
{
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
cgh->artifacts -= g;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//trimming creatures
|
||||
BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
|
||||
{
|
||||
CCreatureSet army = cgh->getArmy();
|
||||
for (TSlots::iterator j = army.slots.begin(); j != army.slots.end(); j++)
|
||||
{
|
||||
if (! (travelOptions.monstersKeptByHero[j->first / 8] & (1 << (j->first%8)) ))
|
||||
{
|
||||
army.slots.erase(j);
|
||||
j = army.slots.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CScenarioTravel::STravelBonus::isBonusForHero() const
|
||||
{
|
||||
return type == 0 || type == 1 || type == 3 || type == 4 || type == 5 || type == 6;
|
||||
@ -482,8 +562,9 @@ void CCampaignState::initNewCampaign( const StartInfo &si )
|
||||
mapsRemaining.push_back(i);
|
||||
}
|
||||
|
||||
void CCampaignState::mapConquered()
|
||||
void CCampaignState::mapConquered( const std::vector<CGHeroInstance*> & heroes )
|
||||
{
|
||||
camp->scenarios[currentMap].prepareCrossoverHeroes(heroes);
|
||||
mapsConquered.push_back(currentMap);
|
||||
mapsRemaining -= currentMap;
|
||||
camp->scenarios[currentMap].conquered = true;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
struct StartInfo;
|
||||
class CGHeroInstance;
|
||||
|
||||
class DLL_EXPORT CCampaignHeader
|
||||
{
|
||||
@ -98,12 +99,16 @@ public:
|
||||
|
||||
CScenarioTravel travelOptions;
|
||||
|
||||
std::vector<CGHeroInstance*> crossoverHeroes;
|
||||
|
||||
void prepareCrossoverHeroes(std::vector<CGHeroInstance *> heroes);
|
||||
|
||||
bool isNotVoid() const;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||
{
|
||||
h & mapName & packedMapSize & preconditionRegion & regionColor & difficulty & conquered & regionText &
|
||||
prolog & epilog & travelOptions;
|
||||
prolog & epilog & travelOptions & crossoverHeroes;
|
||||
}
|
||||
};
|
||||
|
||||
@ -133,7 +138,7 @@ public:
|
||||
ui8 currentMap;
|
||||
|
||||
void initNewCampaign(const StartInfo &si);
|
||||
void mapConquered();
|
||||
void mapConquered(const std::vector<CGHeroInstance*> & heroes);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
@ -834,8 +834,7 @@ void CGHeroInstance::initHero()
|
||||
name = type->name;
|
||||
if (exp == 0xffffffff)
|
||||
{
|
||||
exp=40+ (ran()) % 50;
|
||||
level = 1;
|
||||
initExp();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1568,6 +1567,12 @@ EAlignment CGHeroInstance::getAlignment() const
|
||||
return type->heroClass->getAlignment();
|
||||
}
|
||||
|
||||
void CGHeroInstance::initExp()
|
||||
{
|
||||
exp=40+ (ran()) % 50;
|
||||
level = 1;
|
||||
}
|
||||
|
||||
void CGDwelling::initObj()
|
||||
{
|
||||
switch(ID)
|
||||
|
@ -354,6 +354,8 @@ public:
|
||||
|
||||
void initHero();
|
||||
void initHero(int SUBID);
|
||||
|
||||
void initExp();
|
||||
void initArmy(CCreatureSet *dst = NULL);
|
||||
void giveArtifact (ui32 aid);
|
||||
void initHeroDefInfo();
|
||||
|
@ -4783,7 +4783,7 @@ void CGameHandler::checkLossVictory( ui8 player )
|
||||
|
||||
if(gs->campaign)
|
||||
{
|
||||
gs->campaign->mapConquered();
|
||||
gs->campaign->mapConquered(gs->map->heroes);
|
||||
|
||||
UpdateCampaignState ucs;
|
||||
ucs.camp = gs->campaign;
|
||||
|
Loading…
Reference in New Issue
Block a user