浏览代码

- Fixed Phoenix fire immunity. Again.
- Cheat code with grant all artifacts, including the ones added by mods
- Some clean-up of Berserk effect, however it doesn't work at the moment.

DjWarmonger 12 年之前
父节点
当前提交
c9e95f76df
共有 4 个文件被更改,包括 18 次插入17 次删除
  1. 4 2
      config/creatures/conflux.json
  2. 11 12
      lib/CBattleCallback.cpp
  3. 1 1
      lib/CBattleCallback.h
  4. 2 2
      server/CGameHandler.cpp

+ 4 - 2
config/creatures/conflux.json

@@ -486,7 +486,8 @@
 		{
 			"immuneToFire" :
 			{
-				"type" : "FIRE_IMMUNITY"
+				"type" : "FIRE_IMMUNITY",
+				"subtype" : 0 //this IS important
 			},
 		},
 		"graphics" :
@@ -516,7 +517,8 @@
 			},
 			"immuneToFire" :
 			{
-				"type" : "FIRE_IMMUNITY"
+				"type" : "FIRE_IMMUNITY",
+				"subtype" : 0 //this IS important
 			},
 			"rebirth" : 
 			{

+ 11 - 12
lib/CBattleCallback.cpp

@@ -1181,7 +1181,7 @@ std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePe
 	return ret;
 }
 
-std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned, bool ignoreItself) const
+std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const
 {
 	auto reachability = getReachability(closest);
 
@@ -1196,29 +1196,28 @@ 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
+		if(!atG || atG->ID == closest->ID) //if there is no stack or we are the closest one
 			continue;
 
 		if(boost::logic::indeterminate(attackerOwned) || atG->attackerOwned == attackerOwned)
 		{
-			if(reachability.isReachable(g))
-				continue;
-
-			DistStack hlp = {reachability.distances[reachability.predecessors[g]], atG};
-			stackPairs.push_back(hlp);
+			if (reachability.isReachable(g))
+			//FIXME: hexes occupied by enemy stack are not accessible. Need to use BattleInfo::getPath or similiar
+			{
+				DistStack hlp = {reachability.distances[reachability.predecessors[g]], atG};
+				stackPairs.push_back(hlp);
+			}
 		}
 	}
 
-	if(stackPairs.size() > 0)
+	if (stackPairs.size())
 	{
 		auto comparator = [](DistStack lhs, DistStack rhs) { return lhs.distanceToPred < rhs.distanceToPred; };
 		auto minimal = boost::min_element(stackPairs, comparator);
 		return std::make_pair(minimal->stack, reachability.predecessors[minimal->stack->position]);
 	}
-
-	return std::make_pair<const CStack * , BattleHex>(NULL, BattleHex::INVALID);
+	else
+		return std::make_pair<const CStack * , BattleHex>(NULL, BattleHex::INVALID);
 }
 
 si8 CBattleInfoCallback::battleGetTacticDist() const

+ 1 - 1
lib/CBattleCallback.h

@@ -291,7 +291,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, bool ignoreItself = false) const;
+	std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const;
 protected:
 	ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters params) const;
 	ReachabilityInfo makeBFS(const AccessibilityInfo &accessibility, const ReachabilityInfo::Parameters params) const;

+ 2 - 2
server/CGameHandler.cpp

@@ -3839,7 +3839,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 	{
 		CGHeroInstance *hero = gs->getHero(gs->getPlayer(player)->currentSelection);
 		if(!hero) return;
-		for (int g=7; g<=140; ++g)
+		for (int g = 7; g < VLC->arth->artifacts.size(); ++g) //including artifacts from mods
 			giveHeroNewArtifact(hero, VLC->arth->artifacts[g], ArtifactPosition::PRE_FIRST);
 	}
 	else
@@ -5827,7 +5827,7 @@ void CGameHandler::runBattle()
 
 			if(next->hasBonusOfType(Bonus::ATTACKS_NEAREST_CREATURE)) //while in berserk
 			{ //fixme: stack should not attack itself
-				std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate, true);
+				std::pair<const CStack *, int> attackInfo = curB.getNearestStack(next, boost::logic::indeterminate);
 				if(attackInfo.first != NULL)
 				{
 					BattleAction attack;