From eeb98eb1510fb19177006e1d93c9ed1394445aa9 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 20 Jul 2022 16:03:35 +0100 Subject: [PATCH] Start refactoring held item use --- src/Dodge/Creature.hs | 9 +-- src/Dodge/Creature/Impulse/UseItem.hs | 3 +- src/Dodge/Data.hs | 4 +- src/Dodge/Data/Item/HeldUse.hs | 21 ++++++ src/Dodge/Default/Weapon.hs | 5 +- src/Dodge/HeldUse.hs | 93 +++++++++++++++++++++++++ src/Dodge/Item/Equipment.hs | 2 +- src/Dodge/Item/Weapon/BatteryGuns.hs | 17 +++-- src/Dodge/Item/Weapon/BulletGun/Cane.hs | 2 +- src/Dodge/Item/Weapon/Drone.hs | 2 +- src/Dodge/Item/Weapon/Launcher.hs | 35 ++-------- src/Dodge/Item/Weapon/Radar.hs | 2 +- src/Dodge/Item/Weapon/Shatter.hs | 2 +- src/Dodge/Item/Weapon/SonicGuns.hs | 2 +- src/Dodge/Item/Weapon/Spawn.hs | 4 +- src/Dodge/Item/Weapon/SprayGuns.hs | 40 +---------- src/Dodge/Item/Weapon/Utility.hs | 26 +++---- src/Dodge/Projectile/Update.hs | 4 +- 18 files changed, 164 insertions(+), 109 deletions(-) create mode 100644 src/Dodge/Data/Item/HeldUse.hs create mode 100644 src/Dodge/HeldUse.hs diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 43de291db..34b3cc4a9 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -10,8 +10,6 @@ module Dodge.Creature , armourChaseCrit ) where import Dodge.Creature.State.Data -import Dodge.Prop.Gib ---import Dodge.Item.Weapon.Grenade import Dodge.Item.Equipment.Booster import Dodge.Item.Weapon.Utility --import Dodge.Item.Weapon.Drone @@ -28,7 +26,6 @@ import Dodge.Default import Dodge.Item.Weapon import Dodge.Item.Equipment import Dodge.Item.Consumable -import Dodge.WorldEvent.Cloud import Dodge.Creature.Inanimate import Dodge.Creature.Picture --import Dodge.Creature.ChooseTarget @@ -149,7 +146,7 @@ inventoryX c = case c of [ blinkGun , unsafeBlinkGun , autoDetector WALLDETECTOR - , effectGun "GIBBER" addCrGibs +-- , effectGun "GIBBER" addCrGibs ] 'E' -> [ makeTypeCraftNum 3 PIPE @@ -289,6 +286,6 @@ stackedInventory = IM.fromList $ zip [0..] --,medkit 50 --,bezierGun ] -smokeGenGun :: Item -smokeGenGun = effectGun "smoke" $ const spawnSmokeAtCursor +--smokeGenGun :: Item +--smokeGenGun = effectGun "smoke" $ const spawnSmokeAtCursor diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 3685eaeec..501652698 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -6,6 +6,7 @@ import Dodge.Data import Dodge.Inventory import Dodge.Reloading import Dodge.Item.Location +import Dodge.HeldUse import qualified Data.IntMap.Strict as IM import qualified Data.Map.Strict as M @@ -25,7 +26,7 @@ useItem cr' w = fromMaybe (f w) $ do itemEffect :: Creature -> Item -> World -> World itemEffect cr it w = case it ^? itUse of Just RightUse {_rUse = eff,_useMods = usemods} - -> hammerTest $ tryReload cr it w $ foldr ($) eff usemods it cr + -> hammerTest $ tryReload cr it w $ foldr ($) (useHeld eff) usemods it cr Just LeftUse {} -> doequipmentchange Just EquipUse{} -> doequipmentchange -- ConsumeUse will cause problems if the item is not selected diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 8d3e55041..d6895ef96 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -10,6 +10,7 @@ circular imports are probably not a good idea. {-# LANGUAGE DerivingStrategies #-} module Dodge.Data ( module Dodge.Data + , module Dodge.Data.Item.HeldUse , module Dodge.Data.Item.HeldScroll , module Dodge.Data.Item.Consumption , module Dodge.Data.Gas @@ -58,6 +59,7 @@ module Dodge.Data , module Dodge.Data.RadarBlip , module Dodge.Data.PathGraph ) where +import Dodge.Data.Item.HeldUse import Dodge.Data.Item.HeldScroll import Dodge.Data.Item.Consumption import Dodge.Data.Gas @@ -400,7 +402,7 @@ data PressPlate = PressPlate data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int} data ItemUse = RightUse - { _rUse :: Item -> Creature -> World -> World + { _rUse :: HeldUse -- Item -> Creature -> World -> World , _useDelay :: UseDelay , _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World] , _useHammer :: HammerPosition diff --git a/src/Dodge/Data/Item/HeldUse.hs b/src/Dodge/Data/Item/HeldUse.hs new file mode 100644 index 000000000..64d9ced6d --- /dev/null +++ b/src/Dodge/Data/Item/HeldUse.hs @@ -0,0 +1,21 @@ +module Dodge.Data.Item.HeldUse where +import Dodge.Combine.Data + +data HeldUse = HeldDoNothing + | HeldUseAmmoParams + | HeldOverNozzlesUseGasParams + | HeldPJCreation + | HeldPJCreationX Int + | HeldFireRemoteShell + | HeldExplodeRemoteShell Int Int + | HeldDetectorEffect Detector + | HeldTeslaArc + | HeldLaser + | HeldCircleLaser + | HeldDualLaser + | HeldTractor + | HeldSonicWave + | HeldForceField + | HeldShatter + +data HeldUseMods = HeldModsDoNothing diff --git a/src/Dodge/Default/Weapon.hs b/src/Dodge/Default/Weapon.hs index 87c879afb..154349096 100644 --- a/src/Dodge/Default/Weapon.hs +++ b/src/Dodge/Default/Weapon.hs @@ -1,7 +1,6 @@ module Dodge.Default.Weapon where import Dodge.Data -import Dodge.Bullet import Dodge.Reloading.Action import Dodge.Item.Weapon.Bullet import Dodge.Default.Item @@ -60,7 +59,7 @@ defaultChargeable = ChargeableAmmo 100 100 defaultrUse :: ItemUse defaultrUse = RightUse - { _rUse = \_ _ -> id + { _rUse = HeldDoNothing , _useDelay = FixedRate {_rateMax = 8, _rateTime = 0} , _useMods = [] , _useHammer = HammerUp @@ -107,7 +106,7 @@ defaultWeapon = defaultItem defaultBulletWeapon :: Item defaultBulletWeapon = defaultWeapon & itConsumption .~ defaultBulletLoadable - & itUse . rUse .~ useAmmoParams + & itUse . rUse .~ HeldUseAmmoParams -- useAmmoParams & itType . iyModules . at ModBullet ?~ EMPTYMODULE & itType . iyModules . at ModBulletSpawn ?~ EMPTYMODULE & itType . iyModules . at ModBulletTrajectory ?~ EMPTYMODULE diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs new file mode 100644 index 000000000..4d5bf5597 --- /dev/null +++ b/src/Dodge/HeldUse.hs @@ -0,0 +1,93 @@ +module Dodge.HeldUse where +import Dodge.Data +import Dodge.Bullet +import Dodge.Item.Location +import Dodge.Item.Weapon.Radar +import Dodge.Item.Weapon.BatteryGuns +import Dodge.Item.Weapon.SonicGuns +import Dodge.Item.Weapon.Utility +import Dodge.Item.Weapon.Shatter +import Dodge.Item.Weapon.Launcher +import Dodge.Projectile.Create +import Dodge.Gas +import Geometry +import qualified IntMapHelp as IM +import LensHelp +import RandomHelp + +import Data.Traversable + +useHeld :: HeldUse -> Item -> Creature -> World -> World +useHeld hu = case hu of + HeldDoNothing -> const $ const id + HeldUseAmmoParams -> useAmmoParams + HeldOverNozzlesUseGasParams -> overNozzles useGasParams + HeldPJCreation -> usePjCreation + HeldPJCreationX i -> usePjCreationX i + HeldFireRemoteShell -> fireRemoteShell + HeldDetectorEffect dt -> detectorEffect dt + HeldTeslaArc -> shootTeslaArc + HeldLaser -> shootLaser + HeldCircleLaser -> circleLaser + HeldDualLaser -> shootDualLaser + HeldTractor -> aTractorBeam + HeldSonicWave -> aSonicWave + HeldForceField -> useForceFieldGun + HeldShatter -> shootShatter + HeldExplodeRemoteShell itid pjid -> const $ const $ explodeRemoteRocket itid pjid + +usePjCreation :: Item -> Creature -> World -> World +usePjCreation it = createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it + +usePjCreationX :: Int -> Item -> Creature -> World -> World +usePjCreationX i it cr = foldr f + (createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it cr) + [1..i-1] + where + f n = (. createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i))) + +overNozzles :: (Nozzle -> Item -> Creature -> World -> World) + -> Item -> Creature -> World -> World +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 = crSel $ _creatures w IM.! cid + (neww,newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it) + +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) + +useGasParams :: Nozzle -> Item -> Creature -> World -> World +useGasParams nz it cr = createGas (_amCreateGas (_laAmmoType (_itConsumption it))) + (_nzPressure nz) pos dir cr + where + dir = _crDir cr + pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr)) + +fireRemoteShell :: Item -> Creature -> World -> World +fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse) + (HeldExplodeRemoteShell itid i) + $ addRemRocket w' + where + (w',itid) = getHeldItemLoc cr w + i = IM.newKey $ _props w + cid = _crID cr + addRemRocket = makeShell it cr + [ PJSetScope itid + , PJThrust 330 0 + , PJRemoteDirection 340 0 cid itid + ] + j = crSel cr diff --git a/src/Dodge/Item/Equipment.hs b/src/Dodge/Item/Equipment.hs index 097de34fd..231e53389 100644 --- a/src/Dodge/Item/Equipment.hs +++ b/src/Dodge/Item/Equipment.hs @@ -128,7 +128,7 @@ flatShield = defaultWeapon -- the above seems to work, but I am not sure why: it may break on edge -- cases & itUse .~ defaultrUse - { _rUse = \_ _ -> id + { _rUse = HeldDoNothing , _useDelay = NoDelay , _useMods = [] , _useHammer = HammerUp diff --git a/src/Dodge/Item/Weapon/BatteryGuns.hs b/src/Dodge/Item/Weapon/BatteryGuns.hs index e34355b01..45a365a06 100644 --- a/src/Dodge/Item/Weapon/BatteryGuns.hs +++ b/src/Dodge/Item/Weapon/BatteryGuns.hs @@ -11,6 +11,11 @@ module Dodge.Item.Weapon.BatteryGuns , flameBeamCombine , teslaBeamCombine , splitBeamCombine + , shootTeslaArc + , shootLaser + , circleLaser + , shootDualLaser + , aTractorBeam ) where import Dodge.Data import Dodge.Reloading.Action @@ -70,7 +75,7 @@ teslaGun = defaultBatteryGun & itDimension . dimRad .~ 9 & itDimension . dimCenter .~ V3 4 0 0 & itParams .~ teslaParams - & itUse . rUse .~ shootTeslaArc + & itUse . rUse .~ HeldTeslaArc --shootTeslaArc & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ ammoCheckI @@ -107,9 +112,9 @@ lasCircle = lasGun & itParams . lasColor .~ orange & itParams . lasDamage .~ 2 & itConsumption . laMax .~ 10000 - & itUse . rUse .~ shootLaser + & itUse . rUse .~ HeldLaser --shootLaser & itUse . useDelay .~ NoDelay - & itUse . rUse .~ circleLaser + & itUse . rUse .~ HeldCircleLaser --circleLaser & itUse . useMods .~ [ ammoCheckI , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) @@ -229,7 +234,7 @@ dualBeam = lasGun , _subParams = Nothing , _dbGap = 20 } - & itUse . rUse .~ shootDualLaser + & itUse . rUse .~ HeldDualLaser --shootDualLaser & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ ammoCheckI @@ -281,7 +286,7 @@ lasGun = defaultAutoBatteryGun } & itDimension . dimRad .~ 10 & itDimension . dimCenter .~ V3 15 0 0 - & itUse . rUse .~ shootLaser + & itUse . rUse .~ HeldLaser --shootLaser & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ ammoCheckI @@ -327,7 +332,7 @@ tractorGun = lasGun , _tweakSel = 0 } } - & itUse . rUse .~ aTractorBeam + & itUse . rUse .~ HeldTractor --aTractorBeam & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ ammoCheckI diff --git a/src/Dodge/Item/Weapon/BulletGun/Cane.hs b/src/Dodge/Item/Weapon/BulletGun/Cane.hs index b7b477c82..eda2fba4d 100644 --- a/src/Dodge/Item/Weapon/BulletGun/Cane.hs +++ b/src/Dodge/Item/Weapon/BulletGun/Cane.hs @@ -176,7 +176,7 @@ burstRifle = repeater -- ] miniGunUse :: Int -> ItemUse miniGunUse i = defaultrUse - & rUse .~ useAmmoParams + & rUse .~ HeldUseAmmoParams & useDelay .~ NoDelay & useMods .~ [ ammoCheckI diff --git a/src/Dodge/Item/Weapon/Drone.hs b/src/Dodge/Item/Weapon/Drone.hs index 46e18536b..4cab836df 100644 --- a/src/Dodge/Item/Weapon/Drone.hs +++ b/src/Dodge/Item/Weapon/Drone.hs @@ -15,7 +15,7 @@ import Control.Lens droneLauncher :: Item droneLauncher = defaultWeapon & itUse . useDelay . rateMax .~ 20 - & itUse . rUse .~ aDroneWithItemParams +-- & itUse . rUse .~ aDroneWithItemParams & itUse . useMods .~ [ ammoCheckI , useTimeCheck diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 691dbb67b..0b235c25b 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -3,7 +3,7 @@ module Dodge.Item.Weapon.Launcher , launcherX , remoteLauncher , fireTrackingShell - , fireRemoteShell + , explodeRemoteRocket ) where import Dodge.Data import Dodge.Projectile.Create @@ -44,7 +44,7 @@ launcher = defaultWeapon & itDimension . dimRad .~ 9 & itDimension . dimCenter .~ V3 10 0 0 & itUse . useDelay . rateMax .~ 20 - & itUse . rUse .~ usePjCreation + & itUse . rUse .~ HeldPJCreation --usePjCreation & itUse . useMods .~ [ hammerCheckI , ammoCheckI @@ -65,7 +65,7 @@ launcherX i = launcher & itType . iyBase .~ HELD (LAUNCHERX i) & itConsumption . laMax .~ i & itConsumption . laLoaded .~ i - & itUse . rUse .~ usePjCreationX i + & itUse . rUse .~ HeldPJCreationX i & itUse . useMods .~ [ hammerCheckI , ammoCheckI @@ -74,16 +74,6 @@ launcherX i = launcher , useAmmoAmount i ] -usePjCreation :: Item -> Creature -> World -> World -usePjCreation it = createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it - -usePjCreationX :: Int -> Item -> Creature -> World -> World -usePjCreationX i it cr = foldr f - (createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it cr) - [1..i-1] - where - f n = (. createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i))) - basicAmPjMoves :: IM.IntMap TweakParam basicAmPjMoves = IM.fromList . zip [0..] $ [spinDrag @@ -119,26 +109,11 @@ thrustParam = TweakParam remoteLauncher :: Item remoteLauncher = launcher & itType . iyBase .~ HELD REMOTELAUNCHER - & itUse . rUse .~ fireRemoteShell + & itUse . rUse .~ HeldFireRemoteShell --fireRemoteShell & itScope .~ RemoteScope (V2 0 0) 1 True & itConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell -- TODO consider allowing tweaking rocket speed -fireRemoteShell :: Item -> Creature -> World -> World -fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse) - (\_ _ -> explodeRemoteRocket itid i) - $ addRemRocket w' - where - (w',itid) = getHeldItemLoc cr w - i = IM.newKey $ _props w - cid = _crID cr - addRemRocket = makeShell it cr - [ PJSetScope itid - , PJThrust 330 0 - , PJRemoteDirection 340 0 cid itid - ] - j = crSel cr - explodeRemoteRocket :: Int -- ^ Item id -> Int -- ^ Projectile id @@ -147,7 +122,7 @@ explodeRemoteRocket explodeRemoteRocket itid pjid w = w & projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid] & projectiles . ix pjid . prjDraw .~ DrawBlankProjectile - & itPoint . itUse . rUse .~ (\_ _ -> id) + & itPoint . itUse . rUse .~ HeldDoNothing & usePayload (_prjPayload thepj) (_prjPos thepj) where itPoint = pointToItem $ _itemPositions w IM.! itid diff --git a/src/Dodge/Item/Weapon/Radar.hs b/src/Dodge/Item/Weapon/Radar.hs index 68315851f..3e3614487 100644 --- a/src/Dodge/Item/Weapon/Radar.hs +++ b/src/Dodge/Item/Weapon/Radar.hs @@ -13,7 +13,7 @@ Sends out pulses that display walls. -} clickDetector :: Detector -> Item clickDetector dt = defaultWeapon & itUse . useDelay . rateMax .~ 20 - & itUse . rUse .~ detectorEffect dt + & itUse . rUse .~ HeldDetectorEffect dt --detectorEffect dt & itUse . useMods .~ [ ammoUseCheck ] diff --git a/src/Dodge/Item/Weapon/Shatter.hs b/src/Dodge/Item/Weapon/Shatter.hs index 56b11de20..dd1025363 100644 --- a/src/Dodge/Item/Weapon/Shatter.hs +++ b/src/Dodge/Item/Weapon/Shatter.hs @@ -26,7 +26,7 @@ shatterGun :: Item shatterGun = defaultWeapon & itType . iyBase .~ HELD SHATTERGUN & itUse . useDelay . rateMax .~ 10 - & itUse . rUse .~ shootShatter + & itUse . rUse .~ HeldShatter --shootShatter & itUse . useMods .~ [ ammoHammerCheck , useTimeCheck diff --git a/src/Dodge/Item/Weapon/SonicGuns.hs b/src/Dodge/Item/Weapon/SonicGuns.hs index cf5dee048..c96200242 100644 --- a/src/Dodge/Item/Weapon/SonicGuns.hs +++ b/src/Dodge/Item/Weapon/SonicGuns.hs @@ -37,7 +37,7 @@ sonicGun = defaultAutoGun & itDimension . dimRad .~ 10 & itDimension . dimCenter .~ V3 15 0 0 & itUse . useDelay . rateMax .~ 8 - & itUse . rUse .~ aSonicWave + & itUse . rUse .~ HeldSonicWave --aSonicWave & itUse . useMods .~ [ ammoHammerCheck , useTimeCheck diff --git a/src/Dodge/Item/Weapon/Spawn.hs b/src/Dodge/Item/Weapon/Spawn.hs index 904f8008e..324f8b142 100644 --- a/src/Dodge/Item/Weapon/Spawn.hs +++ b/src/Dodge/Item/Weapon/Spawn.hs @@ -15,9 +15,9 @@ import Control.Lens {- | Creates a creature next to the creature using the item. -} spawnGun :: Creature -> Item -spawnGun cr = defaultWeapon +spawnGun _ = defaultWeapon & itUse . useDelay . rateMax .~ 100 - & itUse . rUse .~ (\_ -> spawnCrNextTo cr) + & itUse . rUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr) & itUse . useMods .~ [ ammoCheckI , hammerCheckI diff --git a/src/Dodge/Item/Weapon/SprayGuns.hs b/src/Dodge/Item/Weapon/SprayGuns.hs index 98c2e9022..d129ef4cc 100644 --- a/src/Dodge/Item/Weapon/SprayGuns.hs +++ b/src/Dodge/Item/Weapon/SprayGuns.hs @@ -7,21 +7,14 @@ module Dodge.Item.Weapon.SprayGuns , flameWall ) where import Dodge.Data -import Dodge.Gas import Dodge.Reloading.Action import Dodge.SoundLogic.LoadSound import Dodge.Default ---import Dodge.Item.Weapon.BulletGuns ---import Dodge.Item.Weapon.InventoryDisplay import Dodge.Item.Weapon.TriggerType ---import Dodge.Item.Attachment import Geometry import LensHelp -import Data.Traversable -import qualified Data.IntMap.Strict as IM import Control.Monad.State ---import Data.Function import System.Random poisonSprayer :: Item poisonSprayer = flameThrower @@ -111,7 +104,7 @@ flameThrower = defaultAutoGun } & itDimension . dimRad .~ 7 & itDimension . dimCenter .~ V3 9 0 0 - & itUse . rUse .~ overNozzles useGasParams + & itUse . rUse .~ HeldOverNozzlesUseGasParams -- overNozzles useGasParams & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ ammoCheckI @@ -128,34 +121,3 @@ flameThrower = defaultAutoGun & itType . iyBase .~ HELD FLAMETHROWER -overNozzles :: (Nozzle -> Item -> Creature -> World -> World) - -> Item -> Creature -> World -> World -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 = crSel $ _creatures w IM.! cid - (neww,newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it) - -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) - -useGasParams :: Nozzle -> Item -> Creature -> World -> World -useGasParams nz it cr = createGas (_amCreateGas (_laAmmoType (_itConsumption it))) - (_nzPressure nz) pos dir cr - where - dir = _crDir cr - pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr)) - diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index cc90c0738..a9526a2a3 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -101,25 +101,25 @@ unsafeBlinkGun = blinkGun & itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction) & itUse . eqEq . eqViewDist ?~ 400 -effectGun :: String -> (Creature -> World -> World) -> Item -effectGun name eff = defaultWeapon - { _itUse = defaultrUse - & rUse .~ const eff - & useMods .~ [hammerCheckI] - } - & itType . iyBase .~ EFFGUN name -autoEffectGun :: String -> (Creature -> World -> World) -> Item -autoEffectGun name eff = defaultWeapon - { _itUse = defaultrUse {_rUse = const eff} - } - & itType . iyBase .~ AUTOEFFGUN name +--effectGun :: String -> (Creature -> World -> World) -> Item +--effectGun name eff = defaultWeapon +-- { _itUse = defaultrUse +-- & rUse .~ const eff +-- & useMods .~ [hammerCheckI] +-- } +-- & itType . iyBase .~ EFFGUN name +--autoEffectGun :: String -> (Creature -> World -> World) -> Item +--autoEffectGun name eff = defaultWeapon +-- { _itUse = defaultrUse {_rUse = const eff} +-- } +-- & itType . iyBase .~ AUTOEFFGUN name forceFieldGun :: Item forceFieldGun = defaultWeapon { _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField , _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw , _itParams = ParamMID Nothing } - & itUse . rUse .~ useForceFieldGun + & itUse . rUse .~ HeldForceField --useForceFieldGun & itUse . useDelay .~ NoDelay & itUse . useMods .~ [ hammerCheckI , ammoCheckI , useAmmoAmount 1] diff --git a/src/Dodge/Projectile/Update.hs b/src/Dodge/Projectile/Update.hs index 78fbcb41b..1e444269d 100644 --- a/src/Dodge/Projectile/Update.hs +++ b/src/Dodge/Projectile/Update.hs @@ -65,7 +65,7 @@ explodeRemoteRocket' mitid thepj w = w updateitem = fromMaybe (projectiles . at pjid .~ Nothing) $ do itid <- mitid itpos <- w ^? itemPositions . ix itid - return $ (pointToItem itpos . itUse . rUse .~ (\_ _ -> id)) + return $ (pointToItem itpos . itUse . rUse .~ HeldDoNothing) . (projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]) pjid = _prjID thepj @@ -118,7 +118,7 @@ retireRemoteProj'' :: Int -> Int -> World -> World retireRemoteProj'' itid pjid w = w & pointToItem (_itemPositions w IM.! itid) %~ ( (itScope . scopePos .~ V2 0 0) - . (itUse . rUse .~ fireRemoteShell) + . (itUse . rUse .~ HeldFireRemoteShell) ) & props %~ IM.delete pjid