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

- Support for "Enchanted" WoG ability.

- Precision will not be cast on non-shooters
This commit is contained in:
DjWarmonger 2012-12-01 18:30:03 +00:00
parent c5d9110176
commit ca9033d0e4
6 changed files with 42 additions and 4 deletions

View File

@ -56,6 +56,7 @@
{ "id": "REBIRTH", "name": "Rebirth (%d%)", "description": "Stack will rise after death" }, { "id": "REBIRTH", "name": "Rebirth (%d%)", "description": "Stack will rise after death" },
{ "id": "SPELLCASTER", "name": "Spellcaster (%s)", "description": "Can cast spells" }, { "id": "SPELLCASTER", "name": "Spellcaster (%s)", "description": "Can cast spells" },
{ "id": "ENCHANTER", "name": "Enchanter (%s)", "description": "Casts mass spell every turn" }, { "id": "ENCHANTER", "name": "Enchanter (%s)", "description": "Casts mass spell every turn" },
{ "id": "ENCHANTED", "name": "Enchanted (%s)", "description": "Affected by permanent spell" },
{ "id": "RANDOM_SPELLCASTER", "name": "Random spellcaster", "description": "Can cast random spell" }, { "id": "RANDOM_SPELLCASTER", "name": "Random spellcaster", "description": "Can cast random spell" },
{ "id": "DAEMON_SUMMONING", "name": "Summoner (%s)", "description": "Can rise creatures from corpses" } { "id": "DAEMON_SUMMONING", "name": "Summoner (%s)", "description": "Can rise creatures from corpses" }
] ]

View File

@ -1517,6 +1517,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C
} }
break; break;
case Spells::FORGETFULNESS: case Spells::FORGETFULNESS:
case Spells::PRECISION:
if (!subject->hasBonusOfType(Bonus::SHOOTER)) if (!subject->hasBonusOfType(Bonus::SHOOTER))
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
break; break;

View File

@ -799,7 +799,6 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.type = Bonus::STACKS_SPEED; break; b.type = Bonus::STACKS_SPEED; break;
case 'O': case 'O':
b.type = Bonus::SHOTS; break; b.type = Bonus::SHOTS; break;
case 'b': case 'b':
b.type = Bonus::ENEMY_DEFENCE_REDUCTION; break; b.type = Bonus::ENEMY_DEFENCE_REDUCTION; break;
case 'C': case 'C':
@ -826,7 +825,6 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.type = Bonus::MAGIC_RESISTANCE; b.type = Bonus::MAGIC_RESISTANCE;
b.subtype = 0; //otherwise creature window goes crazy b.subtype = 0; //otherwise creature window goes crazy
break; break;
case 'f': //on-off skill case 'f': //on-off skill
enable = true; //sometimes format is: 2 -> 0, 1 -> 1 enable = true; //sometimes format is: 2 -> 0, 1 -> 1
switch (mod[0]) switch (mod[0])
@ -866,7 +864,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
case 'U': case 'U':
b.type = Bonus::UNDEAD; break; b.type = Bonus::UNDEAD; break;
default: default:
tlog5 << "Not parsed bonus " << buf << mod << "\n"; tlog5 << "Not parsed bonus " << buf << mod << "\n";
return; return;
break; break;
} }
@ -993,6 +991,11 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.subtype = stringToNumber(mod); b.subtype = stringToNumber(mod);
b.additionalInfo = 3; //always expert? b.additionalInfo = 3; //always expert?
break; break;
case 's':
b.type = Bonus::ENCHANTED;
b.subtype = stringToNumber(mod);
b.valType = Bonus::INDEPENDENT_MAX;
break;
default: default:
tlog5 << "Not parsed bonus " << buf << mod << "\n"; tlog5 << "Not parsed bonus " << buf << mod << "\n";
return; return;

View File

@ -666,6 +666,7 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
case Bonus::SPELL_IMMUNITY: case Bonus::SPELL_IMMUNITY:
case Bonus::SPELLCASTER: case Bonus::SPELLCASTER:
case Bonus::ENCHANTER: case Bonus::ENCHANTER:
case Bonus::ENCHANTED:
boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name); boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
break; break;
case Bonus::MAGIC_RESISTANCE: case Bonus::MAGIC_RESISTANCE:
@ -690,7 +691,8 @@ std::string CStackInstance::bonusToGraphics(Bonus *bonus) const
{ {
//"E_ALIVE.bmp" //"E_ALIVE.bmp"
//"E_ART.bmp" //"E_ART.bmp"
//"E_BLESS.bmp" case Bonus::ENCHANTED:
fileName = "E_BLESS.bmp"; break;
//"E_BLOCK.bmp" //"E_BLOCK.bmp"
//"E_BLOCK1.bmp" //"E_BLOCK1.bmp"
//"E_BLOCK2.bmp" //"E_BLOCK2.bmp"

View File

@ -173,6 +173,7 @@ typedef boost::function<bool(const Bonus*)> CSelector;
BONUS_NAME(SPECIFIC_SPELL_POWER) /* value used for Thunderbolt and Resurrection casted by units, subtype - spell id */\ BONUS_NAME(SPECIFIC_SPELL_POWER) /* value used for Thunderbolt and Resurrection casted by units, subtype - spell id */\
BONUS_NAME(CREATURE_SPELL_POWER) /* value per unit, divided by 100 (so faerie Dragons have 800)*/ \ BONUS_NAME(CREATURE_SPELL_POWER) /* value per unit, divided by 100 (so faerie Dragons have 800)*/ \
BONUS_NAME(CREATURE_ENCHANT_POWER) /* total duration of spells casted by creature */ \ BONUS_NAME(CREATURE_ENCHANT_POWER) /* total duration of spells casted by creature */ \
BONUS_NAME(ENCHANTED) /* permanently enchanted with spell subID of level = val, if val > 3 then spell is mass and has level of val-3*/ \
BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */\ BONUS_NAME(REBIRTH) /* val - percent of life restored, subtype = 0 - regular, 1 - at least one unit (sacred Phoenix) */\
BONUS_NAME(ADDITIONAL_UNITS) /*val of units with id = subtype will be added to hero's army at the beginning of battle */\ BONUS_NAME(ADDITIONAL_UNITS) /*val of units with id = subtype will be added to hero's army at the beginning of battle */\
BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\ BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\

View File

@ -4605,6 +4605,36 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
sendAndApply(&ssp); sendAndApply(&ssp);
} }
} }
bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTED)));
BOOST_FOREACH (auto b, bl)
{
SetStackEffect sse;
int val = bl.valOfBonuses (Selector::typeSubtype(b->type, b->subtype));
if (val > 3)
{
BOOST_FOREACH (auto s, gs->curB->battleGetAllStacks())
{
if (st->owner == s->owner && s->isValidTarget()) //all allied
sse.stacks.push_back (s->ID);
}
}
else
sse.stacks.push_back (st->ID);
//from handleSpellCasting
//SetStackEffect sse;
//Bonus pseudoBonus;
//pseudoBonus.sid = spellID;
//pseudoBonus.val = spellLvl;
//pseudoBonus.turnsRemain = gs->curB->calculateSpellDuration(spell, caster, stackSpellPower ? stackSpellPower : usedSpellPower);
//CStack::stackEffectToFeature(sse.effect, pseudoBonus);
Bonus pseudoBonus;
pseudoBonus.sid = b->subtype;
pseudoBonus.val = ((val > 3) ? (val - 3) : val);
pseudoBonus.turnsRemain = 50;
st->stackEffectToFeature (sse.effect, pseudoBonus);
sendAndApply (&sse);
}
} }
} }