Fix aiming with no weapon crash
This commit is contained in:
@@ -26,39 +26,39 @@ makeShockwaveAt is p rad dam push col = instantParticles .:~ Shockwave
|
||||
{ _ptDraw = drawShockwave
|
||||
, _ptUpdate = mvShockwave is
|
||||
, _ptColor = col
|
||||
, _btPos' = p
|
||||
, _btRad' = rad
|
||||
, _btDam' = dam
|
||||
, _btPush' = push
|
||||
, _btMaxTime' = 10
|
||||
, _btTimer' = 10
|
||||
, _ptPos = p
|
||||
, _ptRad = rad
|
||||
, _ptDam = dam
|
||||
, _ptPush = push
|
||||
, _ptMaxTime = 10
|
||||
, _ptTimer = 10
|
||||
}
|
||||
{- Shockwave picture. -}
|
||||
drawShockwave :: Particle -> Picture
|
||||
drawShockwave pt = setDepth 20
|
||||
. setLayer 1
|
||||
. uncurryV translate (_btPos' pt)
|
||||
. uncurryV translate (_ptPos pt)
|
||||
. color (_ptColor pt)
|
||||
$ thickCircle rad thickness
|
||||
where
|
||||
r = _btRad' pt
|
||||
r = _ptRad pt
|
||||
thickness = tFraction**2 * r
|
||||
rad = r - (3/4) * r * tFraction
|
||||
tFraction = fromIntegral (_btTimer' pt) / fromIntegral (_btMaxTime' pt)
|
||||
tFraction = fromIntegral (_ptTimer pt) / fromIntegral (_ptMaxTime pt)
|
||||
|
||||
mvShockwave
|
||||
:: [Int] -- ^ IDs of invulnerable creatures.
|
||||
-> World -> Particle -> (World, Maybe Particle)
|
||||
mvShockwave is w pt
|
||||
| _btTimer' pt <= 0 = ( w , Nothing)
|
||||
| otherwise = (doDams w , Just $ pt & btTimer' -~ 1)
|
||||
| _ptTimer pt <= 0 = ( w , Nothing)
|
||||
| otherwise = (doDams w , Just $ pt & ptTimer -~ 1)
|
||||
where
|
||||
r = _btRad' pt
|
||||
p = _btPos' pt
|
||||
push = _btPush' pt
|
||||
dam = _btDam' pt
|
||||
t = _btTimer' pt
|
||||
tFraction = fromIntegral t / fromIntegral (_btMaxTime' pt)
|
||||
r = _ptRad pt
|
||||
p = _ptPos pt
|
||||
push = _ptPush pt
|
||||
dam = _ptDam pt
|
||||
t = _ptTimer pt
|
||||
tFraction = fromIntegral t / fromIntegral (_ptMaxTime pt)
|
||||
rad = r - (3/4) * r * tFraction
|
||||
doDams = over creatures (IM.map damCr) . flip (IM.foldl' (flip $ damageWall (Explosive 10000 p)))
|
||||
hitBlocks
|
||||
@@ -79,12 +79,12 @@ inverseShockwaveAt p rad dam push = particles .:~ Shockwave
|
||||
{ _ptDraw = drawInverseShockwave
|
||||
, _ptUpdate = moveInverseShockwave
|
||||
, _ptColor = cyan
|
||||
, _btPos' = p
|
||||
, _btRad' = rad
|
||||
, _btDam' = dam
|
||||
, _btPush' = push
|
||||
, _btMaxTime' = 10
|
||||
, _btTimer' = 10
|
||||
, _ptPos = p
|
||||
, _ptRad = rad
|
||||
, _ptDam = dam
|
||||
, _ptPush = push
|
||||
, _ptMaxTime = 10
|
||||
, _ptTimer = 10
|
||||
}
|
||||
moveInverseShockwave
|
||||
:: World
|
||||
@@ -92,11 +92,11 @@ moveInverseShockwave
|
||||
-> (World, Maybe Particle)
|
||||
moveInverseShockwave w pt
|
||||
| t <= 0 = ( w, Nothing)
|
||||
| otherwise = (dams w, Just $ btTimer' -~ 1 $ pt )
|
||||
| otherwise = (dams w, Just $ ptTimer -~ 1 $ pt )
|
||||
where
|
||||
p = _btPos' pt
|
||||
r = _btRad' pt
|
||||
t = _btTimer' pt
|
||||
p = _ptPos pt
|
||||
r = _ptRad pt
|
||||
t = _ptTimer pt
|
||||
rad = r - 0.1 * r * fromIntegral (10 - t)
|
||||
dams = over creatures (IM.map damCr) . flip (foldr (damageBlocksBy 1)) hitBlocks
|
||||
hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w
|
||||
@@ -110,8 +110,8 @@ drawInverseShockwave pt
|
||||
= setLayer 1 $ onLayer PtLayer $ uncurryV translate p
|
||||
$ color cyan $ thickCircle rad thickness
|
||||
where
|
||||
p = _btPos' pt
|
||||
r = _btRad' pt
|
||||
t = _btTimer' pt
|
||||
p = _ptPos pt
|
||||
r = _ptRad pt
|
||||
t = _ptTimer pt
|
||||
rad = r - 0.1 * r * fromIntegral (10 - t)
|
||||
thickness = fromIntegral (10 - t) **2 * rad / 40
|
||||
|
||||
Reference in New Issue
Block a user