1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

* Ammo Cart won't get move

* fixed crashes on equipping artifacts
* fixed Wisdom handling
This commit is contained in:
Michał W. Urbańczyk 2009-03-29 12:02:37 +00:00
parent d3246cc6de
commit cb31f5ada3
9 changed files with 35 additions and 28 deletions

View File

@ -519,11 +519,13 @@ void CBattleInterface::show(SDL_Surface * to)
//printing amount
if(curStack.amount > 0 //don't print if stack is not alive
&& !LOCPLINT->curAction
&& (!LOCPLINT->curAction
|| (LOCPLINT->curAction->stackNumber != curStackID //don't print if stack is currently taking an action
&& (LOCPLINT->curAction->actionType != 6 || curStack.position != LOCPLINT->curAction->additionalInfo) //nor if it's an object of attack
&& (LOCPLINT->curAction->destinationTile != curStack.position) //nor if it's on destination tile for current action
)
)
&& !vstd::contains(curStack.abilities,SIEGE_WEAPON) //and not a war machine...
)
{
int xAdd = curStack.attackerOwned ? 220 : 202;

View File

@ -379,11 +379,13 @@ int CCallback::getMySerial() const
return gs->players[player].serial;
}
bool CCallback::swapArifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)
bool CCallback::swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)
{
if(player!=hero1->tempOwner || player!=hero2->tempOwner)
return false;
*cl->serv << ui16(509) << hero1->id << pos1 << hero2->id << pos2;
ExchangeArtifacts ea(hero1->id, pos1, hero2->id, pos2);
*cl->serv << &ea;
return true;
}

View File

@ -36,7 +36,7 @@ public:
virtual int mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//joins first stack tothe second (creatures must be same type)
virtual int splitStack(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2, int val)=0;//split creatures from the first stack
virtual bool dismissHero(const CGHeroInstance * hero)=0; //dismisses diven hero; true - successfuly, false - not successfuly
virtual bool swapArifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)=0; //swaps artifacts between two given heroes
virtual bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2)=0; //swaps artifacts between two given heroes
virtual void recruitCreatures(const CGObjectInstance *obj, ui32 ID, ui32 amount)=0;
virtual bool dismissCreature(const CArmedInstance *obj, int stackPos)=0;
virtual bool upgradeCreature(const CArmedInstance *obj, int stackPos, int newID=-1)=0; //if newID==-1 then best possible upgrade will be made
@ -125,7 +125,7 @@ public:
int mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2); //first goes to the second
int splitStack(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2, int val);
bool dismissHero(const CGHeroInstance * hero);
bool swapArifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2);
bool swapArtifacts(const CGHeroInstance * hero1, ui16 pos1, const CGHeroInstance * hero2, ui16 pos2);
bool buildBuilding(const CGTownInstance *town, si32 buildingID);
void recruitCreatures(const CGObjectInstance *obj, ui32 ID, ui32 amount);
bool dismissCreature(const CArmedInstance *obj, int stackPos);

View File

