Cleanup, split CWorld into separate file

This commit is contained in:
2022-07-26 21:19:12 +01:00
parent c2707719fb
commit 6554d219dc
27 changed files with 1049 additions and 911 deletions
+143 -158
View File
@@ -1,173 +1,158 @@
module Dodge.Item.Weapon.BulletGun.Cane
( volleyGun
, repeater
, rifle
, autoRifle
, burstRifle
, miniGunX
) where
import Dodge.Reloading.Action
module Dodge.Item.Weapon.BulletGun.Cane (
volleyGun,
repeater,
rifle,
autoRifle,
burstRifle,
miniGunX,
) where
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Default
import Dodge.Reloading.Action
import Geometry
import LensHelp
defaultBangCane :: Item
defaultBangCane = defaultBulletWeapon
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ BangCaneMod
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itType . iyBase .~ error "undefined bangCane baseitemtype"
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadPartialInsert 10 1]
volleyGun :: Int -> Item
volleyGun i = defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itConsumption . laMax .~ i
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
,_brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle = defaultBangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadEject 5, loadInsert 5 ,loadPrime 5]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 2}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
repeater = rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER
& itConsumption . laCycle .~ [loadEject 20, loadInsert 20 ,loadPrime 20]
& itConsumption . laMax .~ 15
defaultBangCane =
defaultBulletWeapon
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ BangCaneMod
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itType . iyBase .~ error "undefined bangCane baseitemtype"
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadPartialInsert 10 1]
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itConsumption . laMax .~ i
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels
.~ MultiBarrel
{ _brlSpread = AlignedBarrels
, _brlNum = i
, _brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle =
defaultBangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 2}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
repeater =
rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER
& itConsumption . laCycle .~ [loadEject 20, loadInsert 20, loadPrime 20]
& itConsumption . laMax .~ 15
autoRifle :: Item
autoRifle = repeater
& itType . iyBase .~ HELD AUTORIFLE
& itUse . useMods .~ AutoRifleMod
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
autoRifle =
repeater
& itType . iyBase .~ HELD AUTORIFLE
& itUse . useMods .~ AutoRifleMod
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
-- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item
burstRifle = repeater
& itType . iyBase .~ HELD BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~ BurstRifleMod
--fastBurstRifle :: Item
--fastBurstRifle = repeater
-- & itType . iyBase .~ FASTBURSTRIFLE
-- & itParams . gunBarrels . brlInaccuracy .~ 0.06
-- & itUse . useDelay . rateMax .~ 18
-- & itUse . useMods .~
-- [ ammoHammerCheck
-- , useTimeCheck
-- , sideEffectOnFrame 9 (torqueSideEffect 0.4)
-- , lockInvFor 9
-- , \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [2,4,6,8]) f it
-- , withSoundStart tap3S
-- , useAmmoAmount 1
-- , applyInaccuracy
-- , withMuzFlareI
-- , withRecoil
-- ]
--completeBurstRifle :: Item
--completeBurstRifle = repeater
-- & itType . iyBase .~ COMPLETEBURSTRIFLE
-- & itType . iyModules . at ModRifleMag .~ Nothing
-- & itParams . gunBarrels . brlInaccuracy .~ 0.1
-- & itUse . useDelay . rateMax .~ 28
-- & itUse . useMods .~
-- [ ammoHammerCheck
-- , useTimeCheck
-- , sideEffectOnFrame 15 (torqueSideEffect 0.8)
-- , lockInvFor 15
-- , \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [1..14]) f it
-- , withSoundStart tap3S
-- , useAmmoAmount 1
-- , applyInaccuracy
-- , withMuzFlareI
-- , withRecoil
-- ]
burstRifle =
repeater
& itType . iyBase .~ HELD BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~ BurstRifleMod
miniGunUse :: Int -> ItemUse
miniGunUse i = defaultrUse
& rUse .~ HeldUseAmmoParams
& useDelay .~ NoDelay
& useMods .~ MiniGunMod i
miniGunUse i =
defaultrUse
& rUse .~ HeldUseAmmoParams
& useDelay .~ NoDelay
& useMods .~ MiniGunMod i
miniGunX :: Int -> Item
miniGunX i = defaultAutoGun
{ _itConsumption = defaultBulletLoadable
{ _laMax = 1500
, _laLoaded = 1500
miniGunX i =
defaultAutoGun
{ _itConsumption =
defaultBulletLoadable
{ _laMax = 1500
, _laLoaded = 1500
}
& laCycle .~ [loadEject 40, loadInsert 40, loadPrime 40]
, _itUse =
miniGunUse i
& useDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100}
& useAim . aimWeight .~ 6
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
, -- , _itFloorPict = miniGunPictItem
_itParams =
BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
MultiBarrel
{ _brlSpread = RotatingBarrels 0.01
, _brlNum = i
, _brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
, _itInvSize = 4
}
& laCycle .~ [loadEject 40, loadInsert 40 ,loadPrime 40]
, _itUse = miniGunUse i
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 100}
& useAim . aimWeight .~ 6
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
-- , _itFloorPict = miniGunPictItem
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01
,_brlNum = i
,_brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
, _itInvSize = 4
}
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType . iyBase .~ HELD (MINIGUNX i)
& itUse . useAim . aimMuzPos .~ 40
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType . iyBase .~ HELD (MINIGUNX i)
& itUse . useAim . aimMuzPos .~ 40
+6 -6
View File
@@ -1,4 +1,4 @@
--{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TupleSections #-}
{- |
Weapon effects when pulling the trigger. -}
module Dodge.Item.Weapon.TriggerType
@@ -558,12 +558,12 @@ torqueSideEffect torque _ cr w
(rot, g) = randomR (-torque,torque) $ _randGen w
-- pump the updated creature into the chain in later frames
repeatOnFrames :: [Int] -> ChainEffect
repeatOnFrames = const id
--repeatOnFrames is f it cr w = f it cr w
-- & delayedEvents .++~ (is <&> (, f'))
repeatOnFrames :: [Int] -> HeldMod -> ChainEffect
--repeatOnFrames is hm f it cr w = f it cr w
repeatOnFrames is hm f it cr w = f it cr $ w
& cWorld . delayedEvents .++~ (is <&> (, WdWdFromItCrixWdWd (it & itUse . useMods .~ hm) (_crID cr) ItCrWdItemEffect))
-- where
-- f' w' = fromMaybe w' $ do
-- f' = fromMaybe w' $ do
-- cr' <- w' ^? creatures . ix (_crID cr)
-- return $ f it cr' w'