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
|
||||
= DefaultHeldParams
|
||||
| GasSprayParams
|
||||
{ _randomOffset :: Float
|
||||
, _sidePush :: Float
|
||||
{ --_randomOffset :: Float
|
||||
_sidePush :: Float
|
||||
, _weaponInvLock :: Int
|
||||
, _weaponRepeat :: [Int]
|
||||
}
|
||||
| BeamShooterParams
|
||||
| BulletShooterParams
|
||||
{ _randomOffset :: Float
|
||||
, _sidePush :: Float
|
||||
{ --_randomOffset :: Float
|
||||
_sidePush :: Float
|
||||
, _weaponInvLock :: Int
|
||||
, _weaponRepeat :: [Int]
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ defaultHeldUse = UseHeld
|
||||
-- , _heldHammer = HammerUp
|
||||
, _heldMuzzles = defaultMuzzles
|
||||
, _heldParams = BulletShooterParams
|
||||
{ _randomOffset = 0
|
||||
, _sidePush = 0
|
||||
{ _sidePush = 0
|
||||
-- , _bulGunSound = Just (tap3S, 0)
|
||||
, _weaponInvLock = 0
|
||||
, _weaponRepeat = []
|
||||
|
||||
+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
|
||||
|
||||
@@ -85,15 +85,11 @@ miniGunX :: Int -> Item
|
||||
miniGunX i =
|
||||
autoRifle
|
||||
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
|
||||
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
|
||||
-- & itUse . heldParams . bulGunSound ?~ (mini1S,2)
|
||||
& itUse . heldMuzzles
|
||||
.~ replicate i
|
||||
(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 . randomOffset .~ 10
|
||||
& itType .~ HELD (MINIGUNX i)
|
||||
& itEffect . ieInv .~ ItemReduceWarmTime
|
||||
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
|
||||
|
||||
@@ -19,7 +19,6 @@ bangCone =
|
||||
15
|
||||
(Muzzle (V2 15 0) 0 0.5 0 NoFlare MuzzleShootBullet (UseExactly 1) 0)
|
||||
& itUse . heldMuzzles . ix 0 . mzFlareType .~ BasicFlare
|
||||
& itUse . heldParams . randomOffset .~ 12
|
||||
& itType .~ HELD BANGCONE
|
||||
|
||||
blunderbuss :: Item
|
||||
@@ -32,4 +31,3 @@ grapeCannon :: Int -> Item
|
||||
grapeCannon i =
|
||||
blunderbuss
|
||||
& itType .~ HELD (GRAPECANNON i)
|
||||
& itUse . heldParams . randomOffset .~ (12 + 4 * fromIntegral i)
|
||||
|
||||
@@ -21,8 +21,6 @@ rLauncher =
|
||||
& itAmmoSlots .~ singleAmmo LauncherAmmo
|
||||
& itType .~ HELD RLAUNCHER
|
||||
|
||||
-- & itUse . heldParams . bulGunSound ?~ (tap4S, 0)
|
||||
|
||||
gLauncher :: Item
|
||||
gLauncher =
|
||||
rLauncher
|
||||
|
||||
@@ -19,9 +19,7 @@ poisonSprayer =
|
||||
flameThrower
|
||||
& itType .~ HELD POISONSPRAYER
|
||||
& itAmmoSlots .~ singleAmmo GasAmmo
|
||||
& itUse . heldParams . randomOffset .~ 0
|
||||
& itUse . heldParams . sidePush .~ 0
|
||||
-- & itUse . heldParams . bulGunSound ?~ (foamSprayLoopS,5)
|
||||
|
||||
flameSpitter :: Item
|
||||
flameSpitter =
|
||||
@@ -83,8 +81,7 @@ flameThrower =
|
||||
& itAmmoSlots .~ singleAmmo GasAmmo
|
||||
& itType .~ HELD FLAMETHROWER
|
||||
& itUse . heldParams .~ GasSprayParams
|
||||
{ _randomOffset = 0
|
||||
, _sidePush = 25
|
||||
{ _sidePush = 25
|
||||
-- , _bulGunSound = Nothing
|
||||
, _weaponInvLock = 0
|
||||
, _weaponRepeat = mempty
|
||||
|
||||
Reference in New Issue
Block a user