Move item parameters into a more sensible place
This commit is contained in:
+19
-1
@@ -344,7 +344,7 @@ data Item
|
|||||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
||||||
, _itDimension :: ItemDimension
|
, _itDimension :: ItemDimension
|
||||||
, _itCurseStatus :: CurseStatus
|
, _itCurseStatus :: CurseStatus
|
||||||
, _itType :: ItemType
|
, _itParams :: ItemParams
|
||||||
}
|
}
|
||||||
| Consumable
|
| Consumable
|
||||||
{ _itName :: String
|
{ _itName :: String
|
||||||
@@ -516,6 +516,23 @@ data AmmoType
|
|||||||
| DroneAmmo
|
| DroneAmmo
|
||||||
{ _amString :: String }
|
{ _amString :: String }
|
||||||
| GenericAmmo
|
| GenericAmmo
|
||||||
|
data ItemParams
|
||||||
|
= UtilityItem
|
||||||
|
| NoParams
|
||||||
|
| ShellLauncher
|
||||||
|
{ _launchParams :: [PjParam]
|
||||||
|
}
|
||||||
|
| MultiBarrel
|
||||||
|
{ _barrelSpread :: BarrelSpread
|
||||||
|
, _barrelNum :: Int
|
||||||
|
}
|
||||||
|
| SingleBarrel
|
||||||
|
{_inaccuracy :: Float}
|
||||||
|
| AngleWalk
|
||||||
|
{ _maxWalkAngle :: Float
|
||||||
|
, _currentWalkAngle :: Float
|
||||||
|
, _walkSpeed :: Float
|
||||||
|
}
|
||||||
data PjParam = PjParam
|
data PjParam = PjParam
|
||||||
{ _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World
|
{ _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World
|
||||||
, _pjIntParam :: Int
|
, _pjIntParam :: Int
|
||||||
@@ -877,3 +894,4 @@ makeLenses ''ItemDimension
|
|||||||
makeLenses ''Vocalization
|
makeLenses ''Vocalization
|
||||||
makeLenses ''Universe
|
makeLenses ''Universe
|
||||||
makeLenses ''LSParam
|
makeLenses ''LSParam
|
||||||
|
makeLenses ''ItemParams
|
||||||
|
|||||||
@@ -99,11 +99,7 @@ defaultGun = Weapon
|
|||||||
, _itInvDisplay = basicWeaponDisplay
|
, _itInvDisplay = basicWeaponDisplay
|
||||||
, _itInvColor = white
|
, _itInvColor = white
|
||||||
, _itTargeting = Nothing
|
, _itTargeting = Nothing
|
||||||
, _itType = Weapon'
|
, _itParams = NoParams
|
||||||
{ _wpSpread = 0.02
|
|
||||||
, _wpRange = 20
|
|
||||||
, _wpNumBarrels = 1
|
|
||||||
}
|
|
||||||
, _itDimension = defaultItemDimension
|
, _itDimension = defaultItemDimension
|
||||||
}
|
}
|
||||||
defaultItemDimension :: ItemDimension
|
defaultItemDimension :: ItemDimension
|
||||||
|
|||||||
@@ -82,16 +82,12 @@ data UseDelay -- should just be Delay
|
|||||||
{_warmTime :: Int
|
{_warmTime :: Int
|
||||||
,_warmMax :: Int
|
,_warmMax :: Int
|
||||||
}
|
}
|
||||||
data ItemType
|
data BarrelSpread
|
||||||
= Weapon'
|
= AlignedBarrels
|
||||||
{ _wpSpread :: Float
|
| SpreadBarrels {_spreadAngle :: Float}
|
||||||
, _wpRange :: Float
|
| RotatingBarrels {_rotatingBarrelAccuracy :: Float}
|
||||||
, _wpNumBarrels :: Int
|
makeLenses ''BarrelSpread
|
||||||
}
|
|
||||||
| UtilityItem
|
|
||||||
| ConsumableItem
|
|
||||||
makeLenses ''HammerType
|
makeLenses ''HammerType
|
||||||
makeLenses ''ItZoom
|
makeLenses ''ItZoom
|
||||||
makeLenses ''AimParams
|
makeLenses ''AimParams
|
||||||
makeLenses ''UseDelay
|
makeLenses ''UseDelay
|
||||||
makeLenses ''ItemType
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ teslaGun = defaultGun
|
|||||||
& useAim . aimStance .~ TwoHandFlat
|
& useAim . aimStance .~ TwoHandFlat
|
||||||
, _itFloorPict = teslaGunPic
|
, _itFloorPict = teslaGunPic
|
||||||
-- , _itZoom = defaultItZoom
|
-- , _itZoom = defaultItZoom
|
||||||
} & itType . wpSpread .~ 0.001
|
}
|
||||||
teslaGunPic :: Item -> SPic
|
teslaGunPic :: Item -> SPic
|
||||||
teslaGunPic _ = noPic $ colorSH blue $
|
teslaGunPic _ = noPic $ colorSH blue $
|
||||||
upperPrismPoly 5 (rectNESW xb y xa (-y))
|
upperPrismPoly 5 (rectNESW xb y xa (-y))
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ boosterGun = defaultGun
|
|||||||
, _itUse = luseInstantNoH $ boostSelfL 10
|
, _itUse = luseInstantNoH $ boostSelfL 10
|
||||||
, _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)]
|
||||||
, _itEffect = resetAttachmentID
|
, _itEffect = resetAttachmentID
|
||||||
, _itType = UtilityItem
|
|
||||||
}
|
}
|
||||||
resetAttachmentID :: ItEffect
|
resetAttachmentID :: ItEffect
|
||||||
resetAttachmentID = ItInvEffect f 0
|
resetAttachmentID = ItInvEffect f 0
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ autoGun = defaultAutoGun
|
|||||||
, _itAttachment = ItCharMode $ Seq.fromList "MS"
|
, _itAttachment = ItCharMode $ Seq.fromList "MS"
|
||||||
, _itScroll = scrollCharMode
|
, _itScroll = scrollCharMode
|
||||||
, _itInvDisplay = basicWeaponDisplay
|
, _itInvDisplay = basicWeaponDisplay
|
||||||
} & itType . wpSpread .~ autogunSpread
|
, _itParams = SingleBarrel autogunSpread
|
||||||
|
}
|
||||||
autoGunPic :: Item -> SPic
|
autoGunPic :: Item -> SPic
|
||||||
autoGunPic it = noPic $
|
autoGunPic it = noPic $
|
||||||
colorSH red (prismPoly
|
colorSH red (prismPoly
|
||||||
@@ -94,7 +95,7 @@ pistol = defaultGun
|
|||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundStart tap3S
|
, withSoundStart tap3S
|
||||||
, useAmmo 1
|
, useAmmo 1
|
||||||
, randSpreadDir
|
, applyInaccuracy
|
||||||
, withMuzFlareI
|
, withMuzFlareI
|
||||||
]
|
]
|
||||||
, _itFloorPict = pistolPic
|
, _itFloorPict = pistolPic
|
||||||
@@ -104,6 +105,7 @@ pistol = defaultGun
|
|||||||
, _itInvDisplay = basicWeaponDisplay
|
, _itInvDisplay = basicWeaponDisplay
|
||||||
, _itInvColor = white
|
, _itInvColor = white
|
||||||
, _itTargeting = Nothing
|
, _itTargeting = Nothing
|
||||||
|
, _itParams = SingleBarrel 0.05
|
||||||
}
|
}
|
||||||
pistolPic :: Item -> SPic
|
pistolPic :: Item -> SPic
|
||||||
pistolPic it = noPic $ colorSH green (prismPoly
|
pistolPic it = noPic $ colorSH green (prismPoly
|
||||||
@@ -169,16 +171,15 @@ ltAutoGun = defaultAutoGun
|
|||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundStart tap1S
|
, withSoundStart tap1S
|
||||||
, useAmmo 1
|
, useAmmo 1
|
||||||
, withRandomDirI 0.1
|
, applyInaccuracy
|
||||||
, torqueAfterI 0.2
|
, torqueAfterI 0.2
|
||||||
, withSidePushI 50
|
, withSidePushI 50
|
||||||
, modClock 2 withMuzFlareI
|
, modClock 2 withMuzFlareI
|
||||||
]
|
]
|
||||||
, _itFloorPict = ltAutoGunPic
|
, _itFloorPict = ltAutoGunPic
|
||||||
-- , _itZoom = defaultItZoom
|
, _itParams = SingleBarrel 0.1
|
||||||
}
|
}
|
||||||
& itDimension . muzzleLength .~ 10
|
& itDimension . muzzleLength .~ 10
|
||||||
& itType . wpSpread .~ 0.5
|
|
||||||
ltAutoGunPic :: Item -> SPic
|
ltAutoGunPic :: Item -> SPic
|
||||||
ltAutoGunPic it =
|
ltAutoGunPic it =
|
||||||
( colorSH green $ prismPoly
|
( colorSH green $ prismPoly
|
||||||
@@ -298,9 +299,12 @@ spreadGun = defaultGun
|
|||||||
, withMuzFlareI
|
, withMuzFlareI
|
||||||
, spreadNumI
|
, spreadNumI
|
||||||
]
|
]
|
||||||
|
, _itParams = MultiBarrel
|
||||||
|
{_barrelNum = 5
|
||||||
|
,_barrelSpread = SpreadBarrels 0.5
|
||||||
|
}
|
||||||
, _itFloorPict = spreadGunPic
|
, _itFloorPict = spreadGunPic
|
||||||
} & itType . wpSpread .~ spreadGunSpread
|
}
|
||||||
& itType . wpNumBarrels .~ 50
|
|
||||||
spreadGunPic :: Item -> SPic
|
spreadGunPic :: Item -> SPic
|
||||||
spreadGunPic it =
|
spreadGunPic it =
|
||||||
( colorSH green (upperPrismPoly 5 $ map toV2[(-3,0),(3,6),(3,-6)])
|
( colorSH green (upperPrismPoly 5 $ map toV2[(-3,0),(3,6),(3,-6)])
|
||||||
@@ -334,8 +338,11 @@ multGun = defaultGun
|
|||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||||
, _itFloorPict = multGunSPic
|
, _itFloorPict = multGunSPic
|
||||||
-- , _itZoom = defaultItZoom
|
, _itParams = MultiBarrel
|
||||||
} & itType . wpNumBarrels .~ 5
|
{_barrelNum = 5
|
||||||
|
,_barrelSpread = AlignedBarrels
|
||||||
|
}
|
||||||
|
}
|
||||||
multGunSPic :: Item -> SPic
|
multGunSPic :: Item -> SPic
|
||||||
multGunSPic it =
|
multGunSPic it =
|
||||||
( colorSH red (
|
( colorSH red (
|
||||||
@@ -381,7 +388,7 @@ longGun = defaultGun
|
|||||||
, _itScroll = zoomLongGun
|
, _itScroll = zoomLongGun
|
||||||
, _itAttachment = ItScope (V2 0 0) 0 1 False
|
, _itAttachment = ItScope (V2 0 0) 0 1 False
|
||||||
, _itEffect = itemLaserScopeEffect
|
, _itEffect = itemLaserScopeEffect
|
||||||
} & itType . wpRange .~ 200
|
}
|
||||||
longGunSPic :: Item -> SPic
|
longGunSPic :: Item -> SPic
|
||||||
longGunSPic _ =
|
longGunSPic _ =
|
||||||
( colorSH orange $ upperPrismPoly 5 $ rectWH 12 2
|
( colorSH orange $ upperPrismPoly 5 $ rectWH 12 2
|
||||||
|
|||||||
@@ -48,13 +48,10 @@ poisonSprayer = defaultAutoGun
|
|||||||
& useAim . aimSpeed .~ 0.2
|
& useAim . aimSpeed .~ 0.2
|
||||||
& useAim . aimRange .~ 0
|
& useAim . aimRange .~ 0
|
||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
, _itType = Weapon'
|
, _itParams = MultiBarrel {_barrelSpread = SpreadBarrels 0.2
|
||||||
{ _wpRange = 8
|
, _barrelNum = 3
|
||||||
, _wpSpread = 0.1
|
|
||||||
, _wpNumBarrels = 3
|
|
||||||
}
|
}
|
||||||
, _itFloorPict = flamerPic
|
, _itFloorPict = flamerPic
|
||||||
-- , _itZoom = defaultItZoom
|
|
||||||
}
|
}
|
||||||
flamer :: Item
|
flamer :: Item
|
||||||
flamer = defaultAutoGun
|
flamer = defaultAutoGun
|
||||||
@@ -65,7 +62,7 @@ flamer = defaultAutoGun
|
|||||||
, _wpLoadedAmmo = 250
|
, _wpLoadedAmmo = 250
|
||||||
, _wpReloadTime = 100
|
, _wpReloadTime = 100
|
||||||
}
|
}
|
||||||
, _itUse = ruseInstant (\_ -> randWalkAngle 0.2 0.01 aFlame) NoHammer
|
, _itUse = ruseInstant (\_ -> randWalkAngle aFlame) NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, useAmmo 1
|
, useAmmo 1
|
||||||
, withSidePushI 5
|
, withSidePushI 5
|
||||||
@@ -78,7 +75,12 @@ flamer = defaultAutoGun
|
|||||||
, _itFloorPict = flamerPic
|
, _itFloorPict = flamerPic
|
||||||
-- , _itZoom = defaultItZoom
|
-- , _itZoom = defaultItZoom
|
||||||
, _itAttachment = NoItAttachment
|
, _itAttachment = NoItAttachment
|
||||||
} & itType . wpRange .~ 8
|
, _itParams = AngleWalk
|
||||||
|
{_maxWalkAngle = 0.2
|
||||||
|
,_walkSpeed = 0.01
|
||||||
|
,_currentWalkAngle = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
flamerPic :: Item -> SPic
|
flamerPic :: Item -> SPic
|
||||||
flamerPic it =
|
flamerPic it =
|
||||||
( colorSH yellow $
|
( colorSH yellow $
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module Dodge.Item.Weapon.TriggerType
|
|||||||
, shootL
|
, shootL
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, ammoCheckI
|
, ammoCheckI
|
||||||
, randSpreadDir
|
, applyInaccuracy
|
||||||
, modClock
|
, modClock
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@@ -316,11 +316,11 @@ withMuzFlareI f it cr w = makeTlsTimeRadColPos 3 100 (V3 1 1 0.5) flashPos
|
|||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
itLength = _muzzleLength $ _itDimension it
|
itLength = _muzzleLength $ _itDimension it
|
||||||
{- | Applies the effect to a randomly rotated creature,
|
{- | Applies the effect to a randomly rotated creature,
|
||||||
- rotation amount given by wpSpread -}
|
- rotation amount given by inaccuracy in itParams -}
|
||||||
randSpreadDir :: ChainEffect
|
applyInaccuracy :: ChainEffect
|
||||||
randSpreadDir f it cr w = f it (cr & crDir +~ a) $ set randGen g w
|
applyInaccuracy f it cr w = f it (cr & crDir +~ a) $ set randGen g w
|
||||||
where
|
where
|
||||||
acc = _wpSpread $ _itType it
|
acc = _inaccuracy $ _itParams it
|
||||||
(a, g) = randomR (-acc,acc) $ _randGen w
|
(a, g) = randomR (-acc,acc) $ _randGen w
|
||||||
{- | Applies the effect to a randomly rotated creature. -}
|
{- | Applies the effect to a randomly rotated creature. -}
|
||||||
withRandomDirI
|
withRandomDirI
|
||||||
@@ -391,8 +391,8 @@ spreadNumI eff item cr w = foldr f w dirs
|
|||||||
[-spread,-spread+(2*spread/fromIntegral numBul)..spread]
|
[-spread,-spread+(2*spread/fromIntegral numBul)..spread]
|
||||||
(randomRs (0,spread/fromIntegral numBul) (_randGen w))
|
(randomRs (0,spread/fromIntegral numBul) (_randGen w))
|
||||||
f dir = eff item (cr & crDir +~ dir)
|
f dir = eff item (cr & crDir +~ dir)
|
||||||
spread = _wpSpread $ _itType item
|
spread = _spreadAngle . _barrelSpread $ _itParams item
|
||||||
numBul = _wpNumBarrels $ _itType item
|
numBul = _barrelNum $ _itParams item
|
||||||
numI :: ChainEffect
|
numI :: ChainEffect
|
||||||
numI eff item cr w = foldr f w poss
|
numI eff item cr w = foldr f w poss
|
||||||
where
|
where
|
||||||
@@ -401,21 +401,22 @@ numI eff item cr w = foldr f w poss
|
|||||||
poss :: [V2 Float]
|
poss :: [V2 Float]
|
||||||
poss = map (rotateV (_crDir cr) . V2 0 . (*5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
|
poss = map (rotateV (_crDir cr) . V2 0 . (*5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
|
||||||
f pos = eff item (cr & crPos %~ (+.+ pos))
|
f pos = eff item (cr & crPos %~ (+.+ pos))
|
||||||
numBul = _wpNumBarrels $ _itType item
|
numBul = _barrelNum $ _itParams item
|
||||||
{- | Uses '_wpSpread' as a parameter for the current offset angle. -}
|
{- | Uses '_wpSpread' as a parameter for the current offset angle. -}
|
||||||
randWalkAngle
|
randWalkAngle
|
||||||
:: Float -- ^ Max offset angle
|
:: (Creature -> World -> World) -- ^ Underlying effect
|
||||||
-> Float -- ^ Walk speed
|
|
||||||
-> (Creature -> World -> World) -- ^ Underlying effect
|
|
||||||
-> Creature -- ^ Creature id
|
-> Creature -- ^ Creature id
|
||||||
-> World
|
-> World
|
||||||
-> World
|
-> World
|
||||||
randWalkAngle ma aspeed f cr w = w
|
randWalkAngle f cr w = w
|
||||||
& f (cr & crDir +~ a)
|
& f (cr & crDir +~ a)
|
||||||
& creatures . ix cid . crInv . ix i . itType . wpSpread .~ newa
|
& creatures . ix cid . crInv . ix i . itParams . currentWalkAngle .~ newa
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
a = _wpSpread $ _itType $ _crInv (_creatures w IM.! cid) IM.! i
|
a = _currentWalkAngle $ _itParams it
|
||||||
(walka, _) = randomR (-aspeed,aspeed) (_randGen w)
|
(walka, _) = randomR (-aspeed,aspeed) (_randGen w)
|
||||||
newa = min ma $ max (negate ma) (a + walka)
|
newa = min ma $ max (negate ma) (a + walka)
|
||||||
i = _crInvSel $ _creatures w IM.! cid
|
i = _crInvSel $ _creatures w IM.! cid
|
||||||
|
it = _crInv cr IM.! i
|
||||||
|
ma = _maxWalkAngle $ _itParams it
|
||||||
|
aspeed = _walkSpeed $ _itParams it
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ shrinkGun = defaultGun
|
|||||||
}
|
}
|
||||||
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
|
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
|
||||||
& useHammer .~ upHammer
|
& useHammer .~ upHammer
|
||||||
, _itType = UtilityItem
|
|
||||||
, _itFloorPict = shrinkGunPic
|
, _itFloorPict = shrinkGunPic
|
||||||
, _itAttachment = ItBool True
|
, _itAttachment = ItBool True
|
||||||
}
|
}
|
||||||
@@ -95,7 +94,6 @@ blinkGun = defaultGun
|
|||||||
, _itUse = defaultlUse
|
, _itUse = defaultlUse
|
||||||
{_lUse = hammerCheckL $ shootL aSelfL
|
{_lUse = hammerCheckL $ shootL aSelfL
|
||||||
} & useHammer .~ upHammer
|
} & useHammer .~ upHammer
|
||||||
, _itType = UtilityItem
|
|
||||||
, _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
, _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user