Tweak weapons

This commit is contained in:
2021-09-06 21:58:36 +01:00
parent 60dc2d9342
commit 6ecd739d6f
6 changed files with 65 additions and 58 deletions
+22 -22
View File
@@ -350,31 +350,31 @@ data Item
, _itAimStance :: AimStance
}
| Throwable
{ _itName :: String
, _itMaxStack :: Int
, _itAmount :: Int
, _itFloorPict :: Picture
, _twMaxRange :: Float
, _twAccuracy :: Float
, _itUse :: Item -> Creature -> World -> World
, _itUseRate :: Int
, _itUseTime :: Int
, _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _itAimingSpeed :: Float
, _itAimingRange :: Float
, _itZoom :: ItZoom
, _itAimZoom :: ItZoom
, _itEquipPict :: Creature -> Int -> Picture
, _itIdentity :: ItemIdentity
, _itID :: Maybe Int
{ _itName :: String
, _itMaxStack :: Int
, _itAmount :: Int
, _itFloorPict :: Picture
, _twMaxRange :: Float
, _twAccuracy :: Float
, _itUse :: Item -> Creature -> World -> World
, _itUseRate :: Int
, _itUseTime :: Int
, _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _itAimingSpeed :: Float
, _itAimingRange :: Float
, _itZoom :: ItZoom
, _itAimZoom :: ItZoom
, _itEquipPict :: Creature -> Int -> Picture
, _itIdentity :: ItemIdentity
, _itID :: Maybe Int
, _itAttachment :: ItAttachment
, _itInvDisplay :: Item -> String
, _itInvColor :: Color
, _itEffect :: ItEffect
, _itHammer :: HammerPosition
, _itScrollUp :: Int -> World -> World
, _itInvColor :: Color
, _itEffect :: ItEffect
, _itHammer :: HammerPosition
, _itScrollUp :: Int -> World -> World
, _itScrollDown :: Int -> World -> World
, _itAimStance :: AimStance
, _itAimStance :: AimStance
}
| NoItem
+24 -30
View File
@@ -1,4 +1,9 @@
module Dodge.Item.Attachment
( charFiringStratI
, scrollCharMode
, decreaseFuse
, increaseFuse
)
where
import Dodge.Data
import Dodge.Item.Attachment.Data
@@ -6,19 +11,9 @@ import Dodge.Default
import Control.Lens hiding ((|>),(<|))
import Data.Sequence
import Data.Maybe (fromJust)
import Data.Maybe
import qualified Data.IntMap.Strict as IM
incCharMode' :: ItAttachment -> ItAttachment
incCharMode' = itCharMode %~ cycleL
where
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
decCharMode' :: ItAttachment -> ItAttachment
decCharMode' = itCharMode %~ cycleR
where
cycleR (xs :|> x) = x <| xs
cycleR xs = xs
scrollCharMode
:: Float -- ^ Amount scrolled
@@ -34,34 +29,32 @@ incCharMode
:: Int -- ^ Inventory selection
-> World
-> World
incCharMode i = creatures . ix 0 . crInv . ix i . itAttachment %~ incCharMode'
incCharMode i = creatures . ix 0 . crInv . ix i . itAttachment . itCharMode %~ cycleL
where
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
decCharMode
:: Int -- ^ Inventory selection
-> World
-> World
decCharMode i = creatures . ix 0 . crInv . ix i . itAttachment %~ decCharMode'
charFiringStrat
:: [(Char, Creature -> World -> World)] -- ^ Different firing effects for different characters
-> Creature -- ^ Creature id
-> World
-> World
charFiringStrat strats cr w = case w ^? creatures . ix cid . crInv
. ix (_crInvSel $ _creatures w IM.! cid) . itAttachment . itCharMode of
Just (c :<| _) -> fromJust (Prelude.lookup c strats) cr w
_ -> w
decCharMode i = creatures . ix 0 . crInv . ix i . itAttachment . itCharMode %~ cycleR
where
cid = _crID cr
charFiringStratI
:: [(Char, (Item -> Creature -> World -> World) -> Item -> Creature -> World -> World)] -- ^ Different firing effects for different characters
-> (Item -> Creature -> World -> World)
cycleR (xs :|> x) = x <| xs
cycleR xs = xs
type ChainEffect =
(Item -> Creature -> World -> World)
-> Item
-> Creature
-> Creature
-> World
-> World
charFiringStratI
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
-> ChainEffect
charFiringStratI strats eff item cr w = case w ^? creatures . ix cid . crInv
. ix (_crInvSel $ _creatures w IM.! cid) . itAttachment . itCharMode of
Just (c :<| _) -> fromJust (Prelude.lookup c strats) eff item cr w
Just (c :<| _) -> fromMaybe id (Prelude.lookup c strats) eff item cr w
_ -> w
where
cid = _crID cr
@@ -84,7 +77,8 @@ increaseFuse fuse itid w = w
decreaseFuse
:: Int -- ^ Old fuse time
-> Int -- ^ Inventory item reference (I believe)
-> World -> World
-> World
-> World
decreaseFuse fuse itid w = w
& creatures . ix 0 . crInv . ix itid %~
( itScrollUp .~ decreaseFuse newTime )
+2 -2
View File
@@ -67,7 +67,7 @@ pistol = defaultGun
, useTimeCheckI
, withSoundI 0
, useAmmo 1
-- , withRandomDirI 0.1
, randSpreadDir
, withMuzFlareI
]
, _itLeftClickUse = Nothing
@@ -828,7 +828,7 @@ grenade = Throwable
, _itInvDisplay = basicWeaponDisplay
, _itEffect = wpRecock
, _itHammer = HammerUp
, _itScrollUp = decreaseFuse fuseTime
, _itScrollUp = decreaseFuse fuseTime
, _itScrollDown = increaseFuse fuseTime
, _itAimStance = OneHand
}
+5 -2
View File
@@ -32,10 +32,13 @@ autoGun = defaultAutoGun
, _itUse = useAmmoParams
, _itUseModifiers =
[ ammoCheckI
, charFiringStratI
[('S', hammerCheckI)
]
, useTimeCheckI
, charFiringStratI
[('M', torqueBefore 0.05)
,('S', hammerCheckI)
[('M', torqueBefore 0.08)
,('S', torqueBefore 0.05)
]
, withSoundI autoGunSound
, useAmmo 1
+9
View File
@@ -31,6 +31,7 @@ module Dodge.Item.Weapon.TriggerType
, shootL
, useTimeCheckI
, ammoCheckI
, randSpreadDir
)
where
import Dodge.Data
@@ -282,6 +283,14 @@ withMuzFlareI f it cr w = tempLightForAt 3 pos2 -- . muzzleFlashAt pos2
where
--pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
pos2 = _crPos cr +.+ (2 * _crRad cr) *.* unitVectorAtAngle (_crDir cr)
{- | 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
where
acc = _wpSpread it
(a, g) = randomR (-acc,acc) $ _randGen w
{- | Applies the effect to a randomly rotated creature. -}
withRandomDirI
:: Float -- ^ Max possible rotation
+3 -2
View File
@@ -9,7 +9,7 @@ import Dodge.Picture
import Dodge.Picture.Layer
import Dodge.Render.HUD
import Dodge.Render.MenuScreen
import Dodge.Graph
--import Dodge.Graph
import Geometry
import Picture
import Polyhedra.Data
@@ -59,7 +59,8 @@ customMouseCursor w =
$ pictures [ line [V2 (-5) 0,V2 5 0] , line [V2 0 (-5),V2 0 5] ]
testPic :: World -> Picture
testPic w = color green . pictures . map (flip thickLine 5 . tflat2) . graphToEdges $ _pathGraph w
testPic _ = blank
--testPic w = color green . pictures . map (flip thickLine 5 . tflat2) . graphToEdges $ _pathGraph w
crDraw :: World -> Creature -> Picture
crDraw w c = _crPict c c w