Start refactoring held item use
This commit is contained in:
@@ -10,8 +10,6 @@ module Dodge.Creature
|
|||||||
, armourChaseCrit
|
, armourChaseCrit
|
||||||
) where
|
) where
|
||||||
import Dodge.Creature.State.Data
|
import Dodge.Creature.State.Data
|
||||||
import Dodge.Prop.Gib
|
|
||||||
--import Dodge.Item.Weapon.Grenade
|
|
||||||
import Dodge.Item.Equipment.Booster
|
import Dodge.Item.Equipment.Booster
|
||||||
import Dodge.Item.Weapon.Utility
|
import Dodge.Item.Weapon.Utility
|
||||||
--import Dodge.Item.Weapon.Drone
|
--import Dodge.Item.Weapon.Drone
|
||||||
@@ -28,7 +26,6 @@ import Dodge.Default
|
|||||||
import Dodge.Item.Weapon
|
import Dodge.Item.Weapon
|
||||||
import Dodge.Item.Equipment
|
import Dodge.Item.Equipment
|
||||||
import Dodge.Item.Consumable
|
import Dodge.Item.Consumable
|
||||||
import Dodge.WorldEvent.Cloud
|
|
||||||
import Dodge.Creature.Inanimate
|
import Dodge.Creature.Inanimate
|
||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
--import Dodge.Creature.ChooseTarget
|
--import Dodge.Creature.ChooseTarget
|
||||||
@@ -149,7 +146,7 @@ inventoryX c = case c of
|
|||||||
[ blinkGun
|
[ blinkGun
|
||||||
, unsafeBlinkGun
|
, unsafeBlinkGun
|
||||||
, autoDetector WALLDETECTOR
|
, autoDetector WALLDETECTOR
|
||||||
, effectGun "GIBBER" addCrGibs
|
-- , effectGun "GIBBER" addCrGibs
|
||||||
]
|
]
|
||||||
'E' ->
|
'E' ->
|
||||||
[ makeTypeCraftNum 3 PIPE
|
[ makeTypeCraftNum 3 PIPE
|
||||||
@@ -289,6 +286,6 @@ stackedInventory = IM.fromList $ zip [0..]
|
|||||||
--,medkit 50
|
--,medkit 50
|
||||||
--,bezierGun
|
--,bezierGun
|
||||||
]
|
]
|
||||||
smokeGenGun :: Item
|
--smokeGenGun :: Item
|
||||||
smokeGenGun = effectGun "smoke" $ const spawnSmokeAtCursor
|
--smokeGenGun = effectGun "smoke" $ const spawnSmokeAtCursor
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Dodge.Data
|
|||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Reloading
|
import Dodge.Reloading
|
||||||
import Dodge.Item.Location
|
import Dodge.Item.Location
|
||||||
|
import Dodge.HeldUse
|
||||||
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -25,7 +26,7 @@ useItem cr' w = fromMaybe (f w) $ do
|
|||||||
itemEffect :: Creature -> Item -> World -> World
|
itemEffect :: Creature -> Item -> World -> World
|
||||||
itemEffect cr it w = case it ^? itUse of
|
itemEffect cr it w = case it ^? itUse of
|
||||||
Just RightUse {_rUse = eff,_useMods = usemods}
|
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 LeftUse {} -> doequipmentchange
|
||||||
Just EquipUse{} -> doequipmentchange
|
Just EquipUse{} -> doequipmentchange
|
||||||
-- ConsumeUse will cause problems if the item is not selected
|
-- 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 #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
module Dodge.Data
|
module Dodge.Data
|
||||||
( module Dodge.Data
|
( module Dodge.Data
|
||||||
|
, module Dodge.Data.Item.HeldUse
|
||||||
, module Dodge.Data.Item.HeldScroll
|
, module Dodge.Data.Item.HeldScroll
|
||||||
, module Dodge.Data.Item.Consumption
|
, module Dodge.Data.Item.Consumption
|
||||||
, module Dodge.Data.Gas
|
, module Dodge.Data.Gas
|
||||||
@@ -58,6 +59,7 @@ module Dodge.Data
|
|||||||
, module Dodge.Data.RadarBlip
|
, module Dodge.Data.RadarBlip
|
||||||
, module Dodge.Data.PathGraph
|
, module Dodge.Data.PathGraph
|
||||||
) where
|
) where
|
||||||
|
import Dodge.Data.Item.HeldUse
|
||||||
import Dodge.Data.Item.HeldScroll
|
import Dodge.Data.Item.HeldScroll
|
||||||
import Dodge.Data.Item.Consumption
|
import Dodge.Data.Item.Consumption
|
||||||
import Dodge.Data.Gas
|
import Dodge.Data.Gas
|
||||||
@@ -400,7 +402,7 @@ data PressPlate = PressPlate
|
|||||||
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
|
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
|
||||||
data ItemUse
|
data ItemUse
|
||||||
= RightUse
|
= RightUse
|
||||||
{ _rUse :: Item -> Creature -> World -> World
|
{ _rUse :: HeldUse -- Item -> Creature -> World -> World
|
||||||
, _useDelay :: UseDelay
|
, _useDelay :: UseDelay
|
||||||
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
||||||
, _useHammer :: HammerPosition
|
, _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
|
module Dodge.Default.Weapon
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Bullet
|
|
||||||
import Dodge.Reloading.Action
|
import Dodge.Reloading.Action
|
||||||
import Dodge.Item.Weapon.Bullet
|
import Dodge.Item.Weapon.Bullet
|
||||||
import Dodge.Default.Item
|
import Dodge.Default.Item
|
||||||
@@ -60,7 +59,7 @@ defaultChargeable = ChargeableAmmo 100 100
|
|||||||
|
|
||||||
defaultrUse :: ItemUse
|
defaultrUse :: ItemUse
|
||||||
defaultrUse = RightUse
|
defaultrUse = RightUse
|
||||||
{ _rUse = \_ _ -> id
|
{ _rUse = HeldDoNothing
|
||||||
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
|
||||||
, _useMods = []
|
, _useMods = []
|
||||||
, _useHammer = HammerUp
|
, _useHammer = HammerUp
|
||||||
@@ -107,7 +106,7 @@ defaultWeapon = defaultItem
|
|||||||
defaultBulletWeapon :: Item
|
defaultBulletWeapon :: Item
|
||||||
defaultBulletWeapon = defaultWeapon
|
defaultBulletWeapon = defaultWeapon
|
||||||
& itConsumption .~ defaultBulletLoadable
|
& itConsumption .~ defaultBulletLoadable
|
||||||
& itUse . rUse .~ useAmmoParams
|
& itUse . rUse .~ HeldUseAmmoParams -- useAmmoParams
|
||||||
& itType . iyModules . at ModBullet ?~ EMPTYMODULE
|
& itType . iyModules . at ModBullet ?~ EMPTYMODULE
|
||||||
& itType . iyModules . at ModBulletSpawn ?~ EMPTYMODULE
|
& itType . iyModules . at ModBulletSpawn ?~ EMPTYMODULE
|
||||||
& itType . iyModules . at ModBulletTrajectory ?~ 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
|
-- the above seems to work, but I am not sure why: it may break on edge
|
||||||
-- cases
|
-- cases
|
||||||
& itUse .~ defaultrUse
|
& itUse .~ defaultrUse
|
||||||
{ _rUse = \_ _ -> id
|
{ _rUse = HeldDoNothing
|
||||||
, _useDelay = NoDelay
|
, _useDelay = NoDelay
|
||||||
, _useMods = []
|
, _useMods = []
|
||||||
, _useHammer = HammerUp
|
, _useHammer = HammerUp
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ module Dodge.Item.Weapon.BatteryGuns
|
|||||||
, flameBeamCombine
|
, flameBeamCombine
|
||||||
, teslaBeamCombine
|
, teslaBeamCombine
|
||||||
, splitBeamCombine
|
, splitBeamCombine
|
||||||
|
, shootTeslaArc
|
||||||
|
, shootLaser
|
||||||
|
, circleLaser
|
||||||
|
, shootDualLaser
|
||||||
|
, aTractorBeam
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Reloading.Action
|
import Dodge.Reloading.Action
|
||||||
@@ -70,7 +75,7 @@ teslaGun = defaultBatteryGun
|
|||||||
& itDimension . dimRad .~ 9
|
& itDimension . dimRad .~ 9
|
||||||
& itDimension . dimCenter .~ V3 4 0 0
|
& itDimension . dimCenter .~ V3 4 0 0
|
||||||
& itParams .~ teslaParams
|
& itParams .~ teslaParams
|
||||||
& itUse . rUse .~ shootTeslaArc
|
& itUse . rUse .~ HeldTeslaArc --shootTeslaArc
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
@@ -107,9 +112,9 @@ lasCircle = lasGun
|
|||||||
& itParams . lasColor .~ orange
|
& itParams . lasColor .~ orange
|
||||||
& itParams . lasDamage .~ 2
|
& itParams . lasDamage .~ 2
|
||||||
& itConsumption . laMax .~ 10000
|
& itConsumption . laMax .~ 10000
|
||||||
& itUse . rUse .~ shootLaser
|
& itUse . rUse .~ HeldLaser --shootLaser
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . rUse .~ circleLaser
|
& itUse . rUse .~ HeldCircleLaser --circleLaser
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||||
@@ -229,7 +234,7 @@ dualBeam = lasGun
|
|||||||
, _subParams = Nothing
|
, _subParams = Nothing
|
||||||
, _dbGap = 20
|
, _dbGap = 20
|
||||||
}
|
}
|
||||||
& itUse . rUse .~ shootDualLaser
|
& itUse . rUse .~ HeldDualLaser --shootDualLaser
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
@@ -281,7 +286,7 @@ lasGun = defaultAutoBatteryGun
|
|||||||
}
|
}
|
||||||
& itDimension . dimRad .~ 10
|
& itDimension . dimRad .~ 10
|
||||||
& itDimension . dimCenter .~ V3 15 0 0
|
& itDimension . dimCenter .~ V3 15 0 0
|
||||||
& itUse . rUse .~ shootLaser
|
& itUse . rUse .~ HeldLaser --shootLaser
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
@@ -327,7 +332,7 @@ tractorGun = lasGun
|
|||||||
, _tweakSel = 0
|
, _tweakSel = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
& itUse . rUse .~ aTractorBeam
|
& itUse . rUse .~ HeldTractor --aTractorBeam
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ burstRifle = repeater
|
|||||||
-- ]
|
-- ]
|
||||||
miniGunUse :: Int -> ItemUse
|
miniGunUse :: Int -> ItemUse
|
||||||
miniGunUse i = defaultrUse
|
miniGunUse i = defaultrUse
|
||||||
& rUse .~ useAmmoParams
|
& rUse .~ HeldUseAmmoParams
|
||||||
& useDelay .~ NoDelay
|
& useDelay .~ NoDelay
|
||||||
& useMods .~
|
& useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Control.Lens
|
|||||||
droneLauncher :: Item
|
droneLauncher :: Item
|
||||||
droneLauncher = defaultWeapon
|
droneLauncher = defaultWeapon
|
||||||
& itUse . useDelay . rateMax .~ 20
|
& itUse . useDelay . rateMax .~ 20
|
||||||
& itUse . rUse .~ aDroneWithItemParams
|
-- & itUse . rUse .~ aDroneWithItemParams
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module Dodge.Item.Weapon.Launcher
|
|||||||
, launcherX
|
, launcherX
|
||||||
, remoteLauncher
|
, remoteLauncher
|
||||||
, fireTrackingShell
|
, fireTrackingShell
|
||||||
, fireRemoteShell
|
, explodeRemoteRocket
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Projectile.Create
|
import Dodge.Projectile.Create
|
||||||
@@ -44,7 +44,7 @@ launcher = defaultWeapon
|
|||||||
& itDimension . dimRad .~ 9
|
& itDimension . dimRad .~ 9
|
||||||
& itDimension . dimCenter .~ V3 10 0 0
|
& itDimension . dimCenter .~ V3 10 0 0
|
||||||
& itUse . useDelay . rateMax .~ 20
|
& itUse . useDelay . rateMax .~ 20
|
||||||
& itUse . rUse .~ usePjCreation
|
& itUse . rUse .~ HeldPJCreation --usePjCreation
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ hammerCheckI
|
[ hammerCheckI
|
||||||
, ammoCheckI
|
, ammoCheckI
|
||||||
@@ -65,7 +65,7 @@ launcherX i = launcher
|
|||||||
& itType . iyBase .~ HELD (LAUNCHERX i)
|
& itType . iyBase .~ HELD (LAUNCHERX i)
|
||||||
& itConsumption . laMax .~ i
|
& itConsumption . laMax .~ i
|
||||||
& itConsumption . laLoaded .~ i
|
& itConsumption . laLoaded .~ i
|
||||||
& itUse . rUse .~ usePjCreationX i
|
& itUse . rUse .~ HeldPJCreationX i
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ hammerCheckI
|
[ hammerCheckI
|
||||||
, ammoCheckI
|
, ammoCheckI
|
||||||
@@ -74,16 +74,6 @@ launcherX i = launcher
|
|||||||
, useAmmoAmount i
|
, 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.IntMap TweakParam
|
||||||
basicAmPjMoves = IM.fromList . zip [0..] $
|
basicAmPjMoves = IM.fromList . zip [0..] $
|
||||||
[spinDrag
|
[spinDrag
|
||||||
@@ -119,26 +109,11 @@ thrustParam = TweakParam
|
|||||||
remoteLauncher :: Item
|
remoteLauncher :: Item
|
||||||
remoteLauncher = launcher
|
remoteLauncher = launcher
|
||||||
& itType . iyBase .~ HELD REMOTELAUNCHER
|
& itType . iyBase .~ HELD REMOTELAUNCHER
|
||||||
& itUse . rUse .~ fireRemoteShell
|
& itUse . rUse .~ HeldFireRemoteShell --fireRemoteShell
|
||||||
& itScope .~ RemoteScope (V2 0 0) 1 True
|
& itScope .~ RemoteScope (V2 0 0) 1 True
|
||||||
& itConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
|
& itConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
|
||||||
-- TODO consider allowing tweaking rocket speed
|
-- 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
|
explodeRemoteRocket
|
||||||
:: Int -- ^ Item id
|
:: Int -- ^ Item id
|
||||||
-> Int -- ^ Projectile id
|
-> Int -- ^ Projectile id
|
||||||
@@ -147,7 +122,7 @@ explodeRemoteRocket
|
|||||||
explodeRemoteRocket itid pjid w = w
|
explodeRemoteRocket itid pjid w = w
|
||||||
& projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
& projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||||
& projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
& projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||||
& itPoint . itUse . rUse .~ (\_ _ -> id)
|
& itPoint . itUse . rUse .~ HeldDoNothing
|
||||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||||
where
|
where
|
||||||
itPoint = pointToItem $ _itemPositions w IM.! itid
|
itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Sends out pulses that display walls. -}
|
|||||||
clickDetector :: Detector -> Item
|
clickDetector :: Detector -> Item
|
||||||
clickDetector dt = defaultWeapon
|
clickDetector dt = defaultWeapon
|
||||||
& itUse . useDelay . rateMax .~ 20
|
& itUse . useDelay . rateMax .~ 20
|
||||||
& itUse . rUse .~ detectorEffect dt
|
& itUse . rUse .~ HeldDetectorEffect dt --detectorEffect dt
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoUseCheck
|
[ ammoUseCheck
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ shatterGun :: Item
|
|||||||
shatterGun = defaultWeapon
|
shatterGun = defaultWeapon
|
||||||
& itType . iyBase .~ HELD SHATTERGUN
|
& itType . iyBase .~ HELD SHATTERGUN
|
||||||
& itUse . useDelay . rateMax .~ 10
|
& itUse . useDelay . rateMax .~ 10
|
||||||
& itUse . rUse .~ shootShatter
|
& itUse . rUse .~ HeldShatter --shootShatter
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ sonicGun = defaultAutoGun
|
|||||||
& itDimension . dimRad .~ 10
|
& itDimension . dimRad .~ 10
|
||||||
& itDimension . dimCenter .~ V3 15 0 0
|
& itDimension . dimCenter .~ V3 15 0 0
|
||||||
& itUse . useDelay . rateMax .~ 8
|
& itUse . useDelay . rateMax .~ 8
|
||||||
& itUse . rUse .~ aSonicWave
|
& itUse . rUse .~ HeldSonicWave --aSonicWave
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import Control.Lens
|
|||||||
{- |
|
{- |
|
||||||
Creates a creature next to the creature using the item. -}
|
Creates a creature next to the creature using the item. -}
|
||||||
spawnGun :: Creature -> Item
|
spawnGun :: Creature -> Item
|
||||||
spawnGun cr = defaultWeapon
|
spawnGun _ = defaultWeapon
|
||||||
& itUse . useDelay . rateMax .~ 100
|
& itUse . useDelay . rateMax .~ 100
|
||||||
& itUse . rUse .~ (\_ -> spawnCrNextTo cr)
|
& itUse . rUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
|
|||||||
@@ -7,21 +7,14 @@ module Dodge.Item.Weapon.SprayGuns
|
|||||||
, flameWall
|
, flameWall
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Gas
|
|
||||||
import Dodge.Reloading.Action
|
import Dodge.Reloading.Action
|
||||||
import Dodge.SoundLogic.LoadSound
|
import Dodge.SoundLogic.LoadSound
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
--import Dodge.Item.Weapon.BulletGuns
|
|
||||||
--import Dodge.Item.Weapon.InventoryDisplay
|
|
||||||
import Dodge.Item.Weapon.TriggerType
|
import Dodge.Item.Weapon.TriggerType
|
||||||
--import Dodge.Item.Attachment
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
import Data.Traversable
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
--import Data.Function
|
|
||||||
import System.Random
|
import System.Random
|
||||||
poisonSprayer :: Item
|
poisonSprayer :: Item
|
||||||
poisonSprayer = flameThrower
|
poisonSprayer = flameThrower
|
||||||
@@ -111,7 +104,7 @@ flameThrower = defaultAutoGun
|
|||||||
}
|
}
|
||||||
& itDimension . dimRad .~ 7
|
& itDimension . dimRad .~ 7
|
||||||
& itDimension . dimCenter .~ V3 9 0 0
|
& itDimension . dimCenter .~ V3 9 0 0
|
||||||
& itUse . rUse .~ overNozzles useGasParams
|
& itUse . rUse .~ HeldOverNozzlesUseGasParams -- overNozzles useGasParams
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
@@ -128,34 +121,3 @@ flameThrower = defaultAutoGun
|
|||||||
& itType . iyBase .~ HELD FLAMETHROWER
|
& 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 . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
|
||||||
& itUse . eqEq . eqViewDist ?~ 400
|
& itUse . eqEq . eqViewDist ?~ 400
|
||||||
|
|
||||||
effectGun :: String -> (Creature -> World -> World) -> Item
|
--effectGun :: String -> (Creature -> World -> World) -> Item
|
||||||
effectGun name eff = defaultWeapon
|
--effectGun name eff = defaultWeapon
|
||||||
{ _itUse = defaultrUse
|
-- { _itUse = defaultrUse
|
||||||
& rUse .~ const eff
|
-- & rUse .~ const eff
|
||||||
& useMods .~ [hammerCheckI]
|
-- & useMods .~ [hammerCheckI]
|
||||||
}
|
-- }
|
||||||
& itType . iyBase .~ EFFGUN name
|
-- & itType . iyBase .~ EFFGUN name
|
||||||
autoEffectGun :: String -> (Creature -> World -> World) -> Item
|
--autoEffectGun :: String -> (Creature -> World -> World) -> Item
|
||||||
autoEffectGun name eff = defaultWeapon
|
--autoEffectGun name eff = defaultWeapon
|
||||||
{ _itUse = defaultrUse {_rUse = const eff}
|
-- { _itUse = defaultrUse {_rUse = const eff}
|
||||||
}
|
-- }
|
||||||
& itType . iyBase .~ AUTOEFFGUN name
|
-- & itType . iyBase .~ AUTOEFFGUN name
|
||||||
forceFieldGun :: Item
|
forceFieldGun :: Item
|
||||||
forceFieldGun = defaultWeapon
|
forceFieldGun = defaultWeapon
|
||||||
{ _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField
|
{ _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField
|
||||||
, _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw
|
, _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw
|
||||||
, _itParams = ParamMID Nothing
|
, _itParams = ParamMID Nothing
|
||||||
}
|
}
|
||||||
& itUse . rUse .~ useForceFieldGun
|
& itUse . rUse .~ HeldForceField --useForceFieldGun
|
||||||
& itUse . useDelay .~ NoDelay
|
& itUse . useDelay .~ NoDelay
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
|
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ explodeRemoteRocket' mitid thepj w = w
|
|||||||
updateitem = fromMaybe (projectiles . at pjid .~ Nothing) $ do
|
updateitem = fromMaybe (projectiles . at pjid .~ Nothing) $ do
|
||||||
itid <- mitid
|
itid <- mitid
|
||||||
itpos <- w ^? itemPositions . ix itid
|
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])
|
. (projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid])
|
||||||
pjid = _prjID thepj
|
pjid = _prjID thepj
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ retireRemoteProj'' :: Int -> Int -> World -> World
|
|||||||
retireRemoteProj'' itid pjid w = w
|
retireRemoteProj'' itid pjid w = w
|
||||||
& pointToItem (_itemPositions w IM.! itid) %~
|
& pointToItem (_itemPositions w IM.! itid) %~
|
||||||
( (itScope . scopePos .~ V2 0 0)
|
( (itScope . scopePos .~ V2 0 0)
|
||||||
. (itUse . rUse .~ fireRemoteShell)
|
. (itUse . rUse .~ HeldFireRemoteShell)
|
||||||
)
|
)
|
||||||
& props %~ IM.delete pjid
|
& props %~ IM.delete pjid
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user