1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed some battle logs.

This commit is contained in:
DjWarmonger 2011-05-13 10:45:36 +00:00
parent 515ab7e7c1
commit b02527566c
4 changed files with 12 additions and 10 deletions

View File

@ -2930,7 +2930,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
text = CGI->generaltexth->allTexts[118]; //One %s dies under the terrible gaze of the %s.
boost::algorithm::replace_first(text, "%s", curInt->cb->battleGetStackByID(*sc->affectedCres.begin())->type->nameSing);
}
boost::algorithm::replace_first(text, "%s", "Creatures"); //casting stack
boost::algorithm::replace_first(text, "%s", CGI->creh->creatures[sc->attackerType]->namePl); //casting stack
}
else
text = "";
@ -2938,7 +2938,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
case 81:
break; //handled as hero spell - display damage
default:
boost::algorithm::replace_first(text, "%s", "Creature"); //TODO: better fix
boost::algorithm::replace_first(text, "%s", CGI->creh->creatures[sc->attackerType]->namePl); //casting stack
}
if (plural)
{

View File

@ -1364,10 +1364,11 @@ struct BattleSpellCast : public CPackForClient//3009
ui16 tile; //destination tile (may not be set in some global/mass spells
std::vector<ui32> resisted; //ids of creatures that resisted this spell
std::set<ui32> affectedCres; //ids of creatures affected by this spell, generally used if spell does not set any effect (like dispel or cure)
TCreature attackerType;//id of caster to generate console message
ui8 castedByHero; //if true - spell has been casted by hero, otherwise by a creature
template <typename Handler> void serialize(Handler &h, const int version)
{
h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres & castedByHero;
h & dmgToDisplay & side & id & skill & tile & resisted & affectedCres & attackerType & castedByHero;
}
};

View File

@ -3368,7 +3368,7 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
}
}
void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode )
void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack)
{
const CSpell *spell = VLC->spellh->spells[spellID];
@ -3379,6 +3379,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
sc.tile = destination;
sc.dmgToDisplay = 0;
sc.castedByHero = (bool)caster;
sc.attackerType = (stack ? stack->type->idNumber : -1);
//calculating affected creatures for all spells
std::set<CStack*> attackedCres = gs->curB->getAttackedCreatures(spell, spellLvl, casterColor, destination);
@ -3674,7 +3675,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
sendAndApply(&StartAction(ba)); //start spell casting
handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), SpellCasting::HERO_CASTING);
handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), SpellCasting::HERO_CASTING, NULL);
sendAndApply(&EndAction());
if( !gs->curB->getStack(gs->curB->activeStack, false)->alive() )
@ -4280,7 +4281,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
//casting
if (castMe)
handleSpellCasting(spellID, spellLevel, destination, !attacker->attackerOwned, attacker->owner, NULL, NULL, attacker->count, SpellCasting::AFTER_ATTACK_CASTING);
handleSpellCasting(spellID, spellLevel, destination, !attacker->attackerOwned, attacker->owner, NULL, NULL, attacker->count, SpellCasting::AFTER_ATTACK_CASTING, attacker);
}
}
if (attacker->hasBonusOfType(Bonus::DEATH_STARE)) // spell id 79
@ -4302,7 +4303,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
{
if (bat.bsa.size() && bat.bsa[0].newAmount > 0) //TODO: death stare was not originally avaliable for multiple-hex attacks, but...
handleSpellCasting(79, 0, gs->curB->getStack(bat.bsa[0].stackAttacked)->position,
!attacker->attackerOwned, attacker->owner, NULL, NULL, staredCreatures, SpellCasting::AFTER_ATTACK_CASTING);
!attacker->attackerOwned, attacker->owner, NULL, NULL, staredCreatures, SpellCasting::AFTER_ATTACK_CASTING, attacker);
}
}
int acidDamage = 0;
@ -4315,7 +4316,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
{
handleSpellCasting(81, 0, gs->curB->getStack(bat.bsa[0].stackAttacked)->position,
!attacker->attackerOwned, attacker->owner, NULL, NULL,
acidDamage * attacker->count, SpellCasting::AFTER_ATTACK_CASTING);
acidDamage * attacker->count, SpellCasting::AFTER_ATTACK_CASTING, attacker);
}
}
@ -4790,7 +4791,7 @@ void CGameHandler::runBattle()
gs->curB->heroes[i]->getBonuses(bl, Selector::type(Bonus::OPENING_BATTLE_SPELL));
BOOST_FOREACH (Bonus *b, bl)
{
handleSpellCasting(b->subtype, 3, -1, 0, gs->curB->heroes[i]->tempOwner, NULL, gs->curB->heroes[1-i], b->val, SpellCasting::HERO_CASTING);
handleSpellCasting(b->subtype, 3, -1, 0, gs->curB->heroes[i]->tempOwner, NULL, gs->curB->heroes[1-i], b->val, SpellCasting::HERO_CASTING, NULL);
}
}
}

View File

@ -192,7 +192,7 @@ public:
void playerMessage( ui8 player, const std::string &message);
bool makeBattleAction(BattleAction &ba);
void handleSpellCasting(int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode);
void handleSpellCasting(int spellID, int spellLvl, int destination, ui8 casterSide, ui8 casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero, int usedSpellPower, SpellCasting::ECastingMode mode, const CStack * stack);
bool makeCustomAction(BattleAction &ba);
bool queryReply( ui32 qid, ui32 answer );
bool hireHero( const CGObjectInstance *obj, ui8 hid, ui8 player );