Mid implementation of external ammo sources
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Combine.Combinations
|
||||
, bulletWeapons
|
||||
) where
|
||||
|
||||
import Dodge.Item.Ammo
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Item
|
||||
import LensHelp
|
||||
@@ -35,12 +36,19 @@ hatCombinations =
|
||||
po xs it = (map o xs, it)
|
||||
o = (1,)
|
||||
|
||||
magazineCombinations :: [([(ItAmount,ItemBaseType)],Item)]
|
||||
magazineCombinations =
|
||||
[ po [CRAFT TIN, CRAFT SPRING] tinMag ]
|
||||
where
|
||||
po xs it = (map o xs, it)
|
||||
o = (1,)
|
||||
|
||||
itemCombinations :: [([(ItAmount, ItemBaseType)], Item)]
|
||||
itemCombinations =
|
||||
watchCombinations ++
|
||||
backpackCombinations ++
|
||||
hatCombinations ++
|
||||
magazineCombinations ++
|
||||
[ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1)
|
||||
, po [HELD (BANGSTICK 1), CRAFT TIN] pistol
|
||||
, po [HELD PISTOL, CRAFT SPRING] autoPistol
|
||||
|
||||
@@ -98,8 +98,8 @@ data AttachType
|
||||
= SCROLLATTACH ScrollAttachType
|
||||
| AMMOATTACH AmmoAttachType
|
||||
| TARGETATTACH {_ibtAttachTarget :: TargetType}
|
||||
| BULPAYLOADATTACH
|
||||
| BULTRAJECTORYATTACH
|
||||
-- | BULPAYLOADATTACH
|
||||
-- | BULTRAJECTORYATTACH
|
||||
deriving (Eq, Ord, Show, Read)
|
||||
|
||||
data ScrollAttachType
|
||||
@@ -167,6 +167,7 @@ data HeldItemType
|
||||
| GRAPECANNON {_xNum :: Int}
|
||||
| MINIGUNX {_xNum :: Int}
|
||||
| VOLLEYGUN {_xNum :: Int}
|
||||
| MULTIGUN {_xNum :: Int}
|
||||
| RIFLE
|
||||
| REPEATER
|
||||
| AUTORIFLE
|
||||
|
||||
@@ -84,6 +84,7 @@ data HeldMod
|
||||
| AmmoHammerTimeUseOneMod
|
||||
| BangCaneMod
|
||||
| VolleyGunMod
|
||||
| MultiGunMod
|
||||
| AutoRifleMod
|
||||
| BangRodMod
|
||||
| ElephantGunMod
|
||||
|
||||
@@ -58,7 +58,7 @@ data ItemUse
|
||||
|
||||
data AttachParams
|
||||
= ScrollAttachParams {_scrollAttachParams :: ScrollAttachParams}
|
||||
| AmmoAttachParams
|
||||
| AmmoAttachParams {_ammoAttachParams :: InternalAmmo}
|
||||
| TargetAttachParams
|
||||
|
||||
data ScrollAttachParams
|
||||
|
||||
@@ -153,6 +153,17 @@ useMod hm = case hm of
|
||||
, ammoCheckI
|
||||
, blCheck
|
||||
]
|
||||
MultiGunMod ->
|
||||
[ withRecoil
|
||||
, withFlare
|
||||
, duplicateLoadedBarrels
|
||||
, withTorqueAfter
|
||||
, useAllAmmo
|
||||
, withSoundItemChoiceStart caneStickSoundChoice
|
||||
, useTimeCheck
|
||||
, ammoCheckI
|
||||
, blCheck
|
||||
]
|
||||
AutoRifleMod ->
|
||||
-- note this is the same as BangCanemMod with the first changed
|
||||
[ withFlare
|
||||
|
||||
+10
-1
@@ -6,10 +6,19 @@ import Dodge.Default.Item
|
||||
|
||||
tinMag :: Item
|
||||
tinMag = defaultHeldItem & itType . iyBase .~ ATTACH (AMMOATTACH TINMAG)
|
||||
& itUse .~ AttachUse AmmoAttachParams
|
||||
& itUse .~ AttachUse {_attachParams = AmmoAttachParams {_ammoAttachParams = InternalAmmo
|
||||
{ _iaMax = 15
|
||||
, _iaLoaded = 15
|
||||
, _iaPrimed = True
|
||||
, _iaCycle = []
|
||||
, _iaProgress = Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drumMag :: Item
|
||||
drumMag = tinMag & itType . iyBase .~ ATTACH (AMMOATTACH DRUMMAG)
|
||||
& itUse . attachParams . ammoAttachParams . iaMax .~ 30
|
||||
|
||||
beltMag :: Item
|
||||
beltMag = tinMag & itType . iyBase .~ ATTACH (AMMOATTACH BULLETBELT)
|
||||
|
||||
@@ -81,6 +81,7 @@ ammoPosition itm hit = case hit of
|
||||
GRAPECANNON _ -> NoAmmoPosition
|
||||
MINIGUNX _ -> NoAmmoPosition
|
||||
VOLLEYGUN i -> volleygunAmmoPos i
|
||||
MULTIGUN i -> multigunAmmoPos i
|
||||
RIFLE -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
|
||||
REPEATER -> Magazine (V3 10 (-2) 0) rhs
|
||||
AUTORIFLE -> Magazine (V3 10 (-2) 0) rhs
|
||||
@@ -129,6 +130,13 @@ volleygunAmmoPos i =
|
||||
where
|
||||
f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
|
||||
|
||||
multigunAmmoPos :: Int -> AmmoPosition
|
||||
multigunAmmoPos i =
|
||||
Bullets
|
||||
[(V3 5 (f n) 3, Q.axisAngle (V3 1 0 0) 0) | n <- [0 .. i -1]]
|
||||
where
|
||||
f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
|
||||
|
||||
revolverAmmoPos :: AmmoPosition
|
||||
revolverAmmoPos =
|
||||
Bullets
|
||||
@@ -154,6 +162,7 @@ heldItemSPic ht it = case ht of
|
||||
GRAPECANNON _ -> noPic $ bangConeShape 20
|
||||
MINIGUNX i -> miniGunXPictItem i it
|
||||
VOLLEYGUN i -> noPic $ volleyGunShape i <> addBullets it
|
||||
MULTIGUN i -> noPic $ volleyGunShape i <> addBullets it
|
||||
RIFLE -> noPic $ baseRifleShape <> addBullets it
|
||||
REPEATER -> noPic $ baseRifleShape <> addTinClip it
|
||||
AUTORIFLE -> noPic $ baseRifleShape <> addTinClip it
|
||||
|
||||
@@ -39,6 +39,7 @@ itemFromHeldType ht = case ht of
|
||||
GRAPECANNON i -> grapeCannon i
|
||||
MINIGUNX i -> miniGunX i
|
||||
VOLLEYGUN i -> volleyGun i
|
||||
MULTIGUN i -> multiGun i
|
||||
RIFLE -> rifle
|
||||
REPEATER -> repeater
|
||||
AUTORIFLE -> autoRifle
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Held.Cane (
|
||||
volleyGun,
|
||||
multiGun,
|
||||
repeater,
|
||||
rifle,
|
||||
autoRifle,
|
||||
@@ -49,6 +50,19 @@ volleyGun i =
|
||||
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
|
||||
& itType . iyBase .~ HELD (VOLLEYGUN i)
|
||||
|
||||
multiGun :: Int -> Item
|
||||
multiGun i =
|
||||
defaultBangCane
|
||||
& itUse . heldMods .~ MultiGunMod
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimRange .~ 1
|
||||
& itUse . heldAim . aimStance .~ TwoHandFlat
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
|
||||
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
|
||||
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
|
||||
& itType . iyBase .~ HELD (MULTIGUN i)
|
||||
|
||||
rifle :: Item
|
||||
rifle =
|
||||
defaultBangCane
|
||||
|
||||
@@ -55,8 +55,7 @@ pistol =
|
||||
bangStick 1
|
||||
& itUse . heldConsumption
|
||||
.~ ( defaultBulletLoadable
|
||||
& laSource . _InternalSource . iaMax .~ 15
|
||||
& laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
|
||||
& laSource .~ BelowSource
|
||||
)
|
||||
& itUse . heldDelay . rateMax .~ 6
|
||||
& itUse . heldMods .~ PistolMod
|
||||
|
||||
@@ -24,7 +24,6 @@ itBounds ibt = case ibt of
|
||||
HELD hit -> heldBounds hit
|
||||
_ -> V3 0 0 0
|
||||
|
||||
|
||||
heldBounds :: HeldItemType -> Point3
|
||||
heldBounds hit = case hit of
|
||||
BANGSTICK _ -> V3 0 0 0
|
||||
@@ -39,6 +38,7 @@ heldBounds hit = case hit of
|
||||
GRAPECANNON _ -> bbs
|
||||
MINIGUNX _ -> minis
|
||||
VOLLEYGUN _ -> undefined
|
||||
MULTIGUN _ -> undefined
|
||||
RIFLE -> rs
|
||||
REPEATER -> rs
|
||||
AUTORIFLE -> rs
|
||||
|
||||
@@ -150,6 +150,12 @@ ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
|
||||
x <- cr ^? crInv . ix (invid - 1) . itUse . equipEffect . eeUse . euseAmmoAmount
|
||||
return $ x <= 0 ->
|
||||
failsound w
|
||||
Just BelowSource
|
||||
| fromMaybe True $ do
|
||||
invid <- itm ^? itLocation . ipInvID
|
||||
x <- cr ^? crInv . ix (invid + 1) . itUse . attachParams . ammoAttachParams . iaLoaded
|
||||
return $ x <= 0 ->
|
||||
failsound w
|
||||
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
where
|
||||
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
@@ -342,20 +348,19 @@ withSidePushAfterI maxSide eff item cr w =
|
||||
(pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w
|
||||
|
||||
useAllAmmo :: ChainEffect
|
||||
useAllAmmo eff item cr =
|
||||
eff item cr
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded .~ 0)
|
||||
where
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
useAllAmmo eff item cr = fromMaybe id $ do
|
||||
invid <- item ^? itLocation . ipInvID
|
||||
return $ eff item cr
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (invid + 1)
|
||||
. itUse . heldConsumption . laSource . _InternalSource . iaLoaded .~ 0)
|
||||
|
||||
useAmmoUpTo :: Int -> ChainEffect
|
||||
useAmmoUpTo amAmount eff item cr =
|
||||
eff item cr
|
||||
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded
|
||||
useAmmoUpTo amAmount eff itm cr = fromMaybe id $ do
|
||||
invid <- itm ^? itLocation . ipInvID
|
||||
return $ eff itm cr
|
||||
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (invid + 1) . itUse . attachParams . ammoAttachParams . iaLoaded
|
||||
%~ (max 0 . subtract amAmount)
|
||||
)
|
||||
where
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
|
||||
useAmmoAmount :: Int -> ChainEffect
|
||||
useAmmoAmount amAmount eff item cr =
|
||||
|
||||
Reference in New Issue
Block a user