diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 41faa3678..b6923f42d 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -163,7 +163,7 @@ startCr = defaultCreature {- | Items you start with. -} startInvList :: [Item] startInvList = - [ + [ rewindGun ] startInventory :: IM.IntMap Item startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem diff --git a/src/Dodge/Creature/Perception.hs b/src/Dodge/Creature/Perception.hs index 29eb298e9..415b1f750 100644 --- a/src/Dodge/Creature/Perception.hs +++ b/src/Dodge/Creature/Perception.hs @@ -59,8 +59,8 @@ isCognizant _ = False combineAwareness :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel combineAwareness (Suspicious x) (Suspicious y) - | x + y < 10000 = Suspicious $ x + y - | otherwise = Cognizant 5000 + | x + y < 5000 = Suspicious $ x + y + | otherwise = Cognizant 1000 combineAwareness (Suspicious x) (Cognizant y) = Cognizant $ min 10000 $ x + y combineAwareness (Cognizant x) (Suspicious y) = Cognizant $ min 10000 $ x + y combineAwareness (Cognizant x) (Cognizant y) = Cognizant $ min 10000 $ x + y @@ -70,7 +70,7 @@ combineAwareness (Cognizant x) (Cognizant y) = Cognizant $ min 10000 $ x + y decreaseAwareness :: AwarenessLevel -> Maybe AwarenessLevel decreaseAwareness (Suspicious 0) = Nothing decreaseAwareness (Suspicious x) = Just $ Suspicious (x - 50) -decreaseAwareness (Cognizant 0) = Just $ Suspicious 10000 +decreaseAwareness (Cognizant 0) = Just $ Suspicious 1000 decreaseAwareness (Cognizant x) = Just $ Cognizant $ x - 50 {- | Given a fixed group of creatures, direct attention to those of them that diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index bf46e500a..f5ca4c4fd 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -115,6 +115,7 @@ data World = World , _config :: Configuration , _preloadData :: PreloadData , _savedWorlds :: M.Map SaveSlot World + , _rewindWorlds :: [World] , _frameClock :: Int } @@ -421,12 +422,17 @@ data ItemDimension = ItemDimension data ReloadType = ActiveReload | PassiveReload SoundID +-- I believe this is called every frame, not sure when though data ItEffect = NoItEffect | ItInvEffect {_itInvEffect :: ItEffect -> Creature -> Int -> World -> World -- the Int is the items inventory position ,_itEffectCounter :: Int } + | ItRewindEffect + {_itInvEffect :: ItEffect -> Creature -> Int -> World -> World + ,_itStoredWorlds :: [World] + } | ItEffect {_itInvEffect :: ItEffect -> Creature -> Int -> World -> World ,_itFloorEffect :: Int -> World -> World diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index f7dbdb1d4..ce64228d9 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -84,6 +84,7 @@ defaultWorld = World , _preloadData = DummyPdata -- hack TODO remove this , _frameClock = 0 , _worldBounds = defaultBounds + , _rewindWorlds = [] } youLight :: TempLightSource youLight = diff --git a/src/Dodge/Item/Data.hs b/src/Dodge/Item/Data.hs index 801028e9f..2bea63c2d 100644 --- a/src/Dodge/Item/Data.hs +++ b/src/Dodge/Item/Data.hs @@ -27,6 +27,7 @@ data ItemIdentity | LongGun | Flamethrower | Blinker + | Rewinder | Grenade | RemoteBomb | TeslaGun diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index 2396cea92..0bdd160f7 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -1,5 +1,6 @@ module Dodge.Item.Weapon.Utility where import Dodge.Data +import Dodge.Base import Dodge.Default import Dodge.Picture.Layer import Dodge.Creature.Action @@ -7,11 +8,35 @@ import Dodge.Item.Weapon.TriggerType import Dodge.Default.Weapon import Geometry import Picture ---import qualified IntMapHelp as IM +import qualified IntMapHelp as IM import Shape import ShapePicture import Control.Lens + +rewindGun :: Item +rewindGun = defaultGun + { _itName = "REWINDER" + , _itIdentity = Rewinder + , _wpMaxAmmo = 0 + , _wpLoadedAmmo = 0 + , _itUse = useRewindGun + , _itEffect = ItRewindEffect rewindEffect [] + , _itLeftClickUse = Just $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr + } +rewindEffect :: ItEffect -> Creature -> Int -> World -> World +rewindEffect iteff cr invid w = w & rewindWorlds %~ (take 100 . (w' : )) + & creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w) + where + w' = w & rewindWorlds .~ [] + +useRewindGun :: Item -> Creature -> World -> World +useRewindGun it cr w = case _rewindWorlds w of + (_:w':ws) -> w' & keys .~ _keys w + & mouseButtons .~ _mouseButtons w + & rewindWorlds .~ ws + _ -> w + shrinkGun :: Item shrinkGun = defaultGun { _itName = "SHRINKER"