182 lines
5.8 KiB
Haskell
182 lines
5.8 KiB
Haskell
module Dodge.Item.Weapon.Utility where
|
|
import Dodge.Data
|
|
import Dodge.Base.Coordinate
|
|
import Dodge.Default
|
|
--import Dodge.Picture.Layer
|
|
import Dodge.Creature.Action
|
|
import Dodge.Item.Weapon.TriggerType
|
|
import Dodge.Item.Weapon.ExtraEffect
|
|
import Dodge.Default.Weapon
|
|
import Dodge.Wall.ForceField
|
|
import Dodge.Wall.Move
|
|
--import Sound.Data
|
|
import Geometry
|
|
import Picture
|
|
import qualified IntMapHelp as IM
|
|
import Shape
|
|
import ShapePicture
|
|
|
|
import Data.Maybe
|
|
--import qualified Data.Map.Strict as M
|
|
import Control.Lens
|
|
|
|
rewindGun :: Item
|
|
rewindGun = defaultGun
|
|
{ _itName = "REWINDER"
|
|
, _itType = REWINDER
|
|
, _itInvColor = cyan
|
|
, _itConsumption = ChargeableAmmo
|
|
{ _wpMaxCharge = 250
|
|
, _wpCharge = 0
|
|
}
|
|
, _itEffect = ItRewindEffect rewindEffect []
|
|
, _itUse = defaultlUse
|
|
& lUse .~ useRewindGun
|
|
& eqSite .~ GoesOnChest
|
|
}
|
|
rewindEffect :: Item -> Creature -> World -> World
|
|
rewindEffect itm cr w
|
|
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
|
& ptrWpCharge .~ length (_rewindWorlds w)
|
|
| otherwise = w & rewindWorlds .~ []
|
|
& ptrWpCharge .~ 0
|
|
where
|
|
invid = fromJust $ _itInvPos itm
|
|
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
|
maxcharge = _wpMaxCharge . _itConsumption $ itm
|
|
w' = w & rewindWorlds .~ []
|
|
& timeFlow .~ NormalTimeFlow
|
|
|
|
useRewindGun :: Item -> Creature -> World -> World
|
|
useRewindGun _ _ w = case _rewindWorlds w of
|
|
[w'] -> rewindusing w' [w']
|
|
(w':ws) -> rewindusing w' ws
|
|
_ -> w
|
|
where
|
|
rewindusing w' ws = w
|
|
& maybeWorld .~ Just' ( w'
|
|
-- & creatures . ix (_crID cr) .~ cr
|
|
& upbuts
|
|
& rewindWorlds .~ ws
|
|
)
|
|
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
|
|
|
-- needs to shift this item to the current inventory slot
|
|
shrinkGun :: Item
|
|
shrinkGun = defaultGun
|
|
{ _itName = "SHRINKER"
|
|
, _itType = SHRINKER
|
|
, _itConsumption = defaultAmmo
|
|
{ _ammoBaseMax = 100
|
|
, _ammoLoaded = 100
|
|
, _reloadTime = 20
|
|
}
|
|
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
|
|
& useHammer .~ upHammer
|
|
-- , _itFloorPict = shrinkGunPic
|
|
, _itAttachment = ItBool True
|
|
}
|
|
|
|
shrinkGunPic :: Item -> SPic
|
|
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
|
|
|
|
-- be careful changing this around; potential problems include updating the
|
|
-- creature but using the old crInvSel value
|
|
-- 22.05.23 this has been changed from using invids to items
|
|
useShrinkGun :: Item -> Creature -> World -> World
|
|
useShrinkGun it cr w = if _itBool $ _itAttachment it
|
|
then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropExcept cr invid
|
|
else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr
|
|
where
|
|
invid = fromJust $ _itInvPos it
|
|
tryResize x g = maybe w g $ sizeSelf x cr w
|
|
f isInUse cstatus = creatures . ix (_crID cr) . crInv . ix invid %~
|
|
( (itAttachment . itBool .~ isInUse) . (itCurseStatus .~ cstatus) )
|
|
|
|
blinkGun :: Item
|
|
blinkGun = defaultGun
|
|
{ _itName = "BLINKER"
|
|
, _itType = BLINKER
|
|
, _itInvColor = cyan
|
|
, _itConsumption = defaultAmmo
|
|
{ _ammoBaseMax = 100
|
|
, _ammoLoaded = 100
|
|
, _reloadTime = 20
|
|
}
|
|
, _itUse = defaultlUse
|
|
& lUse .~ hammerCheckL (shootL $ const blinkAction)
|
|
& useHammer .~ upHammer
|
|
& eqSite .~ GoesOnWrist
|
|
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
|
}
|
|
|
|
unsafeBlinkGun :: Item
|
|
unsafeBlinkGun = blinkGun
|
|
& itName .~ "BLINKER-UNSAFE"
|
|
& itType .~ BLINKERUNSAFE
|
|
& itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
|
|
|
|
effectGun :: String -> (Creature -> World -> World) -> Item
|
|
effectGun name eff = defaultGun
|
|
{ _itName = name ++ "Gun"
|
|
, _itUse = defaultrUse
|
|
& rUse .~ const eff
|
|
& useMods .~ [hammerCheckI]
|
|
}
|
|
effectGunCont :: String -> (Creature -> World -> World) -> Item
|
|
effectGunCont name eff = defaultGun
|
|
{ _itName = name ++ "Gun"
|
|
, _itUse = defaultrUse {_rUse = const eff}
|
|
}
|
|
autoEffectGun :: String -> (Creature -> World -> World) -> Item
|
|
autoEffectGun name eff = defaultAutoGun
|
|
{ _itName = name ++ "Gun"
|
|
, _itUse = defaultrUse {_rUse = const eff}
|
|
}
|
|
forceFieldGun :: Item
|
|
forceFieldGun = defaultGun
|
|
{ _itName = "FORCEFIELDGUN"
|
|
, _itType = FORCEFIELDGUN
|
|
, _itConsumption = defaultAmmo
|
|
{ _ammoBaseMax = 100
|
|
, _ammoLoaded = 100
|
|
, _reloadTime = 40
|
|
, _reloadState = Nothing'
|
|
}
|
|
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
|
|
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
|
|
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
|
|
, _itTargeting = targetRBPress
|
|
, _itParams = ParamMID Nothing
|
|
}
|
|
|
|
useForceFieldGun :: Item -> Creature -> World -> World
|
|
useForceFieldGun itm cr w = w
|
|
& walls %~ IM.insertWith (\_ x -> x) i forceField {_wlID = i}
|
|
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itParams . paramMID ?~ i
|
|
& moveWallIDUnsafe i wlline
|
|
where
|
|
i = fromMaybe (IM.newKey (_walls w)) $ itm ^? itParams . paramMID . _Just
|
|
a = fromJust . _tgPos $ _itTargeting itm
|
|
wlline = (a,mouseWorldPos w)
|
|
|
|
-- 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
|
|
-- }
|