Start refactoring held item use
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -176,7 +176,7 @@ burstRifle = repeater
|
||||
-- ]
|
||||
miniGunUse :: Int -> ItemUse
|
||||
miniGunUse i = defaultrUse
|
||||
& rUse .~ useAmmoParams
|
||||
& rUse .~ HeldUseAmmoParams
|
||||
& useDelay .~ NoDelay
|
||||
& useMods .~
|
||||
[ ammoCheckI
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user