Continue refactor of reloading

This commit is contained in:
2022-06-20 11:12:24 +01:00
parent 2f4b381484
commit a85cf4d1fb
27 changed files with 243 additions and 299 deletions
-3
View File
@@ -109,9 +109,6 @@ data ItemBaseType
| FLAMEWALL | FLAMEWALL
| BLOWTORCH | BLOWTORCH
| AUTOGUN | AUTOGUN
-- | SPREADGUN
-- | MULTGUN
| LONGGUN
| SPARKGUN | SPARKGUN
| TESLAGUN | TESLAGUN
| LASGUN | LASGUN
+6 -6
View File
@@ -27,19 +27,19 @@ moduleModification imt = case imt of
TARGCR -> itTargeting .~ targetRBCreature TARGCR -> itTargeting .~ targetRBCreature
TARGLAS -> itTargeting .~ targetLaser TARGLAS -> itTargeting .~ targetLaser
TARGPOS -> itTargeting .~ targetRBPress TARGPOS -> itTargeting .~ targetRBPress
MAGNETTRAJ -> (itConsumption . laType . amBulTraj .~ MagnetTrajectory) MAGNETTRAJ -> (itConsumption . laAmmoType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . laType . amBulVel .~ V2 10 0) . (itConsumption . laAmmoType . amBulVel .~ V2 10 0)
FLECHETRAJ -> itConsumption . laType . amBulTraj .~ FlechetteTrajectory FLECHETRAJ -> itConsumption . laAmmoType . amBulTraj .~ FlechetteTrajectory
BEZIERTRAJ -> itConsumption . laType . amBulTraj .~ BezierTrajectory BEZIERTRAJ -> itConsumption . laAmmoType . amBulTraj .~ BezierTrajectory
INCENDLAS -> itParams . lasBeam .~ BeamCombine flameBeamCombine INCENDLAS -> itParams . lasBeam .~ BeamCombine flameBeamCombine
SPLITLAS -> itParams . lasBeam .~ BeamCombine splitBeamCombine SPLITLAS -> itParams . lasBeam .~ BeamCombine splitBeamCombine
STATICLAS -> (itParams . lasBeam .~ BeamCombine teslaBeamCombine) STATICLAS -> (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
. (itParams . subParams ?~ teslaParams) . (itParams . subParams ?~ teslaParams)
WEPTELE -> makeDirectedTele WEPTELE -> makeDirectedTele
LAUNCHHOME -> itConsumption . laType . amPjCreation .~ fireTrackingShell LAUNCHHOME -> itConsumption . laAmmoType . amPjCreation .~ fireTrackingShell
EXTRABATTERY -> itConsumption . laMax +~ 1000 EXTRABATTERY -> itConsumption . laMax +~ 1000
where where
f ameff = itConsumption . laType . amBulEff .~ ameff f ameff = itConsumption . laAmmoType . amBulEff .~ ameff
makeDirectedTele it = it makeDirectedTele it = it
& itTargeting .~ targetRBPress & itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos & itUse . useMods .:~ withPosDirWallCheck directedTelPos
-1
View File
@@ -283,7 +283,6 @@ stackedInventory = IM.fromList $ zip [0..]
, pipe , pipe
,rewindGun ,rewindGun
,tractorGun ,tractorGun
,longGun
,autoGun ,autoGun
,autoPistol ,autoPistol
,pistol ,pistol
+13 -10
View File
@@ -231,16 +231,19 @@ doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
weaponReloadSounds :: Creature -> World -> World weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
Just am@LoadableAmmo{} -> case _laReloadType am of Just am@LoadableAmmo{} -> case am ^? laLoadType . loadProgress of
PassiveReload stype | Just (_laReloadTime am) == am ^? laTransfer . transferTime Just NoTransfer -> w -- stopSoundFrom (CrReloadSound cid) w
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w Just _ -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
PassiveReload _ -> w Nothing -> w
ActiveClear | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w -- PassiveReload stype | Just (_laReloadTime am) == am ^? laTransfer . transferTime
ActiveClear | _laTransfer am == NoTransfer -> w -- -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w -- PassiveReload _ -> w
ActivePartial{} | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w -- ActiveClear | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
ActivePartial{} | _laTransfer am == NoTransfer -> w -- ActiveClear | _laTransfer am == NoTransfer -> w
ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w -- ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
-- ActivePartial{} | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
-- ActivePartial{} | _laTransfer am == NoTransfer -> w
-- ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
Just ChargeableAmmo {} -> w Just ChargeableAmmo {} -> w
Just NoConsumption {} -> w Just NoConsumption {} -> w
Just ItemItselfConsumable {} -> w Just ItemItselfConsumable {} -> w
+15 -13
View File
@@ -482,19 +482,12 @@ data Equipment = Equipment
_itUseAimStance :: Item -> AimStance _itUseAimStance :: Item -> AimStance
_itUseAimStance = _aimStance . _useAim . _itUse _itUseAimStance = _aimStance . _useAim . _itUse
data TransferState
= Transfer { _transferAmount :: Int , _transferTime :: Int}
| NoTransfer
deriving (Eq,Ord,Show)
data ItemConsumption data ItemConsumption
= LoadableAmmo = LoadableAmmo
{ _laType :: AmmoType { _laAmmoType :: AmmoType
, _laMax :: Int , _laMax :: Int
, _laLoaded :: Int , _laLoaded :: Int
, _laReloadTime :: Int , _laLoadType :: LoadType
, _laTransfer :: TransferState
, _laReloadType :: ReloadType
} }
| ChargeableAmmo | ChargeableAmmo
{ _wpMaxCharge :: Int { _wpMaxCharge :: Int
@@ -552,9 +545,17 @@ data ItemPortage
| WornItem | WornItem
| NoPortage | NoPortage
data ReloadType data LoadProgress
= ActiveClear = NoTransfer
| ActivePartial {_partialReloadAmount :: Int} | Eject {_ejectProgress :: Int}
| Insert {_insertProgress :: Int, _insertAmount :: Int }
deriving (Eq,Ord,Show)
data LoadType
= ActiveEject
{_ejectTime :: Int, _insertTime :: Int,_loadProgress :: LoadProgress }
| ActivePartial
{_insertTime :: Int, _loadAmount :: Int, _loadProgress :: LoadProgress }
| PassiveReload SoundID | PassiveReload SoundID
deriving Eq deriving Eq
@@ -1481,7 +1482,8 @@ makeLenses ''ItEffect
makeLenses ''FloorItem makeLenses ''FloorItem
makeLenses ''ItemConsumption makeLenses ''ItemConsumption
makeLenses ''AmmoType makeLenses ''AmmoType
makeLenses ''TransferState makeLenses ''LoadType
makeLenses ''LoadProgress
makeLenses ''TweakParam makeLenses ''TweakParam
makeLenses ''Prop makeLenses ''Prop
makeLenses ''Modification makeLenses ''Modification
+23 -26
View File
@@ -1,6 +1,7 @@
module Dodge.Default.Weapon module Dodge.Default.Weapon
where where
import Dodge.Data import Dodge.Data
import Dodge.Item.Weapon.Bullet
import Dodge.Default.Item import Dodge.Default.Item
import Dodge.Item.Draw import Dodge.Item.Draw
import Picture import Picture
@@ -13,15 +14,17 @@ import Geometry
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Control.Lens import Control.Lens
defaultAmmo :: ItemConsumption defaultLoadable :: ItemConsumption
defaultAmmo = LoadableAmmo defaultLoadable = LoadableAmmo
{ _laType = GenericAmmo { _laAmmoType = GenericAmmo
, _laMax = 15 , _laMax = 15
, _laLoaded = 0 , _laLoaded = 0
, _laReloadTime = 40 , _laLoadType = ActiveEject 20 20 NoTransfer
, _laTransfer = NoTransfer
, _laReloadType = ActiveClear
} }
defaultBulletLoadable :: ItemConsumption
defaultBulletLoadable = defaultLoadable & laAmmoType .~ basicBullet
defaultChargeable :: ItemConsumption
defaultChargeable = ChargeableAmmo 100 100
ruseRate :: Int ruseRate :: Int
-> (Item -> Creature -> World -> World) -> (Item -> Creature -> World -> World)
@@ -94,26 +97,17 @@ defaultAimParams = AimParams
, _aimStance = OneHand , _aimStance = OneHand
} }
-- TODO change this
defaultLeftItem :: Item
defaultLeftItem = defaultWeapon
defaultGun :: Item defaultWeapon :: Item
defaultGun = defaultItem defaultWeapon = defaultItem
{ _itCurseStatus = Uncursed & itConsumption .~ defaultLoadable
, _itConsumption = defaultAmmo & itUse .~ defaultrUse
, _itUse = defaultrUse & itDimension .~ defItDimCol white
, _itDimension = defItDimCol white & itEquipPict .~ pictureWeaponOnAim
, _itEquipPict = pictureWeaponOnAim & itInvColor .~ white
, _itAttachment = NoItAttachment
, _itID = Nothing
, _itInvPos = Nothing
, _itIsHeld = False
, _itEffect = NoItEffect
, _itInvColor = white
, _itInvSize = 1
, _itParams = NoParams
, _itTweaks = NoTweaks
, _itScope = NoScope
, _itTargeting = NoTargeting
}
& itType . iyModules .~ M.fromList & itType . iyModules .~ M.fromList
[(ModBullet, EMPTYMODULE) [(ModBullet, EMPTYMODULE)
,(ModTarget, EMPTYMODULE) ,(ModTarget, EMPTYMODULE)
@@ -121,6 +115,9 @@ defaultGun = defaultItem
,(ModTeleport, EMPTYMODULE) ,(ModTeleport, EMPTYMODULE)
] ]
defaultBulletWeapon :: Item
defaultBulletWeapon = defaultWeapon & itConsumption .~ defaultBulletLoadable
defaultItemValue :: ItemValue defaultItemValue :: ItemValue
defaultItemValue = ItemValue 10 MundaneItem defaultItemValue = ItemValue 10 MundaneItem
defaultCraftable :: Item defaultCraftable :: Item
@@ -161,5 +158,5 @@ defBulletShooter = BulletShooter
} }
defaultAutoGun :: Item defaultAutoGun :: Item
defaultAutoGun = defaultGun defaultAutoGun = defaultBulletWeapon
& itUse . useAim . aimStance .~ TwoHandTwist & itUse . useAim . aimStance .~ TwoHandTwist
+1 -1
View File
@@ -87,7 +87,7 @@ handlePressedKeyInGame scode w = case scode of
ScancodeP -> pauseGame $ escapeMap w ScancodeP -> pauseGame $ escapeMap w
ScancodeF -> youDropItem w ScancodeF -> youDropItem w
ScancodeM -> toggleMap w ScancodeM -> toggleMap w
ScancodeR -> fromMaybe w $ tryStartReloading (you w) w ScancodeR -> crStartReloading (you w) w
ScancodeT -> testEvent w ScancodeT -> testEvent w
ScancodeX -> w & hud . hudElement %~ toggleTweakInv ScancodeX -> w & hud . hudElement %~ toggleTweakInv
ScancodeC -> toggleCombineInv w ScancodeC -> toggleCombineInv w
-2
View File
@@ -60,7 +60,6 @@ itemFromBase ibt = case ibt of
AUTOGUN -> autoGun AUTOGUN -> autoGun
-- SPREADGUN -> spreadGun -- SPREADGUN -> spreadGun
-- MULTGUN -> multGun -- MULTGUN -> multGun
LONGGUN -> longGun
SPARKGUN -> sparkGun SPARKGUN -> sparkGun
TESLAGUN -> teslaGun TESLAGUN -> teslaGun
LASGUN -> lasGun LASGUN -> lasGun
@@ -206,7 +205,6 @@ baseToFamily ibt = case ibt of
AUTOGUN -> HeldFamily AUTOGUN -> HeldFamily
-- | SPREADGUN -> HeldFamily -- | SPREADGUN -> HeldFamily
-- | MULTGUN -> HeldFamily -- | MULTGUN -> HeldFamily
LONGGUN -> HeldFamily
SPARKGUN -> HeldFamily SPARKGUN -> HeldFamily
TESLAGUN -> HeldFamily TESLAGUN -> HeldFamily
LASGUN -> HeldFamily LASGUN -> HeldFamily
+14 -8
View File
@@ -20,14 +20,7 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
++ moduleStrings it ++ repeat "*" ++ moduleStrings it ++ repeat "*"
where where
thename = show . _iyBase $ _itType it thename = show . _iyBase $ _itType it
thenumber = case it ^? itConsumption of thenumber = showConsumption (_itConsumption it)
Just am@LoadableAmmo{} -> case _laTransfer am of
NoTransfer -> show (_laLoaded am)
Transfer _ time -> show time ++ "R" ++ show (_laLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> show (_icAmount x)
Just NoConsumption -> ""
Nothing -> ""
theparam = fromMaybe [] theparam = fromMaybe []
. listToMaybe . listToMaybe
$ mapMaybe ($ it) $ mapMaybe ($ it)
@@ -36,6 +29,19 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
-- , maybeRateStatus -- , maybeRateStatus
] ]
showConsumption :: ItemConsumption -> String
showConsumption ic = case ic of
am@LoadableAmmo{} -> showLoading (_laLoadType ic) ++ show (_laLoaded am)
am@ChargeableAmmo{} -> show $ _wpCharge am
x@ItemItselfConsumable{} -> show (_icAmount x)
NoConsumption -> ""
showLoading :: LoadType -> String
showLoading lt = case lt ^? loadProgress of
Just (Eject t) -> show t ++ "E"
Just (Insert t _) -> show t ++ "R"
Just NoTransfer -> ""
Nothing -> ""
-- & itInvDisplay .~ \it -> head (basicItemDisplay it) : -- & itInvDisplay .~ \it -> head (basicItemDisplay it) :
-- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it) -- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it)
-- ] -- ]
+2 -6
View File
@@ -110,13 +110,9 @@ maxT :: Int
maxT = 20 maxT = 20
boosterGun :: Item boosterGun :: Item
boosterGun = defaultGun boosterGun = defaultLeftItem
{ _itInvColor = cyan { _itInvColor = cyan
, _itConsumption = defaultAmmo , _itConsumption = defaultChargeable
{ _laMax = 100
, _laLoaded = 100
, _laReloadTime = 20
}
, _itUse = luseInstantNoH $ boostSelfL 10 , _itUse = luseInstantNoH $ boostSelfL 10
, _itEffect = resetAttachmentID , _itEffect = resetAttachmentID
} }
+1 -1
View File
@@ -49,7 +49,7 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
sp = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir sp = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
cid = _crID cr cid = _crID cr
dir = _crDir cr dir = _crDir cr
bultype = _laType $ _itConsumption it bultype = _laAmmoType $ _itConsumption it
muzvel = _muzVel $ _itParams it muzvel = _muzVel $ _itParams it
muzlength = aimingMuzzlePos cr it muzlength = aimingMuzzlePos cr it
thetraj = case _amBulTraj bultype of thetraj = case _amBulTraj bultype of
+13 -16
View File
@@ -53,7 +53,7 @@ import qualified Data.Map.Strict as M
--import Control.Monad.State --import Control.Monad.State
defaultBatteryGun :: Item defaultBatteryGun :: Item
defaultBatteryGun = defaultGun defaultBatteryGun = defaultWeapon
& itType . iyModules .~ batteryModules & itType . iyModules .~ batteryModules
batteryModules :: M.Map ModuleSlot ItemModuleType batteryModules :: M.Map ModuleSlot ItemModuleType
@@ -72,11 +72,10 @@ sparkGun = teslaGun
& itParams . arcSize .~ 10 & itParams . arcSize .~ 10
teslaGun :: Item teslaGun :: Item
teslaGun = defaultBatteryGun teslaGun = defaultBatteryGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 200 & laMax .~ 200
, _laLoaded = 200 & laLoadType . ejectTime .~ 40
, _laReloadTime = 80 & laLoadType . insertTime .~ 40
}
, _itUse = ruseInstant shootTeslaArc NoHammer , _itUse = ruseInstant shootTeslaArc NoHammer
[ ammoCheckI [ ammoCheckI
, withTempLight 1 100 (V3 0 0 1) , withTempLight 1 100 (V3 0 0 1)
@@ -253,11 +252,10 @@ lasSwing = lasGun
x' = _lasCycle $ _itParams it x' = _lasCycle $ _itParams it
lasGun :: Item lasGun :: Item
lasGun = defaultAutoBatteryGun lasGun = defaultAutoBatteryGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 200 & laMax .~ 200
, _laLoaded = 200 & laLoadType . ejectTime .~ 40
, _laReloadTime = 80 & laLoadType . insertTime .~ 40
}
, _itUse = ruseInstant shootLaser NoHammer , _itUse = ruseInstant shootLaser NoHammer
[ ammoCheckI [ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
@@ -320,11 +318,10 @@ lasGunTweak = TweakParam
tractorGun :: Item tractorGun :: Item
tractorGun = lasGun tractorGun = lasGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 10000 & laMax .~ 10000
, _laLoaded = 10000 & laLoadType . ejectTime .~ 20
, _laReloadTime = 40 & laLoadType . insertTime .~ 20
}
, _itUse = ruseInstant aTractorBeam NoHammer , _itUse = ruseInstant aTractorBeam NoHammer
[ ammoCheckI [ ammoCheckI
] ]
+11 -15
View File
@@ -21,7 +21,6 @@ import Dodge.Default
--import Dodge.Item.Weapon.InventoryDisplay --import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams import Dodge.Item.Weapon.AmmoParams
import Dodge.Item.Draw import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
import Picture import Picture
@@ -38,7 +37,7 @@ import LensHelp
--import System.Random --import System.Random
bangCane :: Item bangCane :: Item
bangCane = defaultGun bangCane = defaultBulletWeapon
{ _itParams = BulletShooter { _itParams = BulletShooter
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 0.9 , _rifling = 0.9
@@ -50,12 +49,6 @@ bangCane = defaultGun
, _torqueAfter = 0.1 , _torqueAfter = 0.1
, _randomOffset = 0 , _randomOffset = 0
} }
, _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 15
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 6 upHammer , _itUse = ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck [ ammoHammerCheck
, useTimeCheck , useTimeCheck
@@ -79,6 +72,8 @@ bangCane = defaultGun
} }
} & itUse . useAim . aimStance .~ OneHand } & itUse . useAim . aimStance .~ OneHand
& itType . iyBase .~ BANGCANE & itType . iyBase .~ BANGCANE
& itConsumption . laMax .~ 1
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
bangCaneX :: Int -> Item bangCaneX :: Int -> Item
bangCaneX i = bangCane bangCaneX i = bangCane
{ _itUse = ruseAmmoParamsRate 6 upHammer { _itUse = ruseAmmoParamsRate 6 upHammer
@@ -144,6 +139,7 @@ rifle = bangCane
& itUse . useAim . aimStance .~ TwoHandTwist & itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ RIFLE & itType . iyBase .~ RIFLE
& itConsumption . laMax .~ 1 & itConsumption . laMax .~ 1
& itConsumption . laLoadType .~ ActiveEject 5 5 NoTransfer
& itUse . useAim . aimWeight .~ 6 & itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1 & itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5} -- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
@@ -152,8 +148,8 @@ repeater :: Item
repeater = rifle repeater = rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE & itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ REPEATER & itType . iyBase .~ REPEATER
& itConsumption . laReloadType .~ ActiveClear & itConsumption . laLoadType . ejectTime .~ 40
& itConsumption . laReloadTime .~ 80 & itConsumption . laLoadType . insertTime .~ 40
& itConsumption . laMax .~ 15 & itConsumption . laMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape & itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it <> makeTinClipAt 0 (V3 10 (-2) 0) it
@@ -252,14 +248,14 @@ miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
miniGunX :: Int -> Item miniGunX :: Int -> Item
miniGunX i = defaultAutoGun miniGunX i = defaultAutoGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultBulletLoadable
{ _laType = basicBullet { _laMax = 1500
, _laMax = 1500
, _laLoaded = 1500 , _laLoaded = 1500
, _laReloadTime = 200
} }
& laLoadType . ejectTime .~ 60
& laLoadType . insertTime .~ 60
, _itUse = miniGunUse i , _itUse = miniGunUse i
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200} & useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 100}
& useAim . aimWeight .~ 6 & useAim . aimWeight .~ 6
& useAim . aimRange .~ 1 & useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist & useAim . aimStance .~ TwoHandTwist
+7 -9
View File
@@ -22,7 +22,6 @@ import Dodge.Item.Weapon.ExtraEffect
--import Dodge.Item.Weapon.InventoryDisplay --import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams import Dodge.Item.Weapon.AmmoParams
--import Dodge.Item.Draw --import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
import Picture import Picture
@@ -38,7 +37,7 @@ import LensHelp
--import System.Random --import System.Random
bangRod :: Item bangRod :: Item
bangRod = defaultGun bangRod = defaultBulletWeapon
{ _itParams = BulletShooter { _itParams = BulletShooter
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 1 , _rifling = 1
@@ -69,18 +68,16 @@ bangRod = defaultGun
, _dimSPic = \it -> noPic $ baseRodShape , _dimSPic = \it -> noPic $ baseRodShape
<> makeSingleClipAt (V3 5 0 3) it <> makeSingleClipAt (V3 5 0 3) it
} }
, _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 20
}
} }
& itConsumption . laMax .~ 1
& itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
& itType . iyBase .~ BANGROD & itType . iyBase .~ BANGROD
& itUse . useAim . aimWeight .~ 8 & itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1 & itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand & itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5} & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . laType . amBulEff .~ expireAndDamage heavyBulDams & itConsumption . laAmmoType . amBulEff .~ expireAndDamage heavyBulDams
baseRodShape :: Shape baseRodShape :: Shape
baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2 baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2
baseAMRShape :: Shape baseAMRShape :: Shape
@@ -145,6 +142,7 @@ machineGun = bangRod
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0} & useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
) )
& itConsumption . laMax .~ 100 & itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 75 & itConsumption . laLoadType . ejectTime .~ 25
& itConsumption . laLoadType . insertTime .~ 25
& itInvSize .~ 3 & itInvSize .~ 3
& itParams. torqueAfter .~ 0.2 -- not sure if this is necessary? & itParams. torqueAfter .~ 0.2 -- not sure if this is necessary?
+14 -29
View File
@@ -18,7 +18,6 @@ import Dodge.Default
--import Dodge.Item.Weapon.InventoryDisplay --import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams import Dodge.Item.Weapon.AmmoParams
--import Dodge.Item.Draw --import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
import Picture import Picture
@@ -40,14 +39,8 @@ bangStickSoundChoice it
| otherwise = shotgunS | otherwise = shotgunS
bangStick :: Int -> Item bangStick :: Int -> Item
bangStick i = defaultGun bangStick i = defaultBulletWeapon
{ _itConsumption = defaultAmmo { _itUse = ruseAmmoParamsRate 8 upHammer
{ _laType = basicBullet
, _laMax = i
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 8 upHammer
[ ammoHammerCheck [ ammoHammerCheck
, useTimeCheck , useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice , withSoundItemChoiceStart bangStickSoundChoice
@@ -84,6 +77,8 @@ bangStick i = defaultGun
} }
} }
& itType . iyBase .~ BANGSTICK i & itType . iyBase .~ BANGSTICK i
& itConsumption . laMax .~ i
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
baseStickShapeX :: Int -> Shape baseStickShapeX :: Int -> Shape
baseStickShapeX i = foldMap f [0..i-1] baseStickShapeX i = foldMap f [0..i-1]
where where
@@ -110,14 +105,10 @@ stickClip it = case it ^? itConsumption . laLoaded of
revolver :: Item revolver :: Item
revolver = pistol revolver = pistol
{ _itConsumption = defaultAmmo & itConsumption .~
{ _laType = basicBullet (defaultBulletLoadable
, _laMax = 6 & laMax .~ 6
, _laLoaded = 0 & laLoadType .~ ActivePartial 10 1 NoTransfer )
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
}
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it) & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
& itType . iyBase .~ REVOLVER & itType . iyBase .~ REVOLVER
@@ -164,18 +155,12 @@ smgAfterHamMods =
pistol :: Item pistol :: Item
pistol = (bangStick 1) pistol = (bangStick 1)
{ _itConsumption = defaultAmmo & itConsumption .~ ( defaultBulletLoadable
{ _laType = basicBullet & laMax .~ 15
, _laMax = 15 & laLoadType . ejectTime .~ 20
, _laLoaded = 0 & laLoadType . insertTime .~ 20 )
, _laReloadTime = 70 & itUse .~ ruseAmmoParamsRate 6 upHammer (ammoHammerCheck : pistolAfterHamMods)
, _laReloadType = ActiveClear & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
}
, _itUse = ruseAmmoParamsRate 6 upHammer
(ammoHammerCheck : pistolAfterHamMods)
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
& itParams %~ & itParams %~
( ( muzVel .~ 0.8 ) ( ( muzVel .~ 0.8 )
. ( rifling .~ 0.8 ) . ( rifling .~ 0.8 )
+18 -50
View File
@@ -8,7 +8,6 @@ module Dodge.Item.Weapon.BulletGuns
, autogunSpread , autogunSpread
, autoGun , autoGun
, autoGunPic , autoGunPic
, longGun
, module Dodge.Item.Weapon.BulletGun.Stick , module Dodge.Item.Weapon.BulletGun.Stick
, module Dodge.Item.Weapon.BulletGun.Cane , module Dodge.Item.Weapon.BulletGun.Cane
, module Dodge.Item.Weapon.BulletGun.Rod , module Dodge.Item.Weapon.BulletGun.Rod
@@ -16,7 +15,6 @@ module Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.BulletGun.Stick import Dodge.Item.Weapon.BulletGun.Stick
import Dodge.Item.Weapon.BulletGun.Cane import Dodge.Item.Weapon.BulletGun.Cane
import Dodge.Item.Weapon.BulletGun.Rod import Dodge.Item.Weapon.BulletGun.Rod
import Dodge.Item.Weapon.ZoomScope
--import Dodge.Item.Weapon.BulletGun.Clip --import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data import Dodge.Data
--import Dodge.ChainEffect --import Dodge.ChainEffect
@@ -26,7 +24,6 @@ import Dodge.Item.Attachment
--import Dodge.Item.Weapon.InventoryDisplay --import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams import Dodge.Item.Weapon.AmmoParams
import Dodge.Item.Draw import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound import Dodge.SoundLogic.LoadSound
import Picture import Picture
@@ -43,12 +40,12 @@ import System.Random
autoGun :: Item autoGun :: Item
autoGun = defaultAutoGun autoGun = defaultAutoGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultBulletLoadable
{ _laType = basicBullet { _laMax = 30
, _laMax = 30
, _laLoaded = 30 , _laLoaded = 30
, _laReloadTime = 80
} }
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseAmmoParamsRate 4 NoHammer , _itUse = ruseAmmoParamsRate 4 NoHammer
[ ammoCheckI [ ammoCheckI
, charFiringStratI , charFiringStratI
@@ -97,14 +94,8 @@ autoGunPic it = noPic $
x = fromIntegral $ _laLoaded $ _itConsumption it x = fromIntegral $ _laLoaded $ _itConsumption it
bangCone :: Item bangCone :: Item
bangCone = defaultGun bangCone = defaultBulletWeapon
{ _itConsumption = defaultAmmo { _itUse = ruseAmmoParamsRate 20 upHammer
{ _laType = basicBullet
, _laMax = 5
, _laReloadTime = 25
, _laReloadType = ActiveClear
}
, _itUse = ruseAmmoParamsRate 20 upHammer
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheck , useTimeCheck
@@ -140,10 +131,13 @@ bangCone = defaultGun
} }
} }
& itType . iyBase .~ BANGCONE & itType . iyBase .~ BANGCONE
& itConsumption . laMax .~ 5
& itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
coneRandItemUpdate :: State StdGen (Item -> Item) coneRandItemUpdate :: State StdGen (Item -> Item)
coneRandItemUpdate = do coneRandItemUpdate = do
wth <- state $ randomR (1,5) wth <- state $ randomR (1,5)
return (\it -> it & itConsumption . laType . amBulWth .~ wth) return (\it -> it & itConsumption . laAmmoType . amBulWth .~ wth)
coneRandItemParams :: State StdGen (ItemParams -> ItemParams) coneRandItemParams :: State StdGen (ItemParams -> ItemParams)
coneRandItemParams = do coneRandItemParams = do
muzv <- state $ randomR (0.5,1) muzv <- state $ randomR (0.5,1)
@@ -167,7 +161,8 @@ blunderbuss = bangCone
} }
} }
& itConsumption . laMax .~ 25 & itConsumption . laMax .~ 25
& itConsumption . laReloadTime .~ 30 & itConsumption . laLoadType . ejectTime .~ 15
& itConsumption . laLoadType . insertTime .~ 15
& itUse . useAim . aimStance .~ TwoHandTwist & itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimWeight .~ 6 & itUse . useAim . aimWeight .~ 6
& itType . iyBase .~ BLUNDERBUSS & itType . iyBase .~ BLUNDERBUSS
@@ -175,7 +170,8 @@ bigBlunderbuss :: Item
bigBlunderbuss = blunderbuss bigBlunderbuss = blunderbuss
& itType . iyBase .~ BIGBLUNDERBUSS & itType . iyBase .~ BIGBLUNDERBUSS
& itConsumption . laMax .~ 50 & itConsumption . laMax .~ 50
& itConsumption . laReloadTime .~ 36 & itConsumption . laLoadType . ejectTime .~ 18
& itConsumption . laLoadType . insertTime .~ 18
& itParams . recoil .~ 200 & itParams . recoil .~ 200
& itParams . torqueAfter .~ 0.3 & itParams . torqueAfter .~ 0.3
& itParams . randomOffset .~ 16 & itParams . randomOffset .~ 16
@@ -183,7 +179,8 @@ biggerBlunderbuss :: Item
biggerBlunderbuss = bigBlunderbuss biggerBlunderbuss = bigBlunderbuss
& itType . iyBase .~ BIGGERBLUNDERBUSS & itType . iyBase .~ BIGGERBLUNDERBUSS
& itConsumption . laMax .~ 75 & itConsumption . laMax .~ 75
& itConsumption . laReloadTime .~ 43 & itConsumption . laLoadType . ejectTime .~ 20
& itConsumption . laLoadType . insertTime .~ 20
& itParams . recoil .~ 250 & itParams . recoil .~ 250
& itParams . torqueAfter .~ 0.5 & itParams . torqueAfter .~ 0.5
& itParams . randomOffset .~ 20 & itParams . randomOffset .~ 20
@@ -191,7 +188,8 @@ biggestBlunderbuss :: Item
biggestBlunderbuss = biggerBlunderbuss biggestBlunderbuss = biggerBlunderbuss
& itType . iyBase .~ BIGGESTBLUNDERBUSS & itType . iyBase .~ BIGGESTBLUNDERBUSS
& itConsumption . laMax .~ 100 & itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 50 & itConsumption . laLoadType . ejectTime .~ 25
& itConsumption . laLoadType . insertTime .~ 25
& itParams . recoil .~ 300 & itParams . recoil .~ 300
& itParams . torqueAfter .~ 0.7 & itParams . torqueAfter .~ 0.7
& itParams . randomOffset .~ 24 & itParams . randomOffset .~ 24
@@ -199,35 +197,5 @@ biggestBlunderbuss = biggerBlunderbuss
grenadeLauncher :: Int -> Item grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone grenadeLauncher _ = bangCone
longGun :: Item
longGun = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = hvBullet
, _laMax = 1
, _laLoaded = 1
, _laReloadTime = 100
, _laReloadType = PassiveReload skwareFadeTwoSecS
}
, _itUse = ruseAmmoParamsRate 100 upHammer
[ ammoCheckI
, hammerCheckI
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withThickSmokeI
, withTorqueAfter
, withMuzFlareI
]
& useAim . aimWeight .~ 8
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
& heldScroll .~ zoomLongGun
, _itAttachment = NoItAttachment
, _itScope = ZoomScope (V2 0 0) 0 1 0.1 False
-- , _itEffect = itemLaserScopeEffect
}
& itType . iyBase .~ LONGGUN
autogunSpread :: Float autogunSpread :: Float
autogunSpread = 0.07 autogunSpread = 0.07
+7 -9
View File
@@ -19,14 +19,8 @@ import Control.Lens
--import System.Random --import System.Random
droneLauncher :: Item droneLauncher :: Item
droneLauncher = defaultGun droneLauncher = defaultWeapon
{ _itConsumption = defaultAmmo { _itUse = ruseRate 20 aDroneWithItemParams upHammer
{ _laType = DroneAmmo { _amString = "LASDRONE" }
, _laMax = 2
, _laLoaded = 2
, _laReloadTime = 80
}
, _itUse = ruseRate 20 aDroneWithItemParams upHammer
[ ammoCheckI [ ammoCheckI
, useTimeCheck , useTimeCheck
, withSoundStart tap4S , withSoundStart tap4S
@@ -37,6 +31,10 @@ droneLauncher = defaultGun
& useAim . aimStance .~ TwoHandTwist & useAim . aimStance .~ TwoHandTwist
, _itEffect = NoItEffect , _itEffect = NoItEffect
} }
& itConsumption . laAmmoType .~ DroneAmmo { _amString = "LASDRONE" }
& itConsumption . laMax .~ 2
& itConsumption . laLoadType . ejectTime .~ 40
& itConsumption . laLoadType . insertTime .~ 40
& itType . iyBase .~ DRONELAUNCHER & itType . iyBase .~ DRONELAUNCHER
lasDronesPic :: Item -> SPic lasDronesPic :: Item -> SPic
@@ -63,7 +61,7 @@ aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
{ _prPos = pos { _prPos = pos
, _pjStartPos = pos , _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0) , _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laType am , _prDraw = _amPjDraw $ _laAmmoType am
, _pjID = i , _pjID = i
, _pjUpdate = const id , _pjUpdate = const id
} }
+8 -8
View File
@@ -186,7 +186,7 @@ targetRBPressUpdate w t
& tgActive .~ False & tgActive .~ False
targetLaserUpdate :: Item -> Creature -> World -> Targeting -> (World,Targeting) targetLaserUpdate :: Item -> Creature -> World -> Targeting -> (World,Targeting)
targetLaserUpdate it cr w t targetLaserUpdate _ cr w t
| crIsAiming cr = (addLaserPic w,t | crIsAiming cr = (addLaserPic w,t
& tgPos .~ fmap fst mp & tgPos .~ fmap fst mp
& tgActive .~ True & tgActive .~ True
@@ -205,10 +205,10 @@ targetLaserUpdate it cr w t
] ]
, _ptUpdate = ptSimpleTime 1 , _ptUpdate = ptSimpleTime 1
} }
wpammo = _itConsumption it --wpammo = _itConsumption it
reloadFrac -- reloadFrac
| _laLoaded wpammo == 0 = 1 -- | _laLoaded wpammo == 0 = 1
| otherwise = case _laTransfer wpammo of -- | otherwise = case _laTransfer wpammo of
Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo) -- Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
NoTransfer -> 1 -- NoTransfer -> 1
col = mixColors reloadFrac (1-reloadFrac) blue red col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
+13 -13
View File
@@ -34,18 +34,18 @@ import Control.Lens
import Control.Applicative import Control.Applicative
launcher :: Item launcher :: Item
launcher = defaultGun launcher = defaultWeapon
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laType = ProjectileAmmo & laAmmoType .~ ProjectileAmmo
{ _amPayload = makeExplosionAt { _amPayload = makeExplosionAt
, _amString = "EXPLOSIVE SHELL" , _amString = "EXPLOSIVE SHELL"
, _amPjDraw = drawShell , _amPjDraw = drawShell
, _amPjCreation = fireShell , _amPjCreation = fireShell
} }
, _laMax = 1 & laMax .~ 1
, _laLoaded = 1 & laLoaded .~ 1
, _laReloadTime = 80 & laLoadType . ejectTime .~ 40
} & laLoadType . insertTime .~ 40
, _itUse = ruseRate 20 usePjCreation upHammer , _itUse = ruseRate 20 usePjCreation upHammer
[ hammerCheckI [ hammerCheckI
, ammoCheckI , ammoCheckI
@@ -94,14 +94,14 @@ launcherX i = launcher
] ]
usePjCreation :: Item -> Creature -> World -> World usePjCreation :: Item -> Creature -> World -> World
usePjCreation it = _amPjCreation (_laType (_itConsumption it)) it usePjCreation it = _amPjCreation (_laAmmoType (_itConsumption it)) it
usePjCreationX :: Int -> Item -> Creature -> World -> World usePjCreationX :: Int -> Item -> Creature -> World -> World
usePjCreationX i it cr = foldr f usePjCreationX i it cr = foldr f
(_amPjCreation (_laType (_itConsumption it)) it cr) (_amPjCreation (_laAmmoType (_itConsumption it)) it cr)
[1..i-1] [1..i-1]
where where
f n = (. _amPjCreation (_laType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i))) f n = (. _amPjCreation (_laAmmoType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
launcherPic :: Item -> SPic launcherPic :: Item -> SPic
launcherPic _ = launcherPic _ =
@@ -280,7 +280,7 @@ remoteLauncher = launcher
& itType . iyBase .~ REMOTELAUNCHER & itType . iyBase .~ REMOTELAUNCHER
& itUse . rUse .~ fireRemoteShell & itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True & itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . laType . amPjDraw .~ drawRemoteShell & itConsumption . laAmmoType . amPjDraw .~ drawRemoteShell
-- TODO consider allowing tweaking rocket speed -- TODO consider allowing tweaking rocket speed
fireRemoteShell :: Item -> Creature -> World -> World fireRemoteShell :: Item -> Creature -> World -> World
@@ -374,13 +374,13 @@ makeShell it cr theupdate w = w & props %~ IM.insert i Shell
, _pjZ = 20 , _pjZ = 20
, _pjStartPos = pos , _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0) , _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laType am , _prDraw = _amPjDraw $ _laAmmoType am
, _pjID = i , _pjID = i
, _pjUpdate = theupdate , _pjUpdate = theupdate
, _pjAcc = rotateV dir (V2 3 0) , _pjAcc = rotateV dir (V2 3 0)
, _pjDir = dir , _pjDir = dir
, _pjSpin = 0 , _pjSpin = 0
, _pjPayload = _amPayload $ _laType am , _pjPayload = _amPayload $ _laAmmoType am
, _pjTimer = 50 , _pjTimer = 50
} }
where where
+2 -3
View File
@@ -22,9 +22,8 @@ import Control.Lens
{- | {- |
Sends out pulses that display walls. -} Sends out pulses that display walls. -}
clickDetector :: Detector -> Item clickDetector :: Detector -> Item
clickDetector dt = defaultGun clickDetector dt = defaultWeapon
{ _itConsumption = defaultAmmo { _itUse = ruseRate 20 (detectorEffect dt) upHammer
, _itUse = ruseRate 20 (detectorEffect dt) upHammer
[ ammoUseCheck [ ammoUseCheck
] ]
& useAim . aimRange .~ 1 & useAim . aimRange .~ 1
+1 -2
View File
@@ -27,9 +27,8 @@ import LensHelp
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
shatterGun :: Item shatterGun :: Item
shatterGun = defaultGun shatterGun = defaultWeapon
& itType . iyBase .~ SHATTERGUN & itType . iyBase .~ SHATTERGUN
& itConsumption .~ defaultAmmo
& itUse .~ ruseRate 10 shootShatter upHammer & itUse .~ ruseRate 10 shootShatter upHammer
[ ammoHammerCheck [ ammoHammerCheck
, useTimeCheck , useTimeCheck
+4 -5
View File
@@ -30,11 +30,10 @@ import LensHelp
sonicGun :: Item sonicGun :: Item
sonicGun = defaultAutoGun sonicGun = defaultAutoGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 10 & laMax .~ 10
, _laLoaded = 10 & laLoadType . ejectTime .~ 40
, _laReloadTime = 80 & laLoadType . insertTime .~ 40
}
, _itUse = ruseRate 8 aSonicWave (HasHammer HammerUp) , _itUse = ruseRate 8 aSonicWave (HasHammer HammerUp)
[ ammoHammerCheck [ ammoHammerCheck
, useTimeCheck , useTimeCheck
+5 -6
View File
@@ -15,12 +15,11 @@ import Control.Lens
{- | {- |
Creates a creature next to the creature using the item. -} Creates a creature next to the creature using the item. -}
spawnGun :: Creature -> Item spawnGun :: Creature -> Item
spawnGun cr = defaultGun spawnGun cr = defaultWeapon
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 1 & laMax .~ 1
, _laLoaded = 1 & laLoadType . ejectTime .~ 40
, _laReloadTime = 80 & laLoadType . insertTime .~ 40
}
, _itUse = ruseRate 100 , _itUse = ruseRate 100
(\_ -> spawnCrNextTo cr) (\_ -> spawnCrNextTo cr)
upHammer upHammer
+9 -9
View File
@@ -40,7 +40,7 @@ import System.Random
poisonSprayer :: Item poisonSprayer :: Item
poisonSprayer = flameThrower poisonSprayer = flameThrower
& itType . iyBase .~ POISONSPRAYER & itType . iyBase .~ POISONSPRAYER
& itConsumption . laType .~ GasAmmo & itConsumption . laAmmoType .~ GasAmmo
{ _amString = "POISONGAS" { _amString = "POISONGAS"
, _amCreateGas = aGasCloud , _amCreateGas = aGasCloud
} }
@@ -68,7 +68,8 @@ flameSpitter :: Item
flameSpitter = flameThrower flameSpitter = flameThrower
& itType . iyBase .~ FLAMESPITTER & itType . iyBase .~ FLAMESPITTER
& itConsumption . laMax .~ 10 & itConsumption . laMax .~ 10
& itConsumption . laReloadTime .~ 20 & itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4 & itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . useAim . aimStance .~ OneHand & itUse . useAim . aimStance .~ OneHand
& itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0} & itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0}
@@ -116,15 +117,14 @@ flameWall = flameThrower
flameThrower :: Item flameThrower :: Item
flameThrower = defaultAutoGun flameThrower = defaultAutoGun
{ _itConsumption = defaultAmmo { _itConsumption = defaultLoadable
{ _laMax = 250 & laMax .~ 250
, _laLoaded = 0 & laAmmoType .~ GasAmmo
, _laReloadTime = 100
, _laType = GasAmmo
{_amString = "FLAME" {_amString = "FLAME"
,_amCreateGas = aFlame ,_amCreateGas = aFlame
} }
} & laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseInstant (overNozzles useGasParams) NoHammer , _itUse = ruseInstant (overNozzles useGasParams) NoHammer
[ ammoCheckI [ ammoCheckI
, useAmmoAmount 1 , useAmmoAmount 1
@@ -191,7 +191,7 @@ overNozzle eff it cr w nz =
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount) wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
useGasParams :: Nozzle -> Item -> Creature -> World -> World useGasParams :: Nozzle -> Item -> Creature -> World -> World
useGasParams nz it cr = _amCreateGas (_laType (_itConsumption it)) (_nzPressure nz) pos dir cr useGasParams nz it cr = _amCreateGas (_laAmmoType (_itConsumption it)) (_nzPressure nz) pos dir cr
where where
dir = _crDir cr dir = _crDir cr
pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr)) pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr))
+5 -5
View File
@@ -173,15 +173,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
itRef = _crInvSel cr itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_useDelay (_itUse item)) currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = _laTransfer (_itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1 repeatFire = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _laTransfer (_itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 0 firstFire = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 0
{- | Apply effect after a warm up. -} {- | Apply effect after a warm up. -}
-- note this is quite unsafe, requires the item to have the correct delay type -- note this is quite unsafe, requires the item to have the correct delay type
withWarmUp withWarmUp
:: SoundID -- ^ warm up sound id :: SoundID -- ^ warm up sound id
-> ChainEffect -> ChainEffect
withWarmUp soundID f item cr w withWarmUp soundID f item cr w
| _laTransfer (_itConsumption item) /= NoTransfer = w | _loadProgress (_laLoadType $ _itConsumption item) /= NoTransfer = w
| curWarmUp < maxWarmUp = w | curWarmUp < maxWarmUp = w
& pointerToItem . itUse . useDelay . warmTime +~ 2 & pointerToItem . itUse . useDelay . warmTime +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2) & soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
@@ -323,7 +323,7 @@ ammoUseCheck f item cr w
cid = _crID cr cid = _crID cr
itRef = _crInvSel cr itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _laTransfer (_itConsumption item) == NoTransfer fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
&& _rateTime (_useDelay (_itUse item)) == 0 && _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0 && _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0 -- reloadCondition = _laLoaded (_itConsumption item) == 0
@@ -359,7 +359,7 @@ shootL f item cr w
cid = _crID cr cid = _crID cr
invid = fromJust $ _itInvPos item invid = fromJust $ _itInvPos item
pointerToItem = creatures . ix cid . crInv . ix invid pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _laTransfer (_itConsumption item) == NoTransfer fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
&& _rateTime (_useDelay (_itUse item)) == 0 && _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0 && _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0 -- reloadCondition = _laLoaded (_itConsumption item) == 0
+8 -10
View File
@@ -22,7 +22,7 @@ import Control.Lens
--import Control.Monad --import Control.Monad
rewindGun :: Item rewindGun :: Item
rewindGun = defaultGun rewindGun = defaultLeftItem
{ _itInvColor = cyan { _itInvColor = cyan
, _itConsumption = ChargeableAmmo , _itConsumption = ChargeableAmmo
{ _wpMaxCharge = 250 { _wpMaxCharge = 250
@@ -63,9 +63,8 @@ useRewindGun _ _ w = case _rewindWorlds w of
-- needs to shift this item to the current inventory slot -- needs to shift this item to the current inventory slot
shrinkGun :: Item shrinkGun :: Item
shrinkGun = defaultGun shrinkGun = defaultLeftItem
{ _itConsumption = defaultAmmo {_itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer & useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic -- , _itFloorPict = shrinkGunPic
, _itAttachment = AttachBool True , _itAttachment = AttachBool True
@@ -89,9 +88,8 @@ useShrinkGun it cr w = if _atBool $ _itAttachment it
( (itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus) ) ( (itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus) )
blinkGun :: Item blinkGun :: Item
blinkGun = defaultGun blinkGun = defaultLeftItem
{ _itInvColor = cyan { _itInvColor = cyan
, _itConsumption = defaultAmmo
, _itUse = defaultlUse , _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction) & lUse .~ hammerCheckL (shootL $ const blinkAction)
& useHammer .~ upHammer & useHammer .~ upHammer
@@ -107,20 +105,20 @@ unsafeBlinkGun = blinkGun
& itUse . eqEq . eqViewDist ?~ 400 & itUse . eqEq . eqViewDist ?~ 400
effectGun :: String -> (Creature -> World -> World) -> Item effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun effectGun name eff = defaultWeapon
{ _itUse = defaultrUse { _itUse = defaultrUse
& rUse .~ const eff & rUse .~ const eff
& useMods .~ [hammerCheckI] & useMods .~ [hammerCheckI]
} }
& itType . iyBase .~ EFFGUN name & itType . iyBase .~ EFFGUN name
autoEffectGun :: String -> (Creature -> World -> World) -> Item autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultGun autoEffectGun name eff = defaultWeapon
{ _itUse = defaultrUse {_rUse = const eff} { _itUse = defaultrUse {_rUse = const eff}
} }
& itType . iyBase .~ AUTOEFFGUN name & itType . iyBase .~ AUTOEFFGUN name
forceFieldGun :: Item forceFieldGun :: Item
forceFieldGun = defaultGun forceFieldGun = defaultWeapon
{ _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField { _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp) , _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
[ hammerCheckI , ammoCheckI , useAmmoAmount 1] [ hammerCheckI , ammoCheckI , useAmmoAmount 1]
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)] -- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
+43 -33
View File
@@ -1,32 +1,15 @@
module Dodge.Reloading module Dodge.Reloading
( stepReloading ( stepReloading
, tryStartReloading -- , tryStartReloading
, crStopReloading , crStopReloading
, crStartReloading
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Base.Arithmetic --import Dodge.Base.Arithmetic
--import qualified Data.IntMap.Strict as IM --import qualified Data.IntMap.Strict as IM
import Control.Lens import Control.Lens
import Data.Maybe
tryStartReloading :: Creature -> World -> Maybe World
tryStartReloading cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
Just LoadableAmmo {_laMax = ma, _laLoaded = la, _laReloadTime = rtime, _laReloadType = rtype, _laTransfer = NoTransfer}
| ma > la && rtype == ActiveClear -> Just $ w & creatures . ix (_crID cr) %~ clearload
| ma > la && isActivePartial rtype -> Just $ w & creatures . ix (_crID cr) %~ partialload
where
isActivePartial ActivePartial {} = True
isActivePartial _ = False
clearload cr' = cr'
& crInv . ix (_crInvSel cr) . itConsumption . laLoaded .~ 0
& crInv . ix (_crInvSel cr) . itConsumption . laTransfer .~ Transfer ma rtime
& crStance . posture .~ Reloading
partialload cr' = cr'
& crInv . ix (_crInvSel cr) . itConsumption . laTransfer
.~ Transfer (min (ma - la) (_partialReloadAmount rtype)) rtime
& crStance . posture .~ Reloading
_ -> Nothing
---- TODO clean this up, rethink datatypes ---- TODO clean this up, rethink datatypes
--icTryStartReloading :: Item -> Maybe Item --icTryStartReloading :: Item -> Maybe Item
@@ -43,24 +26,51 @@ tryStartReloading cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
-- else id -- else id
-- else Nothing -- else Nothing
crStartReloading :: Creature -> World -> World
crStartReloading cr = creatures . ix (_crID cr) . crStance . posture .~ Reloading
crStopReloading :: Creature -> Creature crStopReloading :: Creature -> Creature
crStopReloading cr = cr & crStance . posture .~ AtEase crStopReloading cr = cr & crStance . posture .~ AtEase
-- ugly TODO cleanup startInsertAmmo :: ItemConsumption -> ItemConsumption
startInsertAmmo ic = ic & laLoadType . loadProgress .~ Insert intime inamount
where
intime = _insertTime (_laLoadType ic)
inamount = maybe id min (ic ^? laLoadType . loadAmount) (_laMax ic - _laLoaded ic)
startEjectAmmo :: ItemConsumption -> ItemConsumption
startEjectAmmo ic = ic & laLoadType . loadProgress .~ Eject (_ejectTime $ _laLoadType ic)
loadAmmo :: Int -> ItemConsumption -> ItemConsumption
loadAmmo inamount ic = ic
& laLoaded +~ inamount
& laLoadType . loadProgress .~ NoTransfer
stepReloading :: Creature -> Creature stepReloading :: Creature -> Creature
stepReloading cr = case cr ^? crInv . ix isel . itConsumption . laTransfer of stepReloading cr = case _posture (_crStance cr) of
Just (Transfer x 0) -> cr Reloading -> fromMaybe (cr & crStance . posture .~ AtEase)
& crInv . ix isel %~ loadItem x (cr & crInv . ix (_crInvSel cr) . itConsumption %%~ stepReloading')
& crStance . posture .~ AtEase
Just Transfer {} -> cr
& crInv . ix isel . itConsumption . laTransfer . transferTime %~ decreaseToZero
_ -> cr _ -> cr
where
isel = _crInvSel cr
loadItem :: Int -> Item -> Item
loadItem x = itConsumption %~ (set laTransfer NoTransfer . (laLoaded +~ x))
stepReloading' :: ItemConsumption -> Maybe ItemConsumption
stepReloading' ic = do
ltype <- ic ^? laLoadType
lprog <- ltype ^? loadProgress
case lprog of
Eject x
| x > 0 -> Just $ ic & laLoadType . loadProgress . ejectProgress -~ 1
| otherwise -> Just $ ic & startInsertAmmo
Insert x inamount
| x > 0 -> Just $ ic & laLoadType . loadProgress . insertProgress -~ 1
| otherwise -> Just $ ic & loadAmmo inamount
NoTransfer
| _laLoaded ic >= _laMax ic
-> Nothing
| otherwise -> case ltype of
ActiveEject {} -> Just $ ic & startEjectAmmo
ActivePartial {} -> Just $ ic & startInsertAmmo
_ -> Nothing
--{- | Start reloading if clip is empty. -} --{- | Start reloading if clip is empty. -}
--crAutoReload :: Creature -> Creature --crAutoReload :: Creature -> Creature
--crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of --crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of