浏览代码

* support for armor of the damned

mateuszb 15 年之前
父节点
当前提交
0ac8430b11
共有 4 个文件被更改,包括 26 次插入6 次删除
  1. 2 2
      client/CBattleInterface.cpp
  2. 2 2
      lib/CGameState.cpp
  3. 1 1
      lib/CGameState.h
  4. 21 1
      server/CGameHandler.cpp

+ 2 - 2
client/CBattleInterface.cpp

@@ -2625,8 +2625,8 @@ void CBattleInterface::spellCast(BattleSpellCast * sc)
 {
 	CSpell &spell = CGI->spellh->spells[sc->id];
 
-
-	if(sc->castedByHero && sc->side == !curInt->cb->battleGetStackByID(activeStack)->attackerOwned)
+	//spell opening battle is cast when no stack is active
+	if(sc->castedByHero && ( activeStack == -1 || sc->side == !curInt->cb->battleGetStackByID(activeStack)->attackerOwned) )
 		bSpell->block(true);
 
 	std::vector< std::string > anims; //for magic arrow and ice bolt

+ 2 - 2
lib/CGameState.cpp

@@ -2776,10 +2776,10 @@ std::set<CStack*> BattleInfo::getAttackedCreatures( const CSpell * s, int skillL
 	return attackedCres;
 }
 
-int BattleInfo::calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster)
+int BattleInfo::calculateSpellDuration( const CSpell * spell, const CGHeroInstance * caster, int usedSpellPower )
 {
 	if(!caster) //TODO: something better
-		return 5;
+		return std::max(5, usedSpellPower);
 	switch(spell->id)
 	{
 	case 56: //frenzy

+ 1 - 1
lib/CGameState.h

@@ -208,7 +208,7 @@ struct DLL_EXPORT BattleInfo : public CBonusSystemNode
 	std::pair<ui32, ui32> calculateDmgRange(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky); //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
 	void calculateCasualties(std::map<ui32,si32> *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount)
 	std::set<CStack*> getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, int destinationTile); //calculates stack affected by given spell
-	static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster);
+	static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster, int usedSpellPower);
 	CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, int /*TerrainTile::EterrainType*/ terrain, int position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
 	ui32 getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell
 	int hexToWallPart(int hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found

+ 21 - 1
server/CGameHandler.cpp

@@ -349,6 +349,26 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
 		}
 	}
 
+	//spells opening battle
+	if (hero1 && hero1->hasBonusOfType(Bonus::OPENING_BATTLE_SPELL))
+	{
+		BonusList bl;
+		hero1->getBonuses(bl, Selector::type(Bonus::OPENING_BATTLE_SPELL));
+		BOOST_FOREACH (Bonus b, bl)
+		{
+			handleSpellCasting(b.subtype, 3, -1, 0, hero1->tempOwner, NULL, hero2, b.val);
+		}
+	}
+	if (hero2 && hero2->hasBonusOfType(Bonus::OPENING_BATTLE_SPELL))
+	{
+		BonusList bl;
+		hero2->getBonuses(bl, Selector::type(Bonus::OPENING_BATTLE_SPELL));
+		BOOST_FOREACH (Bonus b, bl)
+		{
+			handleSpellCasting(b.subtype, 3, -1, 1, hero2->tempOwner, NULL, hero1, b.val);
+		}
+	}
+
 	//main loop
 	while(!battleResult.get()) //till the end of the battle ;]
 	{
@@ -3736,7 +3756,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
 			}
 			sse.effect.id = spellID;
 			sse.effect.level = spellLvl;
-			sse.effect.turnsRemain = BattleInfo::calculateSpellDuration(spell, caster);
+			sse.effect.turnsRemain = BattleInfo::calculateSpellDuration(spell, caster, usedSpellPower);
 			if(!sse.stacks.empty())
 				sendAndApply(&sse);
 			break;