1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Support for Fear & Fearless ability.

Ogre Magi can now cast too.
This commit is contained in:
DjWarmonger
2011-10-08 17:10:43 +00:00
parent 89bd7e273d
commit d607d90a91
5 changed files with 51 additions and 16 deletions

View File

@@ -3512,12 +3512,7 @@ void CBattleInterface::battleTriggerEffect(const BattleTriggerEffect & bte)
switch (bte.effect)
{
case Bonus::HP_REGENERATION:
if( stack->hasBonusOfType(Bonus::HP_REGENERATION) || stack->hasBonusOfType(Bonus::FULL_HP_REGENERATION, 1))
{
displayEffect(74, stack->position);
CCS->soundh->playSound(soundBase::REGENER);
}
if( stack->hasBonusOfType(Bonus::FULL_HP_REGENERATION, 0))
if( stack->hasBonusOfType(Bonus::HP_REGENERATION) || stack->hasBonusOfType(Bonus::FULL_HP_REGENERATION))
{
displayEffect(74, stack->position);
CCS->soundh->playSound(soundBase::REGENER);
@@ -3531,6 +3526,10 @@ void CBattleInterface::battleTriggerEffect(const BattleTriggerEffect & bte)
displayEffect(67, stack->position);
CCS->soundh->playSound(soundBase::POISON);
break;
case Bonus::FEAR:
displayEffect(15, stack->position);
CCS->soundh->playSound(soundBase::FEAR);
break;
default:
return;
}

View File

@@ -957,7 +957,9 @@
"level": 4,
"name": [ "OgreMage" ],
"faction": 6,
"ability_add": [ [ "SPELLCASTER", 2, 43, 6 ] ], //ogre magi cast bloodlust
"ability_add": [ [ "SPELLCASTER", 2, 43, 0 ],
[ "CASTS", 3, 0, 0],
[ "CREATURE_ENCHANT_POWER", 3, 0, 0]], //ogre magi cast bloodlust
"defname": "COGMAG.DEF"
},
@@ -1364,7 +1366,8 @@
"level": 10,
"name": [ "AzureDragon" ],
"faction": -1,
"ability_add": [ [ "DRAGON_NATURE", 0, 0, 0 ] ], //azure dragon is a dragon
"ability_add": [ [ "DRAGON_NATURE", 0, 0, 0 ],
[ "FEAR", 0, 0, 0]], //azure dragon is a dragon
"defname": "CADRGN.DEF"
},

View File

@@ -89,7 +89,7 @@ enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colo
enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
enum ECombatInfo{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING};
enum ECombatInfo{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING, FEAR};
class CGameInfo;
extern const CGameInfo* CGI; //game info for general use

View File

@@ -847,6 +847,7 @@ DLL_EXPORT void BattleNextRound::applyGs( CGameState *gs )
s->state -= WAITING;
s->state -= MOVED;
s->state -= HAD_MORALE;
s->state -= FEAR;
s->counterAttacks = 1 + s->valOfBonuses(Bonus::ADDITIONAL_RETALIATION);
// new turn effects
s->battleTurnPassed();
@@ -889,7 +890,10 @@ DLL_EXPORT void BattleTriggerEffect::applyGs( CGameState *gs )
break;
}
case Bonus::ENCHANTER:
break;
case Bonus::FEAR:
st->state.insert(FEAR);
break;
default:
tlog2 << "Unrecognized trigger effect type "<< type <<"\n";
}

View File

@@ -3987,6 +3987,26 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
}
}
}
if (!st->hasBonusOfType(Bonus::FEARLESS))
{
bool fearsomeCreature = false;
BOOST_FOREACH(CStack * stack, gs->curB->stacks)
{
if (stack->owner != st->owner && stack->hasBonusOfType(Bonus::FEAR))
{
fearsomeCreature = true;
break;
}
}
if (fearsomeCreature)
{
if (rand() % 100 < 10) //fixed 10%
{
bte.effect = Bonus::FEAR;
sendAndApply(&bte);
}
}
}
BonusList * bl = st->getBonuses(Selector::type(Bonus::ENCHANTER)).get();
if (bl->size())
{
@@ -5273,13 +5293,21 @@ void CGameHandler::runBattle()
{
stackTurnTrigger(next); //various effects
BattleSetActiveStack sas;
sas.stack = next->ID;
sendAndApply(&sas);
boost::unique_lock<boost::mutex> lock(battleMadeAction.mx);
battleMadeAction.data = false;
while(next->alive() && (!battleMadeAction.data && !battleResult.get())) //active stack hasn't made its action and battle is still going
battleMadeAction.cond.wait(lock);
if (vstd::contains(next->state, FEAR))
{
makeStackDoNothing(next); //end immediately if stack was affected by fear
}
else
{
BattleSetActiveStack sas;
sas.stack = next->ID;
sendAndApply(&sas);
boost::unique_lock<boost::mutex> lock(battleMadeAction.mx);
battleMadeAction.data = false;
while (next->alive() &&
(!battleMadeAction.data && !battleResult.get())) //active stack hasn't made its action and battle is still going
battleMadeAction.cond.wait(lock);
}
}
if(battleResult.get()) //don't touch it, battle could be finished while waiting got action
@@ -5296,6 +5324,7 @@ void CGameHandler::runBattle()
if(!vstd::contains(next->state,HAD_MORALE) //only one extra move per turn possible
&& !vstd::contains(next->state,DEFENDING)
&& !vstd::contains(next->state,WAITING)
&& !vstd::contains(next->state, FEAR)
&& next->alive()
&& nextStackMorale > 0
&& !(NBonus::hasOfType(gs->curB->heroes[0], Bonus::BLOCK_MORALE) || NBonus::hasOfType(gs->curB->heroes[1], Bonus::BLOCK_MORALE)) //checking if gs->curB->heroes have (or don't have) morale blocking bonuses