feat(gs/xanthous): Creatures use their weapons to attack

If a creature has a weapon wielded, then they now use that weapon to
attack the player *instead of* their natural attacks. This uses a new
`creatureAttackMessage` field on the Item raw for the message to use.

Change-Id: I73614f33dbf88dd4c68081f15710fa27b7b21ba2
This commit is contained in:
Griffin Smith 2021-11-25 09:53:56 -05:00 committed by grfn
parent 4b11859d04
commit a3d220b631
5 changed files with 50 additions and 11 deletions

View file

@ -34,6 +34,7 @@ module Xanthous.Entities.RawTypes
, HasAttacks(..)
, HasChance(..)
, HasChar(..)
, HasCreatureAttackMessage(..)
, HasDamage(..)
, HasDensity(..)
, HasDescription(..)
@ -200,6 +201,17 @@ makeFieldsNoPrefix ''EdibleItem
data WieldableItem = WieldableItem
{ _damage :: !Hitpoints
, _attackMessage :: !(Maybe Message)
-- | Message to use when a creature is using this item to attack the
-- character.
--
-- Grammatically, should be of the form "The creature slashes you with its
-- dagger".
--
-- = Parameters
--
-- [@creature@ (type: 'Creature')] The creature doing the attacking
-- [@item@ (type: 'Item')] The item itself
, _creatureAttackMessage :: !(Maybe Message)
}
deriving stock (Show, Eq, Ord, Generic)
deriving anyclass (NFData, CoArbitrary, Function)

View file

@ -11,6 +11,9 @@ Item:
attackMessage:
- You slash at the {{creature.creatureType.name}} with your dagger.
- You stab the {{creature.creatureType.name}} with your dagger.
creatureAttackMessage:
- The {{creature.creatureType.name}} slashes at you with its dagger.
- The {{creature.creatureType.name}} stabs you with its dagger.
# Just the steel, not the handle, for now
density: [7750 , 8050000]
# 15cm 45cm

View file

@ -12,6 +12,10 @@ Item:
- You bonk the {{creature.creatureType.name}} over the head with your stick.
- You bash the {{creature.creatureType.name}} on the noggin with your stick.
- You whack the {{creature.creatureType.name}} with your stick.
creatureAttackMessage:
- The {{creature.creatureType.name}} bonks you over the head with its stick.
- The {{creature.creatureType.name}} bashes you on the noggin with its stick.
- The {{creature.creatureType.name}} whacks you with its stick.
# https://www.sciencedirect.com/topics/agricultural-and-biological-sciences/wood-density
# it's a hard stick. so it's dense wood.
density: 890000 # g/m³