Allow to equip left click items
This commit is contained in:
@@ -11,10 +11,9 @@ import Geometry
|
||||
|
||||
import Control.Lens
|
||||
|
||||
useAmmoParams :: Item -> Creature -> World -> World
|
||||
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||
where
|
||||
b = _wpAmmo it
|
||||
useAmmoParams :: Either a (Item -> Creature -> World -> World)
|
||||
useAmmoParams = Right $ \it -> let b = _wpAmmo it
|
||||
in withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||
|
||||
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
||||
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||
|
||||
@@ -44,7 +44,7 @@ teslaGun = defaultGun
|
||||
, _itUseRate = 0
|
||||
, _itAimStance = TwoHandFlat
|
||||
, _itUseTime = 0
|
||||
, _itUse = const aTeslaArc
|
||||
, _itUse = Right $ const aTeslaArc
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
@@ -77,7 +77,7 @@ lasGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = const aLaser
|
||||
, _itUse = Right $ const aLaser
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
@@ -117,7 +117,7 @@ tractorGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = aTractorBeam
|
||||
, _itUse = Right aTractorBeam
|
||||
, _itUseModifiers =
|
||||
[ ammoUseCheckI
|
||||
]
|
||||
|
||||
@@ -23,7 +23,7 @@ import Control.Monad.State
|
||||
bezierGun :: Item
|
||||
bezierGun = defaultGun
|
||||
{ _itName = "B-GUN"
|
||||
, _itUse = \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point
|
||||
, _itUse = Right $ \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
|
||||
@@ -54,13 +54,6 @@ boostSelfL x cr invid w = case boostPoint x cr w of
|
||||
. (itAttachment .~ ItInt pid)
|
||||
)
|
||||
|
||||
boostSelf
|
||||
:: Float -- ^ boost amount
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
boostSelf x cr = boostSelfL x cr (_crInvSel cr)
|
||||
|
||||
addBoostShockwave
|
||||
:: Int
|
||||
-> Point2
|
||||
@@ -126,8 +119,7 @@ boosterGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> boostSelf 10
|
||||
, _itLeftClickUse = Just $ boostSelfL 10
|
||||
, _itUse = Left $ boostSelfL 10
|
||||
, _wpSpread = 0.05
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
|
||||
|
||||
@@ -102,7 +102,6 @@ pistol = defaultGun
|
||||
, randSpreadDir
|
||||
, withMuzFlareI
|
||||
]
|
||||
, _itLeftClickUse = Nothing
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = pistolPic
|
||||
@@ -218,7 +217,7 @@ miniGun = defaultAutoGun
|
||||
, _wpMaxWarmUp = 100
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = useAmmoParamsVelMod vm4
|
||||
, _itUse = Right $ useAmmoParamsVelMod vm4
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, withWarmUpI crankSlowS
|
||||
|
||||
@@ -28,7 +28,7 @@ lasDrones = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _itUse = aDroneWithItemParams
|
||||
, _itUse = Right aDroneWithItemParams
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
|
||||
@@ -34,7 +34,7 @@ grenade = Throwable
|
||||
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
|
||||
, _twMaxRange = 150
|
||||
, _twAccuracy = 30
|
||||
, _itUse = \_ -> throwGrenade makeExplosionAt
|
||||
, _itUse = Right $ \_ -> throwGrenade makeExplosionAt
|
||||
, _itUseModifiers =
|
||||
[ useTimeCheckI
|
||||
]
|
||||
@@ -227,7 +227,7 @@ remoteBomb = defaultThrowable
|
||||
[(-3,-3),(-3,3),(3,3),(3,-3)]
|
||||
, _twMaxRange = 150
|
||||
, _twAccuracy = 30
|
||||
, _itUse = const throwRemoteBomb
|
||||
, _itUse = Right $ const throwRemoteBomb
|
||||
, _itUseModifiers =
|
||||
[ hammerCheckI
|
||||
]
|
||||
@@ -260,7 +260,7 @@ throwRemoteBomb cr w = setLocation
|
||||
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
|
||||
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank
|
||||
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
|
||||
$ \_ -> explodeRemoteBomb itid i
|
||||
$ Right $ \_ -> explodeRemoteBomb itid i
|
||||
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||
p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||
| otherwise = p'
|
||||
@@ -277,7 +277,7 @@ explodeRemoteBomb :: Int -> Int -> Creature -> World -> World
|
||||
explodeRemoteBomb itid pjid cr w
|
||||
= set (props . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid)
|
||||
-- $ set (props . ix pjid . pjDraw) (\_ -> blank)
|
||||
$ set (creatures . ix cid . crInv . ix j . itUse) (\_ -> const id)
|
||||
$ set (creatures . ix cid . crInv . ix j . itUse) (Right $ \_ -> const id)
|
||||
$ resetName
|
||||
$ resetPict
|
||||
-- $ resetScope
|
||||
@@ -305,7 +305,7 @@ retireRemoteBomb itid 0 pjid w = w
|
||||
& pointToItem (_itemPositions w IM.! itid) %~
|
||||
( (itAttachment . scopePos .~ V2 0 0)
|
||||
. (itZoom .~ defaultItZoom)
|
||||
. (itUse .~ const throwRemoteBomb)
|
||||
. (itUse .~ (Right $ const throwRemoteBomb))
|
||||
)
|
||||
& props %~ IM.delete pjid
|
||||
retireRemoteBomb itid t pjid w = setScope w
|
||||
|
||||
@@ -43,7 +43,7 @@ launcher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _itUse = aRocketWithItemParams
|
||||
, _itUse = Right aRocketWithItemParams
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
@@ -244,7 +244,7 @@ remoteLauncher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 10
|
||||
, _itUseTime = 0
|
||||
, _itUse = const fireRemoteLauncher
|
||||
, _itUse = Right $ const fireRemoteLauncher
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
@@ -287,7 +287,7 @@ fireRemoteLauncher cr w = setLocation
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
|
||||
$ \_ _ -> explodeRemoteRocket itid i
|
||||
$ Right $ \_ _ -> explodeRemoteRocket itid i
|
||||
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
|
||||
setLocation :: World -> World
|
||||
setLocation w' = case maybeitid of
|
||||
@@ -347,7 +347,7 @@ explodeRemoteRocket
|
||||
explodeRemoteRocket itid pjid w
|
||||
= set (props . ix pjid . pjUpdate) (\_ -> retireRemoteRocket itid 30 pjid)
|
||||
$ set (props . ix pjid . prDraw) (const mempty)
|
||||
$ set (itPoint . itUse) (\_ _ -> id)
|
||||
$ set (itPoint . itUse) (Right $ \_ _ -> id)
|
||||
$ resetName
|
||||
$ makeExplosionAt (_pjPos (_props w IM.! pjid)) w
|
||||
where
|
||||
@@ -379,7 +379,7 @@ remoteShellPic t
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteRocket itid 0 pjid w =
|
||||
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . scopePos) (V2 0 0)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (const fireRemoteLauncher)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (Right $ const fireRemoteLauncher)
|
||||
(w & props %~ IM.delete pjid)
|
||||
retireRemoteRocket itid t pjid w = setScope w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
|
||||
|
||||
@@ -26,7 +26,7 @@ radar = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 120
|
||||
, _itUseTime = 0
|
||||
, _itUse = const aRadarPulse
|
||||
, _itUse = Right $ const aRadarPulse
|
||||
, _itUseModifiers =
|
||||
[ ammoUseCheckI
|
||||
]
|
||||
@@ -51,7 +51,7 @@ sonar = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 120
|
||||
, _itUseTime = 0
|
||||
, _itUse = const aSonarPulse
|
||||
, _itUse = Right $ const aSonarPulse
|
||||
, _itUseModifiers =
|
||||
[ ammoUseCheckI
|
||||
]
|
||||
|
||||
@@ -21,7 +21,7 @@ spawnGun cr = defaultGun
|
||||
, _wpReloadTime = 80
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 100
|
||||
, _itUse = \_ -> spawnCrNextTo cr
|
||||
, _itUse = Right $ \_ -> spawnCrNextTo cr
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
|
||||
@@ -40,7 +40,7 @@ poisonSprayer = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = const aGasCloud
|
||||
, _itUse = Right $ const aGasCloud
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, useTimeCheckI
|
||||
@@ -66,7 +66,7 @@ flamer = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> randWalkAngle 0.2 0.01 aFlame
|
||||
, _itUse = Right $ \_ -> randWalkAngle 0.2 0.01 aFlame
|
||||
, _itUseModifiers =
|
||||
[ ammoUseCheckI
|
||||
, withSidePushI 5
|
||||
|
||||
@@ -22,9 +22,8 @@ rewindGun = defaultGun
|
||||
, _itIdentity = Rewinder
|
||||
, _wpMaxAmmo = 0
|
||||
, _wpLoadedAmmo = 0
|
||||
, _itUse = useRewindGun
|
||||
, _itEffect = ItRewindEffect rewindEffect []
|
||||
, _itLeftClickUse = Just $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
|
||||
, _itUse = Left $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
|
||||
}
|
||||
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
rewindEffect _ cr invid w = w & rewindWorlds %~ (take 250 . (w' : ))
|
||||
@@ -57,12 +56,11 @@ shrinkGun = defaultGun
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itAimStance = TwoHandFlat
|
||||
, _itUse = useShrinkGun
|
||||
, _itUse = Left $ \cr invid -> useShrinkGun (_crInv cr IM.! invid) cr
|
||||
, _itUseModifiers =
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
]
|
||||
, _itLeftClickUse = Nothing
|
||||
, _wpSpread = 0.05
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = shrinkGunPic
|
||||
@@ -95,12 +93,11 @@ blinkGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = const blinkAction
|
||||
, _itUse = Left $ hammerCheckL $ shootL aSelfL
|
||||
, _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)]
|
||||
@@ -118,12 +115,12 @@ aSelfL cr _ = blinkAction cr
|
||||
effectGun :: String -> (Creature -> World -> World) -> Item
|
||||
effectGun name eff = defaultGun
|
||||
{ _itName = name ++ "Gun"
|
||||
, _itUse = const eff
|
||||
, _itUse = Right $ const eff
|
||||
}
|
||||
autoEffectGun :: String -> (Creature -> World -> World) -> Item
|
||||
autoEffectGun name eff = defaultAutoGun
|
||||
{ _itName = name ++ "Gun"
|
||||
, _itUse = const eff
|
||||
, _itUse = Right $ const eff
|
||||
}
|
||||
forceFieldGun :: Item
|
||||
forceFieldGun = defaultGun
|
||||
|
||||
Reference in New Issue
Block a user