module Dodge.Item.Weapon.Utility where import Dodge.Data import Dodge.Default import Dodge.Picture.Layer import Dodge.Creature.Action import Dodge.Item.Weapon.TriggerType import Dodge.Default.Weapon import Geometry import Picture --import qualified IntMapHelp as IM import Shape import ShapePicture import Control.Lens shrinkGun :: Item shrinkGun = defaultGun { _itName = "SHRINKER" , _itIdentity = Generic , _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 , _wpReloadTime = 20 , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itAimStance = TwoHandFlat , _itUse = useShrinkGun , _itUseModifiers = [ ammoCheckI , hammerCheckI ] , _itLeftClickUse = Nothing , _wpSpread = 0.05 , _wpRange = 20 , _itFloorPict = shrinkGunPic , _itAimingSpeed = 1 , _itAimingRange = 0 , _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 useShrinkGun :: Item -> Creature -> World -> World useShrinkGun it cr w = if _itBool $ _itAttachment it then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropUnselected cr else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr where tryResize x g = maybe w g $ maybeSizeSelf x cr w f isInUse cstatus = creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) %~ ( (itAttachment . itBool .~ isInUse) . (itCurseStatus .~ cstatus) ) blinkGun :: Item blinkGun = defaultGun { _itName = "BLINKER" , _itIdentity = Blinker , _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 , _wpReloadTime = 20 , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = const blinkAction , _itUseModifiers = [ ammoCheckI , hammerCheckI ] , _itLeftClickUse = Just $ hammerCheckL $ shootL aSelfL , _wpSpread = 0.05 , _wpRange = 20 , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2[(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)] , _itAimingSpeed = 1 , _itAimingRange = 0 } aSelf :: Creature -> World -> World aSelf = blinkAction aSelfL :: Creature -> Int -> World -> World aSelfL cr _ = blinkAction cr