Cleanup bullet effects

This commit is contained in:
2022-03-25 14:16:27 +00:00
parent e98ecfffb3
commit 59b49956b5
4 changed files with 9 additions and 80 deletions
-72
View File
@@ -1,72 +0,0 @@
{- | Effects of bullets upon impact with walls or creatures. -}
module Dodge.Particle.Bullet.HitEffect
( hvBulHitCr
, hvBulHitWall
) where
import Dodge.Data
import Dodge.Particle.Spark
import Dodge.Wall.Damage
import Dodge.Wall.Reflect
import Geometry
import Picture
import LensHelp
import System.Random
{- | Heavy bullet effects when hitting creature:
piercing, blunt, twisting and pushback damage all applied. -}
hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
hvBulHitCr bt p cr w = w
& creatures . ix cid . crState . crDamage .++~
damageGamut 200 100 d1 sp p ep
where
(d1,_) = randomR (-0.7,0.7) $ _randGen w
cid = _crID cr
sp = head $ _ptTrail bt
ep = sp +.+ _ptVel bt
damageGamut :: Int -> Int -> Float -> Point2 -> Point2 -> Point2
-> [Damage]
damageGamut pdam bdam tor sp p ep =
[Damage Piercing pdam sp p ep NoDamageEffect
,Damage Blunt bdam sp p ep NoDamageEffect
,Damage TorqueDam 1 sp p ep $ TorqueDamage tor
,Damage PushDam 1 sp p ep . PushBackDamage $ 3 *.* (ep -.- sp)
]
--bulletDestroyDamage :: (Particle -> Point2 -> [Damage])
-- -> Particle
-- -> [(Point2, Either Creature Wall)]
-- -> World
-- -> (World, Maybe Particle)
--bulletDestroyDamage fdm bt hitThings w = case hitThings of
-- [] -> (w, mvPt bt)
-- ((p,Left cr):_) -> (creff cr p w, destroyAt p bt)
-- ((p,Right wl):_) -> (wleff wl p, destroyAt p bt)
-- where
-- creff cr p = addDamage
-- where
-- dams = fdm bt p
-- addDamage = creatures . ix cid . crState . crDamage .++~ dams
-- cid = _crID cr
-- wleff wl p = foldr (`damageWall` wl) w dams
-- where
-- dams = fdm bt p
hvBulHitWall
:: Particle
-> Point2 -- ^ Impact point
-> Wall
-> World
-> World
hvBulHitWall bt p wl w = damageWall (Damage Piercing 200 sp p ep NoDamageEffect) wl
. damageWall (Damage Blunt 100 sp p ep NoDamageEffect) wl
$ set randGen g $ foldr ($) w (sparks pOut sv)
where
ep = sp +.+ _ptVel bt
sp = head $ _ptTrail bt
pOut = p +.+ squashNormalizeV (sp -.- p)
(a, g) = randomR (-0.2,0.2) $ _randGen w
sv = unitVectorAtAngle $ a + reflDirWall sp p wl
cs' = take 10 $ randomRs (0,11) $ _randGen w
cs = map (brightX 100 1.5 . numColor) cs'
ts = randomRs (4,8) $ _randGen w
sparks pos vel = zipWith (\t c -> colSpark t c pos (argV vel)) ts cs
+6 -3
View File
@@ -1,7 +1,6 @@
module Dodge.Particle.Damage where
import Dodge.Data
import Geometry
--import LensHelp
import System.Random
import Control.Monad.State
@@ -47,8 +46,12 @@ basicSparkDams bt p =
hvBulDams :: Particle -> Point2 -> [Damage]
hvBulDams bt p =
[ Damage Piercing 100 sp p ep NoDamageEffect
, Damage Blunt 50 sp p ep NoDamageEffect
[ Damage Piercing 25 sp p ep NoDamageEffect
, Damage Piercing 25 sp p ep NoDamageEffect
, Damage Piercing 25 sp p ep NoDamageEffect
, Damage Piercing 25 sp p ep NoDamageEffect
, Damage Piercing 25 sp p ep NoDamageEffect
, Damage Piercing 25 sp p ep NoDamageEffect
, Damage TorqueDam 1 sp p ep $ TorqueDamage 0.7
, Damage PushDam 1 sp p ep . PushBackDamage $ 3 *.* (ep -.- sp)
]