Move item effect functions
This commit is contained in:
@@ -3,6 +3,7 @@ module Dodge.Creature.State
|
||||
, doDamage
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.ItEffect
|
||||
import Dodge.Euse
|
||||
import Dodge.EnergyBall
|
||||
import Dodge.Damage
|
||||
@@ -196,7 +197,7 @@ invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
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 cr it
|
||||
|
||||
+17
-46
@@ -10,6 +10,10 @@ circular imports are probably not a good idea.
|
||||
{-# LANGUAGE DerivingStrategies #-}
|
||||
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.CrWlID
|
||||
, module Dodge.Data.Item.HeldUse
|
||||
@@ -61,6 +65,10 @@ module Dodge.Data
|
||||
, module Dodge.Data.RadarBlip
|
||||
, module Dodge.Data.PathGraph
|
||||
) 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.ArcStep
|
||||
import Dodge.Data.Item.HeldUse
|
||||
@@ -404,39 +412,6 @@ data PressPlate = PressPlate
|
||||
, _ppText :: String
|
||||
}
|
||||
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
|
||||
{ _itConsumption :: ItemConsumption
|
||||
@@ -471,25 +446,25 @@ data Targeting
|
||||
data ItEffect
|
||||
= NoItEffect
|
||||
| ItInvEffect
|
||||
{_ieInv :: Item -> Creature -> World -> World
|
||||
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||
,_ieCounter :: Int
|
||||
}
|
||||
| ItRewindEffect
|
||||
{_ieInv :: Item -> Creature -> World -> World
|
||||
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||
,_ieStoredWorlds :: [World]
|
||||
}
|
||||
| ItEffect
|
||||
{_ieInv :: Item -> Creature -> World -> World
|
||||
,_ieFloor :: Int -> World -> World
|
||||
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||
,_ieFloor :: ItFloorEffect --Int -> World -> World
|
||||
,_ieCounter :: Int
|
||||
}
|
||||
| ItInvEffectID
|
||||
{_ieInv :: Item -> Creature -> World -> World
|
||||
{_ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||
,_ieMID :: Maybe Int
|
||||
} -- the duplication of ieMID may cause errors...
|
||||
| ItInvEffectDrop
|
||||
{ _ieInv :: Item -> Creature -> World -> World
|
||||
, _ieDrop :: Item -> Creature -> World -> World
|
||||
{ _ieInv :: ItInvEffect --Item -> Creature -> World -> World
|
||||
, _ieDrop :: ItDropEffect --Item -> Creature -> World -> World
|
||||
, _ieMID :: Maybe Int
|
||||
}
|
||||
data IntID a = IntID Int a
|
||||
@@ -612,10 +587,6 @@ data GunBarrels
|
||||
, _brlInaccuracy :: Float
|
||||
}
|
||||
| SingleBarrel {_brlInaccuracy :: Float}
|
||||
data EquipParams
|
||||
= NoEquipParams
|
||||
| EquipID {_eparamID :: Int}
|
||||
| EquipCounter {_eparamInt :: Int}
|
||||
data ItemParams
|
||||
= NoParams
|
||||
| ShellLauncher
|
||||
@@ -1256,7 +1227,6 @@ makeLenses ''CreatureState
|
||||
makeLenses ''World
|
||||
makeLenses ''Creature
|
||||
makeLenses ''Item
|
||||
makeLenses ''ItemUse
|
||||
makeLenses ''ItEffect
|
||||
makeLenses ''FloorItem
|
||||
makeLenses ''TweakParam
|
||||
@@ -1288,7 +1258,6 @@ makeLenses ''ScreenLayer
|
||||
makeLenses ''Beam
|
||||
makeLenses ''BeamType
|
||||
makeLenses ''WorldBeams
|
||||
makeLenses ''EquipParams
|
||||
makeLenses ''TerminalCommand
|
||||
makeLenses ''TerminalInput
|
||||
makeLenses ''GenParams
|
||||
@@ -1301,6 +1270,8 @@ makeLenses ''PSType
|
||||
makeLenses ''PlacementSpot
|
||||
makeLenses ''Placement
|
||||
|
||||
_itUseAimStance :: Item -> AimStance
|
||||
_itUseAimStance = _aimStance . _useAim . _itUse
|
||||
|
||||
crSel :: Creature -> Int
|
||||
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 #-}
|
||||
module Dodge.Data.LoadAction where
|
||||
import Sound.Data
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Data.Hammer
|
||||
import Control.Lens
|
||||
data LoadAction
|
||||
= LoadEject {_actionTime :: Int, _actionSound :: SoundID}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Dodge.Default.AimParams where
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Data.Item.Use
|
||||
|
||||
defaultAimParams :: AimParams
|
||||
defaultAimParams = AimParams
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
module Dodge.Hammer where
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Data.Hammer
|
||||
|
||||
moveHammerUp :: HammerPosition -> HammerPosition
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
|
||||
@@ -25,6 +25,7 @@ module Dodge.Inventory
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.ItEffect
|
||||
import Dodge.Euse
|
||||
import Dodge.Inventory.CloseObject
|
||||
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
|
||||
doanyitemeffect = fromMaybe id $ do
|
||||
rmf <- itm ^? itEffect . ieDrop
|
||||
return $ rmf itm cr
|
||||
return $ doDropEffect rmf itm cr
|
||||
removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of
|
||||
Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing
|
||||
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 #-}
|
||||
module Dodge.Item.Data where
|
||||
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
|
||||
= Uncursed
|
||||
| UndroppableIdentified
|
||||
| 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
|
||||
= AlignedBarrels
|
||||
| SpreadBarrels {_spreadAngle :: Float}
|
||||
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
|
||||
makeLenses ''BarrelSpread
|
||||
makeLenses ''HammerType
|
||||
makeLenses ''ItZoom
|
||||
makeLenses ''AimParams
|
||||
makeLenses ''UseDelay
|
||||
|
||||
+16
-27
@@ -22,9 +22,11 @@ module Dodge.Item.Equipment
|
||||
, overCID
|
||||
, onEquipWristShield
|
||||
, onRemoveWristShield
|
||||
|
||||
, createShieldWall
|
||||
, removeShieldWall
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.LightSource.Torch
|
||||
import Dodge.Item.Draw
|
||||
import Dodge.Item.Equipment.Booster
|
||||
import Dodge.LightSource
|
||||
@@ -38,7 +40,8 @@ import Picture
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
--import ShortShow
|
||||
|
||||
import Data.Maybe
|
||||
|
||||
magShield :: Item
|
||||
magShield = defaultEquipment
|
||||
@@ -116,22 +119,14 @@ setWristShieldPos itm cr w = w
|
||||
|
||||
torch :: Item
|
||||
torch = defaultWeapon
|
||||
& itEffect .~ effectOnOffHeld createHeldLight (const $ const id)
|
||||
& itEffect .~ effectOnOffHeld CreateHeldLight NoInvEffect-- createHeldLight (const $ const id)
|
||||
& itType . iyBase .~ HELD TORCH
|
||||
& itUse . useAim . aimHandlePos .~ 5
|
||||
& 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 = 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
|
||||
-- cases
|
||||
& itUse .~ defaultrUse
|
||||
@@ -171,14 +166,14 @@ shieldWall crid = defaultWall
|
||||
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
|
||||
-- _ -> w
|
||||
|
||||
createShieldWall :: Creature -> Int -> World -> World
|
||||
createShieldWall cr invid w = case _ieMID $ _itEffect it of
|
||||
createShieldWall :: Item -> Creature -> World -> World
|
||||
createShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||
Nothing -> let (wlid,w') = createWall ((shieldWall crid) {_wlLine = wlline,_wlID = wlid}) w
|
||||
in w' & creatures . ix crid . crInv . ix invid . itEffect . ieMID ?~ wlid
|
||||
Just wid -> moveWallID wid wlline w
|
||||
where
|
||||
invid = fromJust $ _itID it
|
||||
crid = _crID cr
|
||||
it = _crInv (_creatures w IM.! crid) IM.! invid
|
||||
wlline = (a,b)
|
||||
crdirv = unitVectorAtAngle $ _crDir cr
|
||||
crpos = _crPos cr
|
||||
@@ -187,29 +182,23 @@ createShieldWall cr invid w = case _ieMID $ _itEffect it of
|
||||
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
|
||||
therot | crIsAiming cr = vNormal
|
||||
| otherwise = rotateV (twoFlatHRot cr) . vNormal
|
||||
removeShieldWall :: Creature -> Int -> World -> World
|
||||
removeShieldWall cr invid w = case _ieMID $ _itEffect it of
|
||||
removeShieldWall :: Item -> Creature -> World -> World
|
||||
removeShieldWall it cr w = case _ieMID $ _itEffect it of
|
||||
Nothing -> w
|
||||
Just wid -> w & deleteWallID wid
|
||||
& creatures . ix crid . crInv . ix invid . itEffect . ieMID .~ Nothing
|
||||
where
|
||||
crid = _crID cr
|
||||
it = _crInv (_creatures w IM.! crid) IM.! invid
|
||||
invid = fromJust (_itID it)
|
||||
|
||||
effectOnOffHeld
|
||||
:: (Creature -> Int -> World -> World) -- ^ effect when held
|
||||
-> (Creature -> Int -> World -> World) -- ^ effect when not held
|
||||
:: ItInvEffect -- ^ effect when held
|
||||
-> ItInvEffect -- ^ effect when not held
|
||||
-> ItEffect
|
||||
effectOnOffHeld f f' = ItInvEffectID
|
||||
{ _ieInv = g
|
||||
{ _ieInv = OnOffHeldEffect f f'
|
||||
, _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. -}
|
||||
jetPack :: Item
|
||||
|
||||
@@ -118,12 +118,5 @@ boosterGun = defaultLeftItem
|
||||
}
|
||||
& itType . iyBase .~ LEFT BOOSTER
|
||||
resetAttachmentID :: ItEffect
|
||||
resetAttachmentID = ItInvEffect f 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
|
||||
resetAttachmentID = ItInvEffect ResetAttachmentEffect 0
|
||||
|
||||
|
||||
@@ -76,50 +76,50 @@ grenadeDraw :: Float -> Prop -> SPic
|
||||
grenadeDraw dir prop = translateSPz (_pjZ prop) $ uncurryV translateSPf (_prPos prop)
|
||||
$ rotateSP dir $ grenadePic $ _pjTimer prop
|
||||
|
||||
throwGrenade
|
||||
:: (Point2 -> World -> World) -- ^ Payload
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
||||
where
|
||||
n = _crID cr
|
||||
addG = IM.insert i $ Bomb
|
||||
{ _prPos = p
|
||||
, _pjZ = 10
|
||||
, _pjVelZ = 2
|
||||
, _pjVel = v
|
||||
, _prDraw = grenadeDraw dir
|
||||
, _pjID = i
|
||||
, _pjUpdate = moveGrenade
|
||||
, _pjPayload = thePayload
|
||||
, _pjTimer = fuseTime
|
||||
}
|
||||
j = crSel cr
|
||||
removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
||||
i = IM.newKey $ _props w
|
||||
v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
| otherwise = v'
|
||||
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)
|
||||
| otherwise = p'
|
||||
dir = argV v
|
||||
setWp :: World -> World
|
||||
setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
||||
fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
||||
--throwGrenade
|
||||
-- :: (Point2 -> World -> World) -- ^ Payload
|
||||
-- -> Creature
|
||||
-- -> World
|
||||
-- -> World
|
||||
--throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
||||
-- where
|
||||
-- n = _crID cr
|
||||
-- addG = IM.insert i $ Bomb
|
||||
-- { _prPos = p
|
||||
-- , _pjZ = 10
|
||||
-- , _pjVelZ = 2
|
||||
-- , _pjVel = v
|
||||
-- , _prDraw = grenadeDraw dir
|
||||
-- , _pjID = i
|
||||
-- , _pjUpdate = moveGrenade
|
||||
-- , _pjPayload = thePayload
|
||||
-- , _pjTimer = fuseTime
|
||||
-- }
|
||||
-- j = crSel cr
|
||||
-- removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
||||
-- i = IM.newKey $ _props w
|
||||
-- v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
-- v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
-- | otherwise = v'
|
||||
-- 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)
|
||||
-- | otherwise = p'
|
||||
-- dir = argV v
|
||||
-- setWp :: World -> World
|
||||
-- setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
||||
-- fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
||||
|
||||
throwArmReset :: Int -> ItEffect
|
||||
throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
||||
where
|
||||
f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
||||
where
|
||||
i = _ipInvID $ _itPos itm
|
||||
counterDown it
|
||||
| _ieCounter (_itEffect it) == 0 = it
|
||||
& itUse . useHammer .~ HammerUp
|
||||
-- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
||||
| otherwise = it & itEffect . ieCounter -~ 1
|
||||
--throwArmReset :: Int -> ItEffect
|
||||
--throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
||||
-- where
|
||||
-- f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
||||
-- where
|
||||
-- i = _ipInvID $ _itPos itm
|
||||
-- counterDown it
|
||||
-- | _ieCounter (_itEffect it) == 0 = it
|
||||
-- & itUse . useHammer .~ HammerUp
|
||||
---- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
||||
-- | otherwise = it & itEffect . ieCounter -~ 1
|
||||
|
||||
--flameGrenade :: Item
|
||||
--flameGrenade = grenade {
|
||||
|
||||
@@ -20,24 +20,12 @@ rewindGun = defaultLeftItem
|
||||
{ _wpMaxCharge = 250
|
||||
, _wpCharge = 0
|
||||
}
|
||||
, _itEffect = ItRewindEffect rewindEffect []
|
||||
, _itEffect = ItRewindEffect RewindEffect []
|
||||
, _itUse = defaultlUse
|
||||
& lUse .~ LRewind --useRewindGun
|
||||
& eqEq . eqSite .~ GoesOnChest
|
||||
}
|
||||
& 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
|
||||
shrinkGun :: Item
|
||||
|
||||
Reference in New Issue
Block a user