From 01293baa64fa905c5763020bd6c0b4903d41fc78 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 12 Jun 2021 15:32:53 -0400 Subject: Verified some creature attacks --- src/creature.cc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/creature.cc') 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(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(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; } -- cgit v1.2.3