This commit is contained in:
2022-12-31 23:01:54 +00:00
parent 0dc9a09723
commit 8838d1120b
6 changed files with 54 additions and 71 deletions
+1
View File
@@ -21,6 +21,7 @@ data ItInvEffect
= NoInvEffect
| ChargeIfEquipped
| ChargeIfInInventory
| SetCharge Int
| EffectIfHeld ItInvEffect ItInvEffect
| CreateHeldLight
| CreateShieldWall
+19 -1
View File
@@ -1,5 +1,7 @@
module Dodge.HeldUse where
import Dodge.Wall.Move
import Dodge.Wall.ForceField
import Color
import Data.Maybe
import Data.Traversable
@@ -13,7 +15,6 @@ import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.Radar
import Dodge.Item.Weapon.Shatter
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Utility
import Dodge.Projectile.Create
import Dodge.SoundLogic
import Dodge.Tesla.Arc
@@ -504,3 +505,20 @@ shootTeslaArc it cr w =
(w', ip) = makeTeslaArc (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix
useForceFieldGun :: Item -> Creature -> World -> World
useForceFieldGun itm cr w = fromMaybe w $ do
a <- _tgPos $ _itTargeting itm
let mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
wlline = (a, b)
return $
w
& cWorld . lWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
where
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just
+13 -8
View File
@@ -10,6 +10,7 @@ doInvEffect iie = case iie of
NoInvEffect -> const $ const id
ChargeIfEquipped -> chargeIfEquipped
ChargeIfInInventory -> chargeIfInInventory
SetCharge i -> setItemCharge i
EffectIfHeld f g -> onOffEff f g
CreateHeldLight -> createHeldLight
CreateShieldWall -> createShieldWall
@@ -31,27 +32,31 @@ onOffEff f g it
-- , _futureWorlds = []
-- }
setItemCharge :: Int -> Item -> Creature -> World -> World
setItemCharge i itm cr w =
w & ptrWpCharge %~ const i
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
chargeIfInInventory :: Item -> Creature -> World -> World
chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
chargeIfEquipped :: Item -> Creature -> World -> World
chargeIfEquipped itm cr w
chargeIfEquipped itm cr
| Just invid == cr ^. crLeftInvSel . lisMPos =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise =
w & ptrWpCharge .~ 0
ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise = ptrWpCharge .~ 0
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--resetAttachmentEffect :: Item -> Creature -> World -> World
--resetAttachmentEffect itm cr w
-- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
+1 -1
View File
@@ -82,7 +82,7 @@ rifle =
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 2}
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
+16 -57
View File
@@ -1,18 +1,17 @@
module Dodge.Item.Weapon.Utility where
module Dodge.Item.Weapon.Utility
( stopWatch
, rewindWatch
, scrollWatch
, blinkGun
, unsafeBlinkGun
, shrinkGun
-- , useForceFieldGun
) where
import Control.Lens
import Data.Maybe
import Dodge.Base.Coordinate
import Dodge.Data.World
import Dodge.Data.Item
import Dodge.Default
--import Dodge.Default.Item.Use
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Geometry
import qualified IntMapHelp as IM
import Picture
import Shape
import ShapePicture
stopWatch :: Item
stopWatch =
@@ -23,7 +22,8 @@ stopWatch =
& equipEffect . eeSite .~ GoesOnWrist
)
& itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfInInventory
& itEffect . ieInv .~ ChargeIfEquipped
& itEffect . ieOnDrop .~ SetCharge 0
& itType . iyBase .~ LEFT STOPWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
@@ -33,37 +33,15 @@ stopWatch =
scrollWatch :: Item
scrollWatch =
defaultLeftItem
& itUse
.~ ( defaultLeftUse
& leftUse .~ LTimeScroll
& equipEffect . eeSite .~ GoesOnWrist
)
& itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfInInventory
stopWatch
& itUse . leftUse .~ LTimeScroll
& itType . iyBase .~ LEFT SCROLLWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 100
, _wpCharge = 0
}
rewindWatch :: Item
rewindWatch =
defaultLeftItem
& itUse
.~ ( defaultLeftUse
& leftUse .~ LRewind --useRewindGun
& equipEffect . eeSite .~ GoesOnWrist
)
& itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfEquipped
stopWatch
& itUse . leftUse .~ LRewind --useRewindGun
& itType . iyBase .~ LEFT REWINDWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 100
, _wpCharge = 0
}
-- needs to shift this item to the current inventory slot
shrinkGun :: Item
@@ -73,9 +51,6 @@ shrinkGun =
& itParams .~ ShrinkGunParams FullSize
& itType . iyBase .~ LEFT SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
blinkGun :: Item
blinkGun =
defaultLeftItem
@@ -95,22 +70,6 @@ unsafeBlinkGun =
& itUse . leftUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . equipEffect . eeViewDist ?~ 400
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix
useForceFieldGun :: Item -> Creature -> World -> World
useForceFieldGun itm cr w = fromMaybe w $ do
a <- _tgPos $ _itTargeting itm
let mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a)
wlline = (a, b)
return $
w
& cWorld . lWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
where
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just
-- grapGun = defaultGun
-- { _itName = "grapGun"
+4 -4
View File
@@ -28,7 +28,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
-- this lock can be sensibly applied, perhaps
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
(_, EquipOptions{}) -> scrollRBOption yi w
(_, EquipOptions{}) -> w & rbOptions %~ scrollRBOption yi
(Nothing, _) -> closeObjScrollDir y w
(Just f, _) -> doHeldScroll f y (you w) w
| lbDown -> w & cWorld . camPos . camZoom +~ y
@@ -92,10 +92,10 @@ terminalWheelEvent yi tmid w
tc = scrollCommands tm !! i
arg = getArguments' tc tm w' !! j
scrollRBOption :: Int -> World -> World
scrollRBOption :: Int -> RightButtonOptions -> RightButtonOptions
scrollRBOption y w
| y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . subtract y)
| y > 0 = w & rbOptions . opSel %~ (max 0 . subtract y)
| y < 0 = w & opSel %~ (min (length (_opEquip w) -1) . subtract y)
| y > 0 = w & opSel %~ (max 0 . subtract y)
| otherwise = w
moveTweakSel :: Int -> World -> World