Move randomOffset out of records
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -75,15 +75,15 @@ data AttachParams
|
|||||||
data HeldParams
|
data HeldParams
|
||||||
= DefaultHeldParams
|
= DefaultHeldParams
|
||||||
| GasSprayParams
|
| GasSprayParams
|
||||||
{ _randomOffset :: Float
|
{ --_randomOffset :: Float
|
||||||
, _sidePush :: Float
|
_sidePush :: Float
|
||||||
, _weaponInvLock :: Int
|
, _weaponInvLock :: Int
|
||||||
, _weaponRepeat :: [Int]
|
, _weaponRepeat :: [Int]
|
||||||
}
|
}
|
||||||
| BeamShooterParams
|
| BeamShooterParams
|
||||||
| BulletShooterParams
|
| BulletShooterParams
|
||||||
{ _randomOffset :: Float
|
{ --_randomOffset :: Float
|
||||||
, _sidePush :: Float
|
_sidePush :: Float
|
||||||
, _weaponInvLock :: Int
|
, _weaponInvLock :: Int
|
||||||
, _weaponRepeat :: [Int]
|
, _weaponRepeat :: [Int]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ defaultHeldUse = UseHeld
|
|||||||
-- , _heldHammer = HammerUp
|
-- , _heldHammer = HammerUp
|
||||||
, _heldMuzzles = defaultMuzzles
|
, _heldMuzzles = defaultMuzzles
|
||||||
, _heldParams = BulletShooterParams
|
, _heldParams = BulletShooterParams
|
||||||
{ _randomOffset = 0
|
{ _sidePush = 0
|
||||||
, _sidePush = 0
|
|
||||||
-- , _bulGunSound = Just (tap3S, 0)
|
-- , _bulGunSound = Just (tap3S, 0)
|
||||||
, _weaponInvLock = 0
|
, _weaponInvLock = 0
|
||||||
, _weaponRepeat = []
|
, _weaponRepeat = []
|
||||||
|
|||||||
+60
-17
@@ -9,14 +9,13 @@ module Dodge.HeldUse (
|
|||||||
mcUseHeld,
|
mcUseHeld,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.BaseTriggerType
|
|
||||||
import Sound.Data
|
|
||||||
import Color
|
import Color
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base.Collide
|
import Dodge.Base.Collide
|
||||||
|
import Dodge.BaseTriggerType
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
import Dodge.Data.ComposedItem
|
import Dodge.Data.ComposedItem
|
||||||
import Dodge.Data.DoubleTree
|
import Dodge.Data.DoubleTree
|
||||||
@@ -39,6 +38,7 @@ import NewInt
|
|||||||
import Picture.Base
|
import Picture.Base
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
|
import Sound.Data
|
||||||
|
|
||||||
gadgetEffect ::
|
gadgetEffect ::
|
||||||
PressType ->
|
PressType ->
|
||||||
@@ -160,7 +160,7 @@ doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponR
|
|||||||
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||||
upitm x =
|
upitm x =
|
||||||
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||||
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
-- & ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
||||||
& ldtValue . itUse . heldFrame .~ x
|
& ldtValue . itUse . heldFrame .~ x
|
||||||
|
|
||||||
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
|
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
|
||||||
@@ -251,7 +251,7 @@ recoilAmount itm
|
|||||||
|
|
||||||
-- if the int is 0, play sound on new channel
|
-- if the int is 0, play sound on new channel
|
||||||
-- if >0, continue playing sound for given time
|
-- if >0, continue playing sound for given time
|
||||||
bgunSound :: Item -> Maybe (SoundID,Int)
|
bgunSound :: Item -> Maybe (SoundID, Int)
|
||||||
bgunSound itm
|
bgunSound itm
|
||||||
| HELD hit <- itm ^. itType = case hit of
|
| HELD hit <- itm ^. itType = case hit of
|
||||||
BANGSTICK _ -> Just (tap3S, 0)
|
BANGSTICK _ -> Just (tap3S, 0)
|
||||||
@@ -262,20 +262,20 @@ bgunSound itm
|
|||||||
MACHINEPISTOL -> Just (tap1S, 0)
|
MACHINEPISTOL -> Just (tap1S, 0)
|
||||||
AUTOPISTOL -> Just (tap1S, 0)
|
AUTOPISTOL -> Just (tap1S, 0)
|
||||||
SMG -> Just (tap1S, 0)
|
SMG -> Just (tap1S, 0)
|
||||||
BANGCONE -> Just (bangEchoS,0)
|
BANGCONE -> Just (bangEchoS, 0)
|
||||||
BLUNDERBUSS -> Just (bangEchoS,0)
|
BLUNDERBUSS -> Just (bangEchoS, 0)
|
||||||
GRAPECANNON _ -> Just (bangEchoS,0)
|
GRAPECANNON _ -> Just (bangEchoS, 0)
|
||||||
MINIGUNX _ -> Just (mini1S,2)
|
MINIGUNX _ -> Just (mini1S, 2)
|
||||||
VOLLEYGUN _ -> Just (tap3S, 0)
|
VOLLEYGUN _ -> Just (tap3S, 0)
|
||||||
RIFLE -> Just (tap3S, 0)
|
RIFLE -> Just (tap3S, 0)
|
||||||
ALTERIFLE -> Just (tap3S, 0)
|
ALTERIFLE -> Just (tap3S, 0)
|
||||||
AUTORIFLE -> Just (tap3S, 0)
|
AUTORIFLE -> Just (tap3S, 0)
|
||||||
BURSTRIFLE -> Just (tap3S, 0)
|
BURSTRIFLE -> Just (tap3S, 0)
|
||||||
BANGROD -> Just (bangEchoS,0)
|
BANGROD -> Just (bangEchoS, 0)
|
||||||
ELEPHANTGUN -> Just (bangEchoS,0)
|
ELEPHANTGUN -> Just (bangEchoS, 0)
|
||||||
AMR -> Just (bangEchoS,0)
|
AMR -> Just (bangEchoS, 0)
|
||||||
AUTOAMR -> Just (bangEchoS,0)
|
AUTOAMR -> Just (bangEchoS, 0)
|
||||||
SNIPERRIFLE -> Just (bangEchoS,0)
|
SNIPERRIFLE -> Just (bangEchoS, 0)
|
||||||
FLAMESPITTER -> Nothing
|
FLAMESPITTER -> Nothing
|
||||||
FLAMETHROWER -> Nothing
|
FLAMETHROWER -> Nothing
|
||||||
FLAMETORRENT -> Nothing
|
FLAMETORRENT -> Nothing
|
||||||
@@ -288,7 +288,7 @@ bgunSound itm
|
|||||||
RLAUNCHER -> Just (tap4S, 0)
|
RLAUNCHER -> Just (tap4S, 0)
|
||||||
RLAUNCHERX _ -> Just (tap4S, 0)
|
RLAUNCHERX _ -> Just (tap4S, 0)
|
||||||
GLAUNCHER -> Just (tap4S, 0)
|
GLAUNCHER -> Just (tap4S, 0)
|
||||||
POISONSPRAYER -> Just (foamSprayLoopS,5)
|
POISONSPRAYER -> Just (foamSprayLoopS, 5)
|
||||||
SHATTERGUN -> Nothing
|
SHATTERGUN -> Nothing
|
||||||
TORCH -> Nothing
|
TORCH -> Nothing
|
||||||
FLATSHIELD -> Nothing
|
FLATSHIELD -> Nothing
|
||||||
@@ -590,7 +590,6 @@ creatureShootLaser itmtree cr mz w =
|
|||||||
dir
|
dir
|
||||||
(getLaserColor itmtree)
|
(getLaserColor itmtree)
|
||||||
where
|
where
|
||||||
|
|
||||||
itm = itmtree ^. ldtValue
|
itm = itmtree ^. ldtValue
|
||||||
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
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
|
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||||
dir = _crDir cr + mrot + a
|
dir = _crDir cr + mrot + a
|
||||||
inacc = _mzInaccuracy mz
|
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
|
Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
|
||||||
_ -> 0
|
_ -> 0
|
||||||
|
|
||||||
-- & makeMuzzleSmoke mz itm cr
|
-- & 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 :: Bullet -> Item -> Point2 -> Float -> World -> World
|
||||||
makeBullet thebullet itm bulpos dir w =
|
makeBullet thebullet itm bulpos dir w =
|
||||||
w & randGen .~ g''
|
w & randGen .~ g''
|
||||||
@@ -815,7 +859,6 @@ heldItemRifling = \case
|
|||||||
BLINKER -> ConstFloat 0.8
|
BLINKER -> ConstFloat 0.8
|
||||||
BLINKERUNSAFE -> ConstFloat 0.8
|
BLINKERUNSAFE -> ConstFloat 0.8
|
||||||
|
|
||||||
|
|
||||||
mcUseHeld :: HeldItemType -> Item -> Machine -> World -> World
|
mcUseHeld :: HeldItemType -> Item -> Machine -> World -> World
|
||||||
mcUseHeld hit = case hit of
|
mcUseHeld hit = case hit of
|
||||||
LASER -> mcShootLaser
|
LASER -> mcShootLaser
|
||||||
|
|||||||
@@ -85,15 +85,11 @@ miniGunX :: Int -> Item
|
|||||||
miniGunX i =
|
miniGunX i =
|
||||||
autoRifle
|
autoRifle
|
||||||
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
|
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
|
||||||
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
|
||||||
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
|
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
|
||||||
-- & itUse . heldParams . bulGunSound ?~ (mini1S,2)
|
|
||||||
& itUse . heldMuzzles
|
& itUse . heldMuzzles
|
||||||
.~ replicate i
|
.~ replicate i
|
||||||
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
|
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
|
||||||
-- & itUse . heldParams . recoil .~ 10 * fromIntegral i
|
|
||||||
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
|
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
|
||||||
& itUse . heldParams . randomOffset .~ 10
|
|
||||||
& itType .~ HELD (MINIGUNX i)
|
& itType .~ HELD (MINIGUNX i)
|
||||||
& itEffect . ieInv .~ ItemReduceWarmTime
|
& itEffect . ieInv .~ ItemReduceWarmTime
|
||||||
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
|
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ bangCone =
|
|||||||
15
|
15
|
||||||
(Muzzle (V2 15 0) 0 0.5 0 NoFlare MuzzleShootBullet (UseExactly 1) 0)
|
(Muzzle (V2 15 0) 0 0.5 0 NoFlare MuzzleShootBullet (UseExactly 1) 0)
|
||||||
& itUse . heldMuzzles . ix 0 . mzFlareType .~ BasicFlare
|
& itUse . heldMuzzles . ix 0 . mzFlareType .~ BasicFlare
|
||||||
& itUse . heldParams . randomOffset .~ 12
|
|
||||||
& itType .~ HELD BANGCONE
|
& itType .~ HELD BANGCONE
|
||||||
|
|
||||||
blunderbuss :: Item
|
blunderbuss :: Item
|
||||||
@@ -32,4 +31,3 @@ grapeCannon :: Int -> Item
|
|||||||
grapeCannon i =
|
grapeCannon i =
|
||||||
blunderbuss
|
blunderbuss
|
||||||
& itType .~ HELD (GRAPECANNON i)
|
& itType .~ HELD (GRAPECANNON i)
|
||||||
& itUse . heldParams . randomOffset .~ (12 + 4 * fromIntegral i)
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ rLauncher =
|
|||||||
& itAmmoSlots .~ singleAmmo LauncherAmmo
|
& itAmmoSlots .~ singleAmmo LauncherAmmo
|
||||||
& itType .~ HELD RLAUNCHER
|
& itType .~ HELD RLAUNCHER
|
||||||
|
|
||||||
-- & itUse . heldParams . bulGunSound ?~ (tap4S, 0)
|
|
||||||
|
|
||||||
gLauncher :: Item
|
gLauncher :: Item
|
||||||
gLauncher =
|
gLauncher =
|
||||||
rLauncher
|
rLauncher
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ poisonSprayer =
|
|||||||
flameThrower
|
flameThrower
|
||||||
& itType .~ HELD POISONSPRAYER
|
& itType .~ HELD POISONSPRAYER
|
||||||
& itAmmoSlots .~ singleAmmo GasAmmo
|
& itAmmoSlots .~ singleAmmo GasAmmo
|
||||||
& itUse . heldParams . randomOffset .~ 0
|
|
||||||
& itUse . heldParams . sidePush .~ 0
|
& itUse . heldParams . sidePush .~ 0
|
||||||
-- & itUse . heldParams . bulGunSound ?~ (foamSprayLoopS,5)
|
|
||||||
|
|
||||||
flameSpitter :: Item
|
flameSpitter :: Item
|
||||||
flameSpitter =
|
flameSpitter =
|
||||||
@@ -83,8 +81,7 @@ flameThrower =
|
|||||||
& itAmmoSlots .~ singleAmmo GasAmmo
|
& itAmmoSlots .~ singleAmmo GasAmmo
|
||||||
& itType .~ HELD FLAMETHROWER
|
& itType .~ HELD FLAMETHROWER
|
||||||
& itUse . heldParams .~ GasSprayParams
|
& itUse . heldParams .~ GasSprayParams
|
||||||
{ _randomOffset = 0
|
{ _sidePush = 25
|
||||||
, _sidePush = 25
|
|
||||||
-- , _bulGunSound = Nothing
|
-- , _bulGunSound = Nothing
|
||||||
, _weaponInvLock = 0
|
, _weaponInvLock = 0
|
||||||
, _weaponRepeat = mempty
|
, _weaponRepeat = mempty
|
||||||
|
|||||||
Reference in New Issue
Block a user