From 3aea0db385b2b8d7fe479f41e41d08ad531a7e7a Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 24 Mar 2022 08:06:48 +0000 Subject: [PATCH] Add file --- src/Dodge/Particle/Bullet/DestroyDamage.hs | 47 ++++++++++++++++++++++ src/Dodge/Wall/DamageEffect.hs | 29 +++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/Dodge/Particle/Bullet/DestroyDamage.hs create mode 100644 src/Dodge/Wall/DamageEffect.hs diff --git a/src/Dodge/Particle/Bullet/DestroyDamage.hs b/src/Dodge/Particle/Bullet/DestroyDamage.hs new file mode 100644 index 000000000..2b488224e --- /dev/null +++ b/src/Dodge/Particle/Bullet/DestroyDamage.hs @@ -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) diff --git a/src/Dodge/Wall/DamageEffect.hs b/src/Dodge/Wall/DamageEffect.hs new file mode 100644 index 000000000..9f359d826 --- /dev/null +++ b/src/Dodge/Wall/DamageEffect.hs @@ -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