diff options
Diffstat (limited to 'src/creature.cc')
-rw-r--r-- | src/creature.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/creature.cc b/src/creature.cc index 5130362..6069285 100644 --- a/src/creature.cc +++ b/src/creature.cc @@ -78,6 +78,10 @@ namespace creature { for(int i = 0; i < data->hit_die_count; i++) { data->hpMax += dice::roll(data->hit_die_sides); } + // If less than zero (caused by negative con bonus), set to minimum of 1 + if(data->hpMax <= 0) { + data->hpMax = 1; + } data->hp = data->hpMax; } } @@ -227,10 +231,20 @@ namespace creature { data->hp = data->hpMax; } + int getShieldBonus(const Creature& c) { + for(auto a : utils::castPtrs<entry::Item, entry::Armor>(c.getInventory())) { + if(a->getArmorType() == "shield") { + return a->getACBonus(); + } + } + return 0; + } + const int getAC(const Creature& c) { auto natArmor = c.getNaturalArmor(); if(! natArmor.name.empty()) { - return natArmor.bonus; + // Shields stack with nat armor (see lizardfolk) + return natArmor.bonus + getShieldBonus(c); } int dex = c.getBonus(rules::Ability::Dex()); int baseBonus = 10 + dex; @@ -240,7 +254,7 @@ namespace creature { continue; } auto armorType = a->getArmorType(); - if(armorType== "misc" || armorType == "shield") { + if(armorType == "misc" || armorType == "shield") { miscBonus += a->getACBonus(); } else { baseBonus = a->getACBonus(); @@ -296,7 +310,11 @@ namespace creature { std::stringstream text; text << getGivenName() << " (" << getCreatureName() << "): " << getHP() << "/" << getHPMax() << " hp, " << getAC(*this) << " ac"; if(! getNaturalArmor().name.empty()) { - text << " (" << getNaturalArmor().name << ")"; + text << " (" << getNaturalArmor().name; + if(getShieldBonus(*this) != 0) { + text << ", shield"; + } + text << ")"; } else { std::string armor = utils::join(mapItems(utils::castPtrs<entry::Item, entry::Armor>(getInventory())), ", "); if(! armor.empty()) { @@ -318,9 +336,9 @@ namespace creature { text << std::endl; text << "Senses: "; if(! getSenses().empty()) { - text << utils::join(getSenses(), ", ") << ". "; + text << utils::join(getSenses(), ", ") << ", "; } - text << "Passive Perception " << 10 + getSkillBonus(rules::Skill::Perception()) << std::endl; + text << "Passive Perception " << 10 + getSkillBonus(rules::Skill::Perception()) + (data->observant? 5 : 0) << std::endl; if(! getLanguages().empty()) { text << "Languages: " << getLanguages() << std::endl; } |