Rename ItemAttachments

This commit is contained in:
2022-06-15 08:21:53 +01:00
parent 485c42eb24
commit bf1bfa5453
15 changed files with 98 additions and 80 deletions
+5 -5
View File
@@ -26,7 +26,7 @@ scrollCharMode x _
incCharMode
:: Item
-> Item
incCharMode = itAttachment . itCharMode %~ cycleL
incCharMode = itAttachment . atCharMode %~ cycleL
where
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
@@ -34,7 +34,7 @@ incCharMode = itAttachment . itCharMode %~ cycleL
decCharMode
:: Item
-> Item
decCharMode = itAttachment . itCharMode %~ cycleR
decCharMode = itAttachment . atCharMode %~ cycleR
where
cycleR (xs :|> x) = x <| xs
cycleR xs = xs
@@ -43,7 +43,7 @@ charFiringStratI
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
-> ChainEffect
charFiringStratI strats eff item cr w = case w ^? creatures . ix cid . crInv
. ix (_crInvSel $ _creatures w IM.! cid) . itAttachment . itCharMode of
. ix (_crInvSel $ _creatures w IM.! cid) . itAttachment . atCharMode of
Just (c :<| _) -> fromMaybe id (Prelude.lookup c strats) eff item cr w
_ -> w
where
@@ -55,10 +55,10 @@ changeFuse
-> Item
-> Item
changeFuse scrollAmount _ it = it
& ( itAttachment .~ ItFuse newTime )
& ( itAttachment .~ AttachFuse newTime )
& ( itUse . useAim . aimZoom .~ defaultItZoom{_itZoomMax = zm, _itZoomMin = zm} )
where
oldTime = _itFuseTime $ _itAttachment it
oldTime = _atFuseTime $ _itAttachment it
newTime = min 90 $ max 20 $ oldTime - round (5 * scrollAmount)
zm = 50 / fromIntegral newTime
+8 -8
View File
@@ -8,14 +8,14 @@ import Control.Lens
import qualified Data.Sequence as Seq
data ItAttachment
= ItFuse {_itFuseTime :: Int}
| ItMode {_itMode :: Int}
| ItCharMode {_itCharMode :: Seq.Seq Char }
| ItTargetPos { _itTargetPos :: Point2 }
| ItInt { _itInt :: Int }
| ItMInt { _itMInt :: Maybe Int }
| ItFloat { _itFloat :: Float }
| ItBool { _itBool :: Bool }
= AttachFuse {_atFuseTime :: Int}
| AttachMode {_atMode :: Int}
| AttachCharMode {_atCharMode :: Seq.Seq Char }
| AttachTargetPos { _atTargetPos :: Point2 }
| AttachInt { _atInt :: Int }
| AttachMInt { _atMInt :: Maybe Int }
| AttachFloat { _atFloat :: Float }
| AttachBool { _atBool :: Bool }
| NoItAttachment
data Scope = NoScope
+2 -2
View File
@@ -39,7 +39,7 @@ magShield :: Item
magShield = defaultEquipment
{ _itEquipPict = \_ _ -> (,) emptySH blank
, _itID = Nothing
, _itAttachment = ItMInt Nothing
, _itAttachment = AttachMInt Nothing
}
& itUse . eqEq . eqUse .~ useMagShield
& itUse . eqEq . eqSite .~ GoesOnWrist
@@ -53,7 +53,7 @@ useMagShield it cr w = w & magnets . at mgid ?~ themagnet
,_mgPos = _crPos cr
,_mgField = curveAroundField 50 200
}
mgid = case it ^? itAttachment . itMInt . _Just of
mgid = case it ^? itAttachment . atMInt . _Just of
Just mgid' -> mgid'
Nothing -> IM.newKey $ _magnets w
-- it = _crInv cr IM.! invid
+2 -2
View File
@@ -43,14 +43,14 @@ boostSelfL x itm cr w = case boostPoint x cr w of
cpos = _crPos cr
r = _crRad cr
pid = fromMaybe (IM.newKey $ _props w)
(cr ^? crInv . ix invid . itAttachment . itInt)
(cr ^? crInv . ix invid . itAttachment . atInt)
crEff p ammoEff = addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
& creatures . ix cid %~
(crPos .~ p)
. (crInv . ix invid %~
ammoEff
. (itEffect . ieCounter .~ 1)
. (itAttachment .~ ItInt pid)
. (itAttachment .~ AttachInt pid)
)
addBoostShockwave
+1 -1
View File
@@ -73,7 +73,7 @@ autoGun = defaultAutoGun
-- , _itFloorPict = autoGunPic
-- , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim
, _itAttachment = ItCharMode $ Seq.fromList "MS"
, _itAttachment = AttachCharMode $ Seq.fromList "MS"
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
+1 -1
View File
@@ -111,7 +111,7 @@ throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
dir = argV v
setWp :: World -> World
setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
fuseTime = _itFuseTime $ _itAttachment $ _crInv cr IM.! j
fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
throwArmReset :: Int -> ItEffect
throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
+3 -3
View File
@@ -68,7 +68,7 @@ shrinkGun = defaultGun
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic
, _itAttachment = ItBool True
, _itAttachment = AttachBool True
}
& itType . iyBase .~ SHRINKER
@@ -79,14 +79,14 @@ shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
-- creature but using the old crInvSel value
-- 22.05.23 this has been changed from using invids to items
useShrinkGun :: Item -> Creature -> World -> World
useShrinkGun it cr w = if _itBool $ _itAttachment it
useShrinkGun it cr w = if _atBool $ _itAttachment it
then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropExcept cr invid
else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr
where
invid = fromJust $ _itInvPos it
tryResize x g = maybe w g $ sizeSelf x cr w
f isInUse cstatus = creatures . ix (_crID cr) . crInv . ix invid %~
( (itAttachment . itBool .~ isInUse) . (itCurseStatus .~ cstatus) )
( (itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus) )
blinkGun :: Item
blinkGun = defaultGun