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 = NoInvEffect
| ChargeIfEquipped | ChargeIfEquipped
| ChargeIfInInventory | ChargeIfInInventory
| SetCharge Int
| EffectIfHeld ItInvEffect ItInvEffect | EffectIfHeld ItInvEffect ItInvEffect
| CreateHeldLight | CreateHeldLight
| CreateShieldWall | CreateShieldWall
+19 -1
View File
@@ -1,5 +1,7 @@
module Dodge.HeldUse where module Dodge.HeldUse where
import Dodge.Wall.Move
import Dodge.Wall.ForceField
import Color import Color
import Data.Maybe import Data.Maybe
import Data.Traversable import Data.Traversable
@@ -13,7 +15,6 @@ import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.Radar import Dodge.Item.Weapon.Radar
import Dodge.Item.Weapon.Shatter import Dodge.Item.Weapon.Shatter
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Utility
import Dodge.Projectile.Create import Dodge.Projectile.Create
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.Tesla.Arc import Dodge.Tesla.Arc
@@ -504,3 +505,20 @@ shootTeslaArc it cr w =
(w', ip) = makeTeslaArc (_itParams it) pos dir w (w', ip) = makeTeslaArc (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr 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
+12 -7
View File
@@ -10,6 +10,7 @@ doInvEffect iie = case iie of
NoInvEffect -> const $ const id NoInvEffect -> const $ const id
ChargeIfEquipped -> chargeIfEquipped ChargeIfEquipped -> chargeIfEquipped
ChargeIfInInventory -> chargeIfInInventory ChargeIfInInventory -> chargeIfInInventory
SetCharge i -> setItemCharge i
EffectIfHeld f g -> onOffEff f g EffectIfHeld f g -> onOffEff f g
CreateHeldLight -> createHeldLight CreateHeldLight -> createHeldLight
CreateShieldWall -> createShieldWall CreateShieldWall -> createShieldWall
@@ -31,27 +32,31 @@ onOffEff f g it
-- , _futureWorlds = [] -- , _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 :: Item -> Creature -> World -> World
chargeIfInInventory itm cr w = chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1)) w & ptrWpCharge %~ (min maxcharge . (+ 1))
where where
invid = _ipInvID $ _itLocation itm invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
chargeIfEquipped :: Item -> Creature -> World -> World chargeIfEquipped :: Item -> Creature -> World -> World
chargeIfEquipped itm cr w chargeIfEquipped itm cr
| Just invid == cr ^. crLeftInvSel . lisMPos = | Just invid == cr ^. crLeftInvSel . lisMPos =
w & ptrWpCharge %~ (min maxcharge . (+ 1)) ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise = | otherwise = ptrWpCharge .~ 0
w & ptrWpCharge .~ 0
where where
invid = _ipInvID $ _itLocation itm invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--resetAttachmentEffect :: Item -> Creature -> World -> World --resetAttachmentEffect :: Item -> Creature -> World -> World
--resetAttachmentEffect itm cr w --resetAttachmentEffect itm cr w
-- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment -- | _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 . heldConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 2} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE & itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item 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 Control.Lens
import Data.Maybe import Dodge.Data.Item
import Dodge.Base.Coordinate
import Dodge.Data.World
import Dodge.Default 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 Picture
import Shape
import ShapePicture
stopWatch :: Item stopWatch :: Item
stopWatch = stopWatch =
@@ -23,7 +22,8 @@ stopWatch =
& equipEffect . eeSite .~ GoesOnWrist & equipEffect . eeSite .~ GoesOnWrist
) )
& itInvColor .~ cyan & itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfInInventory & itEffect . ieInv .~ ChargeIfEquipped
& itEffect . ieOnDrop .~ SetCharge 0
& itType . iyBase .~ LEFT STOPWATCH & itType . iyBase .~ LEFT STOPWATCH
& itUse . leftConsumption & itUse . leftConsumption
.~ ChargeableAmmo .~ ChargeableAmmo
@@ -33,37 +33,15 @@ stopWatch =
scrollWatch :: Item scrollWatch :: Item
scrollWatch = scrollWatch =
defaultLeftItem stopWatch
& itUse & itUse . leftUse .~ LTimeScroll
.~ ( defaultLeftUse
& leftUse .~ LTimeScroll
& equipEffect . eeSite .~ GoesOnWrist
)
& itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfInInventory
& itType . iyBase .~ LEFT SCROLLWATCH & itType . iyBase .~ LEFT SCROLLWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 100
, _wpCharge = 0
}
rewindWatch :: Item rewindWatch :: Item
rewindWatch = rewindWatch =
defaultLeftItem stopWatch
& itUse & itUse . leftUse .~ LRewind --useRewindGun
.~ ( defaultLeftUse
& leftUse .~ LRewind --useRewindGun
& equipEffect . eeSite .~ GoesOnWrist
)
& itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfEquipped
& itType . iyBase .~ LEFT REWINDWATCH & itType . iyBase .~ LEFT REWINDWATCH
& itUse . leftConsumption
.~ ChargeableAmmo
{ _wpMaxCharge = 100
, _wpCharge = 0
}
-- needs to shift this item to the current inventory slot -- needs to shift this item to the current inventory slot
shrinkGun :: Item shrinkGun :: Item
@@ -73,9 +51,6 @@ shrinkGun =
& itParams .~ ShrinkGunParams FullSize & itParams .~ ShrinkGunParams FullSize
& itType . iyBase .~ LEFT SHRINKER & itType . iyBase .~ LEFT SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
blinkGun :: Item blinkGun :: Item
blinkGun = blinkGun =
defaultLeftItem defaultLeftItem
@@ -95,22 +70,6 @@ unsafeBlinkGun =
& itUse . leftUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction) & itUse . leftUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . equipEffect . eeViewDist ?~ 400 & 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 -- grapGun = defaultGun
-- { _itName = "grapGun" -- { _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 -- this lock can be sensibly applied, perhaps
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w | w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of | rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
(_, EquipOptions{}) -> scrollRBOption yi w (_, EquipOptions{}) -> w & rbOptions %~ scrollRBOption yi
(Nothing, _) -> closeObjScrollDir y w (Nothing, _) -> closeObjScrollDir y w
(Just f, _) -> doHeldScroll f y (you w) w (Just f, _) -> doHeldScroll f y (you w) w
| lbDown -> w & cWorld . camPos . camZoom +~ y | lbDown -> w & cWorld . camPos . camZoom +~ y
@@ -92,10 +92,10 @@ terminalWheelEvent yi tmid w
tc = scrollCommands tm !! i tc = scrollCommands tm !! i
arg = getArguments' tc tm w' !! j arg = getArguments' tc tm w' !! j
scrollRBOption :: Int -> World -> World scrollRBOption :: Int -> RightButtonOptions -> RightButtonOptions
scrollRBOption y w scrollRBOption y w
| y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w)) -1) . subtract y) | y < 0 = w & opSel %~ (min (length (_opEquip w) -1) . subtract y)
| y > 0 = w & rbOptions . opSel %~ (max 0 . subtract y) | y > 0 = w & opSel %~ (max 0 . subtract y)
| otherwise = w | otherwise = w
moveTweakSel :: Int -> World -> World moveTweakSel :: Int -> World -> World