diff options
author | Your Name <you@example.com> | 2021-12-25 16:52:34 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2021-12-25 16:52:34 -0500 |
commit | 52b91a1aca6640b1797a63afc8a9e9a778b0964a (patch) | |
tree | 0cfb8ebe6a0a511607b3acc6c67228b796cd9c90 /src/weapon.cc | |
parent | d8d1056af0383f0ef67c6d70d1594bcb430d7281 (diff) | |
download | dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.tar.gz dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.tar.bz2 dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.zip |
Added capability to cause two npcs to attack each other
Diffstat (limited to 'src/weapon.cc')
-rw-r--r-- | src/weapon.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/weapon.cc b/src/weapon.cc index 7ae597f..e5f04f2 100644 --- a/src/weapon.cc +++ b/src/weapon.cc @@ -110,27 +110,24 @@ namespace entry { bool first = true; for(Damage& d : dmgs) { d.rolled = 0; - int sides = d.dmg_die_sides; if(first && versatile && w.getProperties().count("versatile")) { - sides += 2; + d.dmg_die_sides += 2; } first = false; for(int i = 0; i < d.dmg_die_count; i++) { - d.rolled += dice::roll(sides); + d.rolled += dice::roll(d.dmg_die_sides); } } return dmgs; } - string formatDmg(const Weapon& w, const creature::Creature& c) { + string formatDmgHelper(const Weapon& w, const creature::Creature& c, const std::vector<Damage>& dmgsNoVersatile, const std::vector<Damage>& dmgsVersatile) { stringstream text; - vector<Damage> dmgsNoVersatile = rollDmg(w, false); - vector<Damage> dmgsVersatile = rollDmg(w, true); int abilityBonus = w.getDamageBonus(c); for(size_t i = 0; i < dmgsNoVersatile.size(); i++) { if(i == 0 and w.getType() == "weapons" and dmgsNoVersatile[0].dmg_die_sides != 1) { text << dmgsNoVersatile[i].rolled + abilityBonus; - if(w.getProperties().count("versatile")) { + if(w.getProperties().count("versatile") and ! dmgsVersatile.empty()) { text << " (or " << dmgsVersatile[i].rolled + abilityBonus << " if two-handed)"; } } else { @@ -148,6 +145,16 @@ namespace entry { return text.str(); } + string formatDmg(const Weapon& w, const creature::Creature& c) { + vector<Damage> dmgsNoVersatile = rollDmg(w, false); + vector<Damage> dmgsVersatile = rollDmg(w, true); + return formatDmgHelper(w, c, dmgsNoVersatile, dmgsVersatile); + } + + string formatDmg(const Weapon& w, const creature::Creature& c, const std::vector<Damage>& dmgs) { + return formatDmgHelper(w, c, dmgs, {}); + } + vector<rules::Ability> getAbilityOptions(const Weapon& w) { // Do finesse if(w.getProperties().count("finesse")) { |