@ -507,6 +507,15 @@ si8 CStack::Luck() const
if(ret < -3) ret = -3;
return ret;
}
bool CStack::willMove()
{
return !vstd::contains(state,DEFENDING)
&& !vstd::contains(state,MOVED)
&& alive()
&& !vstd::contains(abilities,NOT_ACTIVE); //eg. Ammo Cart
}
CGHeroInstance* CGameState::HeroesPool::pickHeroFor(bool native, int player, const CTown *town, int notThatOne)
{
if(player<0 || player>=PLAYER_LIMIT)
@ -1852,22 +1861,13 @@ CStack * BattleInfo::getNextStack()
CStack *current = getStack(activeStack);
for (int i = 0; i < stacks.size(); i++) //find fastest not moved/waited stack (stacks vector is sorted by speed)
{
if(vstd::contains(stacks[i]->state,DEFENDING)
||vstd::contains(stacks[i]->state,WAITING)
||vstd::contains(stacks[i]->state,MOVED)
||!stacks[i]->alive()
)
continue;
return stacks[i];
if(stacks[i]->willMove() && !vstd::contains(stacks[i]->state,WAITING))
return stacks[i];
}
for (int i = stacks.size() - 1; i >= 0 ; i--) //find slowest waiting stack
{
if(vstd::contains(stacks[i]->state,DEFENDING)
||vstd::contains(stacks[i]->state,MOVED)
||!stacks[i]->alive()
)
continue;
return stacks[i];
if(stacks[i]->willMove())
return stacks[i];
}
return NULL; //all stacks moved or defending!
}
@ -1893,7 +1893,8 @@ std::vector<CStack> BattleInfo::getStackQueue()
&& stacks[i]->alive()
&& (moved == 1 || !vstd::contains(stacks[i]->state,MOVED))
&& !vstd::contains(stacks[i]->state,WAITING)
&& taken[i]==0)
&& taken[i]==0
&& !vstd::contains(stacks[i]->abilities,NOT_ACTIVE)) //eg. Ammo Cart
{
if(speed == -1 || stacks[i]->speed() > speed)
{
@ -1916,7 +1917,8 @@ std::vector<CStack> BattleInfo::getStackQueue()
&& stacks[i]->alive()
&& (moved == 1 || !vstd::contains(stacks[i]->state,MOVED))
&& vstd::contains(stacks[i]->state,WAITING)
&& taken[i]==0)
&& taken[i]==0
&& !vstd::contains(stacks[i]->abilities,NOT_ACTIVE)) //eg. Ammo Cart
{
if(stacks[i]->speed() < speed) //slowest one
{

View File

@ -160,6 +160,7 @@ public:
CStack(CCreature * C, int A, int O, int I, bool AO, int S);
CStack() : creature(NULL),amount(-1),owner(255), position(-1), ID(-1), attackerOwned(true), firstHPleft(-1), slot(255), baseAmount(-1), counterAttacks(1), effects(), state(), abilities(){}
const StackEffect * getEffect(ui16 id) const; //effect id (SP)
bool willMove(); //if stack has remaining move this turn
ui32 speed() const;
si8 Morale() const;
si8 Luck() const;

View File

@ -754,7 +754,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
//chceck if swap is possible
if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
{
LOCPLINT->cb->swapArifacts(ourWindow->curHero,slotID,ourWindow->curHero,ourWindow->activeArtPlace->slotID);
LOCPLINT->cb->swapArtifacts(ourWindow->curHero,slotID,ourWindow->curHero,ourWindow->activeArtPlace->slotID);
const CArtifact * pmh = ourArt;
ourArt = ourWindow->activeArtPlace->ourArt;

View File

@ -19,7 +19,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
#define THC
#endif
#define NAME_VER ("VCMI 0.7d")
#define NAME_VER ("VCMI 0.7d2")
#define CONSOLE_LOGGING_LEVEL 5
#define FILE_LOGGING_LEVEL 6
@ -48,8 +48,8 @@ enum EAbilities {DOUBLE_WIDE, FLYING, SHOOTER, TWO_HEX_ATTACK, SIEGE_ABILITY, SI
KING1, KING2, KING3, MIND_IMMUNITY, NO_OBSTACLE_PENALTY, NO_CLOSE_COMBAT_PENALTY,
JOUSTING, FIRE_IMMUNITY, TWICE_ATTACK, NO_ENEMY_RETALIATION, NO_MORAL_PENALTY,
UNDEAD, MULTI_HEAD_ATTACK, EXTENDED_RADIOUS_SHOOTER, GHOST, RAISES_MORALE,
LOWERS_MORALE, DRAGON, STRIKE_AND_RETURN, FEARLESS, REBIRTH}; //some flags are used only for battles
enum ECombatInfo{ALIVE = REBIRTH+1, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING};
LOWERS_MORALE, DRAGON, STRIKE_AND_RETURN, FEARLESS, REBIRTH, NOT_ACTIVE}; //some flags are used only for battles
enum ECombatInfo{ALIVE = NOT_ACTIVE+1, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING};
class CGameInfo;
extern CGameInfo* CGI;

View File

@ -451,8 +451,7 @@ void CCreatureHandler::loadCreatures()
}
inp2.close();
//TODO: create a tidy configuration file to control fixing unit abilities
creatures[115].abilities.insert(DOUBLE_WIDE);//water elemental should be treated as double-wide
creatures[123].abilities.insert(DOUBLE_WIDE);//ice elemental should be treated as double-wide
creatures[140].abilities.insert(DOUBLE_WIDE);//boar should be treated as double-wide
@ -465,8 +464,9 @@ void CCreatureHandler::loadCreatures()
creatures[47].abilities += MULTI_HEAD_ATTACK; //cerberus
creatures[88].abilities += TWICE_ATTACK; //wolf raider
creatures[148].abilities += NOT_ACTIVE; //Ammo Cart
}
void CCreatureHandler::loadAnimationInfo()

View File

@ -1112,7 +1112,7 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
ChangeSpells cs;
cs.hid = h->id;
cs.learn = true;
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(7)+4);i++)
for(int i=0; i<std::min(t->mageGuildLevel(),h->getSecSkillLevel(7)+2);i++)
{
for(int j=0; j<t->spellsAtLevel(i+1,true) && j<t->spells[i].size(); j++)
{