diff --git a/src/Dodge/AIs.hs b/src/Dodge/AIs.hs index 68e5712a3..23d7ec50b 100644 --- a/src/Dodge/AIs.hs +++ b/src/Dodge/AIs.hs @@ -39,22 +39,6 @@ import Foreign.ForeignPtr 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 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 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) speed = 3 * equipFactor diff --git a/src/Dodge/CreatureAction.hs b/src/Dodge/CreatureAction.hs index b468dba15..333ee0243 100644 --- a/src/Dodge/CreatureAction.hs +++ b/src/Dodge/CreatureAction.hs @@ -207,7 +207,13 @@ reloadWeapon cid w = $ set ( itRef . wpReloadState) rT w _ -> 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 p it w = over floorItems (IM.insert i (set flItPos p