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