Split bullet spawning and bouncing/penetration
This commit is contained in:
+6
-19
@@ -21,7 +21,6 @@ import Control.Monad.State
|
|||||||
|
|
||||||
updateBullet :: World -> Bullet -> (World,Maybe Bullet)
|
updateBullet :: World -> Bullet -> (World,Maybe Bullet)
|
||||||
updateBullet w bu = case _buState bu of
|
updateBullet w bu = case _buState bu of
|
||||||
DyingBulletState -> (w,Nothing)
|
|
||||||
DelayedBullet x -> mvBullet x w bu
|
DelayedBullet x -> mvBullet x w bu
|
||||||
_ -> mvBullet 1 w bu
|
_ -> mvBullet 1 w bu
|
||||||
|
|
||||||
@@ -54,16 +53,12 @@ useAmmoParams it cr w = w & instantBullets .:~ (_amBullet bultype
|
|||||||
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
||||||
mvBullet x w bt'
|
mvBullet x w bt'
|
||||||
| t <= 0 || magV (_buVel bt) < 1 = (endspawn w,Nothing)
|
| t <= 0 || magV (_buVel bt) < 1 = (endspawn w,Nothing)
|
||||||
| otherwise = bimap (maybespawn . maybebounce) (fmap dodrag) $
|
| otherwise = bimap maybebounce (fmap dodrag) $
|
||||||
hiteff bt hitstream w
|
hiteff bt hitstream w
|
||||||
where
|
where
|
||||||
endspawn w' = fromMaybe w' $ do
|
endspawn w' = fromMaybe w' $ do
|
||||||
partspawn <- bulletSpawn bt'
|
partspawn <- bulletSpawn bt'
|
||||||
return $ partspawn p w'
|
return $ partspawn p w'
|
||||||
maybespawn w' = fromMaybe w' $ do
|
|
||||||
(hp,_) <- runIdentity (S.head_ hitstream)
|
|
||||||
partspawn <- bulletSpawn bt'
|
|
||||||
return $ partspawn (hp +.+ normalizeV (_buPos bt' -.- hp)) w'
|
|
||||||
maybebounce = fromMaybe id $ do
|
maybebounce = fromMaybe id $ do
|
||||||
guard (_buEffect bt' == BounceBullet)
|
guard (_buEffect bt' == BounceBullet)
|
||||||
(hp,crwl) <- runIdentity (S.head_ hitstream)
|
(hp,crwl) <- runIdentity (S.head_ hitstream)
|
||||||
@@ -101,15 +96,6 @@ bulletSpawn bu = case _buSpawn bu of
|
|||||||
BulBall IncBall -> Just incBallAt
|
BulBall IncBall -> Just incBallAt
|
||||||
BulBall ConcBall -> Just $ randParticleAt concBall
|
BulBall ConcBall -> Just $ randParticleAt concBall
|
||||||
BulBall TeslaBall -> Just makeStaticBall
|
BulBall TeslaBall -> Just makeStaticBall
|
||||||
-- where
|
|
||||||
-- dosatate st p w = w'
|
|
||||||
-- &
|
|
||||||
-- where
|
|
||||||
-- (pt,g) = runState do
|
|
||||||
-- partspawn <- bulletSpawn bt'
|
|
||||||
-- let (thepart,g) = runState (partspawn hp) $ _randGen w'
|
|
||||||
-- return $ w' & instantParticles .:~ thepart
|
|
||||||
-- & randGen .~ g
|
|
||||||
|
|
||||||
hitEffFromBul :: Float -> Bullet
|
hitEffFromBul :: Float -> Bullet
|
||||||
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||||
@@ -138,10 +124,11 @@ moveBullet x pt = Just $ pt
|
|||||||
|
|
||||||
destroyAt' :: Point2 -> Bullet -> Maybe Bullet
|
destroyAt' :: Point2 -> Bullet -> Maybe Bullet
|
||||||
destroyAt' hitp pt = Just $ pt
|
destroyAt' hitp pt = Just $ pt
|
||||||
& buState .~ DyingBulletState
|
& buPos .~ hitp +.+ normalizeV (p -.- hitp)
|
||||||
& buPos .~ hitp
|
& buOldPos .~ p
|
||||||
& buOldPos .~ _buPos pt
|
& buVel .~ 0
|
||||||
& buTimer %~ (min 3 . subtract 1)
|
where
|
||||||
|
p = _buPos pt
|
||||||
|
|
||||||
--penWalls
|
--penWalls
|
||||||
-- :: HitCreatureEffect'
|
-- :: HitCreatureEffect'
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ itemCombinations =
|
|||||||
hd = HELD
|
hd = HELD
|
||||||
eq = EQUIP
|
eq = EQUIP
|
||||||
|
|
||||||
|
-- so there are two requirements for a module combination: the module slot must
|
||||||
|
-- exist on the item, and the item must be in the given list below
|
||||||
|
-- these two requirements should probably be combined
|
||||||
moduleCombinations :: [( ModuleSlot, [Item], [([ItemBaseType],ItemModuleType)] )]
|
moduleCombinations :: [( ModuleSlot, [Item], [([ItemBaseType],ItemModuleType)] )]
|
||||||
moduleCombinations =
|
moduleCombinations =
|
||||||
[ ( ModRifleMag
|
[ ( ModRifleMag
|
||||||
@@ -147,9 +150,14 @@ moduleCombinations =
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
, ( ModBullet
|
, ( ModBullet
|
||||||
|
, bulletWeapons
|
||||||
|
, [amod [cr BOUNCEMODULE] BOUNCEBUL
|
||||||
|
,amod [cr PENMODULE] PENBUL
|
||||||
|
]
|
||||||
|
)
|
||||||
|
, ( ModBulletSpawn
|
||||||
, bulletWeapons
|
, bulletWeapons
|
||||||
, [amod [cr INCENDIARYMODULE] INCENDBUL
|
, [amod [cr INCENDIARYMODULE] INCENDBUL
|
||||||
,amod [cr BOUNCEMODULE] BOUNCEBUL
|
|
||||||
,amod [cr STATICMODULE] STATICBUL
|
,amod [cr STATICMODULE] STATICBUL
|
||||||
,amod [cr CONCUSSMODULE] CONCUSBUL
|
,amod [cr CONCUSSMODULE] CONCUSBUL
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ data CraftType
|
|||||||
| FRAGMODULE
|
| FRAGMODULE
|
||||||
| FLASHMODULE
|
| FLASHMODULE
|
||||||
| BOUNCEMODULE
|
| BOUNCEMODULE
|
||||||
|
| PENMODULE
|
||||||
--
|
--
|
||||||
| TELEPORTMODULE
|
| TELEPORTMODULE
|
||||||
| TIMEMODULE
|
| TIMEMODULE
|
||||||
@@ -184,6 +185,7 @@ data ItemModuleType
|
|||||||
| MAGNETMAG
|
| MAGNETMAG
|
||||||
| INCENDBUL
|
| INCENDBUL
|
||||||
| BOUNCEBUL
|
| BOUNCEBUL
|
||||||
|
| PENBUL
|
||||||
| STATICBUL
|
| STATICBUL
|
||||||
| CONCUSBUL
|
| CONCUSBUL
|
||||||
| TARGCR
|
| TARGCR
|
||||||
@@ -209,6 +211,7 @@ data Detector
|
|||||||
|
|
||||||
data ModuleSlot
|
data ModuleSlot
|
||||||
= ModBullet
|
= ModBullet
|
||||||
|
| ModBulletSpawn
|
||||||
| ModRifleMag
|
| ModRifleMag
|
||||||
| ModAutoMag
|
| ModAutoMag
|
||||||
| ModTarget
|
| ModTarget
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ moduleModification imt = case imt of
|
|||||||
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
|
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
|
||||||
INCENDBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall IncBall
|
INCENDBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall IncBall
|
||||||
BOUNCEBUL -> itConsumption . laAmmoType . amBullet . buEffect .~ BounceBullet
|
BOUNCEBUL -> itConsumption . laAmmoType . amBullet . buEffect .~ BounceBullet
|
||||||
|
PENBUL -> itConsumption . laAmmoType . amBullet . buEffect .~ PenetrateBullet
|
||||||
STATICBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall
|
STATICBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall
|
||||||
CONCUSBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall
|
CONCUSBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall
|
||||||
TARGCR -> itTargeting .~ targetRBCreature
|
TARGCR -> itTargeting .~ targetRBCreature
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ inventoryX c = case c of
|
|||||||
, makeTypeCraftNum 1 SOUNDSENSOR
|
, makeTypeCraftNum 1 SOUNDSENSOR
|
||||||
, makeTypeCraftNum 1 HEATSENSOR
|
, makeTypeCraftNum 1 HEATSENSOR
|
||||||
, makeTypeCraftNum 1 BOUNCEMODULE
|
, makeTypeCraftNum 1 BOUNCEMODULE
|
||||||
|
, makeTypeCraftNum 1 PENMODULE
|
||||||
, makeTypeCraftNum 1 INCENDIARYMODULE
|
, makeTypeCraftNum 1 INCENDIARYMODULE
|
||||||
, makeTypeCraftNum 1 CONCUSSMODULE
|
, makeTypeCraftNum 1 CONCUSSMODULE
|
||||||
, makeTypeCraftNum 1 STATICMODULE
|
, makeTypeCraftNum 1 STATICMODULE
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ data Bullet = Bullet
|
|||||||
}
|
}
|
||||||
data EnergyBallType = IncBall | TeslaBall | ConcBall
|
data EnergyBallType = IncBall | TeslaBall | ConcBall
|
||||||
data BulletState = NormalBulletState
|
data BulletState = NormalBulletState
|
||||||
| DyingBulletState
|
|
||||||
| DelayedBullet Float
|
| DelayedBullet Float
|
||||||
data BulletUpdateMod = NoBulletUpdateMod
|
data BulletUpdateMod = NoBulletUpdateMod
|
||||||
data BulletEffect
|
data BulletEffect
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ data Wall = Wall
|
|||||||
, _wlSeen :: Bool
|
, _wlSeen :: Bool
|
||||||
, _wlOpacity :: Opacity
|
, _wlOpacity :: Opacity
|
||||||
, _wlPathable :: Bool
|
, _wlPathable :: Bool
|
||||||
|
, _wlPenetrable :: Bool
|
||||||
, _wlWalkable :: Bool
|
, _wlWalkable :: Bool
|
||||||
, _wlTouchThrough :: Bool
|
, _wlTouchThrough :: Bool
|
||||||
, _wlFireThrough :: Bool
|
, _wlFireThrough :: Bool
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ defaultWall = Wall
|
|||||||
, _wlSeen = False
|
, _wlSeen = False
|
||||||
, _wlOpacity = Opaque
|
, _wlOpacity = Opaque
|
||||||
, _wlPathable = False
|
, _wlPathable = False
|
||||||
|
, _wlPenetrable = False
|
||||||
, _wlFireThrough = False
|
, _wlFireThrough = False
|
||||||
, _wlTouchThrough = False
|
, _wlTouchThrough = False
|
||||||
, _wlReflect = False
|
, _wlReflect = False
|
||||||
@@ -41,6 +42,7 @@ defaultMachineWall = defaultWall
|
|||||||
, _wlRotateTo = False
|
, _wlRotateTo = False
|
||||||
, _wlStructure = MachinePart 0
|
, _wlStructure = MachinePart 0
|
||||||
, _wlMaterial = Metal
|
, _wlMaterial = Metal
|
||||||
|
, _wlPenetrable = True
|
||||||
}
|
}
|
||||||
defaultDirtWall :: Wall
|
defaultDirtWall :: Wall
|
||||||
defaultDirtWall = defaultWall
|
defaultDirtWall = defaultWall
|
||||||
@@ -51,6 +53,7 @@ defaultDirtWall = defaultWall
|
|||||||
, _wlOpacity = Opaque
|
, _wlOpacity = Opaque
|
||||||
, _wlRotateTo = False
|
, _wlRotateTo = False
|
||||||
, _wlFireThrough = True
|
, _wlFireThrough = True
|
||||||
|
, _wlPenetrable = True
|
||||||
, _wlMaterial = Dirt
|
, _wlMaterial = Dirt
|
||||||
}
|
}
|
||||||
defaultWindow :: Wall
|
defaultWindow :: Wall
|
||||||
@@ -62,4 +65,5 @@ defaultWindow = defaultWall
|
|||||||
, _wlOpacity = SeeThrough
|
, _wlOpacity = SeeThrough
|
||||||
, _wlFireThrough = True
|
, _wlFireThrough = True
|
||||||
, _wlMaterial = Glass
|
, _wlMaterial = Glass
|
||||||
|
, _wlPenetrable = True
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,9 +100,7 @@ defaultWeapon = defaultItem
|
|||||||
& itUse .~ defaultrUse
|
& itUse .~ defaultrUse
|
||||||
& itInvColor .~ white
|
& itInvColor .~ white
|
||||||
& itType . iyModules .~ M.fromList
|
& itType . iyModules .~ M.fromList
|
||||||
[(ModBullet, EMPTYMODULE)
|
[(ModTarget, EMPTYMODULE)
|
||||||
,(ModTarget, EMPTYMODULE)
|
|
||||||
,(ModBulletTrajectory, EMPTYMODULE)
|
|
||||||
,(ModTeleport, EMPTYMODULE)
|
,(ModTeleport, EMPTYMODULE)
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -110,6 +108,9 @@ defaultBulletWeapon :: Item
|
|||||||
defaultBulletWeapon = defaultWeapon
|
defaultBulletWeapon = defaultWeapon
|
||||||
& itConsumption .~ defaultBulletLoadable
|
& itConsumption .~ defaultBulletLoadable
|
||||||
& itUse . rUse .~ useAmmoParams
|
& itUse . rUse .~ useAmmoParams
|
||||||
|
& itType . iyModules . at ModBullet ?~ EMPTYMODULE
|
||||||
|
& itType . iyModules . at ModBulletSpawn ?~ EMPTYMODULE
|
||||||
|
& itType . iyModules . at ModBulletTrajectory ?~ EMPTYMODULE
|
||||||
|
|
||||||
defaultItemValue :: ItemValue
|
defaultItemValue :: ItemValue
|
||||||
defaultItemValue = ItemValue 10 MundaneItem
|
defaultItemValue = ItemValue 10 MundaneItem
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ moduleName imt = case imt of
|
|||||||
MAGNETMAG -> Just "+MAGNET FEED"
|
MAGNETMAG -> Just "+MAGNET FEED"
|
||||||
INCENDBUL -> Just "+INCENDIARY"
|
INCENDBUL -> Just "+INCENDIARY"
|
||||||
BOUNCEBUL -> Just "+BOUNCE"
|
BOUNCEBUL -> Just "+BOUNCE"
|
||||||
|
PENBUL -> Just "+PENETRATE"
|
||||||
STATICBUL -> Just "+STATIC"
|
STATICBUL -> Just "+STATIC"
|
||||||
CONCUSBUL -> Just "+CONCUSS"
|
CONCUSBUL -> Just "+CONCUSS"
|
||||||
TARGCR -> Just "+CREATURETARGETING"
|
TARGCR -> Just "+CREATURETARGETING"
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ baseBlockPane = defaultWall
|
|||||||
, _wlOpacity = Opaque
|
, _wlOpacity = Opaque
|
||||||
, _wlUnshadowed = True
|
, _wlUnshadowed = True
|
||||||
, _wlFireThrough = True
|
, _wlFireThrough = True
|
||||||
|
, _wlPenetrable = True
|
||||||
}
|
}
|
||||||
-- TODO find home for this
|
-- TODO find home for this
|
||||||
{- Replaces instances of a given 'PutID' with 'PSType's drawn from a list. -}
|
{- Replaces instances of a given 'PutID' with 'PSType's drawn from a list. -}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ posEventEffect pv = case _pvType pv of
|
|||||||
SparkSpawner -> spawnElectricalSparks (_pvPos pv)
|
SparkSpawner -> spawnElectricalSparks (_pvPos pv)
|
||||||
|
|
||||||
spawnElectricalSparks :: Point2 -> World -> World
|
spawnElectricalSparks :: Point2 -> World -> World
|
||||||
spawnElectricalSparks p = randSpark ELECTRICAL rspeed rcol rdir p
|
spawnElectricalSparks = randSpark ELECTRICAL rspeed rcol rdir
|
||||||
where
|
where
|
||||||
rspeed = state (randomR (3,6))
|
rspeed = state (randomR (3,6))
|
||||||
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
|
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
|
||||||
|
|||||||
Reference in New Issue
Block a user