1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-06 23:26:26 +02:00

* fixed problem with levelling above 15 lvl (Zamolxis #2 bug)

* probably fixed reported problems with battles (Zamolxis #3 - #7) - needs further testing
This commit is contained in:
mateuszb 2008-11-14 18:18:13 +00:00
parent 0cc5571604
commit 73cd282bbe
5 changed files with 61 additions and 11 deletions

View File

@ -634,8 +634,16 @@ bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick)
if(wideTrick && curs.creature->isDoubleWide()) if(wideTrick && curs.creature->isDoubleWide())
{ {
if(!creDir[number]) if(curs.attackerOwned)
creAnims[number]->pos.x -= 44; {
if(!creDir[number])
creAnims[number]->pos.x -= 44;
}
else
{
if(creDir[number])
creAnims[number]->pos.x += 44;
}
} }
creAnims[number]->setType(7); creAnims[number]->setType(7);
@ -959,6 +967,7 @@ void CBattleInterface::stackAttacking(int ID, int dest)
SDL_framerateDelay(LOCPLINT->mainFPSmng); SDL_framerateDelay(LOCPLINT->mainFPSmng);
} }
CStack aStack = *LOCPLINT->cb->battleGetStackByID(ID); //attacking stack CStack aStack = *LOCPLINT->cb->battleGetStackByID(ID); //attacking stack
int reversedShift = 0; //shift of attacking stack's position due to reversing
if(aStack.attackerOwned) if(aStack.attackerOwned)
{ {
if(aStack.creature->isDoubleWide()) if(aStack.creature->isDoubleWide())
@ -980,6 +989,13 @@ void CBattleInterface::stackAttacking(int ID, int dest)
case 5: case 5:
reverseCreature(ID, aStack.position, true); reverseCreature(ID, aStack.position, true);
break; break;
case -1:
if(BattleInfo::mutualPosition(aStack.position + (aStack.attackerOwned ? -1 : 1), dest) >= 0) //if reversing stack will make its position adjacent to dest
{
reverseCreature(ID, aStack.position, true);
reversedShift = (aStack.attackerOwned ? -1 : 1);
}
break;
} }
} }
else //else for if(aStack.creature->isDoubleWide()) else //else for if(aStack.creature->isDoubleWide())
@ -1026,6 +1042,13 @@ void CBattleInterface::stackAttacking(int ID, int dest)
case 5: case 5:
//reverseCreature(ID, aStack.position, true); //reverseCreature(ID, aStack.position, true);
break; break;
case -1:
if(BattleInfo::mutualPosition(aStack.position + (aStack.attackerOwned ? -1 : 1), dest) >= 0) //if reversing stack will make its position adjacent to dest
{
reverseCreature(ID, aStack.position, true);
reversedShift = (aStack.attackerOwned ? -1 : 1);
}
break;
} }
} }
else //else for if(aStack.creature->isDoubleWide()) else //else for if(aStack.creature->isDoubleWide())
@ -1061,9 +1084,10 @@ void CBattleInterface::stackAttacking(int ID, int dest)
attackingInfo->ID = ID; attackingInfo->ID = ID;
attackingInfo->IDby = LOCPLINT->cb->battleGetStackByPos(dest)->ID; attackingInfo->IDby = LOCPLINT->cb->battleGetStackByPos(dest)->ID;
attackingInfo->reversing = false; attackingInfo->reversing = false;
attackingInfo->posShiftDueToDist = reversedShift;
attackingInfo->shooting = false; attackingInfo->shooting = false;
switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction switch(BattleInfo::mutualPosition(aStack.position + reversedShift, dest)) //attack direction
{ {
case 0: case 0:
attackingInfo->maxframe = creAnims[ID]->framesInGroup(11); attackingInfo->maxframe = creAnims[ID]->framesInGroup(11);
@ -1165,8 +1189,7 @@ void CBattleInterface::hexLclicked(int whichOne)
} }
} }
else if(dest->owner != attackingHeroInstance->tempOwner else if(dest->owner != attackingHeroInstance->tempOwner
&& LOCPLINT->cb->battleCanShoot(activeStack, whichOne) && LOCPLINT->cb->battleCanShoot(activeStack, whichOne) ) //shooting
&& BattleInfo::mutualPosition(LOCPLINT->cb->battleGetPos(activeStack),whichOne) < 0 ) //shooting
{ {
CGI->curh->changeGraphic(1, 6); //cursor should be changed CGI->curh->changeGraphic(1, 6); //cursor should be changed
giveCommand(7,whichOne,activeStack); giveCommand(7,whichOne,activeStack);
@ -1265,6 +1288,7 @@ void CBattleInterface::stackIsShooting(int ID, int dest)
attackingInfo->hitCount = 0; attackingInfo->hitCount = 0;
attackingInfo->ID = ID; attackingInfo->ID = ID;
attackingInfo->reversing = false; attackingInfo->reversing = false;
attackingInfo->posShiftDueToDist = 0;
attackingInfo->shooting = true; attackingInfo->shooting = true;
if(projectileAngle > straightAngle) //upper shot if(projectileAngle > straightAngle) //upper shot
attackingInfo->shootingGroup = 14; attackingInfo->shootingGroup = 14;
@ -1465,7 +1489,7 @@ void CBattleInterface::attackingShowHelper()
{ {
if(aStack.creature->isDoubleWide()) if(aStack.creature->isDoubleWide())
{ {
switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction switch(BattleInfo::mutualPosition(aStack.position+attackingInfo->posShiftDueToDist, attackingInfo->dest)) //attack direction
{ {
case 0: case 0:
creAnims[attackingInfo->ID]->setType(11); creAnims[attackingInfo->ID]->setType(11);
@ -1542,6 +1566,12 @@ void CBattleInterface::attackingShowHelper()
case 5: case 5:
reverseCreature(attackingInfo->ID, aStack.position, true); reverseCreature(attackingInfo->ID, aStack.position, true);
break; break;
case -1:
if(attackingInfo->posShiftDueToDist) //if reversing stack will make its position adjacent to dest
{
reverseCreature(attackingInfo->ID, aStack.position, true);
}
break;
} }
} }
else //else for if(aStack.creature->isDoubleWide()) else //else for if(aStack.creature->isDoubleWide())
@ -1588,6 +1618,12 @@ void CBattleInterface::attackingShowHelper()
case 5: case 5:
//reverseCreature(ID, aStack.position, true); //reverseCreature(ID, aStack.position, true);
break; break;
case -1:
if(attackingInfo->posShiftDueToDist) //if reversing stack will make its position adjacent to dest
{
reverseCreature(attackingInfo->ID, aStack.position, true);
}
break;
} }
} }
else //else for if(aStack.creature->isDoubleWide()) else //else for if(aStack.creature->isDoubleWide())

