Rethink damage data type, work on damage sensors
This commit is contained in:
@@ -12,6 +12,7 @@ import Dodge.WorldEvent.Cloud
|
||||
import Dodge.WorldEvent.Flash
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Wall.Damage
|
||||
import Picture
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -27,26 +28,27 @@ aFlameParticle
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> Particle
|
||||
aFlameParticle t pos vel maycid = PtZ
|
||||
{ _ptDraw = drawFlame vel
|
||||
, _ptUpdate = moveFlame vel
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _ptPos = pos
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 4
|
||||
, _ptTimer = t
|
||||
, _ptHitEff = destroyOnImpact (doFlameDam 1) noEff
|
||||
, _ptZ = 20
|
||||
{ _ptDraw = drawFlame vel
|
||||
, _ptUpdate = moveFlame vel
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _ptPos = pos
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 4
|
||||
, _ptTimer = t
|
||||
, _ptHitEff = destroyOnImpact (doFlameDam 1)
|
||||
(\_ p -> damageWall (Damage Flaming 19 p p p NoDamageEffect))
|
||||
, _ptZ = 20
|
||||
}
|
||||
drawFlame
|
||||
drawFlame
|
||||
:: Point2 -- ^ Rotate direction
|
||||
-> Particle
|
||||
-> Picture
|
||||
drawFlame rotd pt = pictures
|
||||
drawFlame rotd pt = pictures
|
||||
[ glow
|
||||
, aPic 3 prot2 25 (V2 (scaleChange + 1) 2 ) $ V4 2 (-1) (-1) 0.5
|
||||
, aPic 3 prot 22 (V2 (scaleChange + 0.5) 1) $ V4 1 0.5 0 2
|
||||
, aPic 1 prot3 20 (V2 scaleChange 0.5 ) $ V4 1 1 1 1
|
||||
, aPic 3 prot2 25 (V2 (scaleChange + 1) 2 ) $ V4 2 (-1) (-1) 0.5
|
||||
, aPic 3 prot 22 (V2 (scaleChange + 0.5) 1 ) $ V4 1 0.5 0 2
|
||||
, aPic 1 prot3 20 (V2 scaleChange 0.5) $ V4 1 1 1 1
|
||||
]
|
||||
where
|
||||
ep = _ptPos pt
|
||||
@@ -69,17 +71,16 @@ drawFlame rotd pt = pictures
|
||||
prot2 p' = p' +.+ rotateV (negate $ fromIntegral time) (V2 0 1)
|
||||
prot3 p' = p' +.+ rotateV (2 + fromIntegral time * 0.1) (V2 0 2)
|
||||
{- TODO: add generalised area damage particles/hiteffects. -}
|
||||
moveFlame
|
||||
:: Point2 -- ^ Rotation direction
|
||||
moveFlame :: Point2 -- ^ Rotation direction
|
||||
-> World
|
||||
-> Particle
|
||||
-> (World, Maybe Particle)
|
||||
moveFlame rotd w pt
|
||||
| time <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing)
|
||||
| otherwise = case thingsHitExceptCr (_ptCrIgnore pt) sp ep w of
|
||||
((_,Left _):_) -> (doSound damcrs , mvPt 0.7)
|
||||
(thing@(p,Right wl):_) -> (doSound . fst $ hiteff [thing] damcrs , rfl wl p)
|
||||
_ -> (flameFlicker pt $ doSound damcrs , mvPt 0.98)
|
||||
((_,Left _):_) -> (doSound damcrs , mvPt 0.7)
|
||||
(th@(p,Right wl):_) -> (doSound . fst $ hiteff [th] damcrs , rfl wl p)
|
||||
_ -> (flameFlicker pt $ doSound damcrs , mvPt 0.98)
|
||||
where
|
||||
time = _ptTimer pt
|
||||
doSound = soundContinue Flame (V2 x y) fireLoudS (Just 2)
|
||||
@@ -98,7 +99,7 @@ moveFlame rotd w pt
|
||||
angleCoeff x' = abs $ 1 - abs ( (x' * 2 - pi) / pi )
|
||||
hiteff = _ptHitEff pt pt
|
||||
rfl wl p = Just $ pt
|
||||
{ _ptTimer = time -1
|
||||
{ _ptTimer = time - 1
|
||||
, _ptPos = pOut p
|
||||
, _ptVel = reflV wl
|
||||
}
|
||||
@@ -195,7 +196,7 @@ moveFlamelet w pt
|
||||
damcrs = w & creatures %~ IM.map damifclose
|
||||
isClose cr = dist ep (_crPos cr) < _crRad cr + size
|
||||
damifclose cr
|
||||
| isClose cr = cr & crState . crDamage .:~ Flaming 3 sp ep ep
|
||||
| isClose cr = cr & crState . crDamage .:~ Damage Flaming 3 sp ep ep NoDamageEffect
|
||||
| otherwise = cr
|
||||
-- | At writing the radius is half the size of the effect area
|
||||
makeGasCloud
|
||||
@@ -223,6 +224,7 @@ makeGasCloud pos vel w = w
|
||||
cloudPoisonDamage :: Cloud -> World -> World
|
||||
cloudPoisonDamage c w = w & creatures %~ flip (foldr (IM.adjust doDam)) damagedCrs
|
||||
where
|
||||
damagedCrs = IM.keys $ IM.filter f $ creaturesNearPoint (stripZ $ _clPos c) w
|
||||
damagedCrs = IM.keys $ IM.filter f $ creaturesNearPoint clpos w
|
||||
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < _crRad cr + _clRad c + 10
|
||||
doDam cr = cr & crState . crDamage .:~ PoisonDam 1
|
||||
doDam cr = cr & crState . crDamage .:~ Damage PoisonDam 1 clpos clpos clpos NoDamageEffect
|
||||
clpos = stripZ $ _clPos c
|
||||
|
||||
Reference in New Issue
Block a user