Make damage application belong to hit object
This commit is contained in:
@@ -8,21 +8,19 @@ 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)
|
||||
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
|
||||
@@ -41,7 +39,3 @@ bulDamageWall dt amount bt p wl w = w
|
||||
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)
|
||||
|
||||
@@ -13,7 +13,6 @@ import Dodge.Particle.Spark
|
||||
import Dodge.Wall.Damage
|
||||
import Dodge.WorldEvent
|
||||
import Dodge.Particle.Bullet.Spawn
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Creature.Property
|
||||
import Dodge.Wall.Reflect
|
||||
@@ -33,7 +32,7 @@ crArmourSplit normalf armourf bt p cr
|
||||
| otherwise = normalf bt p cr
|
||||
|
||||
basicHitCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
basicHitCr bt p cr = addDamage . bulletHitSound p
|
||||
basicHitCr bt p cr = addDamage
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
@@ -74,10 +73,9 @@ bounceArmour bt p cr = addBouncer . addDamageArmoured
|
||||
|
||||
-- | Basic bullet hit creature effect.
|
||||
bulHitCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
bulHitCr = crArmourSplit basicHitCr basicHitArmour
|
||||
bulHitCr = basicHitCr
|
||||
--bulHitCr = crArmourSplit basicHitCr basicHitArmour
|
||||
|
||||
bulletHitSound :: Point2 -> World -> World
|
||||
bulletHitSound p = soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
|
||||
{- | Bounce off armoured creatures, otherwise do damage. -}
|
||||
bulBounceArmCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
bulBounceArmCr = crArmourSplit basicHitCr bounceArmour
|
||||
@@ -87,7 +85,6 @@ hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
hvBulHitCr bt p cr w = w
|
||||
& creatures . ix cid . crState . crDamage .++~
|
||||
damageGamut 200 100 d1 sp p ep
|
||||
& bulletHitSound ep
|
||||
where
|
||||
(d1,_) = randomR (-0.7,0.7) $ _randGen w
|
||||
cid = _crID cr
|
||||
@@ -114,7 +111,6 @@ bulDestroyCr :: (Point2 -> State StdGen Particle)
|
||||
-> Particle -> Point2 -> Creature -> World -> World
|
||||
bulDestroyCr f bt p cr w = w
|
||||
& instantParticles .:~ (pt & ptPos .~ p)
|
||||
& bulletHitSound p
|
||||
& creatures . ix cid . crState . crDamage .:~ Damage Piercing 60 sp p ep NoDamageEffect
|
||||
& randGen .~ g
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user