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

added bonus type MANUAL_CONTROL

This commit is contained in:
Henning Koehler 2017-08-28 20:09:27 +12:00
parent 5091b117e2
commit 69a538a600
4 changed files with 34 additions and 6 deletions

View File

@ -343,6 +343,12 @@
"type" : "SECONDARY_SKILL_PREMY",
"val" : 1,
"valueType" : "BASE_NUMBER"
},
{
"subtype" : "creature.catapult",
"type" : "MANUAL_CONTROL",
"val" : 100,
"valueType" : "BASE_NUMBER"
}
]
},
@ -711,6 +717,12 @@
"type" : "SECONDARY_SKILL_PREMY",
"val" : 50,
"valueType" : "BASE_NUMBER"
},
{
"subtype" : "creature.ballista",
"type" : "MANUAL_CONTROL",
"val" : 100,
"valueType" : "BASE_NUMBER"
}
]
},
@ -962,6 +974,12 @@
"type" : "SECONDARY_SKILL_PREMY",
"val" : 50,
"valueType" : "BASE_NUMBER"
},
{
"subtype" : "creature.firstAidTent",
"type" : "MANUAL_CONTROL",
"val" : 100,
"valueType" : "BASE_NUMBER"
}
]
},

View File

@ -216,8 +216,10 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
std::vector<std::shared_ptr<Bonus>> result;
// add bonus based on current values - useful for adding multiple bonuses easily
auto addBonus = [=,&result](int bonusVal, Bonus::BonusType bonusType = Bonus::SECONDARY_SKILL_PREMY) {
int subtype = (bonusType == Bonus::SECONDARY_SKILL_PREMY || bonusType == Bonus::SECONDARY_SKILL_VAL2) ? skill : 0;
auto addBonus = [=,&result](int bonusVal, Bonus::BonusType bonusType = Bonus::SECONDARY_SKILL_PREMY, int subtype = 0)
{
if(bonusType == Bonus::SECONDARY_SKILL_PREMY || bonusType == Bonus::SECONDARY_SKILL_VAL2)
subtype = skill;
result.push_back(std::make_shared<Bonus>(Bonus::PERMANENT, bonusType, Bonus::SECONDARY_SKILL, bonusVal, skill, subtype, Bonus::BASE_NUMBER));
};
@ -239,6 +241,10 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
addBonus(level, Bonus::MORALE); break;
case SecondarySkill::LUCK:
addBonus(level, Bonus::LUCK); break;
case SecondarySkill::BALLISTICS:
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::CATAPULT);
addBonus(level);
break;
case SecondarySkill::EAGLE_EYE:
addBonus(30 + 10 * level);
addBonus(1 + level, Bonus::SECONDARY_SKILL_VAL2);
@ -257,9 +263,11 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
case SecondarySkill::TACTICS:
addBonus(1 + 2 * level); break;
case SecondarySkill::ARTILLERY:
addBonus(25 + 25 * level); break;
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::BALLISTA);
addBonus(25 + 25 * level);
if(level > 1) // extra attack
addBonus(1, Bonus::SECONDARY_SKILL_VAL2);
break;
case SecondarySkill::LEARNING:
addBonus(5 * level); break;
case SecondarySkill::OFFENCE:
@ -273,6 +281,7 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
case SecondarySkill::RESISTANCE:
addBonus(5 << (level-1)); break;
case SecondarySkill::FIRST_AID:
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::FIRST_AID_TENT);
addBonus(25 + 25 * level); break;
default:
addBonus(level); break;

View File

@ -236,6 +236,7 @@ private:
BONUS_NAME(RANGED_RETALIATION) /*allows shooters to perform ranged retaliation*/\
BONUS_NAME(BLOCKS_RANGED_RETALIATION) /*disallows ranged retaliation for shooter unit, BLOCKS_RETALIATION bonus is for melee retaliation only*/\
BONUS_NAME(SECONDARY_SKILL_VAL2) /*for secondary skills that have multiple effects, like eagle eye (max level and chance)*/ \
BONUS_NAME(MANUAL_CONTROL) /* manually control warmachine with id = subtype, chance = val */ \
/* end of list */

View File

@ -5799,7 +5799,7 @@ void CGameHandler::runBattle()
const CGHeroInstance * curOwner = battleGetOwnerHero(next);
if ((next->position < 0 || next->getCreature()->idNumber == CreatureID::BALLISTA) //arrow turret or ballista
&& (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::ARTILLERY) == 0)) //hero has no artillery
&& (!curOwner || getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(Bonus::MANUAL_CONTROL, CreatureID::BALLISTA)))
{
BattleAction attack;
attack.actionType = Battle::SHOOT;
@ -5829,7 +5829,7 @@ void CGameHandler::runBattle()
continue;
}
if (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::BALLISTICS) == 0)
if (!curOwner || getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(Bonus::MANUAL_CONTROL, CreatureID::CATAPULT))
{
BattleAction attack;
attack.destinationTile = *RandomGeneratorUtil::nextItem(attackableBattleHexes,
@ -5857,7 +5857,7 @@ void CGameHandler::runBattle()
continue;
}
if (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::FIRST_AID) == 0) //no hero or hero has no first aid
if (!curOwner || getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(Bonus::MANUAL_CONTROL, CreatureID::FIRST_AID_TENT))
{
RandomGeneratorUtil::randomShuffle(possibleStacks, getRandomGenerator());
const CStack * toBeHealed = possibleStacks.front();