Commit before changes to item grammar
This commit is contained in:
+34
-7
@@ -131,15 +131,15 @@ applyTorqueCME itm cr w
|
||||
|
||||
-- (Muzzle,Int,Int) = (muzzle, amountloaded, id of mag taken from)
|
||||
loadMuzzle :: LabelDoubleTree ComposeLinkType Item
|
||||
-> Muzzle -> (LabelDoubleTree ComposeLinkType Item,(Muzzle, Int,Maybe Int))
|
||||
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t,(mz, 0,Nothing)) $ do
|
||||
-> Muzzle -> (LabelDoubleTree ComposeLinkType Item,Maybe (Muzzle, Int,LabelDoubleTree ComposeLinkType Item))
|
||||
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t,Nothing) $ do
|
||||
let as = _mzAmmoSlot mz
|
||||
amamount = 1
|
||||
(i,(_,mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
||||
availableammo <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
|
||||
let usedammo = min amamount availableammo
|
||||
return (t & ldtLeft . ix i . _2 . ldtValue . itUse . amagLoadStatus . iaLoaded -~ usedammo
|
||||
, (mz, usedammo, mag ^? ldtValue . itLocation . ilInvID)
|
||||
, Just (mz, usedammo, mag)
|
||||
)
|
||||
|
||||
makeMuzzleFlare :: Muzzle -> Item -> Creature -> World -> World
|
||||
@@ -183,20 +183,23 @@ isAmmoIntLink :: Int -> ComposeLinkType -> Bool
|
||||
isAmmoIntLink i (AmmoInLink j _) = i == j
|
||||
isAmmoIntLink _ _ = False
|
||||
|
||||
useLoadedAmmo :: Item -> Creature -> (CumulativeMuzzleEffect,World) -> (Int,(Muzzle,Int,Maybe Int))
|
||||
useLoadedAmmo :: Item -> Creature -> (CumulativeMuzzleEffect,World)
|
||||
-> (Int,Maybe (Muzzle,Int,LabelDoubleTree ComposeLinkType Item))
|
||||
-> (CumulativeMuzzleEffect,World)
|
||||
useLoadedAmmo _ _ (cme,w) (_,(_,0,_)) = (cme, w)
|
||||
useLoadedAmmo itm cr (cme,w) (mzid,(mz,x,mid)) = (,) (cme & cmeSound .~ True) $
|
||||
useLoadedAmmo _ _ (cme,w) (_,Nothing) = (cme, w)
|
||||
useLoadedAmmo itm cr (cme,w) (mzid,Just (mz,x,magtree)) = (,) (cme & cmeSound .~ True) $
|
||||
removeAmmoFromMag x mid cr . makeMuzzleFlare mz itm cr $ case _mzEffect mz of
|
||||
MuzzleShootBullet -> shootBullet itm cr w (mz,x,mid)
|
||||
MuzzleLaser -> shootLaser' itm cr mz w
|
||||
MuzzleTesla -> shootTeslaArc itm cr mz w
|
||||
MuzzleTractor -> shootTractorBeam itm cr w
|
||||
MuzzleLauncher -> createProjectile mid mz itm cr w
|
||||
MuzzleLauncher -> createProjectile magtree mz itm cr w
|
||||
MuzzleNozzle {} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
|
||||
MuzzleShatter -> shootShatter itm cr w
|
||||
MuzzleForceField -> useForceFieldGun itm cr w
|
||||
MuzzleDetector -> itemDetectorEffect itm cr w
|
||||
where
|
||||
mid = magtree ^? ldtValue . itLocation . ilInvID
|
||||
|
||||
itemDetectorEffect :: Item -> Creature -> World -> World
|
||||
itemDetectorEffect itm cr w = fromMaybe w $ do
|
||||
@@ -493,3 +496,27 @@ useForceFieldGun itm cr w = fromMaybe w $ do
|
||||
& moveWallIDUnsafe i wlline
|
||||
where
|
||||
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just
|
||||
|
||||
createProjectile :: LabelDoubleTree ComposeLinkType Item -> Muzzle -> Item -> Creature -> World -> World
|
||||
createProjectile mmagtree muz itm cr = fromMaybe failsound $ do
|
||||
magid <- mmagtree ^? ldtValue . itLocation . ilInvID
|
||||
ammoitem <- cr ^? crInv . ix magid
|
||||
-- let mremotescreen = magtree ^.
|
||||
-- matype <- ammoitem ^? itUse . amagType
|
||||
-- guard $ matype == ProjectileAmmo
|
||||
j <- ammoitem ^? itLocation . ilInvID
|
||||
pt <- ammoitem ^? itUse . amagParams . ampPjCreation
|
||||
return $ case pt of
|
||||
CreateShell -> fireShell ammoitem muz itm cr . extrafuncs j
|
||||
CreateTrackingShell -> fireTrackingShell ammoitem muz itm cr . extrafuncs j
|
||||
where
|
||||
--extrafuncs j = cancelanyreloading . startthesound . useammo j
|
||||
extrafuncs j = startthesound . useammo j
|
||||
useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
|
||||
|
||||
--cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
-- the sound should be moved to the projectile firing
|
||||
startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing
|
||||
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||
|
||||
Reference in New Issue
Block a user