Explorar el Código

* fixed problem with levelling above 15 lvl (Zamolxis #2 bug)
* probably fixed reported problems with battles (Zamolxis #3 - #7) - needs further testing

mateuszb hace 17 años
padre
commit
73cd282bbe
Se han modificado 5 ficheros con 61 adiciones y 11 borrados
  1. 42 6
      CBattleInterface.cpp
  2. 1 0
      CBattleInterface.h
  3. 10 2
      CGameState.cpp
  4. 3 2
      hch/CHeroHandler.cpp
  5. 5 1
      hch/CObjectHandler.cpp

+ 42 - 6
CBattleInterface.cpp

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

+ 1 - 0
CBattleInterface.h

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

+ 10 - 2
CGameState.cpp

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

+ 3 - 2
hch/CHeroHandler.cpp

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

+ 5 - 1
hch/CObjectHandler.cpp

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