Move randomOffset out of records
This commit is contained in:
+61
-18
@@ -9,14 +9,13 @@ module Dodge.HeldUse (
|
||||
mcUseHeld,
|
||||
) where
|
||||
|
||||
import Dodge.BaseTriggerType
|
||||
import Sound.Data
|
||||
import Color
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.BaseTriggerType
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
@@ -39,6 +38,7 @@ import NewInt
|
||||
import Picture.Base
|
||||
import RandomHelp
|
||||
import qualified SDL
|
||||
import Sound.Data
|
||||
|
||||
gadgetEffect ::
|
||||
PressType ->
|
||||
@@ -160,7 +160,7 @@ doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponR
|
||||
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||
upitm x =
|
||||
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
||||
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
||||
& ldtValue . itUse . heldFrame .~ x
|
||||
|
||||
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
|
||||
@@ -244,14 +244,14 @@ recoilAmount itm
|
||||
SHATTERGUN -> 0
|
||||
TORCH -> 0
|
||||
FLATSHIELD -> 0
|
||||
KEYCARD _ -> 0
|
||||
KEYCARD _ -> 0
|
||||
BLINKER -> 0
|
||||
BLINKERUNSAFE -> 0
|
||||
| otherwise = 0
|
||||
|
||||
-- if the int is 0, play sound on new channel
|
||||
-- if >0, continue playing sound for given time
|
||||
bgunSound :: Item -> Maybe (SoundID,Int)
|
||||
bgunSound :: Item -> Maybe (SoundID, Int)
|
||||
bgunSound itm
|
||||
| HELD hit <- itm ^. itType = case hit of
|
||||
BANGSTICK _ -> Just (tap3S, 0)
|
||||
@@ -262,20 +262,20 @@ bgunSound itm
|
||||
MACHINEPISTOL -> Just (tap1S, 0)
|
||||
AUTOPISTOL -> Just (tap1S, 0)
|
||||
SMG -> Just (tap1S, 0)
|
||||
BANGCONE -> Just (bangEchoS,0)
|
||||
BLUNDERBUSS -> Just (bangEchoS,0)
|
||||
GRAPECANNON _ -> Just (bangEchoS,0)
|
||||
MINIGUNX _ -> Just (mini1S,2)
|
||||
BANGCONE -> Just (bangEchoS, 0)
|
||||
BLUNDERBUSS -> Just (bangEchoS, 0)
|
||||
GRAPECANNON _ -> Just (bangEchoS, 0)
|
||||
MINIGUNX _ -> Just (mini1S, 2)
|
||||
VOLLEYGUN _ -> Just (tap3S, 0)
|
||||
RIFLE -> Just (tap3S, 0)
|
||||
ALTERIFLE -> Just (tap3S, 0)
|
||||
AUTORIFLE -> Just (tap3S, 0)
|
||||
BURSTRIFLE -> Just (tap3S, 0)
|
||||
BANGROD -> Just (bangEchoS,0)
|
||||
ELEPHANTGUN -> Just (bangEchoS,0)
|
||||
AMR -> Just (bangEchoS,0)
|
||||
AUTOAMR -> Just (bangEchoS,0)
|
||||
SNIPERRIFLE -> Just (bangEchoS,0)
|
||||
BANGROD -> Just (bangEchoS, 0)
|
||||
ELEPHANTGUN -> Just (bangEchoS, 0)
|
||||
AMR -> Just (bangEchoS, 0)
|
||||
AUTOAMR -> Just (bangEchoS, 0)
|
||||
SNIPERRIFLE -> Just (bangEchoS, 0)
|
||||
FLAMESPITTER -> Nothing
|
||||
FLAMETHROWER -> Nothing
|
||||
FLAMETORRENT -> Nothing
|
||||
@@ -288,7 +288,7 @@ bgunSound itm
|
||||
RLAUNCHER -> Just (tap4S, 0)
|
||||
RLAUNCHERX _ -> Just (tap4S, 0)
|
||||
GLAUNCHER -> Just (tap4S, 0)
|
||||
POISONSPRAYER -> Just (foamSprayLoopS,5)
|
||||
POISONSPRAYER -> Just (foamSprayLoopS, 5)
|
||||
SHATTERGUN -> Nothing
|
||||
TORCH -> Nothing
|
||||
FLATSHIELD -> Nothing
|
||||
@@ -590,7 +590,6 @@ creatureShootLaser itmtree cr mz w =
|
||||
dir
|
||||
(getLaserColor itmtree)
|
||||
where
|
||||
|
||||
itm = itmtree ^. ldtValue
|
||||
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
@@ -702,12 +701,57 @@ makeBullet' bu itm cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
dir = _crDir cr + mrot + a
|
||||
inacc = _mzInaccuracy mz
|
||||
offset = case itm ^? itUse . heldParams . randomOffset of
|
||||
offset = case itemRandomOffset <$> itm ^? itType . ibtHeld of
|
||||
Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
|
||||
_ -> 0
|
||||
|
||||
-- & makeMuzzleSmoke mz itm cr
|
||||
|
||||
itemRandomOffset :: HeldItemType -> Float
|
||||
itemRandomOffset = \case
|
||||
BANGSTICK {} -> 0
|
||||
REWINDER -> 0
|
||||
TIMESTOPPER -> 0
|
||||
TIMESCROLLER -> 0
|
||||
PISTOL -> 0
|
||||
MACHINEPISTOL -> 0
|
||||
AUTOPISTOL -> 0
|
||||
SMG -> 0
|
||||
BANGCONE -> 12
|
||||
BLUNDERBUSS -> 12
|
||||
GRAPECANNON i -> 12 + 4 * fromIntegral i
|
||||
MINIGUNX {} -> 10
|
||||
VOLLEYGUN{} -> 0
|
||||
RIFLE -> 0
|
||||
ALTERIFLE -> 0
|
||||
AUTORIFLE -> 0
|
||||
BURSTRIFLE -> 0
|
||||
BANGROD -> 0
|
||||
ELEPHANTGUN -> 0
|
||||
AMR -> 0
|
||||
AUTOAMR -> 0
|
||||
SNIPERRIFLE -> 0
|
||||
FLAMESPITTER -> 0
|
||||
FLAMETHROWER -> 0
|
||||
FLAMETORRENT -> 0
|
||||
FLAMEWALL -> 0
|
||||
BLOWTORCH -> 0
|
||||
SPARKGUN -> 0
|
||||
TESLAGUN -> 0
|
||||
LASER -> 0
|
||||
TRACTORGUN -> 0
|
||||
RLAUNCHER -> 0
|
||||
RLAUNCHERX{} -> 0
|
||||
GLAUNCHER -> 0
|
||||
POISONSPRAYER -> 0
|
||||
SHATTERGUN -> 0
|
||||
TORCH -> 0
|
||||
FLATSHIELD -> 0
|
||||
KEYCARD{} -> 0
|
||||
BLINKER -> 0
|
||||
BLINKERUNSAFE -> 0
|
||||
|
||||
|
||||
makeBullet :: Bullet -> Item -> Point2 -> Float -> World -> World
|
||||
makeBullet thebullet itm bulpos dir w =
|
||||
w & randGen .~ g''
|
||||
@@ -815,7 +859,6 @@ heldItemRifling = \case
|
||||
BLINKER -> ConstFloat 0.8
|
||||
BLINKERUNSAFE -> ConstFloat 0.8
|
||||
|
||||
|
||||
mcUseHeld :: HeldItemType -> Item -> Machine -> World -> World
|
||||
mcUseHeld hit = case hit of
|
||||
LASER -> mcShootLaser
|
||||
|
||||
Reference in New Issue
Block a user