Browse Source

- Added missing abilities for devil & ghost dragon
- Stack affected by Berserk should not try to attack itself

Neither of these can be actually seen in game duo to more general engine bugs :/

DjWarmonger 12 years ago
parent
commit
32c87f532f

+ 2 - 1
config/creatures/inferno.json

@@ -347,7 +347,8 @@
 			{
 				"type" : "HATE",
 				"subtype" : "creature.angel",
-				"val" : 50
+				"val" : 50,
+				"description" : "Devil -1"
 			},
 			"FLYING_ARMY" :
 			{

+ 13 - 1
config/creatures/necropolis.json

@@ -329,6 +329,12 @@
 			"dragon" :
 			{
 				"type" : "DRAGON_NATURE"
+			},
+			"descreaseMorale" :
+			{
+				"type" : "MORALE",
+				"effectRange" : "ONLY_ENEMY_ARMY",
+				"val" : -1
 			}
 		},
 		"upgrades": ["ghostDragon"],
@@ -354,7 +360,13 @@
 		{
 			"dragon" :
 			{
-				"type" : "DRAGON_NATURE"
+				"type" : "DRAGON_NATURE",
+			},
+			"descreaseMorale" :
+			{
+				"type" : "MORALE",
+				"effectRange" : "ONLY_ENEMY_ARMY",
+				"val" : -1
 			},
 			"age" :
 			{

+ 1 - 3
lib/BattleState.cpp

@@ -684,7 +684,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 		curB->tacticDistance = 0;
 
 
-	// workaround — bonuses affecting only enemy
+	// workaround — bonuses affecting only enemy - DOES NOT WORK
 	for(int i = 0; i < 2; i++)
 	{
 		TNodes nodes;
@@ -883,8 +883,6 @@ void CStack::postInit()
 	assert(type);
 	assert(getParentNodes().size());
 
-	//FIXME: the following should take into account ONLY_ENEMY_ARMY bonus range
-
 	firstHPleft = MaxHealth();
 	shots = getCreature()->valOfBonuses(Bonus::SHOTS);
 	counterAttacks = 1 + valOfBonuses(Bonus::ADDITIONAL_RETALIATION);

+ 3 - 1
lib/CBattleCallback.cpp

@@ -1175,7 +1175,7 @@ std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePe
 	return ret;
 }
 
-std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const
+std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned, bool ignoreItself) const
 {
 	auto reachability = getReachability(closest);
 
@@ -1190,6 +1190,8 @@ std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const
 	for(int g=0; g<GameConstants::BFIELD_SIZE; ++g)
 	{
 		const CStack * atG = battleGetStackByPos(g);
+		if (ignoreItself && atG == closest) //don't attack itself in berserk
+			continue;
 		if(!atG || atG->ID == closest->ID) //if there is not stack or we are the closest one
 			continue;
 

+ 1 - 1
lib/CBattleCallback.h

@@ -290,7 +290,7 @@ public:
 	AccessibilityInfo getAccesibility() const;
 	AccessibilityInfo getAccesibility(const CStack *stack) const; //Hexes ocupied by stack will be marked as accessible.
 	AccessibilityInfo getAccesibility(const std::vector<BattleHex> &accessibleHexes) const; //given hexes will be marked as accessible
-	std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const;
+	std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned, bool ignoreItself = false) const;
 protected:
 	ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters params) const;
 	ReachabilityInfo makeBFS(const AccessibilityInfo &accessibility, const ReachabilityInfo::Parameters params) const;

+ 2 - 2
server/CGameHandler.cpp

@@ -5780,8 +5780,8 @@ void CGameHandler::runBattle()
 			}
 
 			if(next->hasBonusOfType(Bonus::ATTACKS_NEAREST_CREATURE)) //while in berserk
-			{
-				std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate);
+			{ //fixme: stack should not attack itself
+				std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate, true);
 				if(attackInfo.first != NULL)
 				{
 					BattleAction attack;