Small chance of hurting self when punching

When attacking monsters with bare fists, there is a small chance (8%,
right now) of causing 1 point of self-damage
This commit is contained in:
Griffin Smith 2020-05-10 20:26:44 -04:00
parent b64dd08c6e
commit ce3730ba3a
3 changed files with 26 additions and 1 deletions

View file

@ -548,9 +548,16 @@ attackAt pos =
msg <- uses character getAttackMessage
message msg msgParams
entities . ix creatureID . positioned .= SomeEntity creature'
whenM (uses character $ isNothing . weapon)
$ whenM (chance (0.08 :: Float)) $ do
say_ ["combat", "fistSelfDamage"]
character %= Character.damage 1
stepGame -- TODO
weapon chr = chr ^? inventory . wielded . wieldedItems . wieldableItem
getAttackMessage chr =
case chr ^? inventory . wielded . wieldedItems . wieldableItem of
case weapon chr of
Just wi ->
fromMaybe (Messages.lookup ["combat", "hit", "generic"])
$ wi ^. attackMessage