From 07b8f87fb779b1878093cb4e3afc328b33aafe6d Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sun, 2 Oct 2011 07:16:34 +0000 Subject: [PATCH] Partial support for Daemon Summoning. It freezes for unknown reason, but still. Minor fixes. --- config/creatures.json | 7 +++++-- lib/BattleState.cpp | 4 +--- lib/NetPacks.h | 2 +- lib/NetPacksLib.cpp | 3 +-- server/CGameHandler.cpp | 14 ++++++++------ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/config/creatures.json b/config/creatures.json index 6d425b212..89d3838d7 100644 --- a/config/creatures.json +++ b/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" }, diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 408678b23..ab29cbf0a 100644 --- a/lib/BattleState.cpp +++ b/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 diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 8d3ad281b..a17eaf0e5 100644 --- a/lib/NetPacks.h +++ b/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 void serialize(Handler &h, const int version) { h & stackID & healedHP & lowLevelResurrection; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 87874b53f..74dba6e5c 100644 --- a/lib/NetPacksLib.cpp +++ b/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 ); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index a31a5f495..7161031c3 100644 --- a/server/CGameHandler.cpp +++ b/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;