View File

@ -147,6 +147,7 @@ private:
int frame, maxframe; //frame of animation, number of frames of animation int frame, maxframe; //frame of animation, number of frames of animation
int hitCount; //for delaying animation int hitCount; //for delaying animation
bool reversing; bool reversing;
int posShiftDueToDist;
bool shooting; bool shooting;
int shootingGroup; //if shooting is true, print this animation group int shootingGroup; //if shooting is true, print this animation group
} * attackingInfo; } * attackingInfo;

View File

@ -188,8 +188,16 @@ bool BattleInfo::isStackBlocked(int ID)
|| stacks[i]->owner==our->owner || stacks[i]->owner==our->owner
) )
continue; //we ommit dead and allied stacks continue; //we ommit dead and allied stacks
if( mutualPosition(stacks[i]->position,our->position) >= 0 ) if(stacks[i]->creature->isDoubleWide())
return true; {
if( mutualPosition(stacks[i]->position, our->position) >= 0 || mutualPosition(stacks[i]->position + (stacks[i]->attackerOwned ? -1 : 1), our->position) >= 0)
return true;
}
else
{
if( mutualPosition(stacks[i]->position, our->position) >= 0 )
return true;
}
} }
return false; return false;
} }

View File

@ -346,17 +346,18 @@ unsigned int CHeroHandler::level(unsigned int experience)
unsigned int CHeroHandler::reqExp(unsigned int level) unsigned int CHeroHandler::reqExp(unsigned int level)
{ {
level-=1; level-=1;
if(level<=expPerLevel.size()) if(level<expPerLevel.size())
return expPerLevel[level]; return expPerLevel[level];
else else
{ {
unsigned int exp = expPerLevel[expPerLevel.size()-1]; unsigned int exp = expPerLevel[expPerLevel.size()-1];
level-=expPerLevel.size(); level-=(expPerLevel.size()-1);
while(level>0) while(level>0)
{ {
--level; --level;
exp*=1.2; exp*=1.2;
} }
return exp;
} }
return -1; return -1;
} }

View File

@ -618,11 +618,15 @@ void CGHeroInstance::initHero()
name = type->name; name = type->name;
if (!biography.length()) if (!biography.length())
biography = type->biography; biography = type->biography;
if (level<1) if (exp == -1)
{ {
exp=40+ (ran()) % 50; exp=40+ (ran()) % 50;
level = 1; level = 1;
} }
else
{
level = VLC->heroh->level(exp);
}
if (!army.slots.size()) //standard army//initial army if (!army.slots.size()) //standard army//initial army
{ {