From 2eeb55f7d6d594280f8016e254a10e08679ac0f7 Mon Sep 17 00:00:00 2001 From: Andrew Wright Date: Fri, 16 Mar 2018 19:56:43 +0000 Subject: [PATCH] Converted prisoners are often too powerful. Torturing needs to harm them? --- body.h | 4 ++-- collective.cpp | 2 +- creature.cpp | 22 ++++++++++++++++++++++ creature.h | 1 + creature_attributes.cpp | 4 ++++ creature_attributes.h | 1 + 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/body.h b/body.h index 5b3845913..4ecc9e3ed 100644 --- a/body.h +++ b/body.h @@ -113,6 +113,8 @@ class Body { void updateViewObject(ViewObject&) const; const optional& getCarryLimit() const; void bleed(WCreature, double amount); + void looseBodyPart(BodyPart); + void injureBodyPart(BodyPart); WItem chooseWeapon(WItem realWeapon) const; const EnumMap>& getIntrinsicAttacks() const; EnumMap>& getIntrinsicAttacks(); @@ -129,8 +131,6 @@ class Body { int numInjured(BodyPart) const; void clearInjured(BodyPart); void clearLost(BodyPart); - void looseBodyPart(BodyPart); - void injureBodyPart(BodyPart); void decreaseHealth(double amount); bool isPartDamaged(BodyPart, double damage) const; bool isCritical(BodyPart) const; diff --git a/collective.cpp b/collective.cpp index 026c0b0df..5ebf49d6c 100644 --- a/collective.cpp +++ b/collective.cpp @@ -718,7 +718,7 @@ void Collective::onEvent(const GameEvent& event) { setTrait(victim, MinionTrait::FIGHTER); victim->removeEffect(LastingEffect::TIED_UP); } - } + } else victim->sufferFromTorture(); } }, [&](const CreatureStunned& info) { diff --git a/creature.cpp b/creature.cpp index aa24786bf..1079f80e7 100644 --- a/creature.cpp +++ b/creature.cpp @@ -1000,6 +1000,28 @@ bool Creature::captureDamage(double damage, WCreature attacker) { return false; } +void Creature::sufferFromTorture() { + int injuryType = Random.get(1,30); + if (injuryType < 15) return; + if (injuryType < 29) { + AttrType ability = Random.choose ( + AttrType::DAMAGE, + AttrType::DEFENSE, + AttrType::SPELL_DAMAGE, + AttrType::RANGED_DAMAGE); + attributes->sufferScar(ability); + return; + } + BodyPart bp = Random.choose({ + BodyPart::LEG, + BodyPart::ARM}, {1, 1}); + if (Random.roll(2)) { + attributes->getBody().looseBodyPart(bp); + } else { + attributes->getBody().injureBodyPart(bp); + } +} + bool Creature::takeDamage(const Attack& attack) { PROFILE; if (WCreature attacker = attack.attacker) { diff --git a/creature.h b/creature.h index 434f07118..0a01af531 100644 --- a/creature.h +++ b/creature.h @@ -77,6 +77,7 @@ class Creature : public Renderable, public UniqueEntity, public OwnedO Position getPosition() const; bool dodgeAttack(const Attack&); bool takeDamage(const Attack&); + void sufferFromTorture(); void onAttackedBy(WCreature); void heal(double amount = 1); /** Morale is in the range [-1:1] **/ diff --git a/creature_attributes.cpp b/creature_attributes.cpp index 3a1be8132..cec389bac 100644 --- a/creature_attributes.cpp +++ b/creature_attributes.cpp @@ -76,6 +76,10 @@ void CreatureAttributes::setBaseAttr(AttrType type, int v) { attr[type] = v; } +void CreatureAttributes::sufferScar(AttrType type) { + if (attr[type] > 5) attr[type] -= 1; +} + double CreatureAttributes::getCourage() const { if (!body->hasBrain()) return 1; diff --git a/creature_attributes.h b/creature_attributes.h index 64595cd43..c5da564b6 100644 --- a/creature_attributes.h +++ b/creature_attributes.h @@ -59,6 +59,7 @@ class CreatureAttributes { CreatureName& getName(); int getRawAttr(AttrType) const; void setBaseAttr(AttrType, int); + void sufferScar(AttrType type); double getCourage() const; void setCourage(double); string getDeathDescription() const;