Add simple flamethrower upgrade path

This commit is contained in:
2022-03-03 15:11:20 +00:00
parent 08389ad4e0
commit fd622b4b80
6 changed files with 136 additions and 74 deletions
+3 -2
View File
@@ -62,8 +62,9 @@ itemCombinations =
, po [LIGHTER,PIPE,CAN] flameStick , po [LIGHTER,PIPE,CAN] flameStick
, po [FLAMESTICK,CAN,PUMP] blowTorch , po [FLAMESTICK,CAN,PUMP] blowTorch
, po [FLAMESTICK,IRONBAR,DRUM] flameThrower , po [FLAMESTICK,DRUM] flameThrower
, po [FLAMESTICK,DRUM,DRUM] flameWall , po [FLAMETHROWER,DRUM] flameWall
, po [FLAMETHROWER,PUMP] flameTorrent
, p [o PRISM,p 2 PIPE,o HARDWARE] lasGun , p [o PRISM,p 2 PIPE,o HARDWARE] lasGun
+4 -3
View File
@@ -39,9 +39,10 @@ data CombineType
| SNIPERRIFLE | SNIPERRIFLE
| MACHINEGUN | MACHINEGUN
| FLAMESTICK | FLAMESTICK
| FLAMER
| BLOWTORCH
| FLAMETHROWER | FLAMETHROWER
| FLAMETORRENT
| FLAMEWALL
| BLOWTORCH
| AUTOGUN | AUTOGUN
| SPREADGUN | SPREADGUN
| MULTGUN | MULTGUN
@@ -54,7 +55,7 @@ data CombineType
| LAUNCHERX Int | LAUNCHERX Int
-- | TRACKINGLAUNCHER -- | TRACKINGLAUNCHER
| REMOTELAUNCHER | REMOTELAUNCHER
| SPRAYER | POISONSPRAYER
| DRONELAUNCHER | DRONELAUNCHER
| GRENADE | GRENADE
| REMOTEBOMB | REMOTEBOMB
+5 -3
View File
@@ -173,8 +173,10 @@ testInventory = IM.fromList $ zip [0..]
, makeTypeCraftNum 1 LIGHTER , makeTypeCraftNum 1 LIGHTER
, makeTypeCraftNum 5 TUBE , makeTypeCraftNum 5 TUBE
-- , makeTypeCraftNum 5 CREATURESENSOR -- , makeTypeCraftNum 5 CREATURESENSOR
, makeTypeCraftNum 3 PRISM -- , makeTypeCraftNum 3 PRISM
, makeTypeCraftNum 1 MAGNET , makeTypeCraftNum 3 DRUM
, makeTypeCraftNum 3 PUMP
-- , makeTypeCraftNum 1 MAGNET
, makeTypeCraftNum 5 HARDWARE , makeTypeCraftNum 5 HARDWARE
, makeTypeCraftNum 3 SPRING , makeTypeCraftNum 3 SPRING
, makeTypeCraftNum 10 CAN , makeTypeCraftNum 10 CAN
@@ -207,7 +209,7 @@ stackedInventory = IM.fromList $ zip [0..]
-- ,grenade -- ,grenade
,spawnGun (lamp 5) ,spawnGun (lamp 5)
,lasGun ,lasGun
,flamer ,flameThrower
,poisonSprayer ,poisonSprayer
,launcher ,launcher
,lasDrones ,lasDrones
+6 -2
View File
@@ -535,6 +535,10 @@ data AmmoType
} }
| DroneAmmo | DroneAmmo
{ _amString :: String } { _amString :: String }
| GasAmmo
{ _amString :: String
, _amCreateGas :: Float -> Point2 -> Float -> Creature -> World -> World
}
| GenericAmmo | GenericAmmo
data ItemTweaks data ItemTweaks
= NoTweaks = NoTweaks
@@ -550,7 +554,7 @@ data TweakParam = TweakParam
, _nameTweak :: String , _nameTweak :: String
} }
data Nozzle = Nozzle data Nozzle = Nozzle
{ _nzPressure :: Int { _nzPressure :: Float
, _nzDir :: Float , _nzDir :: Float
, _nzMaxWalkAngle :: Float , _nzMaxWalkAngle :: Float
, _nzCurrentWalkAngle :: Float , _nzCurrentWalkAngle :: Float
@@ -588,7 +592,7 @@ data ItemParams
, _nozzleNum :: Int , _nozzleNum :: Int
} }
| Sprayer' | Sprayer'
{ _sprayerNozzles :: [Nozzle] { _sprayNozzles :: [Nozzle]
} }
| AngleWalk | AngleWalk
{ _maxWalkAngle :: Float { _maxWalkAngle :: Float
+117 -62
View File
@@ -1,9 +1,9 @@
module Dodge.Item.Weapon.SprayGuns module Dodge.Item.Weapon.SprayGuns
( poisonSprayer ( poisonSprayer
, flamer
, flameStick , flameStick
, blowTorch , blowTorch
, flameThrower , flameThrower
, flameTorrent
, flameWall , flameWall
) where ) where
import Dodge.Data import Dodge.Data
@@ -36,38 +36,21 @@ import qualified Data.IntMap.Strict as IM
--import Data.Function --import Data.Function
import System.Random import System.Random
poisonSprayer :: Item poisonSprayer :: Item
poisonSprayer = defaultAutoGun poisonSprayer = flameThrower
{ _itName = "POISON" { _itName = "POISONSPRAYER"
, _itType = SPRAYER , _itType = POISONSPRAYER
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 500
, _ammoLoaded = 500
, _reloadTime = 100
} }
, _itUse = ruseInstant (const aGasCloud) NoHammer & itConsumption . aoType .~ GasAmmo
{ _amString = "POISONGAS"
, _amCreateGas = aGasCloud
}
& itUse . useMods .~
[ ammoCheckI [ ammoCheckI
, withSoundForI foamSprayLoopS 5 , withSoundForI foamSprayLoopS 5
, useAmmoAmount 1 , useAmmoAmount 1
-- , spreadNumI -- , 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 :: Item -> SPic
flamerPic it = flamerPic it =
( colorSH yellow $ ( colorSH yellow $
@@ -82,24 +65,74 @@ flamerPic it =
r = 5 r = 5
am = fractionLoadedAmmo2 it am = fractionLoadedAmmo2 it
flameStick :: Item flameStick :: Item
flameStick = flamer flameStick = flameThrower
& itUse . rUse .~ const aFlame & 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 :: Item
blowTorch = flamer blowTorch = flameThrower
flameThrower :: Item & itName .~ "BLOWTORCH"
flameThrower = flamer & itType .~ BLOWTORCH
flameWall :: Item flameWall :: Item
flameWall = flamer flameWall = flameThrower
flamer :: Item & itName .~ "FLAMEWALL"
flamer = defaultAutoGun & itType .~ FLAMEWALL
{ _itName = "FLAMER" & itParams . sprayNozzles .~
, _itType = FLAMER [ 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 , _itConsumption = defaultAmmo
{ _ammoBaseMax = 250 { _ammoBaseMax = 250
, _ammoLoaded = 250 , _ammoLoaded = 0
, _reloadTime = 100 , _reloadTime = 100
, _aoType = GasAmmo
{_amString = "FLAME"
,_amCreateGas = aFlame
} }
, _itUse = ruseInstant (\_ -> randWalkAngle aFlame) NoHammer }
, _itUse = ruseInstant (overNozzles useGasParams) NoHammer
[ ammoCheckI [ ammoCheckI
, useAmmoAmount 1 , useAmmoAmount 1
, withSidePushI 5 , withSidePushI 5
@@ -112,43 +145,65 @@ flamer = defaultAutoGun
-- , _itFloorPict = flamerPic -- , _itFloorPict = flamerPic
-- , _itZoom = defaultItZoom -- , _itZoom = defaultItZoom
, _itAttachment = NoItAttachment , _itAttachment = NoItAttachment
, _itParams = AngleWalk , _itParams = Sprayer'
{_maxWalkAngle = 0.2 { _sprayNozzles =
,_walkSpeed = 0.01 [ Nozzle
,_currentWalkAngle = 0 { _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 -> 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 where
cid = _crID cr cid = _crID cr
i = _crInvSel $ _creatures w IM.! cid 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) overNozzle :: (Nozzle -> Item -> Creature -> World -> World)
-> Creature -> World -> Nozzle -> (World, Nozzle) -> Item -> Creature -> World -> Nozzle -> (World, Nozzle)
overNozzle eff cr w nz = (eff (cr & crDir +~ wa) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa) overNozzle eff it cr w nz = (eff nz it (cr & crDir +~ wa + na) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa)
where where
na = _nzDir nz
(walkamount, g) = randomR (-aspeed,aspeed) (_randGen w) (walkamount, g) = randomR (-aspeed,aspeed) (_randGen w)
aspeed = _nzWalkSpeed nz aspeed = _nzWalkSpeed nz
maxa = _nzMaxWalkAngle nz maxa = _nzMaxWalkAngle nz
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount) wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
aFlame :: Creature -> World -> World useGasParams :: Nozzle -> Item -> Creature -> World -> World
aFlame cr w = w & particles .:~ aFlameParticle t pos vel (Just cid) 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 where
(t,_) = randomR (99,101) (_randGen w) (t,_) = randomR (99,101) (_randGen w)
cid = _crID cr cid = _crID cr
dir = _crDir cr vel = (_crPos cr -.- _crOldPos cr) +.+ pressure *.* unitVectorAtAngle dir
pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir
+1 -2
View File
@@ -91,8 +91,7 @@ moveFlame rotd w pt
, _ptPos = ep , _ptPos = ep
, _ptCrIgnore = Nothing , _ptCrIgnore = Nothing
, _ptVel = speed *.* vel } , _ptVel = speed *.* vel }
damcrs = foldr (\cr -> fst . hiteff [(ep,Left cr)]) w damcrs = foldr (\cr -> fst . hiteff [(ep,Left cr)]) w $ IM.filter closeCrs $ _creatures w
$ IM.filter closeCrs $ _creatures w
closeCrs cr = dist ep (_crPos cr) closeCrs cr = dist ep (_crPos cr)
< _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80)) < _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80))
+ 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd) + 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd)