This commit is contained in:
2022-03-24 08:06:48 +00:00
parent 11d954674c
commit 3aea0db385
2 changed files with 76 additions and 0 deletions
@@ -0,0 +1,47 @@
module Dodge.Particle.Bullet.DestroyDamage
( bulletDestroyDamage
) where
import Dodge.Data
import Dodge.WorldEvent.HitEffect
import Dodge.Wall.Damage
import Dodge.SoundLogic
import Geometry
import LensHelp
-- TODO cleanup wrt destroyOnImpact etc
bulletDestroyDamage :: DamageType
-> Int -- | damage amount
-> Particle
-> [(Point2, Either Creature Wall)]
-> World
-> (World, Maybe Particle)
bulletDestroyDamage dt amount = destroyOnImpact (bulDamageCr dt amount)
(bulDamageWall dt amount)
{- | Create a particle when hitting a creature. -}
bulDamageCr :: DamageType -> Int
-> Particle -> Point2 -> Creature -> World -> World
bulDamageCr dt amount bt p cr w = w
& bulletHitSound' p
& creatures . ix cid . crState . crDamage .:~ Damage dt amount sp p ep NoDamageEffect
where
cid = _crID cr
sp = head $ _ptTrail bt
ep = sp +.+ _ptVel bt
bulDamageWall :: DamageType
-> Int
-> Particle
-> Point2 -- Impact point
-> Wall
-> World
-> World
bulDamageWall dt amount bt p wl w = w
& damageWall (Damage dt amount sp p ep NoDamageEffect) wl
where
ep = sp +.+ _ptVel bt
sp = head $ _ptTrail bt
-- this is a duplicate! anyway, sound should be made by the hit creature
bulletHitSound' :: Point2 -> World -> World
bulletHitSound' p = soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
+29
View File
@@ -0,0 +1,29 @@
module Dodge.Wall.DamageEffect where
import Dodge.Data
import Dodge.Particle.Spark
import Dodge.Wall.Reflect
import Dodge.Wall.Dust
import Geometry
import Color
defaultWallDamage :: Damage -> Wall -> World -> World
defaultWallDamage dm wl = case _dmType dm of
Lasering -> colSpark 8 lSparkCol outTo (reflDirWall sp p wl)
Piercing -> colSparkRandDir 0.2 8 pSparkCol outTo (reflDirWall sp p wl)
. wlDustAt wl outTo
Blunt -> wlDustAt wl outTo
Explosive-> id
Cutting -> id
SparkDam -> id
Flaming -> id
Electrical -> id
Concussive -> id
TorqueDam -> id
PushDam -> id
PoisonDam -> id
where
sp = _dmFrom dm
p = _dmTo dm
outTo = p +.+ squashNormalizeV (sp -.- p)
pSparkCol = brightX 100 1.5 white
lSparkCol = V4 20 (-5) 0 1