Start refactoring held item use
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user