Files
loop/src/Dodge/Item/Weapon/Utility.hs
T

101 lines
3.1 KiB
Haskell

module Dodge.Item.Weapon.Utility where
import Dodge.Default.Item.Use
import Control.Lens
import Data.Maybe
import Dodge.Base.Coordinate
import Dodge.Data.World
import Dodge.Default
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Geometry
import qualified IntMapHelp as IM
import Picture
import Shape
import ShapePicture
rewindGun :: Item
rewindGun =
defaultLeftItem
{ _itInvColor = cyan
, _itUse =
defaultLeftUse
& leftUse .~ LRewind --useRewindGun
& equipEffect . eeSite .~ GoesOnChest
}
& itEffect . ieInv .~ RewindEffect
& itType . iyBase .~ LEFT REWINDER
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 250
, _wpCharge = 0
}
-- needs to shift this item to the current inventory slot
shrinkGun :: Item
shrinkGun =
defaultLeftItem
& itUse .~ (defaultLeftUse & leftUse .~ LShrink)
& itParams .~ ShrinkGunParams FullSize
& itType . iyBase .~ LEFT SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
blinkGun :: Item
blinkGun =
defaultLeftItem
{ _itInvColor = cyan
, _itUse =
defaultLeftUse
& leftUse .~ LBlink --hammerCheckL (shootL $ const blinkAction)
& equipEffect . eeSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
& itType . iyBase .~ LEFT BLINKER
unsafeBlinkGun :: Item
unsafeBlinkGun =
blinkGun
& itType . iyBase .~ LEFT BLINKERUNSAFE
& itUse . leftUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . equipEffect . eeViewDist ?~ 400
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix
useForceFieldGun :: Item -> Creature -> World -> World
useForceFieldGun itm cr w = fromMaybe w $ do
a <- _tgPos $ _itTargeting itm
let mwp = mouseWorldPos w
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
wlline = (a, b)
return $
w
& cWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
where
i = fromMaybe (IM.newKey (_walls (_cWorld w))) $ itm ^? itParams . paramMID . _Just
-- grapGun = defaultGun
-- { _itName = "grapGun"
-- , _itIdentity = GrapGun
-- , _wpMaxAmmo = 1
-- , _wpLoadedAmmo = 1
-- , _wpReloadTime = 40
-- , _wpReloadState = 0
-- , _itUseRate = 10
-- , _itUseTime = 0
-- , _itUse = grapFire
-- , _wpSpread = 0.002
-- , _wpRange = 20
-- , _wpIsAuto = False
-- , _itFloorPict = onLayer FlItLayer $ polygon [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
-- , _itAmount = 1
-- , _itMaxStack = 1
-- , _itAimingSpeed = 1
-- , _itAimingRange = 0.5
-- }