Push item use delay inside datatype, currently broken

This commit is contained in:
2021-11-27 16:37:30 +00:00
parent 224db733f6
commit 8639b2d428
21 changed files with 162 additions and 177 deletions
+3 -3
View File
@@ -32,8 +32,8 @@ itemEffect
-> World -> World
itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w) itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
itemEffect cr it w = case it ^? itUse of itemEffect cr it w = case it ^? itUse of
Just (RightUse eff) -> foldr ($) eff (_itUseModifiers it) it cr w Just (RightUse {_rUse = eff,_useMods = usemods}) -> foldr ($) eff usemods it cr w
Just (LeftUse _ ) -> w & creatures . ix (_crID cr) . crLeftInvSel ?~ _crInvSel cr Just (LeftUse {}) -> w & creatures . ix (_crID cr) . crLeftInvSel ?~ _crInvSel cr
_ -> w _ -> w
--this is ugly --this is ugly
@@ -42,7 +42,7 @@ useLeftItem cid w = case _crInv cr IM.! crinvsel ^? itUse . lUse of
Just f -> f cr crinvsel w & creatures . ix cid . crLeftInvSel ?~ crinvsel Just f -> f cr crinvsel w & creatures . ix cid . crLeftInvSel ?~ crinvsel
Nothing -> case _crLeftInvSel cr of Nothing -> case _crLeftInvSel cr of
Just invid -> case _itUse $ _crInv cr IM.! invid of Just invid -> case _itUse $ _crInv cr IM.! invid of
LeftUse f -> f cr invid w LeftUse {_lUse = f} -> f cr invid w
_ -> w & creatures . ix cid . crLeftInvSel .~ Nothing _ -> w & creatures . ix cid . crLeftInvSel .~ Nothing
Nothing -> case luse of Nothing -> case luse of
Nothing -> w Nothing -> w
+1 -1
View File
@@ -165,7 +165,7 @@ isFrictionless cr = case cr ^? crStance . carriage of
stepItemUseCooldown :: Creature -> Creature stepItemUseCooldown :: Creature -> Creature
stepItemUseCooldown cr = cr & crInv . ix iSel %~ stepItemUseCooldown cr = cr & crInv . ix iSel %~
(itUseTime %~ decreaseToZero) . (wpCurWarmUp %~ decreaseToZero) (itUse . useDelay . rateTime %~ decreaseToZero) . (wpCurWarmUp %~ decreaseToZero)
where where
iSel = _crInvSel cr iSel = _crInvSel cr
+14 -12
View File
@@ -289,12 +289,23 @@ data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float,
data ItemPos data ItemPos
= InInv { _itCrId :: Int , _itInvId :: Int } = InInv { _itCrId :: Int , _itInvId :: Int }
| OnFloor { _itFlID :: Int } | OnFloor { _itFlID :: Int }
data UseDelay -- should just be Delay
= NoDelay
| DelayRate
{_rateMax :: Int
,_rateTime :: Int
}
data ItemUse data ItemUse
= RightUse = RightUse
{ _rUse :: Item -> Creature -> World -> World { _rUse :: Item -> Creature -> World -> World
, _useDelay :: UseDelay
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _useHammer :: HammerType
} }
| LeftUse | LeftUse
{ _lUse :: Creature -> Int -> World -> World { _lUse :: Creature -> Int -> World -> World
, _itUseDelay :: UseDelay
, _itHammer :: HammerType
} }
| NoUse | NoUse
data ItemAmmo data ItemAmmo
@@ -318,13 +329,9 @@ data Item
, _wpCurWarmUp :: Int , _wpCurWarmUp :: Int
, _wpMaxCoolDown :: Int , _wpMaxCoolDown :: Int
, _wpCurCoolDown :: Int , _wpCurCoolDown :: Int
, _itUseRate :: Int
, _itUseTime :: Int
, _itUse :: ItemUse , _itUse :: ItemUse
, _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _wpSpread :: Float , _wpSpread :: Float
, _wpRange :: Float , _wpRange :: Float
, _itHammer :: HammerPosition
, _itFloorPict :: Item -> SPic , _itFloorPict :: Item -> SPic
, _itAimingSpeed :: Float , _itAimingSpeed :: Float
, _itAimingRange :: Float , _itAimingRange :: Float
@@ -357,7 +364,6 @@ data Item
, _itInvDisplay :: Item -> String , _itInvDisplay :: Item -> String
, _itInvColor :: Color , _itInvColor :: Color
, _itEffect :: ItEffect , _itEffect :: ItEffect
, _itHammer :: HammerPosition
, _itAimStance :: AimStance , _itAimStance :: AimStance
, _itCurseStatus :: CurseStatus , _itCurseStatus :: CurseStatus
, _itDimension :: ItemDimension , _itDimension :: ItemDimension
@@ -389,7 +395,6 @@ data Item
, _itAimZoom :: ItZoom , _itAimZoom :: ItZoom
, _itInvDisplay :: Item -> String , _itInvDisplay :: Item -> String
, _itInvColor :: Color , _itInvColor :: Color
, _itHammer :: HammerPosition
, _itAimStance :: AimStance , _itAimStance :: AimStance
, _itCurseStatus :: CurseStatus , _itCurseStatus :: CurseStatus
, _itDimension :: ItemDimension , _itDimension :: ItemDimension
@@ -402,9 +407,6 @@ data Item
, _twMaxRange :: Float , _twMaxRange :: Float
, _twAccuracy :: Float , _twAccuracy :: Float
, _itUse :: ItemUse , _itUse :: ItemUse
, _itUseRate :: Int
, _itUseTime :: Int
, _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _itAimingSpeed :: Float , _itAimingSpeed :: Float
, _itAimingRange :: Float , _itAimingRange :: Float
, _itZoom :: ItZoom , _itZoom :: ItZoom
@@ -416,7 +418,6 @@ data Item
, _itInvDisplay :: Item -> String , _itInvDisplay :: Item -> String
, _itInvColor :: Color , _itInvColor :: Color
, _itEffect :: ItEffect , _itEffect :: ItEffect
, _itHammer :: HammerPosition
, _itScroll :: Float -> Creature -> Item -> Item , _itScroll :: Float -> Creature -> Item -> Item
, _itAimStance :: AimStance , _itAimStance :: AimStance
, _itCurseStatus :: CurseStatus , _itCurseStatus :: CurseStatus
@@ -892,3 +893,4 @@ makeLenses ''MachineType
makeLenses ''Zone makeLenses ''Zone
makeLenses ''ItemDimension makeLenses ''ItemDimension
makeLenses ''Vocalization makeLenses ''Vocalization
makeLenses ''UseDelay
+3 -3
View File
@@ -137,7 +137,6 @@ defaultEquipment = Equipment
, _itFloorPict = \_ -> (,) emptySH $ setLayer 0 $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)] , _itFloorPict = \_ -> (,) emptySH $ setLayer 0 $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \_ _ -> (,) emptySH blank , _itEquipPict = \_ _ -> (,) emptySH blank
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itHammer = HammerUp
, _itID = Nothing , _itID = Nothing
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
@@ -164,7 +163,6 @@ defaultConsumable = Consumable
, _itInvColor = blue , _itInvColor = blue
, _itInvDisplay = \it -> _itName it ++ " x" ++ show (_itAmount it) , _itInvDisplay = \it -> _itName it ++ " x" ++ show (_itAmount it)
, _itEffect = wpRecock , _itEffect = wpRecock
, _itHammer = HammerUp
, _itAimStance = LeaveHolstered , _itAimStance = LeaveHolstered
, _itDimension = defaultItemDimension , _itDimension = defaultItemDimension
} }
@@ -214,7 +212,6 @@ defaultIt = Consumable
, _itInvDisplay = _itName , _itInvDisplay = _itName
, _itInvColor = blue , _itInvColor = blue
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itHammer = HammerUp
, _itAimStance = LeaveHolstered , _itAimStance = LeaveHolstered
} }
defaultMachine :: Machine defaultMachine :: Machine
@@ -305,3 +302,6 @@ defaultTLS = TLS
f _ t f _ t
| _tlsTime t <= 0 = Nothing | _tlsTime t <= 0 = Nothing
| otherwise = Just $ t & tlsTime -~ 1 | otherwise = Just $ t & tlsTime -~ 1
upHammer :: HammerType
upHammer = HasHammer HammerUp
+49 -5
View File
@@ -20,6 +20,54 @@ defaultAmmo = LoadableAmmo
, _wpReloadType = ActiveReload , _wpReloadType = ActiveReload
} }
ruseRate :: Int
-> (Item -> Creature -> World -> World)
-> HammerType
-> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
-> ItemUse
ruseRate i f ht usemods = RightUse
{ _rUse = f
, _useDelay = DelayRate
{ _rateMax = i
, _rateTime = 0
}
, _useMods = usemods
, _useHammer = ht
}
ruseInstant
:: (Item -> Creature -> World -> World)
-> HammerType
-> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
-> ItemUse
ruseInstant f ht usemods = RightUse
{ _rUse = f
, _useDelay = NoDelay
, _useMods = usemods
, _useHammer = ht
}
defaultrUse :: ItemUse
defaultrUse = RightUse
{ _rUse = \_ _ -> id
, _useDelay = DelayRate {_rateMax = 8, _rateTime = 0}
, _useMods = []
, _useHammer = HasHammer HammerUp
}
defaultlUse :: ItemUse
defaultlUse = LeftUse
{ _lUse = \_ _ -> id
, _itUseDelay = DelayRate {_rateMax = 8, _rateTime = 0}
, _itHammer = NoHammer
}
luseInstantNoH :: (Creature -> Int -> World -> World) -> ItemUse
luseInstantNoH f = LeftUse
{ _lUse = f
, _itUseDelay = NoDelay
, _itHammer = NoHammer
}
defaultGun :: Item defaultGun :: Item
defaultGun = Weapon defaultGun = Weapon
{ _itName = "default" { _itName = "default"
@@ -30,13 +78,9 @@ defaultGun = Weapon
, _wpCurWarmUp = 0 , _wpCurWarmUp = 0
, _wpMaxCoolDown = 0 , _wpMaxCoolDown = 0
, _wpCurCoolDown = 0 , _wpCurCoolDown = 0
, _itUseRate = 8 , _itUse = defaultrUse
, _itUseTime = 0
, _itUse = RightUse $ \_ _ -> id
, _itUseModifiers = []
, _wpSpread = 0.02 , _wpSpread = 0.02
, _wpRange = 20 , _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = const $ noPic $ colorSH green (prismPoly , _itFloorPict = const $ noPic $ colorSH green (prismPoly
(map (addZ 3) $ rectNESW 3 3 (-3) (-3)) (map (addZ 3) $ rectNESW 3 3 (-3) (-3))
(map (addZ 0) $ rectNESW 5 3 (-5) (-7)) (map (addZ 0) $ rectNESW 5 3 (-5) (-7))
-2
View File
@@ -17,7 +17,6 @@ keyToken n = defaultEquipment
, _itFloorPict = \_ -> (,) emptySH $ setDepth 0.5 keyPic , _itFloorPict = \_ -> (,) emptySH $ setDepth 0.5 keyPic
, _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itHammer = HammerUp
, _itID = Nothing , _itID = Nothing
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
@@ -41,7 +40,6 @@ latchkey n = defaultEquipment
, _itFloorPict = \_ -> (,) emptySH $ setDepth 0.5 latchkeyPic , _itFloorPict = \_ -> (,) emptySH $ setDepth 0.5 latchkeyPic
, _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) latchkeyPic , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) latchkeyPic
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itHammer = HammerUp
, _itID = Nothing , _itID = Nothing
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
+9 -3
View File
@@ -1,11 +1,16 @@
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
module Dodge.Item.Data {-# LANGUAGE TemplateHaskell #-}
where module Dodge.Item.Data where
import Control.Lens
data HammerType
= NoHammer
| HasHammer {_hammerPosition :: HammerPosition}
deriving
(Eq, Ord, Show)
data HammerPosition data HammerPosition
= HammerDown = HammerDown
| HammerReleased | HammerReleased
| HammerUp | HammerUp
| NoHammer
deriving deriving
(Eq, Ord, Show) (Eq, Ord, Show)
data ItemIdentity data ItemIdentity
@@ -49,3 +54,4 @@ data AimStance
| LeaveHolstered | LeaveHolstered
deriving deriving
(Eq,Show,Ord,Enum) (Eq,Show,Ord,Enum)
makeLenses ''HammerType
+16 -3
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Weapon.AmmoParams module Dodge.Item.Weapon.AmmoParams
( useAmmoParams ( useAmmoParams
, useAmmoParamsRate
, loadedAmmo , loadedAmmo
, useAmmoParamsVelMod , useAmmoParamsVelMod
, fractionLoadedAmmo , fractionLoadedAmmo
@@ -11,9 +12,21 @@ import Geometry
import Control.Lens import Control.Lens
useAmmoParams :: ItemUse useAmmoParamsRate :: Int
useAmmoParams = RightUse $ \it -> let b = _aoType $ _wpAmmo it -> HammerType
in withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b) -> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
-> ItemUse
useAmmoParamsRate rate ht usemods = RightUse
{ _rUse = useAmmoParams
, _useDelay = DelayRate {_rateMax = rate,_rateTime = 0}
, _useMods = usemods
, _useHammer = ht
}
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
b = _aoType $ _wpAmmo it
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b) useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
+3 -12
View File
@@ -42,11 +42,8 @@ teslaGun = defaultGun
, _wpLoadedAmmo = 200 , _wpLoadedAmmo = 200
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 0
, _itAimStance = TwoHandFlat , _itAimStance = TwoHandFlat
, _itUseTime = 0 , _itUse = ruseInstant (const aTeslaArc) NoHammer
, _itUse = RightUse $ const aTeslaArc
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withTempLight 1 100 (V3 0 0 1) , withTempLight 1 100 (V3 0 0 1)
@@ -77,10 +74,7 @@ lasGun = defaultAutoGun
, _wpLoadedAmmo = 200 , _wpLoadedAmmo = 200
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 0 , _itUse = ruseInstant (const aLaser) NoHammer
, _itUseTime = 0
, _itUse = RightUse $ const aLaser
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withTempLight 1 100 (V3 1 1 0) , withTempLight 1 100 (V3 1 1 0)
@@ -118,10 +112,7 @@ tractorGun = defaultAutoGun
, _wpLoadedAmmo = 10000 , _wpLoadedAmmo = 10000
, _wpReloadTime = 40 , _wpReloadTime = 40
} }
, _itUseRate = 0 , _itUse = ruseInstant aTractorBeam NoHammer
, _itUseTime = 0
, _itUse = RightUse aTractorBeam
, _itUseModifiers =
[ ammoUseCheckI [ ammoUseCheckI
] ]
, _wpSpread = 0.00001 , _wpSpread = 0.00001
+2 -4
View File
@@ -23,8 +23,8 @@ import Control.Monad.State
bezierGun :: Item bezierGun :: Item
bezierGun = defaultGun bezierGun = defaultGun
{ _itName = "B-GUN" { _itName = "B-GUN"
, _itUse = RightUse $ \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point , _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
, _itUseModifiers = NoHammer
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundStart tap2S , withSoundStart tap2S
@@ -36,14 +36,12 @@ bezierGun = defaultGun
, _itFloorPict = bezierGunSPic , _itFloorPict = bezierGunSPic
, _itAttachment = NoItAttachment , _itAttachment = NoItAttachment
, _itScroll = \_ _ -> removeItTarget , _itScroll = \_ _ -> removeItTarget
, _itHammer = HammerUp
, _itEffect = rbSetTarget , _itEffect = rbSetTarget
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimingRange = 0 , _itAimingRange = 0
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 50 { _wpMaxAmmo = 50
} }
, _itUseRate = 6
, _itAimStance = TwoHandTwist , _itAimStance = TwoHandTwist
} }
bezierGunSPic :: Item -> SPic bezierGunSPic :: Item -> SPic
+1 -3
View File
@@ -118,9 +118,7 @@ boosterGun = defaultGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 20 , _wpReloadTime = 20
} }
, _itUseRate = 0 , _itUse = luseInstantNoH $ boostSelfL 10
, _itUseTime = 0
, _itUse = LeftUse $ boostSelfL 10
, _wpSpread = 0.05 , _wpSpread = 0.05
, _wpRange = 20 , _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)] , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
+8 -33
View File
@@ -41,10 +41,7 @@ autoGun = defaultAutoGun
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 5 , _itUse = useAmmoParamsRate 5 NoHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, charFiringStratI , charFiringStratI
[('S', hammerCheckI) [('S', hammerCheckI)
@@ -93,10 +90,7 @@ pistol = defaultGun
, _wpLoadedAmmo = 15 , _wpLoadedAmmo = 15
, _wpReloadTime = 40 , _wpReloadTime = 40
} }
, _itUseRate = 8 , _itUse = useAmmoParamsRate 8 upHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
@@ -142,10 +136,7 @@ hvAutoGun = defaultAutoGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 200 , _wpReloadTime = 200
} }
, _itUseRate = 25 , _itUse = useAmmoParamsRate 25 NoHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2) , rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
, withSoundStart bangEchoS , withSoundStart bangEchoS
@@ -178,10 +169,7 @@ ltAutoGun = defaultAutoGun
, _wpLoadedAmmo = 25 , _wpLoadedAmmo = 25
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 3 , _itUse = useAmmoParamsRate 3 NoHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundStart tap1S , withSoundStart tap1S
@@ -221,10 +209,7 @@ miniGun = defaultAutoGun
, _wpReloadTime = 200 , _wpReloadTime = 200
} }
, _wpMaxWarmUp = 100 , _wpMaxWarmUp = 100
, _itUseRate = 0 , _itUse = ruseInstant (useAmmoParamsVelMod vm4) NoHammer
, _itUseTime = 0
, _itUse = RightUse $ useAmmoParamsVelMod vm4
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, withWarmUpI crankSlowS , withWarmUpI crankSlowS
, useTimeCheckI , useTimeCheckI
@@ -312,11 +297,7 @@ spreadGun = defaultGun
, _wpLoadedAmmo = 5 , _wpLoadedAmmo = 5
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 20 , _itUse = useAmmoParamsRate 20 upHammer
, _itUseTime = 0
--, _itUse = \_ -> spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
@@ -351,10 +332,7 @@ multGun = defaultGun
, _wpLoadedAmmo = 2 , _wpLoadedAmmo = 2
, _wpReloadTime = 40 , _wpReloadTime = 40
} }
, _itUseRate = 20 , _itUse = useAmmoParamsRate 20 upHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
@@ -400,10 +378,7 @@ longGun = defaultGun
, _wpReloadTime = 100 , _wpReloadTime = 100
, _wpReloadType = PassiveReload skwareFadeTwoSecS , _wpReloadType = PassiveReload skwareFadeTwoSecS
} }
, _itUseRate = 100 , _itUse = useAmmoParamsRate 100 upHammer
, _itUseTime = 0
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
+2 -5
View File
@@ -1,6 +1,7 @@
module Dodge.Item.Weapon.Drone where module Dodge.Item.Weapon.Drone where
import Dodge.Data import Dodge.Data
import Dodge.Default.Weapon import Dodge.Default.Weapon
import Dodge.Default
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Geometry import Geometry
@@ -28,10 +29,7 @@ lasDrones = defaultGun
, _wpLoadedAmmo = 2 , _wpLoadedAmmo = 2
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 20 , _itUse = ruseRate 20 aDroneWithItemParams upHammer
, _itUseTime = 0
, _itUse = RightUse aDroneWithItemParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundStart tap4S , withSoundStart tap4S
@@ -42,7 +40,6 @@ lasDrones = defaultGun
, _itFloorPict = lasDronesPic , _itFloorPict = lasDronesPic
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 0.5 , _itAimingRange = 0.5
, _itHammer = NoHammer
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itAimStance = TwoHandTwist , _itAimStance = TwoHandTwist
} }
+2 -3
View File
@@ -38,8 +38,7 @@ wpRecock = ItInvEffect
moveHammerUp HammerDown = HammerReleased moveHammerUp HammerDown = HammerReleased
moveHammerUp HammerReleased = HammerUp moveHammerUp HammerReleased = HammerUp
moveHammerUp HammerUp = HammerUp moveHammerUp HammerUp = HammerUp
moveHammerUp NoHammer = NoHammer fOnIt it = it & itUse . itHammer . hammerPosition %~ moveHammerUp
fOnIt it = it & itHammer %~ moveHammerUp
--{- | --{- |
--Special recock for the bezier gun. --Special recock for the bezier gun.
--Not sure of its purpose at this time... -} --Not sure of its purpose at this time... -}
@@ -66,7 +65,7 @@ itemLaserScopeEffect
f _ cr invid w f _ cr invid w
| invid == _crInvSel cr && crIsAiming' cr = w | invid == _crInvSel cr && crIsAiming' cr = w
& particles %~ (:) (makeLaserScope sp ep reloadFrac) & particles %~ (:) (makeLaserScope sp ep reloadFrac)
& creatures . ix (_crID cr) . crInv . ix invid . itHammer %~ moveHammerUp & creatures . ix (_crID cr) . crInv . ix invid . itUse . itHammer . hammerPosition %~ moveHammerUp
| otherwise = w | otherwise = w
where where
p = _crPos cr p = _crPos cr
+8 -14
View File
@@ -34,8 +34,7 @@ grenade = Throwable
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)] , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _twMaxRange = 150 , _twMaxRange = 150
, _twAccuracy = 30 , _twAccuracy = 30
, _itUse = RightUse $ \_ -> throwGrenade makeExplosionAt , _itUse = ruseRate 25 (\_ -> throwGrenade makeExplosionAt) upHammer
, _itUseModifiers =
[ useTimeCheckI [ useTimeCheckI
] ]
, _itAimingSpeed = 1 , _itAimingSpeed = 1
@@ -44,13 +43,10 @@ grenade = Throwable
, _itAimZoom = defaultItZoom {_itZoomMax = f fuseTime, _itZoomMin = f fuseTime} , _itAimZoom = defaultItZoom {_itZoomMax = f fuseTime, _itZoomMin = f fuseTime}
, _itEquipPict = pictureWeaponOnAim' $ \_ -> grenadePic fuseTime , _itEquipPict = pictureWeaponOnAim' $ \_ -> grenadePic fuseTime
, _itID = Nothing , _itID = Nothing
, _itUseRate = 25
, _itUseTime = 0
, _itAttachment = ItFuse fuseTime , _itAttachment = ItFuse fuseTime
, _itInvColor = white , _itInvColor = white
, _itInvDisplay = basicWeaponDisplay , _itInvDisplay = basicWeaponDisplay
, _itEffect = wpRecock , _itEffect = wpRecock
, _itHammer = HammerUp
, _itScroll = changeFuse , _itScroll = changeFuse
, _itAimStance = OneHand , _itAimStance = OneHand
} }
@@ -133,7 +129,7 @@ throwArmReset x = ItInvEffect {_itInvEffect = f ,_itEffectCounter = x }
f _ cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i f _ cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
counterDown it counterDown it
| _itEffectCounter (_itEffect it) == 0 = it | _itEffectCounter (_itEffect it) == 0 = it
& itHammer .~ HammerUp & itUse . itHammer . hammerPosition .~ HammerUp
& itEquipPict .~ pictureWeaponOnAim' (\_ -> grenadePic 50) & itEquipPict .~ pictureWeaponOnAim' (\_ -> grenadePic 50)
| otherwise = it & itEffect . itEffectCounter -~ 1 | otherwise = it & itEffect . itEffectCounter -~ 1
@@ -227,10 +223,8 @@ remoteBomb = defaultThrowable
[(-3,-3),(-3,3),(3,3),(3,-3)] [(-3,-3),(-3,3),(3,3),(3,-3)]
, _twMaxRange = 150 , _twMaxRange = 150
, _twAccuracy = 30 , _twAccuracy = 30
, _itUse = RightUse $ const throwRemoteBomb , _itUse = ruseRate 25 (const throwRemoteBomb) upHammer
, _itUseModifiers = [ hammerCheckI ]
[ hammerCheckI
]
, _itAttachment = ItScope (V2 0 0) 0 1 True , _itAttachment = ItScope (V2 0 0) 0 1 True
, _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH remoteBombUnarmedPic , _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH remoteBombUnarmedPic
} }
@@ -259,8 +253,8 @@ throwRemoteBomb cr w = setLocation
j = _crInvSel cr j = _crInvSel cr
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE" resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank
resetFire = set (creatures . ix cid . crInv . ix j . itUse) resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
$ RightUse $ \_ -> explodeRemoteBomb itid i $ \_ -> explodeRemoteBomb itid i
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0) 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) p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
| otherwise = p' | otherwise = p'
@@ -277,7 +271,7 @@ explodeRemoteBomb :: Int -> Int -> Creature -> World -> World
explodeRemoteBomb itid pjid cr w explodeRemoteBomb itid pjid cr w
= set (props . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid) = set (props . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid)
-- $ set (props . ix pjid . pjDraw) (\_ -> blank) -- $ set (props . ix pjid . pjDraw) (\_ -> blank)
$ set (creatures . ix cid . crInv . ix j . itUse) (RightUse $ \_ -> const id) $ set (creatures . ix cid . crInv . ix j . itUse . rUse) (\_ -> const id)
$ resetName $ resetName
$ resetPict $ resetPict
-- $ resetScope -- $ resetScope
@@ -305,7 +299,7 @@ retireRemoteBomb itid 0 pjid w = w
& pointToItem (_itemPositions w IM.! itid) %~ & pointToItem (_itemPositions w IM.! itid) %~
( (itAttachment . scopePos .~ V2 0 0) ( (itAttachment . scopePos .~ V2 0 0)
. (itZoom .~ defaultItZoom) . (itZoom .~ defaultItZoom)
. (itUse .~ (RightUse $ const throwRemoteBomb)) . (itUse . rUse .~ const throwRemoteBomb)
) )
& props %~ IM.delete pjid & props %~ IM.delete pjid
retireRemoteBomb itid t pjid w = setScope w retireRemoteBomb itid t pjid w = setScope w
+7 -13
View File
@@ -3,6 +3,7 @@ module Dodge.Item.Weapon.Launcher
, remoteLauncher , remoteLauncher
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Default
import Dodge.Default.Weapon import Dodge.Default.Weapon
import Dodge.Default.Shell import Dodge.Default.Shell
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
@@ -48,10 +49,7 @@ launcher = defaultGun
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 20 , _itUse = ruseRate 20 aRocketWithItemParams upHammer
, _itUseTime = 0
, _itUse = RightUse aRocketWithItemParams
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundStart tap4S , withSoundStart tap4S
@@ -62,7 +60,6 @@ launcher = defaultGun
, _itFloorPict = launcherPic , _itFloorPict = launcherPic
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 0.5 , _itAimingRange = 0.5
, _itHammer = NoHammer
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _itAimStance = TwoHandTwist , _itAimStance = TwoHandTwist
} }
@@ -250,10 +247,7 @@ remoteLauncher = defaultGun
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 10 , _itUse = ruseRate 10 (const fireRemoteLauncher) upHammer
, _itUseTime = 0
, _itUse = RightUse $ const fireRemoteLauncher
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
] ]
@@ -294,8 +288,8 @@ fireRemoteLauncher cr w = setLocation
j = _crInvSel cr j = _crInvSel cr
newitid = IM.newKey $ _itemPositions w newitid = IM.newKey $ _itemPositions w
maybeitid = cr ^? crInv . ix j . itID . _Just maybeitid = cr ^? crInv . ix j . itID . _Just
resetFire = set (creatures . ix cid . crInv . ix j . itUse) resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
$ RightUse $ \_ _ -> explodeRemoteRocket itid i $ \_ _ -> explodeRemoteRocket itid i
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET" resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
setLocation :: World -> World setLocation :: World -> World
setLocation w' = case maybeitid of setLocation w' = case maybeitid of
@@ -355,7 +349,7 @@ explodeRemoteRocket
explodeRemoteRocket itid pjid w explodeRemoteRocket itid pjid w
= set (props . ix pjid . pjUpdate) (\_ -> retireRemoteRocket itid 30 pjid) = set (props . ix pjid . pjUpdate) (\_ -> retireRemoteRocket itid 30 pjid)
$ set (props . ix pjid . prDraw) (const mempty) $ set (props . ix pjid . prDraw) (const mempty)
$ set (itPoint . itUse) (RightUse $ \_ _ -> id) $ set (itPoint . itUse . rUse) (\_ _ -> id)
$ resetName $ resetName
$ makeExplosionAt (_pjPos (_props w IM.! pjid)) w $ makeExplosionAt (_pjPos (_props w IM.! pjid)) w
where where
@@ -387,7 +381,7 @@ remoteShellPic t
retireRemoteRocket :: Int -> Int -> Int -> World -> World retireRemoteRocket :: Int -> Int -> Int -> World -> World
retireRemoteRocket itid 0 pjid w = retireRemoteRocket itid 0 pjid w =
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . scopePos) (V2 0 0) set (pointToItem (_itemPositions w IM.! itid) . itAttachment . scopePos) (V2 0 0)
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (RightUse $ const fireRemoteLauncher) $ set (pointToItem (_itemPositions w IM.! itid) . itUse . rUse) (const fireRemoteLauncher)
(w & props %~ IM.delete pjid) (w & props %~ IM.delete pjid)
retireRemoteRocket itid t pjid w = setScope w retireRemoteRocket itid t pjid w = setScope w
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid) & props . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
+2 -10
View File
@@ -25,15 +25,11 @@ radar = defaultGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 200 , _wpReloadTime = 200
} }
, _itUseRate = 120 , _itUse = ruseRate 120 (const aRadarPulse) upHammer
, _itUseTime = 0
, _itUse = RightUse $ const aRadarPulse
, _itUseModifiers =
[ ammoUseCheckI [ ammoUseCheckI
] ]
, _wpSpread = autogunSpread , _wpSpread = autogunSpread
, _wpRange = 20 , _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5) , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom { _itZoomMax = 1} , _itZoom = defaultItZoom { _itZoomMax = 1}
@@ -51,14 +47,10 @@ sonar = defaultGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 200 , _wpReloadTime = 200
} }
, _itUseRate = 120 , _itUse = ruseRate 120 (const aSonarPulse) upHammer
, _itUseTime = 0
, _itUse = RightUse $ const aSonarPulse
, _itUseModifiers =
[ ammoUseCheckI [ ammoUseCheckI
] ]
, _wpRange = 20 , _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5) , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom {_itZoomMax = 1} , _itZoom = defaultItZoom {_itZoomMax = 1}
+4 -3
View File
@@ -3,6 +3,7 @@ import Dodge.Data
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
--import Dodge.Item.Weapon.Remote --import Dodge.Item.Weapon.Remote
import Dodge.Default.Weapon import Dodge.Default.Weapon
import Dodge.Default
--import Dodge.Item.Weapon.Grenade --import Dodge.Item.Weapon.Grenade
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -21,9 +22,9 @@ spawnGun cr = defaultGun
, _wpLoadedAmmo = 1 , _wpLoadedAmmo = 1
, _wpReloadTime = 80 , _wpReloadTime = 80
} }
, _itUseRate = 100 , _itUse = ruseRate 100
, _itUse = RightUse $ \_ -> spawnCrNextTo cr (\_ -> spawnCrNextTo cr)
, _itUseModifiers = upHammer
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
] ]
+2 -8
View File
@@ -39,10 +39,7 @@ poisonSprayer = defaultAutoGun
, _wpLoadedAmmo = 500 , _wpLoadedAmmo = 500
, _wpReloadTime = 100 , _wpReloadTime = 100
} }
, _itUseRate = 0 , _itUse = ruseInstant (const aGasCloud) NoHammer
, _itUseTime = 0
, _itUse = RightUse $ const aGasCloud
, _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundForI foamSprayLoopS 5 , withSoundForI foamSprayLoopS 5
@@ -66,10 +63,7 @@ flamer = defaultAutoGun
, _wpLoadedAmmo = 250 , _wpLoadedAmmo = 250
, _wpReloadTime = 100 , _wpReloadTime = 100
} }
, _itUseRate = 0 , _itUse = ruseInstant (\_ -> randWalkAngle 0.2 0.01 aFlame) NoHammer
, _itUseTime = 0
, _itUse = RightUse $ \_ -> randWalkAngle 0.2 0.01 aFlame
, _itUseModifiers =
[ ammoUseCheckI [ ammoUseCheckI
, withSidePushI 5 , withSidePushI 5
--, withTempLight 1 100 (V3 1 0 0) --, withTempLight 1 100 (V3 1 0 0)
+21 -18
View File
@@ -110,23 +110,23 @@ rateIncABI
-> ChainEffect -> ChainEffect
rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
| repeatFire = w | repeatFire = w
& pointItem %~ ( (itUseRate .~ max fastRate (currentRate - 1)) & pointItem %~ ( (itUse . useDelay . rateMax .~ max fastRate (currentRate - 1))
. (wpAmmo . wpLoadedAmmo -~ 1) . (wpAmmo . wpLoadedAmmo -~ 1)
. (itUseTime .~ currentRate) ) . (itUse . useDelay . rateTime .~ currentRate) )
& exeffCont eff item cr & exeffCont eff item cr
| firstFire = w | firstFire = w
& pointItem %~ ( (itUseRate .~ startRate - 1) & pointItem %~ ( (itUse . useDelay . rateMax .~ startRate - 1)
. (wpAmmo . wpLoadedAmmo -~ 1) . (wpAmmo . wpLoadedAmmo -~ 1)
. (itUseTime .~ startRate) ) . (itUse . useDelay . rateTime .~ startRate) )
& exeffFirst eff item cr & exeffFirst eff item cr
| otherwise = w | otherwise = w
where where
cid = _crID cr cid = _crID cr
itRef = _crInvSel cr itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _itUseRate item currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 1 repeatFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 0 firstFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 0
{- | Apply effect after a warm up. -} {- | Apply effect after a warm up. -}
withWarmUpI withWarmUpI
:: SoundID -- ^ warm up sound id :: SoundID -- ^ warm up sound id
@@ -221,26 +221,28 @@ useAmmo amAmount eff item cr = eff item cr
{- | {- |
Applies a world effect after an item use cooldown check. -} Applies a world effect after an item use cooldown check. -}
useTimeCheckI :: ChainEffect useTimeCheckI :: ChainEffect
useTimeCheckI f item cr w = case item ^? itUseTime of useTimeCheckI f item cr w = case item ^? itUse . useDelay . rateTime of
Just 0 -> f item cr $ setUseTime w Just 0 -> f item cr $ setUseTime w
_ -> w _ -> w
where where
cid = _crID cr cid = _crID cr
setUseTime = creatures . ix cid . crInv . ix (_crInvSel cr) . itUseTime +~ useRate setUseTime = creatures . ix cid . crInv . ix (_crInvSel cr) . itUse . useDelay . rateTime +~ userate
useRate = fromMaybe 0 $ item ^? itUseRate userate = fromMaybe 0 $ item ^? itUse . useDelay . rateMax
{- | Applies a world effect after a hammer position check. -} {- | Applies a world effect after a hammer position check. -}
hammerCheckI :: ChainEffect hammerCheckI :: ChainEffect
hammerCheckI f it cr w = case it ^? itHammer of hammerCheckI f it cr w = case it ^? itUse . itHammer . hammerPosition of
Just HammerUp -> f it cr $ setHammerDown w Just HammerUp -> f it cr $ setHammerDown w
_ -> setHammerDown w _ -> setHammerDown w
where where
cid = _crID cr cid = _crID cr
setHammerDown = creatures . ix cid . crInv . ix (_crInvSel cr) . itHammer .~ HammerDown setHammerDown = creatures . ix cid . crInv . ix (_crInvSel cr) . itUse
. itHammer . hammerPosition .~ HammerDown
{- | Applies a world effect after an ammo check. -} {- | Applies a world effect after an ammo check. -}
ammoUseCheckI :: ChainEffect ammoUseCheckI :: ChainEffect
ammoUseCheckI f item cr w ammoUseCheckI f item cr w
| fireCondition = f item cr w & pointerToItem %~ | fireCondition = f item cr w & pointerToItem %~
( (wpAmmo . wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) ) ( (wpAmmo . wpLoadedAmmo -~ 1)
. (itUse . useDelay . rateTime .~ _rateMax ( _useDelay (_itUse item)) ))
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w | otherwise = w
where where
@@ -248,7 +250,7 @@ ammoUseCheckI f item cr w
itRef = _crInvSel cr itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _wpReloadState (_wpAmmo item) == 0 fireCondition = _wpReloadState (_wpAmmo item) == 0
&& _itUseTime item == 0 && _rateTime (_useDelay (_itUse item)) == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0 && _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
{- | Applies a world effect after a hammer position check. {- | Applies a world effect after a hammer position check.
@@ -259,12 +261,12 @@ hammerCheckL
-> Int -> Int
-> World -> World
-> World -> World
hammerCheckL f cr invid w = case (_crInv cr IM.! invid) ^? itHammer of hammerCheckL f cr invid w = case (_crInv cr IM.! invid) ^? itUse . itHammer . hammerPosition of
Just HammerUp -> f cr invid $ setHammerDown w Just HammerUp -> f cr invid $ setHammerDown w
_ -> setHammerDown w _ -> setHammerDown w
where where
cid = _crID cr cid = _crID cr
setHammerDown = creatures . ix cid . crInv . ix invid . itHammer .~ HammerDown setHammerDown = creatures . ix cid . crInv . ix invid . itUse . itHammer . hammerPosition .~ HammerDown
{- | Applies a world effect after an ammo check. {- | Applies a world effect after an ammo check.
Arbitrary inventory position. -} Arbitrary inventory position. -}
shootL shootL
@@ -276,7 +278,8 @@ shootL
-> World -> World
shootL f cr invid w shootL f cr invid w
| fireCondition = f cr invid w & pointerToItem %~ | fireCondition = f cr invid w & pointerToItem %~
( (wpAmmo . wpLoadedAmmo -~ 1) . (itUseTime .~ _itUseRate item) ) ( (wpAmmo . wpLoadedAmmo -~ 1)
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w | otherwise = w
where where
@@ -284,7 +287,7 @@ shootL f cr invid w
item = _crInv cr IM.! invid item = _crInv cr IM.! invid
pointerToItem = creatures . ix cid . crInv . ix invid pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _wpReloadState (_wpAmmo item) == 0 fireCondition = _wpReloadState (_wpAmmo item) == 0
&& _itUseTime item == 0 && _rateTime (_useDelay (_itUse item)) == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0 && _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
withTempLight :: Int -> Float -> V3 Float -> ChainEffect withTempLight :: Int -> Float -> V3 Float -> ChainEffect
+5 -19
View File
@@ -25,7 +25,7 @@ rewindGun = defaultGun
, _wpCharge = 0 , _wpCharge = 0
} }
, _itEffect = ItRewindEffect rewindEffect [] , _itEffect = ItRewindEffect rewindEffect []
, _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr , _itUse = defaultlUse {_lUse = \cr invid -> useRewindGun (_crInv cr IM.! invid) cr}
} }
rewindEffect :: ItEffect -> Creature -> Int -> World -> World rewindEffect :: ItEffect -> Creature -> Int -> World -> World
rewindEffect _ cr invid w rewindEffect _ cr invid w
@@ -60,14 +60,8 @@ shrinkGun = defaultGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 20 , _wpReloadTime = 20
} }
, _itUseRate = 0
, _itUseTime = 0
, _itAimStance = TwoHandFlat , _itAimStance = TwoHandFlat
, _itUse = LeftUse $ \cr invid -> useShrinkGun (_crInv cr IM.! invid) cr , _itUse = defaultlUse {_lUse = \cr invid -> useShrinkGun (_crInv cr IM.! invid) cr}
, _itUseModifiers =
[ ammoCheckI
, hammerCheckI
]
, _wpSpread = 0.05 , _wpSpread = 0.05
, _wpRange = 20 , _wpRange = 20
, _itFloorPict = shrinkGunPic , _itFloorPict = shrinkGunPic
@@ -99,13 +93,7 @@ blinkGun = defaultGun
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
, _wpReloadTime = 20 , _wpReloadTime = 20
} }
, _itUseRate = 0 , _itUse = defaultlUse {_lUse = hammerCheckL $ shootL aSelfL}
, _itUseTime = 0
, _itUse = LeftUse $ hammerCheckL $ shootL aSelfL
, _itUseModifiers =
[ ammoCheckI
, hammerCheckI
]
, _wpSpread = 0.05 , _wpSpread = 0.05
, _wpRange = 20 , _wpRange = 20
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2[(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)] , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2[(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
@@ -123,12 +111,12 @@ aSelfL cr _ = blinkAction cr
effectGun :: String -> (Creature -> World -> World) -> Item effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun effectGun name eff = defaultGun
{ _itName = name ++ "Gun" { _itName = name ++ "Gun"
, _itUse = RightUse $ const eff , _itUse = defaultrUse {_rUse = const eff}
} }
autoEffectGun :: String -> (Creature -> World -> World) -> Item autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultAutoGun autoEffectGun name eff = defaultAutoGun
{ _itName = name ++ "Gun" { _itName = name ++ "Gun"
, _itUse = RightUse $ const eff , _itUse = defaultrUse {_rUse = const eff}
} }
forceFieldGun :: Item forceFieldGun :: Item
forceFieldGun = defaultGun forceFieldGun = defaultGun
@@ -140,8 +128,6 @@ forceFieldGun = defaultGun
, _wpReloadTime = 40 , _wpReloadTime = 40
, _wpReloadState = 0 , _wpReloadState = 0
} }
, _itUseRate = 10
, _itUseTime = 0
, _itUse = undefined , _itUse = undefined
, _wpSpread = 0.02 , _wpSpread = 0.02
, _wpRange = 20 , _wpRange = 20