Implement simple flak and frag bullets

This commit is contained in:
2023-01-12 15:48:32 +00:00
parent 3508d9c266
commit d08b6c5727
14 changed files with 133 additions and 42 deletions
+40 -1
View File
@@ -3,6 +3,8 @@ module Dodge.Bullet (
useAmmoParams,
) where
import Dodge.Item.Weapon.Bullet
import System.Random
import Data.Foldable
import Data.Maybe
import Dodge.Base.Coordinate
@@ -27,7 +29,9 @@ updateBullet w bu = case _buDelayFraction bu of
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
mvBullet x w bu
| _buTimer bu <= 0 || magV (_buVel bu) < 1 = (endspawn w, Nothing)
-- | magV (_buVel bu) < 1 = (w, Nothing)
-- | _buTimer bu <= 0 = (endspawn w, Nothing)
| magV (_buVel bu) < 1 || _buTimer bu <= 0 = (endspawn w, Nothing)
| otherwise =
second (fmap updateBulVel)
. hitEffFromBul x w
@@ -88,9 +92,44 @@ bounceDir _ = Nothing
bulletSpawn :: Bullet -> Maybe (Point2 -> World -> World)
bulletSpawn bu = case _buSpawn bu of
BulSpark -> Nothing
BulFlak -> Just (makeFlak bu)
BulFrag -> Just makeFragBullets
BulGas -> Just (flip makeGasCloud (V2 0 0))
BulBall IncBall -> Just incBallAt
BulBall ConcBall -> Just $ \p -> cWorld . lWorld . shockwaves .:~ concBall p
BulBall TeslaBall -> Just makeStaticBall
BulBall FlashBall -> Just makeFlashBall
makeFragBullets :: Point2 -> World -> World
makeFragBullets p w = w & cWorld . lWorld . instantBullets .++~ bus
where
bus = zipWith f (take 10 as) (take 10 ss)
as = randomRs (0, 2 * pi) $ _randGen w
ss = randomRs (5, 15) $ _randGen w
f a s = defaultBullet & buVel .~ s *.* (unitVectorAtAngle a)
& buDrag .~ 0.8
& buPos .~ p
& buOldPos .~ p
& buWidth .~ 1
& buDamages .~
[ Damage PIERCING 5 0 0 0 NoDamageEffect
, Damage PUSHDAM 1 0 0 0 . PushBackDamage $ 2
]
makeFlak :: Bullet -> Point2 -> World -> World
makeFlak bu _ w = w & cWorld . lWorld . instantBullets .++~ [f x | x <- xs]
where
s = min 10 (0.5 * magV (_buVel bu))
xs = take 5 $ randomRs (-s,s) $ _randGen w
f x = bu & buVel %~ g x
& buTimer .~ 97
& buSpawn .~ BulSpark
& buWidth .~ 0.5
& buDamages .~
[ Damage PIERCING 25 0 0 0 NoDamageEffect
, Damage PUSHDAM 1 0 0 0 . PushBackDamage $ 2
]
g x v = v +.+ x *.* normalizeV (vNormal v)
hitEffFromBul ::
Float ->
+9 -5
View File
@@ -94,8 +94,8 @@ itemCombinations =
, po [cr MICROCHIP, cr TRANSMITTER, cr HEATSENSOR] (autoDetector CREATUREDETECTOR)
, po [cr BATTERY, cr LED] torch
, po [hd TORCH, eq HAT] headLamp
, po [cr LIGHTER, cr THERMOMETER, cr MICROCHIP] (bulletPayloadCraft IncBall)
, po [cr TRANSFORMER, cr BATTERY, cr MICROCHIP] (bulletPayloadCraft TeslaBall)
, po [cr LIGHTER, cr THERMOMETER, cr MICROCHIP] (energyBallCraft IncBall)
, po [cr TRANSFORMER, cr BATTERY, cr MICROCHIP] (energyBallCraft TeslaBall)
]
++ map (\i -> po [HELD (LASWIDE i), cr TRANSFORMER] $ lasWide (i + 1)) [2 .. 9]
++ map (\i -> po [cr PIPE, HELD (BANGSTICK i)] $ bangStick (i + 1)) [1 .. 8]
@@ -166,7 +166,11 @@ moduleCombinations =
( ModBulletPayload
, bulletWeapons
,
[ amod [cr (BULPAYLOADMODULE x)] (BULPAY x) | x <- [minBound ..]
[ amod [cr (ENERGYBALLCRAFT x)] (BULPAY (BulBall x)) | x <- [minBound ..]
] ++
[ amod [cr GASINJECTOR] (BULPAY BulGas)
, amod [cr FRAGCRAFT] (BULPAY BulFrag)
, amod [cr FLAKCRAFT] (BULPAY BulFlak)
]
)
,
@@ -191,9 +195,9 @@ moduleCombinations =
( ModDualBeam
, [dualBeam]
,
[ amod [cr (BULPAYLOADMODULE IncBall)] INCENDLAS
[ amod [cr (ENERGYBALLCRAFT IncBall)] INCENDLAS
, amod [cr TRANSFORMER] SPLITLAS
, amod [cr (BULPAYLOADMODULE TeslaBall)] STATICLAS
, amod [cr (ENERGYBALLCRAFT TeslaBall)] STATICLAS
]
)
,
+3 -1
View File
@@ -13,7 +13,9 @@ moduleModification imt = case imt of
DRUMMAG -> itUse . heldConsumption . laMax .~ 45
BELTMAG -> itUse . heldConsumption . laMax .~ 150
MAGNETMAG -> itUse . heldDelay . rateMax .~ 4
BULPAY thepayload -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall thepayload
BULPAY BulFlak -> (itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulFlak)
. (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3)
BULPAY thepayload -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ thepayload
BULBODY thebody -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ thebody
TARGET t -> itUse . useTargeting ?~ t
BULTRAJ BasicBulletTrajectoryType -> id
+10 -10
View File
@@ -176,16 +176,16 @@ inventoryX c = case c of
, makeTypeCraftNum 5 TRANSFORMER
, makeTypeCraftNum 5 PRISM
, makeTypeCraftNum 5 LIGHTER
, makeTypeCraftNum 5 (BULPAYLOADMODULE IncBall)
, makeTypeCraftNum 5 (ENERGYBALLCRAFT IncBall)
]
'G' ->
[ autoPistol
, pistol
, makeTypeCraftNum 2 HARDWARE
, makeTypeCraftNum 2 MAGNET
, makeTypeCraftNum 5 (BULPAYLOADMODULE IncBall)
, makeTypeCraftNum 5 (BULPAYLOADMODULE TeslaBall)
, makeTypeCraftNum 5 (BULPAYLOADMODULE ConcBall)
, makeTypeCraftNum 5 (ENERGYBALLCRAFT IncBall)
, makeTypeCraftNum 5 (ENERGYBALLCRAFT TeslaBall)
, makeTypeCraftNum 5 (ENERGYBALLCRAFT ConcBall)
, makeTypeCraftNum 5 (BULBODYCRAFT BounceBullet)
, makeTypeCraftNum 5 (BULBODYCRAFT PenetrateBullet)
]
@@ -216,9 +216,9 @@ inventoryX c = case c of
, makeTypeCraftNum 1 HEATSENSOR
, makeTypeCraftNum 1 (BULBODYCRAFT BounceBullet)
, makeTypeCraftNum 1 (BULBODYCRAFT PenetrateBullet)
, makeTypeCraftNum 1 (BULPAYLOADMODULE IncBall)
, makeTypeCraftNum 1 (BULPAYLOADMODULE TeslaBall)
, makeTypeCraftNum 1 (BULPAYLOADMODULE ConcBall)
, makeTypeCraftNum 1 (ENERGYBALLCRAFT IncBall)
, makeTypeCraftNum 1 (ENERGYBALLCRAFT TeslaBall)
, makeTypeCraftNum 1 (ENERGYBALLCRAFT ConcBall)
]
'L' -> [scrollWatch]
'M' -> stackedInventory
@@ -238,9 +238,9 @@ testInventory =
, flatShield
, sniperRifle
, makeTypeCraftNum 1 MOTOR
, makeTypeCraft (BULPAYLOADMODULE IncBall)
, makeTypeCraft (BULPAYLOADMODULE TeslaBall)
, makeTypeCraft (BULPAYLOADMODULE ConcBall)
, makeTypeCraft (ENERGYBALLCRAFT IncBall)
, makeTypeCraft (ENERGYBALLCRAFT TeslaBall)
, makeTypeCraft (ENERGYBALLCRAFT ConcBall)
, teleportModule
, makeTypeCraftNum 10 HARDWARE
, makeTypeCraftNum 3 SPRING
+7 -1
View File
@@ -31,6 +31,7 @@ data Bullet = Bullet
deriving (Show, Eq, Ord, Read) --Generic, Flat)
data EnergyBallType = IncBall | TeslaBall | ConcBall
| FlashBall
deriving (Show, Eq, Ord, Enum, Bounded, Read) --Generic, Flat)
data BulletUpdateMod = NoBulletUpdateMod
@@ -43,7 +44,12 @@ data BulletEffect
| PenetrateBullet
deriving (Eq, Ord, Show, Enum, Bounded, Read) --Generic, Flat)
data BulletSpawn = BulBall {_spawnEBT :: EnergyBallType} | BulSpark
data BulletSpawn
= BulBall {_spawnEBT :: EnergyBallType}
| BulSpark
| BulFlak
| BulFrag
| BulGas
deriving (Show, Eq, Ord, Read) --Generic, Flat)
data BulletTrajectory
+5 -2
View File
@@ -69,7 +69,10 @@ data CraftType
| PORTABLEFUSION
| FRAGMODULE
| FLASHMODULE
| BULPAYLOADMODULE EnergyBallType
| GASINJECTOR
| FLAKCRAFT
| FRAGCRAFT
| ENERGYBALLCRAFT EnergyBallType
| BULBODYCRAFT BulletEffect
| TELEPORTMODULE
| TIMEMODULE
@@ -183,7 +186,7 @@ data ItemModuleType
| DRUMMAG
| BELTMAG
| MAGNETMAG
| BULPAY EnergyBallType
| BULPAY BulletSpawn
| BULBODY BulletEffect
| BULTRAJ BulletTrajectoryType
| TARGET TargetType
+21
View File
@@ -1,6 +1,7 @@
module Dodge.EnergyBall
( updateEnergyBall
, incBallAt
, makeFlashBall
, makeFlamelet
) where
@@ -70,6 +71,26 @@ incBallAt p w =
, _ebRot = rot
}
makeFlashBall :: Point2 -> World -> World
makeFlashBall p w =
w & cWorld . lWorld . energyBalls .:~ theincball
& randGen .~ g
where
(theincball, g) = runState thestate (_randGen w)
thestate = do
rot <- state $ randomR (0, 3)
return
EnergyBall
{ _ebVel = 0
, _ebColor = yellow
, _ebPos = p
, _ebWidth = 3
, _ebTimer = 20
, _ebEff = (LASERING, 1)
, _ebZ = 20
, _ebRot = rot
}
ebFlicker :: EnergyBall -> World -> World
ebFlicker pt
| _ebTimer pt `mod` 7 == 0 =
+1 -1
View File
@@ -23,7 +23,7 @@ initialAnoTree =
[ IntAnno $ AnTree . startRoom
, IntAnno $
PassthroughLockKeyLists
[(sensorRoomRunPast ELECTRICAL, takeOne [CRAFT (BULPAYLOADMODULE TeslaBall), HELD SPARKGUN])]
[(sensorRoomRunPast ELECTRICAL, takeOne [CRAFT (ENERGYBALLCRAFT TeslaBall), HELD SPARKGUN])]
itemRooms
, IntAnno $ AnTree . lasSensorTurretTest
, -- , AnRoom $ tanksRoom [] [] <&> rmPmnts .~ []
+4 -4
View File
@@ -16,14 +16,14 @@ makeTypeCraftNum i ct =
makeTypeCraft :: CraftType -> Item
makeTypeCraft = makeTypeCraftNum 1
bulletPayloadCraft :: EnergyBallType -> Item
bulletPayloadCraft ebt =
makeTypeCraft (BULPAYLOADMODULE ebt)
energyBallCraft :: EnergyBallType -> Item
energyBallCraft ebt =
makeTypeCraft (ENERGYBALLCRAFT ebt)
& itInvSize .~ 1
& itInvColor .~ chartreuse
incendiaryModule :: Item
incendiaryModule = bulletPayloadCraft IncBall
incendiaryModule = energyBallCraft IncBall
bulletBodyCraft :: BulletEffect -> Item
bulletBodyCraft ebt =
+1
View File
@@ -257,6 +257,7 @@ bulletPayloadColor ebt = case ebt of
IncBall -> orange
TeslaBall -> cyan
ConcBall -> white
FlashBall -> yellow
volleyGunSPic :: Int -> Item -> SPic
volleyGunSPic i it =
+7 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Info where
import StringHelp
import Dodge.Module.Info
import Data.Char
import Dodge.Data.Item
@@ -182,10 +183,11 @@ craftInfo fit = case fit of
BATTERY -> "A store of electical potential energy."
FUELCELL -> "A devices that converts chemical energy into electricity."
PORTABLEFUSION -> "A miniature nuclear reactor."
BULPAYLOADMODULE ebt -> "A device that converts projectiles into " ++ displayBulletPayload ebt ++ " projectiles."
GASINJECTOR -> "A device that can inject small quantities of gas into objects."
ENERGYBALLCRAFT ebt -> "A device that can create " ++ addIndefiniteArticle (displayEnergyBallType ebt) ++ " effect."
FRAGMODULE -> "A device that converts projectiles into fragmentation projectiles."
FLASHMODULE -> "A device that converts projectiles into flashbang projectiles."
BULBODYCRAFT be -> "A device that converts projectiles into " ++ displayBulletBody be ++ " projectiles."
BULBODYCRAFT be -> "A device that converts bullets into " ++ displayBulletBody be ++ " projectiles."
TELEPORTMODULE -> "A device that allows for near-instant translocation across space."
TIMEMODULE -> "A device that can affect temporality."
SIZEMODULE -> "A device that can affect physical size."
@@ -193,6 +195,9 @@ craftInfo fit = case fit of
TARGETMODULE _ -> "A targeting module."
FLAKCRAFT -> "Creates flak bullets."
FRAGCRAFT -> "Creates fragmentation bullets."
detectorInfo :: Detector -> String
detectorInfo d = case d of
+1
View File
@@ -1,6 +1,7 @@
module Dodge.Item.Weapon.Bullet (
basicBullet,
hvBullet,
defaultBullet,
) where
import Dodge.Data.Item.Use.Consumption.Ammo
+5 -5
View File
@@ -25,8 +25,8 @@ lockRoomMultiItems =
lockRoomKeyItems :: RandomGen g => [(Int -> State g (MetaTree Room String), State g ItemBaseType)]
lockRoomKeyItems =
[ (lasCenSensEdge, takeOne [HELD LAUNCHER, HELD LASGUN, HELD SPARKGUN, HELD FLATSHIELD, HELD FORCEFIELDGUN])
, (sensorRoomRunPast ELECTRICAL, takeOne [CRAFT (BULPAYLOADMODULE TeslaBall), HELD SPARKGUN])
, (sensorRoomRunPast FLAMING, takeOne [HELD FLAMESPITTER, CRAFT (BULPAYLOADMODULE IncBall)])
, (sensorRoomRunPast ELECTRICAL, takeOne [CRAFT (ENERGYBALLCRAFT TeslaBall), HELD SPARKGUN])
, (sensorRoomRunPast FLAMING, takeOne [HELD FLAMESPITTER, CRAFT (ENERGYBALLCRAFT IncBall)])
, (sensorRoomRunPast LASERING, return $ HELD LASGUN)
, (const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
, (const longRoomRunPast, takeOne [HELD SNIPERRIFLE, HELD FLATSHIELD])
@@ -107,17 +107,17 @@ itemRooms =
]
)
,
( CRAFT (BULPAYLOADMODULE IncBall)
( CRAFT (ENERGYBALLCRAFT IncBall)
, join $
takeOne
[ rc [incendiaryModule]
]
)
,
( CRAFT (BULPAYLOADMODULE TeslaBall)
( CRAFT (ENERGYBALLCRAFT TeslaBall)
, join $
takeOne
[ rc [makeTypeCraft (BULPAYLOADMODULE TeslaBall)]
[ rc [makeTypeCraft (ENERGYBALLCRAFT TeslaBall)]
]
)
]
+19 -10
View File
@@ -5,18 +5,27 @@ import Dodge.Data.Item
displayBulletBody :: BulletEffect -> String
displayBulletBody be = case be of
DestroyBullet -> "DESBUL-shouldn't display"
BounceBullet -> "BOUNCING"
PenetrateBullet -> "PENETRATING"
BounceBullet -> "bouncing"
PenetrateBullet -> "penetrating"
displayBulletPayload :: EnergyBallType -> String
displayBulletPayload ebt = case ebt of
IncBall -> "INCENDIARY"
TeslaBall -> "STATIC"
ConcBall -> "CONCUSSIVE"
displayBulletPayload :: BulletSpawn -> String
displayBulletPayload x = case x of
BulSpark -> ""
BulFrag -> "fragmentation"
BulFlak -> "flak"
BulGas -> "gaseous"
BulBall y -> displayEnergyBallType y
displayEnergyBallType :: EnergyBallType -> String
displayEnergyBallType ebt = case ebt of
IncBall -> "incendiary"
TeslaBall -> "static"
ConcBall -> "concussive"
FlashBall -> "blinding"
displayBulletTraj :: BulletTrajectoryType -> String
displayBulletTraj x = case x of
BasicBulletTrajectoryType-> "BTRAJ-shouldn't display"
BezierTrajectoryType -> "MAGNET"
FlechetteTrajectoryType -> "FLECHETTE"
MagnetTrajectoryType -> "BEZIER CURVE"
BezierTrajectoryType -> "magnet"
FlechetteTrajectoryType -> "flechette"
MagnetTrajectoryType -> "bezier curve"