Fix aiming with no weapon crash
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
module Dodge.WorldEvent.SpawnParticle
|
||||
( makeGasCloud
|
||||
, aFlameParticle
|
||||
, makeFlameletTimed
|
||||
, makeFlamelet
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
@@ -31,11 +31,11 @@ aFlameParticle t pos vel maycid = PtZ
|
||||
, _ptUpdate = moveFlame vel
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _btPos' = pos
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = 4
|
||||
, _btTimer' = t
|
||||
, _btHitEffect' = destroyOnImpact (doFlameDam 1) noEff
|
||||
, _ptPos = pos
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 4
|
||||
, _ptTimer = t
|
||||
, _ptHitEff = destroyOnImpact (doFlameDam 1) noEff
|
||||
, _ptZ = 20
|
||||
}
|
||||
drawFlame
|
||||
@@ -49,7 +49,7 @@ drawFlame rotd pt = pictures
|
||||
, aPic 1 prot3 20 (V2 scaleChange 0.5 ) $ V4 1 1 1 1
|
||||
]
|
||||
where
|
||||
ep = _btPos' pt
|
||||
ep = _ptPos pt
|
||||
aPic :: Int -> (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
|
||||
aPic lay offset depth (V2 scalex scaley) col
|
||||
= setLayer lay
|
||||
@@ -61,7 +61,7 @@ drawFlame rotd pt = pictures
|
||||
$ circleSolid 5
|
||||
glow = setLayer 1 $ setDepth 0.3 $ uncurryV translate ep
|
||||
$ circleSolidCol (withAlpha 0 orange) (withAlpha 0.02 orange) 50
|
||||
time = _btTimer' pt
|
||||
time = _ptTimer pt
|
||||
scaleChange
|
||||
| time < 80 = 3
|
||||
| otherwise = 3 - (fromIntegral time - 80) * 0.2
|
||||
@@ -76,20 +76,20 @@ moveFlame
|
||||
-> (World, Maybe Particle)
|
||||
moveFlame rotd w pt
|
||||
| time <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing)
|
||||
| otherwise = case thingsHitExceptCr (_btPassThrough' pt) sp ep w of
|
||||
| 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)
|
||||
where
|
||||
time = _btTimer' pt
|
||||
time = _ptTimer pt
|
||||
doSound = soundContinue Flame (V2 x y) fireLoudS (Just 2)
|
||||
sp@(V2 x y) = _btPos' pt
|
||||
sp@(V2 x y) = _ptPos pt
|
||||
vel = _ptVel pt
|
||||
ep = sp +.+ vel
|
||||
mvPt speed = Just $ pt
|
||||
{ _btTimer' = time - 1
|
||||
, _btPos' = ep
|
||||
, _btPassThrough' = Nothing
|
||||
{ _ptTimer = time - 1
|
||||
, _ptPos = ep
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptVel = speed *.* vel }
|
||||
damcrs = foldr (\cr -> fst . hiteff [(ep,Left cr)]) w
|
||||
$ IM.filter closeCrs $ _creatures w
|
||||
@@ -97,37 +97,37 @@ moveFlame rotd w pt
|
||||
< _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80))
|
||||
+ 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd)
|
||||
angleCoeff x' = abs $ 1 - abs ( (x' * 2 - pi) / pi )
|
||||
hiteff = _btHitEffect' pt pt
|
||||
hiteff = _ptHitEff pt pt
|
||||
rfl wl p = Just $ pt
|
||||
{ _btTimer' = time -1
|
||||
, _btPos' = pOut p
|
||||
{ _ptTimer = time -1
|
||||
, _ptPos = pOut p
|
||||
, _ptVel = reflV wl
|
||||
}
|
||||
pOut p = p +.+ squashNormalizeV (sp -.- p)
|
||||
reflV wall = (0.3 *.* reflectIn (uncurry (-.-) . swap $ _wlLine wall) vel )
|
||||
+.+ (0.2 *.* vel)
|
||||
|
||||
makeFlameletTimed
|
||||
makeFlamelet
|
||||
:: Point2 -- ^ Position
|
||||
-> Float -- ^ z position
|
||||
-> Point2 -- ^ Velocity
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> Maybe Int -- ^ Ignore creature id
|
||||
-> Float -- ^ Size
|
||||
-> Int -- ^ Timer
|
||||
-> World
|
||||
-> World
|
||||
makeFlameletTimed (V2 x y) z vel maycid size time w = w
|
||||
makeFlamelet (V2 x y) z vel maycid size time w = w
|
||||
& randGen .~ g
|
||||
& instantParticles .:~ PtZ
|
||||
{ _ptDraw = drawFlameletZ rot
|
||||
, _ptUpdate = moveFlamelet
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _btPos' = V2 x y
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = size
|
||||
, _btTimer' = time
|
||||
, _btHitEffect' = destroyOnImpact (doFlameDam 1) noEff
|
||||
, _ptPos = V2 x y
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = size
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = destroyOnImpact (doFlameDam 1) noEff
|
||||
, _ptZ = z
|
||||
}
|
||||
where
|
||||
@@ -144,12 +144,12 @@ drawFlameletZ rot pt = pictures
|
||||
]
|
||||
where
|
||||
z = _ptZ pt
|
||||
sp = _btPos' pt
|
||||
sp = _ptPos pt
|
||||
vel = _ptVel pt
|
||||
ep = sp +.+ vel
|
||||
size = _btWidth' pt
|
||||
size = _ptWidth pt
|
||||
siz2 = size + 0.2
|
||||
time = _btTimer' pt
|
||||
time = _ptTimer pt
|
||||
piu = setDepth (z + 25)
|
||||
. uncurryV translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
@@ -182,17 +182,17 @@ drawFlameletZ rot pt = pictures
|
||||
Applies movement and attaches damage to nearby creatures. -}
|
||||
moveFlamelet :: World -> Particle -> (World, Maybe Particle)
|
||||
moveFlamelet w pt
|
||||
| _btTimer' pt <= 0 = ( w, Nothing)
|
||||
| _ptTimer pt <= 0 = ( w, Nothing)
|
||||
| otherwise = (flameFlicker pt damcrs, mvPt)
|
||||
where
|
||||
sp = _btPos' pt
|
||||
sp = _ptPos pt
|
||||
vel = _ptVel pt
|
||||
ep = sp +.+ vel
|
||||
size = _btWidth' pt
|
||||
mvPt = Just $ pt & btTimer' -~ 1
|
||||
& btPos' .~ ep
|
||||
& btPassThrough' .~ Nothing
|
||||
& ptVel .~ 0.8 *.* vel
|
||||
size = _ptWidth pt
|
||||
mvPt = Just $ pt & ptTimer -~ 1
|
||||
& ptPos .~ ep
|
||||
& ptCrIgnore .~ Nothing
|
||||
& ptVel .~ 0.8 *.* vel
|
||||
damcrs = w & creatures %~ IM.map damifclose
|
||||
isClose cr = dist ep (_crPos cr) < _crRad cr + size
|
||||
damifclose cr
|
||||
|
||||
Reference in New Issue
Block a user