From fd622b4b803f2ba97e59a79415bd499836e7097a Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 3 Mar 2022 15:11:20 +0000 Subject: [PATCH] Add simple flamethrower upgrade path --- src/Dodge/Combine/Combinations.hs | 5 +- src/Dodge/Combine/Data.hs | 7 +- src/Dodge/Creature.hs | 8 +- src/Dodge/Data.hs | 8 +- src/Dodge/Item/Weapon/SprayGuns.hs | 179 +++++++++++++++++--------- src/Dodge/WorldEvent/SpawnParticle.hs | 3 +- 6 files changed, 136 insertions(+), 74 deletions(-) diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index f4d84c224..50ee3a3c1 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -62,8 +62,9 @@ itemCombinations = , po [LIGHTER,PIPE,CAN] flameStick , po [FLAMESTICK,CAN,PUMP] blowTorch - , po [FLAMESTICK,IRONBAR,DRUM] flameThrower - , po [FLAMESTICK,DRUM,DRUM] flameWall + , po [FLAMESTICK,DRUM] flameThrower + , po [FLAMETHROWER,DRUM] flameWall + , po [FLAMETHROWER,PUMP] flameTorrent , p [o PRISM,p 2 PIPE,o HARDWARE] lasGun diff --git a/src/Dodge/Combine/Data.hs b/src/Dodge/Combine/Data.hs index f3e327c86..cacdf5e99 100644 --- a/src/Dodge/Combine/Data.hs +++ b/src/Dodge/Combine/Data.hs @@ -39,9 +39,10 @@ data CombineType | SNIPERRIFLE | MACHINEGUN | FLAMESTICK - | FLAMER - | BLOWTORCH | FLAMETHROWER + | FLAMETORRENT + | FLAMEWALL + | BLOWTORCH | AUTOGUN | SPREADGUN | MULTGUN @@ -54,7 +55,7 @@ data CombineType | LAUNCHERX Int -- | TRACKINGLAUNCHER | REMOTELAUNCHER - | SPRAYER + | POISONSPRAYER | DRONELAUNCHER | GRENADE | REMOTEBOMB diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 0be1b49ed..36d0a6ec8 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -173,8 +173,10 @@ testInventory = IM.fromList $ zip [0..] , makeTypeCraftNum 1 LIGHTER , makeTypeCraftNum 5 TUBE -- , makeTypeCraftNum 5 CREATURESENSOR - , makeTypeCraftNum 3 PRISM - , makeTypeCraftNum 1 MAGNET +-- , makeTypeCraftNum 3 PRISM + , makeTypeCraftNum 3 DRUM + , makeTypeCraftNum 3 PUMP +-- , makeTypeCraftNum 1 MAGNET , makeTypeCraftNum 5 HARDWARE , makeTypeCraftNum 3 SPRING , makeTypeCraftNum 10 CAN @@ -207,7 +209,7 @@ stackedInventory = IM.fromList $ zip [0..] -- ,grenade ,spawnGun (lamp 5) ,lasGun - ,flamer + ,flameThrower ,poisonSprayer ,launcher ,lasDrones diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 64bd29766..2d7c108ed 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -535,6 +535,10 @@ data AmmoType } | DroneAmmo { _amString :: String } + | GasAmmo + { _amString :: String + , _amCreateGas :: Float -> Point2 -> Float -> Creature -> World -> World + } | GenericAmmo data ItemTweaks = NoTweaks @@ -550,7 +554,7 @@ data TweakParam = TweakParam , _nameTweak :: String } data Nozzle = Nozzle - { _nzPressure :: Int + { _nzPressure :: Float , _nzDir :: Float , _nzMaxWalkAngle :: Float , _nzCurrentWalkAngle :: Float @@ -588,7 +592,7 @@ data ItemParams , _nozzleNum :: Int } | Sprayer' - { _sprayerNozzles :: [Nozzle] + { _sprayNozzles :: [Nozzle] } | AngleWalk { _maxWalkAngle :: Float diff --git a/src/Dodge/Item/Weapon/SprayGuns.hs b/src/Dodge/Item/Weapon/SprayGuns.hs index 83c312c3e..ee80cec3a 100644 --- a/src/Dodge/Item/Weapon/SprayGuns.hs +++ b/src/Dodge/Item/Weapon/SprayGuns.hs @@ -1,9 +1,9 @@ module Dodge.Item.Weapon.SprayGuns ( poisonSprayer - , flamer , flameStick , blowTorch , flameThrower + , flameTorrent , flameWall ) where import Dodge.Data @@ -36,38 +36,21 @@ import qualified Data.IntMap.Strict as IM --import Data.Function import System.Random poisonSprayer :: Item -poisonSprayer = defaultAutoGun - { _itName = "POISON" - , _itType = SPRAYER - , _itConsumption = defaultAmmo - { _ammoBaseMax = 500 - , _ammoLoaded = 500 - , _reloadTime = 100 +poisonSprayer = flameThrower + { _itName = "POISONSPRAYER" + , _itType = POISONSPRAYER + } + & itConsumption . aoType .~ GasAmmo + { _amString = "POISONGAS" + , _amCreateGas = aGasCloud } - , _itUse = ruseInstant (const aGasCloud) NoHammer + & itUse . useMods .~ [ ammoCheckI , withSoundForI foamSprayLoopS 5 , useAmmoAmount 1 -- , spreadNumI ] - & useAim . aimSpeed .~ 0.2 - & useAim . aimRange .~ 0 - & useAim . aimStance .~ TwoHandTwist - , _itParams = Sprayer - { _nozzleSpread = 0.2 - , _nozzleNum = 3 - } - , _itDimension = ItemDimension - { _dimRad = 7 - , _dimCenter = V3 9 0 0 - , _dimPortage = HeldItem - { _handlePos = 5 - , _muzPos = 18 - } - , _dimSPic = flamerPic - } --- , _itFloorPict = flamerPic - } + flamerPic :: Item -> SPic flamerPic it = ( colorSH yellow $ @@ -82,24 +65,74 @@ flamerPic it = r = 5 am = fractionLoadedAmmo2 it flameStick :: Item -flameStick = flamer - & itUse . rUse .~ const aFlame +flameStick = flameThrower + & itName .~ "FLAMESTICK" + & itType .~ FLAMESTICK + & itConsumption . ammoBaseMax .~ 10 + & itConsumption . reloadTime .~ 20 + & itParams . sprayNozzles . ix 0 . nzPressure .~ 4 + & itUse . useAim . aimStance .~ OneHand + +flameTorrent :: Item +flameTorrent = flameThrower + & itName .~ "FLAMETORRENT" + & itType .~ FLAMETORRENT + & itUse . useAim . aimZoom .~ defaultItZoom + & itParams . sprayNozzles . ix 0 %~ + ( (nzPressure .~ 10) + . (nzMaxWalkAngle .~ 1.5) + . (nzWalkSpeed .~ 0.05) + ) + blowTorch :: Item -blowTorch = flamer -flameThrower :: Item -flameThrower = flamer +blowTorch = flameThrower + & itName .~ "BLOWTORCH" + & itType .~ BLOWTORCH flameWall :: Item -flameWall = flamer -flamer :: Item -flamer = defaultAutoGun - { _itName = "FLAMER" - , _itType = FLAMER +flameWall = flameThrower + & itName .~ "FLAMEWALL" + & itType .~ FLAMEWALL + & itParams . sprayNozzles .~ + [ Nozzle + { _nzPressure = 2.5 + , _nzDir = 0 + , _nzMaxWalkAngle = 0.2 + , _nzWalkSpeed = 0.01 + , _nzCurrentWalkAngle = 0 + , _nzLength = 20 + } + , Nozzle + { _nzPressure = 3 + , _nzDir = 0.5 + , _nzMaxWalkAngle = 0.2 + , _nzWalkSpeed = 0.01 + , _nzCurrentWalkAngle = 0 + , _nzLength = 20 + } + , Nozzle + { _nzPressure = 3 + , _nzDir = -0.5 + , _nzMaxWalkAngle = 0.2 + , _nzWalkSpeed = 0.01 + , _nzCurrentWalkAngle = 0 + , _nzLength = 20 + } + ] + +flameThrower :: Item +flameThrower = defaultAutoGun + { _itName = "FLAMETHROWER" + , _itType = FLAMETHROWER , _itConsumption = defaultAmmo { _ammoBaseMax = 250 - , _ammoLoaded = 250 + , _ammoLoaded = 0 , _reloadTime = 100 + , _aoType = GasAmmo + {_amString = "FLAME" + ,_amCreateGas = aFlame + } } - , _itUse = ruseInstant (\_ -> randWalkAngle aFlame) NoHammer + , _itUse = ruseInstant (overNozzles useGasParams) NoHammer [ ammoCheckI , useAmmoAmount 1 , withSidePushI 5 @@ -112,43 +145,65 @@ flamer = defaultAutoGun -- , _itFloorPict = flamerPic -- , _itZoom = defaultItZoom , _itAttachment = NoItAttachment - , _itParams = AngleWalk - {_maxWalkAngle = 0.2 - ,_walkSpeed = 0.01 - ,_currentWalkAngle = 0 + , _itParams = Sprayer' + { _sprayNozzles = + [ Nozzle + { _nzPressure = 4 + , _nzDir = 0 + , _nzMaxWalkAngle = 0.2 + , _nzWalkSpeed = 0.01 + , _nzCurrentWalkAngle = 0 + , _nzLength = 10 + } + ] } + , _itDimension = ItemDimension + { _dimRad = 7 + , _dimCenter = V3 9 0 0 + , _dimPortage = HeldItem + { _handlePos = 5 + , _muzPos = 18 + } + , _dimSPic = flamerPic + } +-- , _itFloorPict = flamerPic } -aGasCloud :: Creature -> World -> World -aGasCloud cr w = insertCloud $ set randGen g w - where - (a,g) = randomR (-0.1,0.1) (_randGen w) - dir = _crDir cr + a - pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr)) - vel = (_crPos cr -.- _crOldPos cr) +.+ 10 *.* unitVectorAtAngle dir - insertCloud = makeGasCloud pos vel -overNozzles :: (Creature -> World -> Nozzle -> (World,Nozzle)) +aGasCloud :: Float -> Point2 -> Float -> Creature -> World -> World +aGasCloud pressure pos dir cr = makeGasCloud pos + $ (_crPos cr -.- _crOldPos cr) +.+ pressure *.* unitVectorAtAngle dir + +overNozzles :: (Nozzle -> Item -> Creature -> World -> World) -> Item -> Creature -> World -> World -overNozzles eff it cr w = neww & creatures . ix cid . crInv . ix i . itParams . sprayerNozzles .~ newNozzles +overNozzles = overNozzles' . overNozzle + +overNozzles' :: (Item -> Creature -> World -> Nozzle -> (World,Nozzle)) + -> Item -> Creature -> World -> World +overNozzles' eff it cr w = neww & creatures . ix cid . crInv . ix i . itParams . sprayNozzles .~ newNozzles where cid = _crID cr i = _crInvSel $ _creatures w IM.! cid - (neww,newNozzles) = mapAccumR (eff cr) w $ _sprayerNozzles (_itParams it) + (neww,newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it) -overNozzle :: (Creature -> World -> World) - -> Creature -> World -> Nozzle -> (World, Nozzle) -overNozzle eff cr w nz = (eff (cr & crDir +~ wa) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa) +overNozzle :: (Nozzle -> Item -> Creature -> World -> World) + -> Item -> Creature -> World -> Nozzle -> (World, Nozzle) +overNozzle eff it cr w nz = (eff nz it (cr & crDir +~ wa + na) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa) where + na = _nzDir nz (walkamount, g) = randomR (-aspeed,aspeed) (_randGen w) aspeed = _nzWalkSpeed nz maxa = _nzMaxWalkAngle nz wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount) -aFlame :: Creature -> World -> World -aFlame cr w = w & particles .:~ aFlameParticle t pos vel (Just cid) +useGasParams :: Nozzle -> Item -> Creature -> World -> World +useGasParams nz it cr = _amCreateGas (_aoType (_itConsumption it)) (_nzPressure nz) pos dir cr + where + dir = _crDir cr + pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr)) + +aFlame :: Float -> Point2 -> Float -> Creature -> World -> World +aFlame pressure pos dir cr w = w & particles .:~ aFlameParticle t pos vel (Just cid) where (t,_) = randomR (99,101) (_randGen w) cid = _crID cr - dir = _crDir cr - pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr)) - vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir + vel = (_crPos cr -.- _crOldPos cr) +.+ pressure *.* unitVectorAtAngle dir diff --git a/src/Dodge/WorldEvent/SpawnParticle.hs b/src/Dodge/WorldEvent/SpawnParticle.hs index 7c9ce3bc3..f41e6c817 100644 --- a/src/Dodge/WorldEvent/SpawnParticle.hs +++ b/src/Dodge/WorldEvent/SpawnParticle.hs @@ -91,8 +91,7 @@ moveFlame rotd w pt , _ptPos = ep , _ptCrIgnore = Nothing , _ptVel = speed *.* vel } - damcrs = foldr (\cr -> fst . hiteff [(ep,Left cr)]) w - $ IM.filter closeCrs $ _creatures w + damcrs = foldr (\cr -> fst . hiteff [(ep,Left cr)]) w $ IM.filter closeCrs $ _creatures w closeCrs cr = dist ep (_crPos cr) < _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80)) + 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd)