Sfoglia il codice sorgente

Fixed Berserk spell effect aka Bonus::ATTACKS_NEAREST_CREATURE
* issue http://bugs.vcmi.eu/view.php?id=2513
* fix is not retroactive

AlexVinS 9 anni fa
parent
commit
34b8b2c91b
3 ha cambiato i file con 7 aggiunte e 30 eliminazioni
  1. 3 28
      config/spells/timed.json
  2. 0 1
      lib/BattleState.h
  3. 4 1
      server/CGameHandler.cpp

+ 3 - 28
config/spells/timed.json

@@ -1113,40 +1113,15 @@
 				"effects" : {
 					"attacksNearestCreature" : {
 						"type" : "ATTACKS_NEAREST_CREATURE",
-						"duration" : "N_TURNS",
-						"turns" : 1
-					}
-				}
-			},
-			"none":{
-				"effects" : {
-					"attacksNearestCreature" : {
-						"val" : 0
-					}
-				}
-			},
-			"basic":{
-				"effects" : {
-					"attacksNearestCreature" : {
-						"val" : 1
+						"duration" : "STACK_GETS_TURN"
 					}
 				}
 			},
 			"advanced":{
-				"range" : "0-1",
-				"effects" : {
-					"attacksNearestCreature" : {
-						"val" : 2
-					}
-				}
+				"range" : "0-1"
 			},
 			"expert":{
-				"range" : "0-2",
-				"effects" : {
-					"attacksNearestCreature" : {
-						"val" : 3
-					}
-				}
+				"range" : "0-2"
 			}
 		},
 		"absoluteImmunity" : {

+ 0 - 1
lib/BattleState.h

@@ -139,7 +139,6 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	CStack * generateNewStack(const CStackInstance &base, bool attackerOwned, SlotID slot, BattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
 	CStack * generateNewStack(const CStackBasicDescriptor &base, bool attackerOwned, SlotID slot, BattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
 	int getIdForNewStack() const; //suggest a currently unused ID that'd suitable for generating a new stack
-	//std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex)
 
 	const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player
 

+ 4 - 1
server/CGameHandler.cpp

@@ -5704,7 +5704,8 @@ void CGameHandler::runBattle()
 			}
 
 			if(next->hasBonusOfType(Bonus::ATTACKS_NEAREST_CREATURE)) //while in berserk
-			{ //fixme: stack should not attack itself
+			{
+				logGlobal->debug("Handle Berserk effect");
 				std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate);
 				if(attackInfo.first != nullptr)
 				{
@@ -5716,10 +5717,12 @@ void CGameHandler::runBattle()
 					attack.destinationTile = attackInfo.second;
 
 					makeAutomaticAction(next, attack);
+					logGlobal->debug("Attacked nearest target %s", attackInfo.first->nodeName());
 				}
 				else
 				{
 					makeStackDoNothing(next);
+					logGlobal->debug("No target found");
 				}
 				continue;
 			}