2
0
Эх сурвалжийг харах

Partial support for Daemon Summoning.
It freezes for unknown reason, but still.

Minor fixes.

DjWarmonger 14 жил өмнө
parent
commit
07b8f87fb7

+ 5 - 2
config/creatures.json

@@ -152,7 +152,8 @@
 				"ability_add": [ [ "SPECIFIC_SPELL_POWER", 100, 38, 0 ],			// 100 hp per Archangel
 							   	 [ "SPELLCASTER", 0, 38, 0 ],			//archangels cast resurrection
 								 [ "HATE", 50, 55, 0 ],					//archangels hate arch
-								 [ "HATE", 50, 54, 0 ] ],					//archangels hate devils
+								 [ "HATE", 50, 54, 0 ] ,					//archangels hate devils
+								 [ "CASTS", 1, 0, 0]],
 				"defname": "CRANGL.DEF"
 			},
 
@@ -397,6 +398,7 @@
 				"faction": 2,
 				"ability_add": [ [ "CREATURE_ENCHANT_POWER", 6, 0, 0 ],		//spells last 6 turns
 							   	 [ "RANDOM_SPELLCASTER", 0, 0, 0 ],  		//master genies cast spells
+								 [ "CASTS", 3, 0, 0],
 								 [ "HATE", 50, 53, 0 ],
 								 [ "HATE", 50, 52, 0 ] ],				  	//master genies hate efreet sultans
 				"defname": "CSULTA.DEF"
@@ -544,7 +546,8 @@
 				"level": 5,
 				"name": [ "PitFoe" ],
 				"faction": 3,
-				"ability_add": [ [ "DAEMON_SUMMONING", 0, 52, 0 ] ],		//pit lord		//Efreeti
+				"ability_add": [ [ "DAEMON_SUMMONING", 50, 48, 0 ], 
+								[ "CASTS", 1, 0, 0] ],		//pit lord
 				"defname": "CPFOE.DEF"
 			},
 

+ 1 - 3
lib/BattleState.cpp

@@ -2192,13 +2192,11 @@ void CStack::postInit()
 	assert(type);
 	assert(getParentNodes().size());
 
-	firstHPleft = valOfBonuses(Bonus::STACK_HEALTH);
+	firstHPleft = MaxHealth();
 	shots = getCreature()->valOfBonuses(Bonus::SHOTS);
 	counterAttacks = 1 + valOfBonuses(Bonus::ADDITIONAL_RETALIATION);
 	casts = valOfBonuses(Bonus::CASTS); //TODO: set them in cr_abils.txt
 	state.insert(ALIVE);  //alive state indication
-
-	assert(firstHPleft > 0);
 }
 
 ui32 CStack::Speed( int turn /*= 0*/ ) const

+ 1 - 1
lib/NetPacks.h

@@ -1238,7 +1238,7 @@ struct StacksHealedOrResurrected : public CPackForClient //3013
 	{
 		ui32 stackID;
 		ui32 healedHP;
-		ui8 lowLevelResurrection; //in case this stack is resurrected by this heal, it will be marked as SUMMONED
+		ui8 lowLevelResurrection; //in case this stack is resurrected by this heal, it will be marked as SUMMONED //TODO: replace with separate counter
 		template <typename Handler> void serialize(Handler &h, const int version)
 		{
 			h & stackID & healedHP & lowLevelResurrection;

+ 1 - 2
lib/NetPacksLib.cpp

@@ -1168,8 +1168,7 @@ DLL_EXPORT void StacksHealedOrResurrected::applyGs( CGameState *gs )
 		{
 			changedStack->state.insert(ALIVE);
 			if(healedStacks[g].lowLevelResurrection)
-				changedStack->state.insert(SUMMONED);
-				//changedStack->addNewBonus( makeFeature(HeroBonus::SUMMONED, HeroBonus::ONE_BATTLE, 0, 0, HeroBonus::BONUS_FROM_HERO) );
+				changedStack->state.insert(SUMMONED); //TODO: different counter for rised units
 		}
 		//int missingHPfirst = changedStack->MaxHealth() - changedStack->firstHPleft;
 		int res = std::min( healedStacks[g].healedHP / changedStack->MaxHealth() , changedStack->baseAmount - changedStack->count );

+ 8 - 6
server/CGameHandler.cpp

@@ -3286,7 +3286,6 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 		case BattleAction::DAEMON_SUMMONING:
 			//TODO: From Strategija:
 			//Summon Demon is a level 2 spell.
-			//Cloned Pit Lord stack can use the specialty as well.
 		{
 			StartAction start_action(ba);
 			sendAndApply(&start_action);
@@ -3299,15 +3298,18 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 
 			bsa.creID = summoner->getBonus(Selector::type(Bonus::DAEMON_SUMMONING))->subtype; //in case summoner can summon more than one type of monsters... scream!
 			ui64 risedHp = summoner->count * summoner->valOfBonuses(Bonus::DAEMON_SUMMONING, bsa.creID);
-			bsa.amount = std::min ((ui32)(risedHp/destStack->MaxHealth()), destStack->baseAmount);
+			bsa.amount = std::min ((ui32)(risedHp / VLC->creh->creatures[bsa.creID]->MaxHealth()), destStack->baseAmount);
 
 			bsa.pos = gs->curB->getAvaliableHex(bsa.creID, bsa.attacker, destStack->position);
 			bsa.summoned = false;
 
-			BattleStacksRemoved bsr; //remove body
-			bsr.stackIDs.insert(destStack->ID);
-			sendAndApply(&bsr);
-			sendAndApply(&bsa);
+			if (bsa.amount) //there's rare possibility single creature cannot rise desired type
+			{
+				BattleStacksRemoved bsr; //remove body
+				bsr.stackIDs.insert(destStack->ID);
+				sendAndApply(&bsr);
+				sendAndApply(&bsa);
+			}
 
 			sendAndApply(&end_action);
 			break;