From d08b6c5727e405817395bb81006c34de26fa8ffc Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 12 Jan 2023 15:48:32 +0000 Subject: [PATCH] Implement simple flak and frag bullets --- src/Dodge/Bullet.hs | 41 ++++++++++++++++++++++++++++++- src/Dodge/Combine/Combinations.hs | 14 +++++++---- src/Dodge/Combine/Module.hs | 4 ++- src/Dodge/Creature.hs | 20 +++++++-------- src/Dodge/Data/Bullet.hs | 8 +++++- src/Dodge/Data/Item/Combine.hs | 7 ++++-- src/Dodge/EnergyBall.hs | 21 ++++++++++++++++ src/Dodge/Floor.hs | 2 +- src/Dodge/Item/Craftable.hs | 8 +++--- src/Dodge/Item/Draw/SPic.hs | 1 + src/Dodge/Item/Info.hs | 9 +++++-- src/Dodge/Item/Weapon/Bullet.hs | 1 + src/Dodge/LockAndKey.hs | 10 ++++---- src/Dodge/Module/Info.hs | 29 ++++++++++++++-------- 14 files changed, 133 insertions(+), 42 deletions(-) diff --git a/src/Dodge/Bullet.hs b/src/Dodge/Bullet.hs index 89ad96178..a65694f80 100644 --- a/src/Dodge/Bullet.hs +++ b/src/Dodge/Bullet.hs @@ -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 -> diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index 623f76fe6..1493eaf94 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -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 ] ) , diff --git a/src/Dodge/Combine/Module.hs b/src/Dodge/Combine/Module.hs index f8d59da85..bd288be44 100644 --- a/src/Dodge/Combine/Module.hs +++ b/src/Dodge/Combine/Module.hs @@ -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 diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index a8d48a9ac..63d62a11d 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -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 diff --git a/src/Dodge/Data/Bullet.hs b/src/Dodge/Data/Bullet.hs index 83062f4d5..7d70f38a2 100644 --- a/src/Dodge/Data/Bullet.hs +++ b/src/Dodge/Data/Bullet.hs @@ -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 diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index dda7f14dd..8960b64da 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -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 diff --git a/src/Dodge/EnergyBall.hs b/src/Dodge/EnergyBall.hs index 8dae22dd1..626406d9d 100644 --- a/src/Dodge/EnergyBall.hs +++ b/src/Dodge/EnergyBall.hs @@ -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 = diff --git a/src/Dodge/Floor.hs b/src/Dodge/Floor.hs index cac079316..31b8eaabe 100644 --- a/src/Dodge/Floor.hs +++ b/src/Dodge/Floor.hs @@ -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 .~ [] diff --git a/src/Dodge/Item/Craftable.hs b/src/Dodge/Item/Craftable.hs index 006781a07..92b1f1bab 100644 --- a/src/Dodge/Item/Craftable.hs +++ b/src/Dodge/Item/Craftable.hs @@ -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 = diff --git a/src/Dodge/Item/Draw/SPic.hs b/src/Dodge/Item/Draw/SPic.hs index 9bc8243ff..e21f5d21a 100644 --- a/src/Dodge/Item/Draw/SPic.hs +++ b/src/Dodge/Item/Draw/SPic.hs @@ -257,6 +257,7 @@ bulletPayloadColor ebt = case ebt of IncBall -> orange TeslaBall -> cyan ConcBall -> white + FlashBall -> yellow volleyGunSPic :: Int -> Item -> SPic volleyGunSPic i it = diff --git a/src/Dodge/Item/Info.hs b/src/Dodge/Item/Info.hs index a61bf06b7..545562b35 100644 --- a/src/Dodge/Item/Info.hs +++ b/src/Dodge/Item/Info.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/Bullet.hs b/src/Dodge/Item/Weapon/Bullet.hs index bce0ce540..63db93cc9 100644 --- a/src/Dodge/Item/Weapon/Bullet.hs +++ b/src/Dodge/Item/Weapon/Bullet.hs @@ -1,6 +1,7 @@ module Dodge.Item.Weapon.Bullet ( basicBullet, hvBullet, + defaultBullet, ) where import Dodge.Data.Item.Use.Consumption.Ammo diff --git a/src/Dodge/LockAndKey.hs b/src/Dodge/LockAndKey.hs index ff62ac618..7e95b1863 100644 --- a/src/Dodge/LockAndKey.hs +++ b/src/Dodge/LockAndKey.hs @@ -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)] ] ) ] diff --git a/src/Dodge/Module/Info.hs b/src/Dodge/Module/Info.hs index 929afa433..9a67ed3db 100644 --- a/src/Dodge/Module/Info.hs +++ b/src/Dodge/Module/Info.hs @@ -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"