Implement automatic reload
This commit is contained in:
+1
-17
@@ -39,22 +39,6 @@ import Foreign.ForeignPtr
|
|||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
---}
|
---}
|
||||||
|
|
||||||
--killCr :: World -> (World -> World) -> Creature -> ((World -> World,StdGen), Maybe Creature)
|
|
||||||
--killCr w f cr = ((g . f, _randGen w),Nothing)
|
|
||||||
-- where crBeforeDeath = colCrWall w $ cr
|
|
||||||
-- addCorpse = insertNewKey $ uncurry translate (_crPos crBeforeDeath)
|
|
||||||
-- $ rotate (radToDeg (_crDir cr))
|
|
||||||
-- (_crCorpse cr)
|
|
||||||
-- maybeIt = evalState (maybeTakeOne $ IM.elems (_crInv cr)) (_randGen w)
|
|
||||||
-- insertIt = case maybeIt of
|
|
||||||
-- Just it -> createItemAt (offset +.+ _crPos crBeforeDeath)
|
|
||||||
-- (FlIt {_flIt=it,_flItPos=(0,0),_flItRot=rot,_flItID=0})
|
|
||||||
-- Nothing -> id
|
|
||||||
-- offset = _crRad cr *.* unitVectorAtAngle rot
|
|
||||||
-- (rot,_) = randomR (-pi,pi) $ _randGen w
|
|
||||||
-- g = stopSoundFrom (CrWeaponSound (_crID cr)) . over decorations addCorpse . insertIt
|
|
||||||
|
|
||||||
|
|
||||||
factionIs :: Faction -> Creature -> Bool
|
factionIs :: Faction -> Creature -> Bool
|
||||||
factionIs f c = (_faction $ _crState $ c) == f
|
factionIs f c = (_faction $ _crState $ c) == f
|
||||||
|
|
||||||
@@ -1888,7 +1872,7 @@ spCrRadFac = 8^2
|
|||||||
|
|
||||||
yourControl :: World -> (World -> World,StdGen) -> Creature -> ((World -> World,StdGen), Maybe Creature)
|
yourControl :: World -> (World -> World,StdGen) -> Creature -> ((World -> World,StdGen), Maybe Creature)
|
||||||
yourControl w (f,g) cr = ( (mouseActionsWorld (_mouseButtons w) . f, g)
|
yourControl w (f,g) cr = ( (mouseActionsWorld (_mouseButtons w) . f, g)
|
||||||
, Just $ mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed strafeSpeed 0 cr
|
, Just . crAutoReload . mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed strafeSpeed 0 cr
|
||||||
)
|
)
|
||||||
where strafeSpeed = 3 * equipFactor * (fromMaybe 1 $ yourItem w ^? itAimingSpeed)
|
where strafeSpeed = 3 * equipFactor * (fromMaybe 1 $ yourItem w ^? itAimingSpeed)
|
||||||
speed = 3 * equipFactor
|
speed = 3 * equipFactor
|
||||||
|
|||||||
@@ -207,7 +207,13 @@ reloadWeapon cid w =
|
|||||||
$ set ( itRef . wpReloadState) rT w
|
$ set ( itRef . wpReloadState) rT w
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
crAutoReload :: Creature -> Creature
|
||||||
|
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpLoadedAmmo of
|
||||||
|
Just 0 -> cr & crInv . ix (_crInvSel cr) . wpReloadState %~ (`fromMaybe` reloadT)
|
||||||
|
& crInv . ix (_crInvSel cr) . wpLoadedAmmo %~ (`fromMaybe` maxA)
|
||||||
|
_ -> cr
|
||||||
|
where reloadT = cr ^? crInv . ix (_crInvSel cr) . wpReloadTime
|
||||||
|
maxA = cr ^? crInv . ix (_crInvSel cr) . wpMaxAmmo
|
||||||
|
|
||||||
createItemAt :: Point2 -> FloorItem -> World -> World
|
createItemAt :: Point2 -> FloorItem -> World -> World
|
||||||
createItemAt p it w = over floorItems (IM.insert i (set flItPos p
|
createItemAt p it w = over floorItems (IM.insert i (set flItPos p
|
||||||
|
|||||||
Reference in New Issue
Block a user