Refactor sounds

This commit is contained in:
2021-09-09 14:58:07 +01:00
parent be7b2d2cd7
commit 70c97f5367
26 changed files with 113 additions and 162 deletions
+6 -5
View File
@@ -52,9 +52,9 @@ followImpulse cr w imp = case imp of
ChangePosture post -> (id, cr & crStance . posture .~ post)
UseItem -> (tryUseItem cr, cr)
SwitchToItem i -> (id, cr & crInvSel .~ i)
Melee cid ->
(hitCr cid
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown .~ 20) -- randomise cooldown?
Melee cid' ->
(hitCr cid'
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20) -- randomise cooldown?
RandomTurn a -> (id, creatureTurn (rr a) cr)
MakeSound sid -> ( soundOnceOrigin sid (CrSound (_crID cr)) (_crPos cr) , cr )
DropItem -> undefined
@@ -78,8 +78,9 @@ followImpulse cr w imp = case imp of
turnRad = _mvTurnRad mvType
cpos = _crPos cr
cdir = _crDir cr
posFromID cid = _crPos $ _creatures w IM.! cid
cid = _crID cr
posFromID cid' = _crPos $ _creatures w IM.! cid'
rr a = fst $ randomR (-a,a) $ _randGen w
hitCr i = over (creatures . ix i . crState . crDamage) (addDam i)
. soundOnce hitSound
. soundFrom (CrSound cid) cpos hitSound Nothing
addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams