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 w bu = case _buState bu of
|
||||
DyingBulletState -> (w,Nothing)
|
||||
DelayedBullet x -> mvBullet x 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 x w bt'
|
||||
| t <= 0 || magV (_buVel bt) < 1 = (endspawn w,Nothing)
|
||||
| otherwise = bimap (maybespawn . maybebounce) (fmap dodrag) $
|
||||
| otherwise = bimap maybebounce (fmap dodrag) $
|
||||
hiteff bt hitstream w
|
||||
where
|
||||
endspawn w' = fromMaybe w' $ do
|
||||
partspawn <- bulletSpawn bt'
|
||||
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
|
||||
guard (_buEffect bt' == BounceBullet)
|
||||
(hp,crwl) <- runIdentity (S.head_ hitstream)
|
||||
@@ -101,15 +96,6 @@ bulletSpawn bu = case _buSpawn bu of
|
||||
BulBall IncBall -> Just incBallAt
|
||||
BulBall ConcBall -> Just $ randParticleAt concBall
|
||||
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
|
||||
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||
@@ -138,10 +124,11 @@ moveBullet x pt = Just $ pt
|
||||
|
||||
destroyAt' :: Point2 -> Bullet -> Maybe Bullet
|
||||
destroyAt' hitp pt = Just $ pt
|
||||
& buState .~ DyingBulletState
|
||||
& buPos .~ hitp
|
||||
& buOldPos .~ _buPos pt
|
||||
& buTimer %~ (min 3 . subtract 1)
|
||||
& buPos .~ hitp +.+ normalizeV (p -.- hitp)
|
||||
& buOldPos .~ p
|
||||
& buVel .~ 0
|
||||
where
|
||||
p = _buPos pt
|
||||
|
||||
--penWalls
|
||||
-- :: HitCreatureEffect'
|
||||
|
||||
@@ -118,6 +118,9 @@ itemCombinations =
|
||||
hd = HELD
|
||||
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 =
|
||||
[ ( ModRifleMag
|
||||
@@ -147,9 +150,14 @@ moduleCombinations =
|
||||
]
|
||||
)
|
||||
, ( ModBullet
|
||||
, bulletWeapons
|
||||
, [amod [cr BOUNCEMODULE] BOUNCEBUL
|
||||
,amod [cr PENMODULE] PENBUL
|
||||
]
|
||||
)
|
||||
, ( ModBulletSpawn
|
||||
, bulletWeapons
|
||||
, [amod [cr INCENDIARYMODULE] INCENDBUL
|
||||
,amod [cr BOUNCEMODULE] BOUNCEBUL
|
||||
,amod [cr STATICMODULE] STATICBUL
|
||||
,amod [cr CONCUSSMODULE] CONCUSBUL
|
||||
]
|
||||
|
||||
@@ -61,6 +61,7 @@ data CraftType
|
||||
| FRAGMODULE
|
||||
| FLASHMODULE
|
||||
| BOUNCEMODULE
|
||||
| PENMODULE
|
||||
--
|
||||
| TELEPORTMODULE
|
||||
| TIMEMODULE
|
||||
@@ -184,6 +185,7 @@ data ItemModuleType
|
||||
| MAGNETMAG
|
||||
| INCENDBUL
|
||||
| BOUNCEBUL
|
||||
| PENBUL
|
||||
| STATICBUL
|
||||
| CONCUSBUL
|
||||
| TARGCR
|
||||
@@ -209,6 +211,7 @@ data Detector
|
||||
|
||||
data ModuleSlot
|
||||
= ModBullet
|
||||
| ModBulletSpawn
|
||||
| ModRifleMag
|
||||
| ModAutoMag
|
||||
| ModTarget
|
||||
|
||||
@@ -19,6 +19,7 @@ moduleModification imt = case imt of
|
||||
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
|
||||
INCENDBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall IncBall
|
||||
BOUNCEBUL -> itConsumption . laAmmoType . amBullet . buEffect .~ BounceBullet
|
||||
PENBUL -> itConsumption . laAmmoType . amBullet . buEffect .~ PenetrateBullet
|
||||
STATICBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall
|
||||
CONCUSBUL -> itConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall
|
||||
TARGCR -> itTargeting .~ targetRBCreature
|
||||
|
||||
@@ -239,6 +239,7 @@ inventoryX c = case c of
|
||||
, makeTypeCraftNum 1 SOUNDSENSOR
|
||||
, makeTypeCraftNum 1 HEATSENSOR
|
||||
, makeTypeCraftNum 1 BOUNCEMODULE
|
||||
, makeTypeCraftNum 1 PENMODULE
|
||||
, makeTypeCraftNum 1 INCENDIARYMODULE
|
||||
, makeTypeCraftNum 1 CONCUSSMODULE
|
||||
, makeTypeCraftNum 1 STATICMODULE
|
||||
|
||||
@@ -20,7 +20,6 @@ data Bullet = Bullet
|
||||
}
|
||||
data EnergyBallType = IncBall | TeslaBall | ConcBall
|
||||
data BulletState = NormalBulletState
|
||||
| DyingBulletState
|
||||
| DelayedBullet Float
|
||||
data BulletUpdateMod = NoBulletUpdateMod
|
||||
data BulletEffect
|
||||
|
||||
@@ -15,6 +15,7 @@ data Wall = Wall
|
||||
, _wlSeen :: Bool
|
||||
, _wlOpacity :: Opacity
|
||||
, _wlPathable :: Bool
|
||||
, _wlPenetrable :: Bool
|
||||
, _wlWalkable :: Bool
|
||||
, _wlTouchThrough :: Bool
|
||||
, _wlFireThrough :: Bool
|
||||
|
||||
@@ -13,6 +13,7 @@ defaultWall = Wall
|
||||
, _wlSeen = False
|
||||
, _wlOpacity = Opaque
|
||||
, _wlPathable = False
|
||||
, _wlPenetrable = False
|
||||
, _wlFireThrough = False
|
||||
, _wlTouchThrough = False
|
||||
, _wlReflect = False
|
||||
@@ -41,6 +42,7 @@ defaultMachineWall = defaultWall
|
||||
, _wlRotateTo = False
|
||||
, _wlStructure = MachinePart 0
|
||||
, _wlMaterial = Metal
|
||||
, _wlPenetrable = True
|
||||
}
|
||||
defaultDirtWall :: Wall
|
||||
defaultDirtWall = defaultWall
|
||||
@@ -51,6 +53,7 @@ defaultDirtWall = defaultWall
|
||||
, _wlOpacity = Opaque
|
||||
, _wlRotateTo = False
|
||||
, _wlFireThrough = True
|
||||
, _wlPenetrable = True
|
||||
, _wlMaterial = Dirt
|
||||
}
|
||||
defaultWindow :: Wall
|
||||
@@ -62,4 +65,5 @@ defaultWindow = defaultWall
|
||||
, _wlOpacity = SeeThrough
|
||||
, _wlFireThrough = True
|
||||
, _wlMaterial = Glass
|
||||
, _wlPenetrable = True
|
||||
}
|
||||
|
||||
@@ -100,9 +100,7 @@ defaultWeapon = defaultItem
|
||||
& itUse .~ defaultrUse
|
||||
& itInvColor .~ white
|
||||
& itType . iyModules .~ M.fromList
|
||||
[(ModBullet, EMPTYMODULE)
|
||||
,(ModTarget, EMPTYMODULE)
|
||||
,(ModBulletTrajectory, EMPTYMODULE)
|
||||
[(ModTarget, EMPTYMODULE)
|
||||
,(ModTeleport, EMPTYMODULE)
|
||||
]
|
||||
|
||||
@@ -110,6 +108,9 @@ defaultBulletWeapon :: Item
|
||||
defaultBulletWeapon = defaultWeapon
|
||||
& itConsumption .~ defaultBulletLoadable
|
||||
& itUse . rUse .~ useAmmoParams
|
||||
& itType . iyModules . at ModBullet ?~ EMPTYMODULE
|
||||
& itType . iyModules . at ModBulletSpawn ?~ EMPTYMODULE
|
||||
& itType . iyModules . at ModBulletTrajectory ?~ EMPTYMODULE
|
||||
|
||||
defaultItemValue :: ItemValue
|
||||
defaultItemValue = ItemValue 10 MundaneItem
|
||||
|
||||
@@ -31,6 +31,7 @@ moduleName imt = case imt of
|
||||
MAGNETMAG -> Just "+MAGNET FEED"
|
||||
INCENDBUL -> Just "+INCENDIARY"
|
||||
BOUNCEBUL -> Just "+BOUNCE"
|
||||
PENBUL -> Just "+PENETRATE"
|
||||
STATICBUL -> Just "+STATIC"
|
||||
CONCUSBUL -> Just "+CONCUSS"
|
||||
TARGCR -> Just "+CREATURETARGETING"
|
||||
|
||||
@@ -87,6 +87,7 @@ baseBlockPane = defaultWall
|
||||
, _wlOpacity = Opaque
|
||||
, _wlUnshadowed = True
|
||||
, _wlFireThrough = True
|
||||
, _wlPenetrable = True
|
||||
}
|
||||
-- TODO find home for this
|
||||
{- 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)
|
||||
|
||||
spawnElectricalSparks :: Point2 -> World -> World
|
||||
spawnElectricalSparks p = randSpark ELECTRICAL rspeed rcol rdir p
|
||||
spawnElectricalSparks = randSpark ELECTRICAL rspeed rcol rdir
|
||||
where
|
||||
rspeed = state (randomR (3,6))
|
||||
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
|
||||
|
||||
Reference in New Issue
Block a user