Start to move damage effects of bullets into a more sensible place

This commit is contained in:
2022-03-25 09:45:11 +00:00
parent 41ad289de2
commit af6cdfd048
7 changed files with 102 additions and 99 deletions
@@ -4,7 +4,6 @@ module Dodge.Particle.Bullet.DestroyDamage
import Dodge.Data
import Dodge.WorldEvent.HitEffect
import Dodge.Wall.Damage
import Dodge.SoundLogic
import Geometry
import LensHelp
+12 -34
View File
@@ -31,28 +31,6 @@ crArmourSplit normalf armourf bt p cr
| crIsArmouredFrom p cr = armourf bt p cr
| otherwise = normalf bt p cr
basicHitCr :: Particle -> Point2 -> Creature -> World -> World
basicHitCr bt p cr = addDamage
where
sp = head $ _ptTrail bt
bulVel = _ptVel bt
ep = sp +.+ bulVel
mvDams = [ Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage .++~
(Damage Piercing 100 sp p ep NoDamageEffect : mvDams)
cid = _crID cr
-- | Basic bullet hit creature effect.
basicHitArmour :: Particle -> Point2 -> Creature -> World -> World
basicHitArmour bt p cr w = colSpark 8 (_ptColor bt) p1 (argV (p1 -.- p)) $ addDamageArmoured w
where
sp = head $ _ptTrail bt
bulVel = _ptVel bt
ep = sp +.+ bulVel
mvDams = [ Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel ]
addDamageArmoured = creatures . ix cid . crState . crDamage .++~ mvDams
cid = _crID cr
p1 = p +.+ 2 *.* squashNormalizeV (p -.- _crPos cr)
bounceArmour :: Particle -> Point2 -> Creature -> World -> World
bounceArmour bt p cr = addBouncer . addDamageArmoured
@@ -73,12 +51,20 @@ bounceArmour bt p cr = addBouncer . addDamageArmoured
-- | Basic bullet hit creature effect.
bulHitCr :: Particle -> Point2 -> Creature -> World -> World
bulHitCr = basicHitCr
--bulHitCr = crArmourSplit basicHitCr basicHitArmour
bulHitCr bt p cr = addDamage
where
sp = head $ _ptTrail bt
bulVel = _ptVel bt
ep = sp +.+ bulVel
mvDams = [ Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage .++~
(Damage Piercing 100 sp p ep NoDamageEffect : mvDams)
cid = _crID cr
{- | Bounce off armoured creatures, otherwise do damage. -}
bulBounceArmCr :: Particle -> Point2 -> Creature -> World -> World
bulBounceArmCr = crArmourSplit basicHitCr bounceArmour
bulBounceArmCr = crArmourSplit bulHitCr bounceArmour
{- | Heavy bullet effects when hitting creature:
piercing, blunt, twisting and pushback damage all applied. -}
hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
@@ -145,18 +131,10 @@ bulHitWall bt p = damageWall (Damage Piercing 100 sp p ep NoDamageEffect)
sp = head $ _ptTrail bt
{- | Bounce off walls, do damage to blocks. -}
bulBounceWall :: Particle -> Point2 -> Wall -> World -> World
bulBounceWall bt p wl = damageWall (Damage Blunt 50 sp p ep NoDamageEffect) wl
. over instantParticles (bouncer :)
bulBounceWall bt p = damageWall (Damage Blunt 50 sp p ep (BounceBullet bt))
where
ep = sp +.+ _ptVel bt
sp = head $ _ptTrail bt
pOut = p +.+ squashNormalizeV (sp -.- p)
bouncer = (aBulAt Nothing id (Just (_ptColor bt)) 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
-- this list
hvBulHitWall
:: Particle