Move item effect functions
This commit is contained in:
@@ -3,6 +3,7 @@ module Dodge.Creature.State
|
|||||||
, doDamage
|
, doDamage
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.ItEffect
|
||||||
import Dodge.Euse
|
import Dodge.Euse
|
||||||
import Dodge.EnergyBall
|
import Dodge.EnergyBall
|
||||||
import Dodge.Damage
|
import Dodge.Damage
|
||||||
@@ -196,7 +197,7 @@ invSideEff :: Creature -> World -> World
|
|||||||
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||||
where
|
where
|
||||||
f i it w' = itemInvSideEffect cr it
|
f i it w' = itemInvSideEffect cr it
|
||||||
$ doItemTargeting i cr w' & maybe id (\g -> g it cr) (it ^? itEffect . ieInv)
|
$ doItemTargeting i cr w' & maybe id (\g -> doInvEffect g it cr) (it ^? itEffect . ieInv)
|
||||||
|
|
||||||
itemInvSideEffect :: Creature -> Item -> World -> World
|
itemInvSideEffect :: Creature -> Item -> World -> World
|
||||||
itemInvSideEffect cr it
|
itemInvSideEffect cr it
|
||||||
|
|||||||
+17
-46
@@ -10,6 +10,10 @@ circular imports are probably not a good idea.
|
|||||||
{-# LANGUAGE DerivingStrategies #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
module Dodge.Data
|
module Dodge.Data
|
||||||
( module Dodge.Data
|
( module Dodge.Data
|
||||||
|
, module Dodge.Data.ItEffect
|
||||||
|
, module Dodge.Data.Hammer
|
||||||
|
, module Dodge.Data.Item.Use
|
||||||
|
, module Dodge.Data.Item.UseDelay
|
||||||
, module Dodge.Data.ArcStep
|
, module Dodge.Data.ArcStep
|
||||||
, module Dodge.Data.CrWlID
|
, module Dodge.Data.CrWlID
|
||||||
, module Dodge.Data.Item.HeldUse
|
, module Dodge.Data.Item.HeldUse
|
||||||
@@ -61,6 +65,10 @@ module Dodge.Data
|
|||||||
, module Dodge.Data.RadarBlip
|
, module Dodge.Data.RadarBlip
|
||||||
, module Dodge.Data.PathGraph
|
, module Dodge.Data.PathGraph
|
||||||
) where
|
) where
|
||||||
|
import Dodge.Data.ItEffect
|
||||||
|
import Dodge.Data.Hammer
|
||||||
|
import Dodge.Data.Item.Use
|
||||||
|
import Dodge.Data.Item.UseDelay
|
||||||
import Dodge.Data.CrWlID
|
import Dodge.Data.CrWlID
|
||||||
import Dodge.Data.ArcStep
|
import Dodge.Data.ArcStep
|
||||||
import Dodge.Data.Item.HeldUse
|
import Dodge.Data.Item.HeldUse
|
||||||
@@ -404,39 +412,6 @@ data PressPlate = PressPlate
|
|||||||
, _ppText :: String
|
, _ppText :: String
|
||||||
}
|
}
|
||||||
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
|
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
|
||||||
data ItemUse
|
|
||||||
= RightUse
|
|
||||||
{ _rUse :: HeldUse -- Item -> Creature -> World -> World
|
|
||||||
, _useDelay :: UseDelay
|
|
||||||
, _useMods :: HeldMod --[(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
|
||||||
, _useHammer :: HammerPosition
|
|
||||||
, _useAim :: AimParams
|
|
||||||
, _heldScroll :: HeldScroll --Float -> Creature -> Item -> Item
|
|
||||||
}
|
|
||||||
| LeftUse
|
|
||||||
{ _lUse :: Luse --Item -> Creature -> World -> World
|
|
||||||
, _useDelay :: UseDelay
|
|
||||||
, _useHammer :: HammerPosition
|
|
||||||
, _eqEq :: Equipment
|
|
||||||
}
|
|
||||||
| ConsumeUse
|
|
||||||
{ _cUse :: Cuse --Item -> Creature -> World -> World
|
|
||||||
}
|
|
||||||
| EquipUse
|
|
||||||
{ _eqEq :: Equipment
|
|
||||||
}
|
|
||||||
| NoUse
|
|
||||||
data Equipment = Equipment
|
|
||||||
{ _eqUse :: Euse --Item -> Creature -> World -> World
|
|
||||||
, _eqOnEquip :: Euse --Item -> Creature -> World -> World
|
|
||||||
, _eqOnRemove :: Euse --Item -> Creature -> World -> World
|
|
||||||
, _eqSite :: EquipSite
|
|
||||||
, _eqParams :: EquipParams
|
|
||||||
, _eqViewDist :: Maybe Float
|
|
||||||
}
|
|
||||||
|
|
||||||
_itUseAimStance :: Item -> AimStance
|
|
||||||
_itUseAimStance = _aimStance . _useAim . _itUse
|
|
||||||
|
|
||||||
data Item = Item
|
data Item = Item
|
||||||
{ _itConsumption :: ItemConsumption
|
{ _itConsumption :: ItemConsumption
|
||||||
@@ -471,25 +446,25 @@ data Targeting
|
|||||||
data ItEffect
|
data ItEffect
|
||||||
= NoItEffect
|
= NoItEffect
|
||||||
| ItInvEffect
|
| ItInvEffect
|
||||||
{_ieInv :: Item -> Creature -> World -> World
|
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||||
,_ieCounter :: Int
|
,_ieCounter :: Int
|
||||||
}
|
}
|
||||||
| ItRewindEffect
|
| ItRewindEffect
|
||||||
{_ieInv :: Item -> Creature -> World -> World
|
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||||
,_ieStoredWorlds :: [World]
|
,_ieStoredWorlds :: [World]
|
||||||
}
|
}
|
||||||
| ItEffect
|
| ItEffect
|
||||||
{_ieInv :: Item -> Creature -> World -> World
|
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||||
,_ieFloor :: Int -> World -> World
|
,_ieFloor :: ItFloorEffect --Int -> World -> World
|
||||||
,_ieCounter :: Int
|
,_ieCounter :: Int
|
||||||
}
|
}
|
||||||
| ItInvEffectID
|
| ItInvEffectID
|
||||||
{_ieInv :: Item -> Creature -> World -> World
|
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||||
,_ieMID :: Maybe Int
|
,_ieMID :: Maybe Int
|
||||||
} -- the duplication of ieMID may cause errors...
|
} -- the duplication of ieMID may cause errors...
|
||||||
| ItInvEffectDrop
|
| ItInvEffectDrop
|
||||||
{ _ieInv :: Item -> Creature -> World -> World
|
{ _ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||||
, _ieDrop :: Item -> Creature -> World -> World
|
, _ieDrop :: ItDropEffect --Item -> Creature -> World -> World
|
||||||
, _ieMID :: Maybe Int
|
, _ieMID :: Maybe Int
|
||||||
}
|
}
|
||||||
data IntID a = IntID Int a
|
data IntID a = IntID Int a
|
||||||
@@ -612,10 +587,6 @@ data GunBarrels
|
|||||||
, _brlInaccuracy :: Float
|
, _brlInaccuracy :: Float
|
||||||
}
|
}
|
||||||
| SingleBarrel {_brlInaccuracy :: Float}
|
| SingleBarrel {_brlInaccuracy :: Float}
|
||||||
data EquipParams
|
|
||||||
= NoEquipParams
|
|
||||||
| EquipID {_eparamID :: Int}
|
|
||||||
| EquipCounter {_eparamInt :: Int}
|
|
||||||
data ItemParams
|
data ItemParams
|
||||||
= NoParams
|
= NoParams
|
||||||
| ShellLauncher
|
| ShellLauncher
|
||||||
@@ -1256,7 +1227,6 @@ makeLenses ''CreatureState
|
|||||||
makeLenses ''World
|
makeLenses ''World
|
||||||
makeLenses ''Creature
|
makeLenses ''Creature
|
||||||
makeLenses ''Item
|
makeLenses ''Item
|
||||||
makeLenses ''ItemUse
|
|
||||||
makeLenses ''ItEffect
|
makeLenses ''ItEffect
|
||||||
makeLenses ''FloorItem
|
makeLenses ''FloorItem
|
||||||
makeLenses ''TweakParam
|
makeLenses ''TweakParam
|
||||||
@@ -1288,7 +1258,6 @@ makeLenses ''ScreenLayer
|
|||||||
makeLenses ''Beam
|
makeLenses ''Beam
|
||||||
makeLenses ''BeamType
|
makeLenses ''BeamType
|
||||||
makeLenses ''WorldBeams
|
makeLenses ''WorldBeams
|
||||||
makeLenses ''EquipParams
|
|
||||||
makeLenses ''TerminalCommand
|
makeLenses ''TerminalCommand
|
||||||
makeLenses ''TerminalInput
|
makeLenses ''TerminalInput
|
||||||
makeLenses ''GenParams
|
makeLenses ''GenParams
|
||||||
@@ -1301,6 +1270,8 @@ makeLenses ''PSType
|
|||||||
makeLenses ''PlacementSpot
|
makeLenses ''PlacementSpot
|
||||||
makeLenses ''Placement
|
makeLenses ''Placement
|
||||||
|
|
||||||
|
_itUseAimStance :: Item -> AimStance
|
||||||
|
_itUseAimStance = _aimStance . _useAim . _itUse
|
||||||
|
|
||||||
crSel :: Creature -> Int
|
crSel :: Creature -> Int
|
||||||
crSel = _iselPos . _crInvSel
|
crSel = _iselPos . _crInvSel
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
module Dodge.Data.Hammer where
|
||||||
|
import Control.Lens
|
||||||
|
data HammerType
|
||||||
|
= NoHammer
|
||||||
|
| HasHammer {_hammerPosition :: HammerPosition}
|
||||||
|
deriving
|
||||||
|
(Eq, Ord, Show)
|
||||||
|
data HammerPosition
|
||||||
|
= HammerDown
|
||||||
|
| HammerReleased
|
||||||
|
| HammerUp
|
||||||
|
deriving
|
||||||
|
(Eq, Ord, Show)
|
||||||
|
makeLenses ''HammerType
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
module Dodge.Data.ItEffect where
|
||||||
|
|
||||||
|
data ItInvEffect = NoInvEffect
|
||||||
|
| RewindEffect
|
||||||
|
| ResetAttachmentEffect
|
||||||
|
| OnOffHeldEffect ItInvEffect ItInvEffect
|
||||||
|
| CreateHeldLight
|
||||||
|
| CreateShieldWall
|
||||||
|
| RemoveShieldWall
|
||||||
|
data ItFloorEffect = NoFloorEffect
|
||||||
|
data ItDropEffect = NoDropEffect
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
module Dodge.Data.Item.Use where
|
||||||
|
import Dodge.Data.Item.HeldUse
|
||||||
|
import Dodge.Data.Item.HeldScroll
|
||||||
|
import Dodge.Data.Item.UseDelay
|
||||||
|
import Dodge.Data.Hammer
|
||||||
|
import Dodge.Equipment.Data
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
data ItemUse
|
||||||
|
= RightUse
|
||||||
|
{ _rUse :: HeldUse -- Item -> Creature -> World -> World
|
||||||
|
, _useDelay :: UseDelay
|
||||||
|
, _useMods :: HeldMod --[(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
||||||
|
, _useHammer :: HammerPosition
|
||||||
|
, _useAim :: AimParams
|
||||||
|
, _heldScroll :: HeldScroll --Float -> Creature -> Item -> Item
|
||||||
|
}
|
||||||
|
| LeftUse
|
||||||
|
{ _lUse :: Luse --Item -> Creature -> World -> World
|
||||||
|
, _useDelay :: UseDelay
|
||||||
|
, _useHammer :: HammerPosition
|
||||||
|
, _eqEq :: Equipment
|
||||||
|
}
|
||||||
|
| ConsumeUse
|
||||||
|
{ _cUse :: Cuse --Item -> Creature -> World -> World
|
||||||
|
}
|
||||||
|
| EquipUse
|
||||||
|
{ _eqEq :: Equipment
|
||||||
|
}
|
||||||
|
| NoUse
|
||||||
|
data Equipment = Equipment
|
||||||
|
{ _eqUse :: Euse --Item -> Creature -> World -> World
|
||||||
|
, _eqOnEquip :: Euse --Item -> Creature -> World -> World
|
||||||
|
, _eqOnRemove :: Euse --Item -> Creature -> World -> World
|
||||||
|
, _eqSite :: EquipSite
|
||||||
|
, _eqParams :: EquipParams
|
||||||
|
, _eqViewDist :: Maybe Float
|
||||||
|
}
|
||||||
|
data AimParams = AimParams
|
||||||
|
{ _aimWeight :: Int
|
||||||
|
, _aimRange :: Float
|
||||||
|
, _aimZoom :: ItZoom
|
||||||
|
, _aimStance :: AimStance
|
||||||
|
, _aimHandlePos :: Float
|
||||||
|
, _aimMuzPos :: Float
|
||||||
|
}
|
||||||
|
data AimStance
|
||||||
|
= TwoHandTwist
|
||||||
|
| TwoHandFlat
|
||||||
|
| OneHand
|
||||||
|
| LeaveHolstered
|
||||||
|
deriving
|
||||||
|
(Eq,Show,Ord,Enum)
|
||||||
|
|
||||||
|
data EquipParams
|
||||||
|
= NoEquipParams
|
||||||
|
| EquipID {_eparamID :: Int}
|
||||||
|
| EquipCounter {_eparamInt :: Int}
|
||||||
|
data ItZoom = ItZoom
|
||||||
|
{ _itZoomMax :: Float
|
||||||
|
, _itZoomMin :: Float
|
||||||
|
, _itZoomFac :: Float
|
||||||
|
}
|
||||||
|
makeLenses ''ItemUse
|
||||||
|
makeLenses ''AimParams
|
||||||
|
makeLenses ''EquipParams
|
||||||
|
makeLenses ''ItZoom
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{-# LANGUAGE StrictData #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
module Dodge.Data.Item.UseDelay where
|
||||||
|
import Control.Lens
|
||||||
|
data UseDelay -- should just be Delay
|
||||||
|
= NoDelay
|
||||||
|
| FixedRate
|
||||||
|
{_rateMax :: Int
|
||||||
|
,_rateTime :: Int
|
||||||
|
}
|
||||||
|
| VariableRate
|
||||||
|
{_rateMax :: Int
|
||||||
|
,_rateTime :: Int
|
||||||
|
,_rateMaxMax :: Int
|
||||||
|
,_rateMinMax :: Int
|
||||||
|
}
|
||||||
|
| WarmUpNoDelay
|
||||||
|
{_warmTime :: Int
|
||||||
|
,_warmMax :: Int
|
||||||
|
}
|
||||||
|
makeLenses ''UseDelay
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Data.LoadAction where
|
module Dodge.Data.LoadAction where
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
import Dodge.Item.Data
|
import Dodge.Data.Hammer
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
data LoadAction
|
data LoadAction
|
||||||
= LoadEject {_actionTime :: Int, _actionSound :: SoundID}
|
= LoadEject {_actionTime :: Int, _actionSound :: SoundID}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Dodge.Default.AimParams where
|
module Dodge.Default.AimParams where
|
||||||
import Dodge.Item.Data
|
import Dodge.Data.Item.Use
|
||||||
|
|
||||||
defaultAimParams :: AimParams
|
defaultAimParams :: AimParams
|
||||||
defaultAimParams = AimParams
|
defaultAimParams = AimParams
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
module Dodge.Hammer where
|
module Dodge.Hammer where
|
||||||
import Dodge.Item.Data
|
import Dodge.Data.Hammer
|
||||||
|
|
||||||
moveHammerUp :: HammerPosition -> HammerPosition
|
moveHammerUp :: HammerPosition -> HammerPosition
|
||||||
moveHammerUp HammerDown = HammerReleased
|
moveHammerUp HammerDown = HammerReleased
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ module Dodge.Inventory
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.ItEffect
|
||||||
import Dodge.Euse
|
import Dodge.Euse
|
||||||
import Dodge.Inventory.CloseObject
|
import Dodge.Inventory.CloseObject
|
||||||
import Dodge.Inventory.CheckSlots
|
import Dodge.Inventory.CheckSlots
|
||||||
@@ -75,7 +76,7 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
|
|||||||
return $ useE rmf itm cr
|
return $ useE rmf itm cr
|
||||||
doanyitemeffect = fromMaybe id $ do
|
doanyitemeffect = fromMaybe id $ do
|
||||||
rmf <- itm ^? itEffect . ieDrop
|
rmf <- itm ^? itEffect . ieDrop
|
||||||
return $ rmf itm cr
|
return $ doDropEffect rmf itm cr
|
||||||
removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of
|
removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of
|
||||||
Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing
|
Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
module Dodge.ItEffect where
|
||||||
|
import Dodge.Data
|
||||||
|
import Dodge.Item.Equipment
|
||||||
|
import Dodge.LightSource.Torch
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
|
||||||
|
doInvEffect iie = case iie of
|
||||||
|
NoInvEffect -> const $ const id
|
||||||
|
RewindEffect -> rewindEffect
|
||||||
|
ResetAttachmentEffect -> resetAttachmentEffect
|
||||||
|
OnOffHeldEffect f g -> onOffEff f g
|
||||||
|
CreateHeldLight -> createHeldLight
|
||||||
|
CreateShieldWall -> createShieldWall
|
||||||
|
RemoveShieldWall -> removeShieldWall
|
||||||
|
|
||||||
|
doFloorEffect :: ItFloorEffect -> Int -> World -> World
|
||||||
|
doFloorEffect NoFloorEffect = const id
|
||||||
|
|
||||||
|
doDropEffect :: ItDropEffect -> Item -> Creature -> World -> World
|
||||||
|
doDropEffect iie = case iie of
|
||||||
|
NoDropEffect -> const $ const id
|
||||||
|
|
||||||
|
onOffEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World
|
||||||
|
onOffEff f g it
|
||||||
|
| _itIsHeld it = doInvEffect f it
|
||||||
|
| otherwise = doInvEffect g it
|
||||||
|
|
||||||
|
|
||||||
|
rewindEffect :: Item -> Creature -> World -> World
|
||||||
|
rewindEffect itm cr w
|
||||||
|
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
||||||
|
& ptrWpCharge .~ length (_rewindWorlds w)
|
||||||
|
| otherwise = w & rewindWorlds .~ []
|
||||||
|
& ptrWpCharge .~ 0
|
||||||
|
where
|
||||||
|
invid = _ipInvID $ _itPos itm
|
||||||
|
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
||||||
|
maxcharge = _wpMaxCharge . _itConsumption $ itm
|
||||||
|
w' = w & rewindWorlds .~ []
|
||||||
|
& timeFlow .~ NormalTimeFlow
|
||||||
|
|
||||||
|
resetAttachmentEffect :: Item -> Creature -> World -> World
|
||||||
|
resetAttachmentEffect itm cr w
|
||||||
|
| _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
||||||
|
| otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
||||||
|
where
|
||||||
|
iteff = _itEffect itm
|
||||||
|
invid = _ipInvID $ _itPos itm
|
||||||
|
pointToIt = creatures . ix (_crID cr) . crInv . ix invid
|
||||||
|
|
||||||
|
createHeldLight :: Item -> Creature -> World -> World
|
||||||
|
createHeldLight itm cr = createTorchLightOffset cr itm 0
|
||||||
|
|
||||||
@@ -2,98 +2,12 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
module Dodge.Item.Data where
|
module Dodge.Item.Data where
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
data HammerType
|
|
||||||
= NoHammer
|
|
||||||
| HasHammer {_hammerPosition :: HammerPosition}
|
|
||||||
deriving
|
|
||||||
(Eq, Ord, Show)
|
|
||||||
data HammerPosition
|
|
||||||
= HammerDown
|
|
||||||
| HammerReleased
|
|
||||||
| HammerUp
|
|
||||||
deriving
|
|
||||||
(Eq, Ord, Show)
|
|
||||||
--data ItemIdentity
|
|
||||||
-- = Pistol
|
|
||||||
-- | SpreadGun
|
|
||||||
-- | MultGun
|
|
||||||
-- | HvAutoGun
|
|
||||||
-- | AutoGun
|
|
||||||
-- | LtAutoGun
|
|
||||||
-- | MiniGun
|
|
||||||
-- | Medkit25
|
|
||||||
-- | MagShield
|
|
||||||
-- | FrontArmour
|
|
||||||
-- | JetPack
|
|
||||||
-- | FlameShield
|
|
||||||
-- | Generic
|
|
||||||
-- | SparkGun
|
|
||||||
-- | ShatterGun
|
|
||||||
-- | LongGun
|
|
||||||
-- | Flamethrower
|
|
||||||
-- | Blinker
|
|
||||||
-- | Rewinder
|
|
||||||
-- | Grenade
|
|
||||||
-- | RemoteBomb
|
|
||||||
-- | TeslaGun
|
|
||||||
-- | LasGun
|
|
||||||
-- | ForceFieldGun
|
|
||||||
-- | GrapGun
|
|
||||||
-- | TractorGun
|
|
||||||
-- | Launcher
|
|
||||||
-- | RemoteLauncher
|
|
||||||
-- | LightningGun
|
|
||||||
-- | PoisonSprayer
|
|
||||||
-- | FlatShield
|
|
||||||
-- deriving
|
|
||||||
-- (Eq,Show,Ord,Enum)
|
|
||||||
data AimStance
|
|
||||||
= TwoHandTwist
|
|
||||||
| TwoHandFlat
|
|
||||||
| OneHand
|
|
||||||
| LeaveHolstered
|
|
||||||
deriving
|
|
||||||
(Eq,Show,Ord,Enum)
|
|
||||||
-- TODO check how much of this is necessary
|
|
||||||
data ItZoom = ItZoom
|
|
||||||
{ _itZoomMax :: Float
|
|
||||||
, _itZoomMin :: Float
|
|
||||||
, _itZoomFac :: Float
|
|
||||||
}
|
|
||||||
data CurseStatus
|
data CurseStatus
|
||||||
= Uncursed
|
= Uncursed
|
||||||
| UndroppableIdentified
|
| UndroppableIdentified
|
||||||
| UndroppableUnidentified
|
| UndroppableUnidentified
|
||||||
data AimParams = AimParams
|
|
||||||
{ _aimWeight :: Int
|
|
||||||
, _aimRange :: Float
|
|
||||||
, _aimZoom :: ItZoom
|
|
||||||
, _aimStance :: AimStance
|
|
||||||
, _aimHandlePos :: Float
|
|
||||||
, _aimMuzPos :: Float
|
|
||||||
}
|
|
||||||
data UseDelay -- should just be Delay
|
|
||||||
= NoDelay
|
|
||||||
| FixedRate
|
|
||||||
{_rateMax :: Int
|
|
||||||
,_rateTime :: Int
|
|
||||||
}
|
|
||||||
| VariableRate
|
|
||||||
{_rateMax :: Int
|
|
||||||
,_rateTime :: Int
|
|
||||||
,_rateMaxMax :: Int
|
|
||||||
,_rateMinMax :: Int
|
|
||||||
}
|
|
||||||
| WarmUpNoDelay
|
|
||||||
{_warmTime :: Int
|
|
||||||
,_warmMax :: Int
|
|
||||||
}
|
|
||||||
data BarrelSpread
|
data BarrelSpread
|
||||||
= AlignedBarrels
|
= AlignedBarrels
|
||||||
| SpreadBarrels {_spreadAngle :: Float}
|
| SpreadBarrels {_spreadAngle :: Float}
|
||||||
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
|
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
|
||||||
makeLenses ''BarrelSpread
|
makeLenses ''BarrelSpread
|
||||||
makeLenses ''HammerType
|
|
||||||
makeLenses ''ItZoom
|
|
||||||
makeLenses ''AimParams
|
|
||||||
makeLenses ''UseDelay
|
|
||||||
|
|||||||
+16
-27
@@ -22,9 +22,11 @@ module Dodge.Item.Equipment
|
|||||||
, overCID
|
, overCID
|
||||||
, onEquipWristShield
|
, onEquipWristShield
|
||||||
, onRemoveWristShield
|
, onRemoveWristShield
|
||||||
|
|
||||||
|
, createShieldWall
|
||||||
|
, removeShieldWall
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.LightSource.Torch
|
|
||||||
import Dodge.Item.Draw
|
import Dodge.Item.Draw
|
||||||
import Dodge.Item.Equipment.Booster
|
import Dodge.Item.Equipment.Booster
|
||||||
import Dodge.LightSource
|
import Dodge.LightSource
|
||||||
@@ -38,7 +40,8 @@ import Picture
|
|||||||
import Geometry
|
import Geometry
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
--import ShortShow
|
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
magShield :: Item
|
magShield :: Item
|
||||||
magShield = defaultEquipment
|
magShield = defaultEquipment
|
||||||
@@ -116,22 +119,14 @@ setWristShieldPos itm cr w = w
|
|||||||
|
|
||||||
torch :: Item
|
torch :: Item
|
||||||
torch = defaultWeapon
|
torch = defaultWeapon
|
||||||
& itEffect .~ effectOnOffHeld createHeldLight (const $ const id)
|
& itEffect .~ effectOnOffHeld CreateHeldLight NoInvEffect-- createHeldLight (const $ const id)
|
||||||
& itType . iyBase .~ HELD TORCH
|
& itType . iyBase .~ HELD TORCH
|
||||||
& itUse . useAim . aimHandlePos .~ 5
|
& itUse . useAim . aimHandlePos .~ 5
|
||||||
& itUse . useAim . aimMuzPos .~ 10
|
& itUse . useAim . aimMuzPos .~ 10
|
||||||
|
|
||||||
createHeldLight :: Creature -> Int -> World -> World
|
|
||||||
createHeldLight cr i = createTorchLightOffset cr itm 0
|
|
||||||
-- tempLightSources .:~ tlsTimeRadColPos 1 250 0.7
|
|
||||||
-- (p +.+.+ rotate3 (_crDir cr) (heldItemOffset itm cr (V3 8 0 1.5)))
|
|
||||||
where
|
|
||||||
-- p = addZ 0 $ _crPos cr
|
|
||||||
itm = cr ^?! crInv . ix i
|
|
||||||
|
|
||||||
flatShield :: Item
|
flatShield :: Item
|
||||||
flatShield = defaultWeapon
|
flatShield = defaultWeapon
|
||||||
& itEffect .~ effectOnOffHeld createShieldWall removeShieldWall
|
& itEffect .~ effectOnOffHeld CreateShieldWall RemoveShieldWall --createShieldWall removeShieldWall
|
||||||
-- the above seems to work, but I am not sure why: it may break on edge
|
-- the above seems to work, but I am not sure why: it may break on edge
|
||||||
-- cases
|
-- cases
|
||||||
& itUse .~ defaultrUse
|
& itUse .~ defaultrUse
|
||||||
@@ -171,14 +166,14 @@ shieldWall crid = defaultWall
|
|||||||
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
|
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
|
||||||
-- _ -> w
|
-- _ -> w
|
||||||
|
|
||||||
createShieldWall :: Creature -> Int -> World -> World
|
createShieldWall :: Item -> Creature -> World -> World
|
||||||
createShieldWall cr invid w = case _ieMID $ _itEffect it of
|
createShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||||
Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w
|
Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w
|
||||||
in w' & creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
|
in w' & creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
|
||||||
Just wid -> moveWallID wid wlline w
|
Just wid -> moveWallID wid wlline w
|
||||||
where
|
where
|
||||||
|
invid = fromJust $ _itID it
|
||||||
crid = _crID cr
|
crid = _crID cr
|
||||||
it = _crInv (_creatures w IM.! crid) IM.! invid
|
|
||||||
wlline = (a,b)
|
wlline = (a,b)
|
||||||
crdirv = unitVectorAtAngle $ _crDir cr
|
crdirv = unitVectorAtAngle $ _crDir cr
|
||||||
crpos = _crPos cr
|
crpos = _crPos cr
|
||||||
@@ -187,29 +182,23 @@ createShieldWall cr invid w = case _ieMID $ _itEffect it of
|
|||||||
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
|
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
|
||||||
therot | crIsAiming cr = vNormal
|
therot | crIsAiming cr = vNormal
|
||||||
| otherwise = rotateV (twoFlatHRot cr) . vNormal
|
| otherwise = rotateV (twoFlatHRot cr) . vNormal
|
||||||
removeShieldWall :: Creature -> Int -> World -> World
|
removeShieldWall :: Item -> Creature -> World -> World
|
||||||
removeShieldWall cr invid w = case _ieMID $ _itEffect it of
|
removeShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
Just wid -> w & deleteWallID wid
|
Just wid -> w & deleteWallID wid
|
||||||
& creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
|
& creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
|
||||||
where
|
where
|
||||||
crid = _crID cr
|
crid = _crID cr
|
||||||
it = _crInv (_creatures w IM.! crid) IM.! invid
|
invid = fromJust (_itID it)
|
||||||
|
|
||||||
effectOnOffHeld
|
effectOnOffHeld
|
||||||
:: (Creature -> Int -> World -> World) -- ^ effect when held
|
:: ItInvEffect -- ^ effect when held
|
||||||
-> (Creature -> Int -> World -> World) -- ^ effect when not held
|
-> ItInvEffect -- ^ effect when not held
|
||||||
-> ItEffect
|
-> ItEffect
|
||||||
effectOnOffHeld f f' = ItInvEffectID
|
effectOnOffHeld f f' = ItInvEffectID
|
||||||
{ _ieInv = g
|
{ _ieInv = OnOffHeldEffect f f'
|
||||||
, _ieMID = Nothing
|
, _ieMID = Nothing
|
||||||
}
|
}
|
||||||
where
|
|
||||||
g itm cr w
|
|
||||||
| crSel cr == invid = f cr invid w
|
|
||||||
| otherwise = f' cr invid w
|
|
||||||
where
|
|
||||||
invid = _ipInvID $ _itPos itm
|
|
||||||
|
|
||||||
{- | Increases speed, reduces friction, cannot only move forwards. -}
|
{- | Increases speed, reduces friction, cannot only move forwards. -}
|
||||||
jetPack :: Item
|
jetPack :: Item
|
||||||
|
|||||||
@@ -118,12 +118,5 @@ boosterGun = defaultLeftItem
|
|||||||
}
|
}
|
||||||
& itType . iyBase .~ LEFT BOOSTER
|
& itType . iyBase .~ LEFT BOOSTER
|
||||||
resetAttachmentID :: ItEffect
|
resetAttachmentID :: ItEffect
|
||||||
resetAttachmentID = ItInvEffect f 0
|
resetAttachmentID = ItInvEffect ResetAttachmentEffect 0
|
||||||
where
|
|
||||||
f itm cr w
|
|
||||||
| _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
|
||||||
| otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
|
||||||
where
|
|
||||||
iteff = _itEffect itm
|
|
||||||
invid = _ipInvID $ _itPos itm
|
|
||||||
pointToIt = creatures . ix (_crID cr) . crInv . ix invid
|
|
||||||
|
|||||||
@@ -76,50 +76,50 @@ grenadeDraw :: Float -> Prop -> SPic
|
|||||||
grenadeDraw dir prop = translateSPz (_pjZ prop) $ uncurryV translateSPf (_prPos prop)
|
grenadeDraw dir prop = translateSPz (_pjZ prop) $ uncurryV translateSPf (_prPos prop)
|
||||||
$ rotateSP dir $ grenadePic $ _pjTimer prop
|
$ rotateSP dir $ grenadePic $ _pjTimer prop
|
||||||
|
|
||||||
throwGrenade
|
--throwGrenade
|
||||||
:: (Point2 -> World -> World) -- ^ Payload
|
-- :: (Point2 -> World -> World) -- ^ Payload
|
||||||
-> Creature
|
-- -> Creature
|
||||||
-> World
|
-- -> World
|
||||||
-> World
|
-- -> World
|
||||||
throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
--throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
||||||
where
|
-- where
|
||||||
n = _crID cr
|
-- n = _crID cr
|
||||||
addG = IM.insert i $ Bomb
|
-- addG = IM.insert i $ Bomb
|
||||||
{ _prPos = p
|
-- { _prPos = p
|
||||||
, _pjZ = 10
|
-- , _pjZ = 10
|
||||||
, _pjVelZ = 2
|
-- , _pjVelZ = 2
|
||||||
, _pjVel = v
|
-- , _pjVel = v
|
||||||
, _prDraw = grenadeDraw dir
|
-- , _prDraw = grenadeDraw dir
|
||||||
, _pjID = i
|
-- , _pjID = i
|
||||||
, _pjUpdate = moveGrenade
|
-- , _pjUpdate = moveGrenade
|
||||||
, _pjPayload = thePayload
|
-- , _pjPayload = thePayload
|
||||||
, _pjTimer = fuseTime
|
-- , _pjTimer = fuseTime
|
||||||
}
|
-- }
|
||||||
j = crSel cr
|
-- j = crSel cr
|
||||||
removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
-- removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
||||||
i = IM.newKey $ _props w
|
-- i = IM.newKey $ _props w
|
||||||
v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
-- v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||||
v | magV v' > 6 = 6 *.* normalizeV v'
|
-- v | magV v' > 6 = 6 *.* normalizeV v'
|
||||||
| otherwise = v'
|
-- | otherwise = v'
|
||||||
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
-- p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||||
p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
-- p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||||
| otherwise = p'
|
-- | otherwise = p'
|
||||||
dir = argV v
|
-- dir = argV v
|
||||||
setWp :: World -> World
|
-- setWp :: World -> World
|
||||||
setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
-- setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
||||||
fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
-- fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
||||||
|
|
||||||
throwArmReset :: Int -> ItEffect
|
--throwArmReset :: Int -> ItEffect
|
||||||
throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
--throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
||||||
where
|
-- where
|
||||||
f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
-- f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
||||||
where
|
-- where
|
||||||
i = _ipInvID $ _itPos itm
|
-- i = _ipInvID $ _itPos itm
|
||||||
counterDown it
|
-- counterDown it
|
||||||
| _ieCounter (_itEffect it) == 0 = it
|
-- | _ieCounter (_itEffect it) == 0 = it
|
||||||
& itUse . useHammer .~ HammerUp
|
-- & itUse . useHammer .~ HammerUp
|
||||||
-- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
---- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
||||||
| otherwise = it & itEffect . ieCounter -~ 1
|
-- | otherwise = it & itEffect . ieCounter -~ 1
|
||||||
|
|
||||||
--flameGrenade :: Item
|
--flameGrenade :: Item
|
||||||
--flameGrenade = grenade {
|
--flameGrenade = grenade {
|
||||||
|
|||||||
@@ -20,24 +20,12 @@ rewindGun = defaultLeftItem
|
|||||||
{ _wpMaxCharge = 250
|
{ _wpMaxCharge = 250
|
||||||
, _wpCharge = 0
|
, _wpCharge = 0
|
||||||
}
|
}
|
||||||
, _itEffect = ItRewindEffect rewindEffect []
|
, _itEffect = ItRewindEffect RewindEffect []
|
||||||
, _itUse = defaultlUse
|
, _itUse = defaultlUse
|
||||||
& lUse .~ LRewind --useRewindGun
|
& lUse .~ LRewind --useRewindGun
|
||||||
& eqEq . eqSite .~ GoesOnChest
|
& eqEq . eqSite .~ GoesOnChest
|
||||||
}
|
}
|
||||||
& itType . iyBase .~ LEFT REWINDER
|
& itType . iyBase .~ LEFT REWINDER
|
||||||
rewindEffect :: Item -> Creature -> World -> World
|
|
||||||
rewindEffect itm cr w
|
|
||||||
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
|
||||||
& ptrWpCharge .~ length (_rewindWorlds w)
|
|
||||||
| otherwise = w & rewindWorlds .~ []
|
|
||||||
& ptrWpCharge .~ 0
|
|
||||||
where
|
|
||||||
invid = _ipInvID $ _itPos itm
|
|
||||||
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
|
||||||
maxcharge = _wpMaxCharge . _itConsumption $ itm
|
|
||||||
w' = w & rewindWorlds .~ []
|
|
||||||
& timeFlow .~ NormalTimeFlow
|
|
||||||
|
|
||||||
-- needs to shift this item to the current inventory slot
|
-- needs to shift this item to the current inventory slot
|
||||||
shrinkGun :: Item
|
shrinkGun :: Item
|
||||||
|
|||||||
Reference in New Issue
Block a user