Move item parameters into a more sensible place

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