Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions body.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class Body {
void updateViewObject(ViewObject&) const;
const optional<double>& getCarryLimit() const;
void bleed(WCreature, double amount);
void looseBodyPart(BodyPart);
void injureBodyPart(BodyPart);
WItem chooseWeapon(WItem realWeapon) const;
const EnumMap<BodyPart, optional<IntrinsicAttack>>& getIntrinsicAttacks() const;
EnumMap<BodyPart, optional<IntrinsicAttack>>& getIntrinsicAttacks();
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion collective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Creature : public Renderable, public UniqueEntity<Creature>, 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] **/
Expand Down
4 changes: 4 additions & 0 deletions creature_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions creature_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down