module Dodge.Item.Weapon.Utility where import Dodge.Data import Dodge.Base.Coordinate import Dodge.Default import Dodge.Item.Weapon.ExtraEffect import Dodge.Wall.ForceField import Dodge.Wall.Move import Geometry import Picture import qualified IntMapHelp as IM import Shape import ShapePicture import Data.Maybe import Control.Lens rewindGun :: Item rewindGun = defaultLeftItem { _itInvColor = cyan , _itConsumption = ChargeableAmmo { _wpMaxCharge = 250 , _wpCharge = 0 } , _itEffect = ItRewindEffect RewindEffect-- [] , _itUse = defaultlUse & lUse .~ LRewind --useRewindGun & eqEq . eqSite .~ GoesOnChest } & itType . iyBase .~ LEFT REWINDER -- needs to shift this item to the current inventory slot shrinkGun :: Item shrinkGun = defaultLeftItem {_itUse = defaultlUse & lUse .~ LShrink -- hammerCheckL useShrinkGun -- , _itFloorPict = shrinkGunPic , _itAttachment = AttachBool True } & itType . iyBase .~ LEFT SHRINKER shrinkGunPic :: Item -> SPic shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5 blinkGun :: Item blinkGun = defaultLeftItem { _itInvColor = cyan , _itUse = defaultlUse & lUse .~ LBlink --hammerCheckL (shootL $ const blinkAction) & eqEq . eqSite .~ GoesOnWrist -- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2 } & itType . iyBase .~ LEFT BLINKER unsafeBlinkGun :: Item unsafeBlinkGun = blinkGun & itType . iyBase .~ LEFT BLINKERUNSAFE & itUse . lUse .~ LUnsafeBlink --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 forceFieldGun :: Item forceFieldGun = defaultWeapon { _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField , _itTargeting = targetRBPress & tgDraw .~ TargetDistanceDraw , _itParams = ParamMID Nothing } & itUse . rUse .~ HeldForceField --useForceFieldGun & itUse . useDelay .~ NoDelay & itUse . useMods .~ AmmoHammerTimeUseOneMod -- this is slightly different -- than the list below --[ hammerCheckI , ammoCheckI , useAmmoAmount 1] & itType . iyBase .~ HELD FORCEFIELDGUN -- 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 (_itPos 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 -- }