Fix aiming with no weapon crash
This commit is contained in:
@@ -8,4 +8,4 @@ drawBul :: Particle -> Picture
|
||||
drawBul pt = setLayer 1
|
||||
. setDepth 20
|
||||
. color (_ptColor pt)
|
||||
$ thickLine (take 3 $ _ptTrail pt) (_btWidth' pt)
|
||||
$ thickLine (take 3 $ _ptTrail pt) (_ptWidth pt)
|
||||
|
||||
@@ -52,8 +52,8 @@ bulBounceArmCr' bt p cr w
|
||||
reflectVel = magV bulVel *.* newDir
|
||||
addBouncer = instantParticles .:~ bouncer
|
||||
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt)
|
||||
(_btHitEffect' bt) (_btWidth' bt)
|
||||
) {_btTimer' = _btTimer' bt - 1}
|
||||
(_ptHitEff bt) (_ptWidth bt)
|
||||
) {_ptTimer = _ptTimer bt - 1}
|
||||
{- | Bullet pass through creatures. -}
|
||||
bulPenCr' :: Particle -> Point2 -> Creature -> World -> World
|
||||
bulPenCr' bt p cr w = w
|
||||
@@ -71,8 +71,8 @@ bulPenCr' bt p cr w = w
|
||||
sp = head $ _ptTrail bt
|
||||
ep = sp +.+ _ptVel bt
|
||||
piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt)
|
||||
(_btHitEffect' bt) (_btWidth' bt)
|
||||
) {_btTimer' = _btTimer' bt - 1}
|
||||
(_ptHitEff bt) (_ptWidth bt)
|
||||
) {_ptTimer = _ptTimer bt - 1}
|
||||
{- | Heavy bullet effects when hitting creature:
|
||||
piercing, blunt, twisting and pushback damage all applied. -}
|
||||
hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
@@ -92,7 +92,7 @@ hvBulHitCr bt p cr w = w
|
||||
{- | Create a flamelet when hitting a creature. -}
|
||||
bulIncCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
bulIncCr bt p cr w = w
|
||||
& makeFlameletTimed p 20 v Nothing 3 20
|
||||
& makeFlamelet p 20 v Nothing 3 20
|
||||
& bulletHitSound p
|
||||
& creatures . ix cid . crState . crDamage .:~ Piercing 60 sp p ep
|
||||
where
|
||||
@@ -123,8 +123,8 @@ bulBounceWall bt p wl = damageWall (Blunt 50 sp p ep) wl
|
||||
ep = sp +.+ _ptVel bt
|
||||
sp = head $ _ptTrail bt
|
||||
pOut = p +.+ squashNormalizeV (sp -.- p)
|
||||
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt) (_btHitEffect' bt) (_btWidth' bt)
|
||||
) {_btTimer' = _btTimer' bt - 1}
|
||||
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt) (_ptHitEff bt) (_ptWidth bt)
|
||||
) {_ptTimer = _ptTimer bt - 1}
|
||||
reflectVel = reflVelWall wl (_ptVel bt)
|
||||
-- the hack is to get around the fact that the particles list gets reset after
|
||||
-- all projectiles in it are checked, so we cannot add to it as we accumulate over
|
||||
@@ -138,7 +138,7 @@ bulIncWall
|
||||
-> World
|
||||
-> World
|
||||
bulIncWall bt p wl = damageWall (Blunt 50 sp p ep) wl
|
||||
. makeFlameletTimed pOut 20 reflectVel Nothing 3 20
|
||||
. makeFlamelet pOut 20 reflectVel Nothing 3 20
|
||||
where
|
||||
ep = sp +.+ _ptVel bt
|
||||
sp = head $ _ptTrail bt
|
||||
|
||||
@@ -27,10 +27,10 @@ aGenBulAt maycid pos vel drag hiteff width = BulletPt
|
||||
, _btDrag = drag
|
||||
, _ptColor = V4 2 2 2 2
|
||||
, _ptTrail = [pos]
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = width
|
||||
, _btTimer' = 100
|
||||
, _btHitEffect' = hiteff
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = width
|
||||
, _ptTimer = 100
|
||||
, _ptHitEff = hiteff
|
||||
}
|
||||
aDelayedBulAt
|
||||
:: Float -- ^ Start velocity step factor
|
||||
@@ -48,10 +48,10 @@ aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
|
||||
, _btDrag = drag
|
||||
, _ptColor = V4 2 2 2 2
|
||||
, _ptTrail = [pos]
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = width
|
||||
, _btTimer' = 100
|
||||
, _btHitEffect' = hiteff
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = width
|
||||
, _ptTimer = 100
|
||||
, _ptHitEff = hiteff
|
||||
}
|
||||
where
|
||||
resetVel = second $ fmap $ (ptUpdate .~ mvBullet) . (ptVel .~ vel)
|
||||
@@ -72,11 +72,11 @@ aCurveBulAt maycid col pos control targ hiteff width = BulletPt
|
||||
, _btDrag = 1
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = width
|
||||
, _btTimer' = 100
|
||||
, _btHitEffect' = hiteff
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = width
|
||||
, _ptTimer = 100
|
||||
, _ptHitEff = hiteff
|
||||
}
|
||||
where
|
||||
setVel pt = pt & ptVel .~ bf (fromIntegral $ _btTimer' pt - 1) -.- bf (fromIntegral $ _btTimer' pt)
|
||||
setVel pt = pt & ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
||||
bf t = bQuadToF (pos,control,targ) $ (100 - t) * 0.05
|
||||
|
||||
@@ -8,10 +8,9 @@ import Dodge.Data
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
--import Picture
|
||||
import Geometry
|
||||
--import Geometry.Vector3D
|
||||
import LensHelp
|
||||
|
||||
import Data.Bifunctor
|
||||
import Control.Lens
|
||||
{- Update for a generic bullet. -}
|
||||
mvBullet :: World -> Particle -> (World, Maybe Particle)
|
||||
mvBullet w bt'
|
||||
@@ -20,10 +19,10 @@ mvBullet w bt'
|
||||
hiteff bt (thingsHitExceptCr mcr p (p +.+ vel) w) w
|
||||
where
|
||||
bt = foldr (\mg b -> _mgField mg mg b) bt' $ _magnets w
|
||||
dodrag = ptVel %~ (drag *.*)
|
||||
dodrag = ptVel .*.*~ drag
|
||||
drag = _btDrag bt
|
||||
mcr = _btPassThrough' bt
|
||||
mcr = _ptCrIgnore bt
|
||||
(p:_) = _ptTrail bt
|
||||
vel = _ptVel bt
|
||||
hiteff = _btHitEffect' bt
|
||||
t = _btTimer' bt
|
||||
hiteff = _ptHitEff bt
|
||||
t = _ptTimer bt
|
||||
|
||||
@@ -23,10 +23,10 @@ createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
|
||||
, _btDrag = 0.9
|
||||
, _ptColor = numColor colid
|
||||
, _ptTrail = [pos]
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = 1
|
||||
, _btTimer' = time
|
||||
, _btHitEffect' = destroyOnImpact sparkEff noEff
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = destroyOnImpact sparkEff noEff
|
||||
}
|
||||
where
|
||||
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage .:~ SparkDam 1 sp p ep
|
||||
@@ -49,10 +49,10 @@ colSparkRandDir randDir time col pos baseDir w = w
|
||||
, _ptVel = rotateV dir (V2 5 0)
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _btPassThrough' = Nothing
|
||||
, _btWidth' = 1
|
||||
, _btTimer' = time
|
||||
, _btHitEffect' = destroyOnImpact sparkEff noEff
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = destroyOnImpact sparkEff noEff
|
||||
}
|
||||
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage .:~ SparkDam 1 sp p ep
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user