Fix crsHitRadial, unify some radial damages
This commit is contained in:
+9
-22
@@ -3,8 +3,8 @@ module Dodge.Flame (
|
||||
updateFlame,
|
||||
) where
|
||||
|
||||
import Data.Foldable
|
||||
import Dodge.Base.Wall
|
||||
import Dodge.Damage
|
||||
import Dodge.Data.World
|
||||
import Dodge.Flame.Size
|
||||
import Dodge.SoundLogic
|
||||
@@ -18,34 +18,20 @@ import RandomHelp
|
||||
|
||||
updateFlame :: World -> Flame -> (World, Maybe Flame)
|
||||
updateFlame w pt
|
||||
| time <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing)
|
||||
| _flTimer pt <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing)
|
||||
| Just (_, Right wl) <- thit = (doupdate, Just $ reflame wl)
|
||||
-- might want to move differently if we hit a creature?
|
||||
| otherwise = (flFlicker pt doupdate, Just mvflame)
|
||||
where
|
||||
reflame wl = pt & flTimer -~ 1 & flVel %~ reflVelWallDamp 0.9 wl
|
||||
doupdate = soundContinue FlameSound sp fireLoudS (Just 2) dodamage
|
||||
doupdate =
|
||||
soundContinue FlameSound sp fireLoudS (Just 2) $
|
||||
damageInCircle (const $ Flaming 1) ep r w
|
||||
thit = List.safeHead $ thingsHit sp ep w
|
||||
time = _flTimer pt
|
||||
sp = _flPos pt
|
||||
ep = sp +.+ _flVel pt
|
||||
mvflame =
|
||||
pt
|
||||
& flTimer -~ 1
|
||||
& flPos .~ ep
|
||||
& flVel *~ 0.98
|
||||
dodamage =
|
||||
foldl'
|
||||
damcr
|
||||
(foldl' damwl w (wlsHitRadial ep r w))
|
||||
(crsHitRadial ep r w)
|
||||
r = flameSize pt
|
||||
damcr w' (_, cr) =
|
||||
w' & cWorld . lWorld . creatures . ix (_crID cr) . crDamage
|
||||
.:~ Flaming 1
|
||||
damwl w' (_, wl) =
|
||||
w' & cWorld . lWorld . wallDamages . at (_wlID wl)
|
||||
. non [] <>~ [Flaming 1]
|
||||
mvflame = pt & flTimer -~ 1 & flPos .~ ep & flVel *~ 0.98
|
||||
r = max 0 $ flameSize pt - 1
|
||||
|
||||
flFlicker :: Flame -> World -> World
|
||||
flFlicker pt
|
||||
@@ -55,7 +41,8 @@ flFlicker pt
|
||||
| otherwise = id
|
||||
|
||||
makeFlame :: Point2 -> Point2 -> World -> World
|
||||
makeFlame pos vel w = w
|
||||
makeFlame pos vel w =
|
||||
w
|
||||
& cWorld . lWorld . flames .:~ Flame t pos vel
|
||||
& randGen .~ g
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user