Sfoglia il codice sorgente

Fixed Remove Obstacle. TODO: limit its working on spell-created obstacles depending on spell school level.

Michał W. Urbańczyk 12 anni fa
parent
commit
1e11904d8a
2 ha cambiato i file con 30 aggiunte e 8 eliminazioni
  1. 26 0
      lib/CBattleCallback.cpp
  2. 4 8
      server/CGameHandler.cpp

+ 26 - 0
lib/CBattleCallback.cpp

@@ -1778,6 +1778,32 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 
 	if(spell->getTargetType() == CSpell::OBSTACLE)
 	{
+		if(spell->id == SpellID::REMOVE_OBSTACLE)
+		{
+			if(auto obstacle = battleGetObstacleOnPos(dest, false))
+			{
+				switch (obstacle->obstacleType)
+				{
+				case CObstacleInstance::ABSOLUTE_OBSTACLE: //cliff-like obstacles cant be removed
+				case CObstacleInstance::MOAT: 
+					return ESpellCastProblem::NO_APPROPRIATE_TARGET;
+				case CObstacleInstance::USUAL:
+					return ESpellCastProblem::OK;
+
+// 				//TODO FIRE_WALL only for ADVANCED level casters
+// 				case CObstacleInstance::FIRE_WALL:
+// 					return 
+// 				//TODO other magic obstacles for EXPERT
+// 				case CObstacleInstance::QUICKSAND:
+// 				case CObstacleInstance::LAND_MINE:
+// 				case CObstacleInstance::FORCE_FIELD:
+// 					return 
+				default:
+//					assert(0);
+					return ESpellCastProblem::OK;
+				}
+			}
+		}
 		//isObstacleOnTile(dest)
 		//
 		//

+ 4 - 8
server/CGameHandler.cpp

@@ -4299,18 +4299,14 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 		break;
 	case SpellID::REMOVE_OBSTACLE:
 		{
-			ObstaclesRemoved obr;
-			for(auto &obstacle : battleGetAllObstacles())
+			if(auto obstacleToRemove = battleGetObstacleOnPos(destination, false))
 			{
-				if(vstd::contains(obstacle->getBlockedTiles(), destination))
-					obr.obstacles.insert(obstacle->uniqueID);
-			}
-
-			if(!obr.obstacles.empty())
+				ObstaclesRemoved obr;
+				obr.obstacles.insert(obstacleToRemove->uniqueID);
 				sendAndApply(&obr);
+			}
 			else
 				complain("There's no obstacle to remove!");
-			break;
 		}
 		break;
 	case SpellID::DEATH_STARE: //handled in a bit different way