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

Partial support for Clone spell.

This commit is contained in:
DjWarmonger 2012-02-10 13:13:24 +00:00
parent 9e5fcc3152
commit c724092028
5 changed files with 42 additions and 2 deletions

View File

@ -2147,6 +2147,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
case Spells::SUMMON_EARTH_ELEMENTAL:
case Spells::SUMMON_WATER_ELEMENTAL:
case Spells::SUMMON_AIR_ELEMENTAL:
case Spells::CLONE: //TODO: make it smarter?
addNewAnim(new CDummyAnimation(this, 2));
break;
} //switch(sc->id)

View File

@ -2729,6 +2729,13 @@ void CStack::prepareAttacked(BattleStackAttacked &bsa) const
bsa.killedAmount = bsa.damageAmount / MaxHealth();
unsigned damageFirst = bsa.damageAmount % MaxHealth();
if (bsa.damageAmount && vstd::contains(state, EBattleStackState::CLONED)) // block ability should not kill clone (0 damage)
{
bsa.killedAmount = count;
bsa.flags |= BattleStackAttacked::KILLED;
return; // no rebirth I believe
}
if( firstHPleft <= damageFirst )
{
bsa.killedAmount++;

View File

@ -1519,7 +1519,7 @@ struct BattleSetStackProperty : public CPackForClient //3018
{
BattleSetStackProperty(){type = 3018;};
enum BattleStackProperty {CASTS, ENCHANTER_COUNTER, UNBIND};
enum BattleStackProperty {CASTS, ENCHANTER_COUNTER, UNBIND, CLONED};
DLL_LINKAGE void applyGs(CGameState *gs);
//void applyCl(CClient *cl){};

View File

@ -1312,6 +1312,11 @@ DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState *gs)
stack->popBonuses(Selector::type(Bonus::BIND_EFFECT));
break;
}
case CLONED:
{
stack->state.insert(EBattleStackState::CLONED);
break;
}
}
}

View File

@ -3874,6 +3874,33 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
complain("Summoning elementals didn't summon any!");
}
break;
case Spells::CLONE:
{
CStack * clonedStack = NULL;
if (attackedCres.size())
clonedStack = *attackedCres.begin();
if (!clonedStack)
{
complain ("No target stack to clone!");
return;
}
BattleStackAdded bsa;
bsa.creID = clonedStack->type->idNumber;
bsa.attacker = !(bool)casterSide;
bsa.summoned = true;
bsa.pos = gs->curB->getAvaliableHex(bsa.creID, !(bool)casterSide); //TODO: unify it
bsa.amount = clonedStack->count;
sendAndApply (&bsa);
BattleSetStackProperty ssp;
ssp.stackID = gs->curB->stacks.back()->ID; //how to get recent stack?
ssp.which = BattleSetStackProperty::CLONED; //using enum values
ssp.val = 0;
ssp.absolute = 1;
sendAndApply(&ssp);
}
break;
case Spells::REMOVE_OBSTACLE:
{
ObstaclesRemoved obr;
@ -3991,7 +4018,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
}
const CSpell *s = VLC->spellh->spells[ba.additionalInfo];
if (s->mainEffectAnim > -1 || (s->id >= 66 || s->id <= 69)) //allow summon elementals
if (s->mainEffectAnim > -1 || (s->id >= 66 || s->id <= 69) || s->id == Spells::CLONE) //allow summon elementals
//TODO: special effects, like Clone
{
ui8 skill = h->getSpellSchoolLevel(s); //skill level