Held item rclick use, tweak reload on lclick
This commit is contained in:
+13
-1
@@ -19,6 +19,7 @@ import Dodge.Base.Arithmetic
|
||||
import Dodge.Base.NewID
|
||||
import Dodge.Base.Coordinate
|
||||
import Dodge.Base.CardinalPoint
|
||||
import Data.List (unfoldr)
|
||||
--import Dodge.Zone
|
||||
--import Dodge.Zone.Data
|
||||
import Dodge.Base.Window
|
||||
@@ -151,4 +152,15 @@ spreadAroundCenter :: Int -> Float -> [Float]
|
||||
spreadAroundCenter i x = [x * fromIntegral j - x*fromIntegral (i-1)*0.5 | j <- [0 .. i - 1]]
|
||||
|
||||
spreadFromCenter :: Int -> Float -> [Float]
|
||||
spreadFromCenter i x = [x * fromIntegral j - x*fromIntegral (i-1)*0.5 | j <- [0 .. i - 1]]
|
||||
spreadFromCenter i x = [x * fromIntegral j | j <- js]
|
||||
where
|
||||
js = take i outwardIntegers
|
||||
|
||||
outwardIntegers :: [Int]
|
||||
outwardIntegers = unfoldr f (0, False)
|
||||
where
|
||||
f (x,True) = Just (x, (x,False))
|
||||
f (x,False) = Just (-x, (x+1,True))
|
||||
|
||||
spreadCenter :: Int -> Float -> [Float]
|
||||
spreadCenter i x = [x * fromIntegral j - x*fromIntegral (i-1)*0.5 | j <- [0 .. i - 1]]
|
||||
|
||||
@@ -259,7 +259,7 @@ stackedInventory =
|
||||
, flatShield
|
||||
, spawnGun (lamp 5)
|
||||
, lasGun
|
||||
, lasWide 5
|
||||
, lasWide 20
|
||||
, flameThrower
|
||||
, poisonSprayer
|
||||
, launcher
|
||||
|
||||
@@ -5,8 +5,6 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Dodge.Inventory.RBList
|
||||
import Dodge.Hotkey
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
@@ -15,7 +13,9 @@ import Dodge.Cuse
|
||||
import Dodge.Data.World
|
||||
import Dodge.Euse
|
||||
import Dodge.HeldUse
|
||||
import Dodge.Hotkey
|
||||
import Dodge.Inventory
|
||||
import Dodge.Item.Location
|
||||
import Dodge.Luse
|
||||
import Dodge.Reloading
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -28,6 +28,7 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
|
||||
return $
|
||||
itemEffect cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& f
|
||||
where
|
||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
@@ -35,6 +36,7 @@ itemEffect :: Creature -> Item -> World -> World
|
||||
itemEffect cr it w = case it ^. itUse of
|
||||
HeldUse{_heldUse = eff, _heldMods = usemods} ->
|
||||
foldl' (&) (useHeld eff) (useMod usemods) it cr w
|
||||
& pointerToItem it . itUse . heldHammer .~ HammerDown
|
||||
LeftUse{} -> doequipmentchange
|
||||
EquipUse{} -> doequipmentchange
|
||||
-- ConsumeUse will cause problems if the item is not selected
|
||||
|
||||
+17
-18
@@ -72,36 +72,36 @@ useMod hm = case hm of
|
||||
]
|
||||
CircleLaserMod ->
|
||||
[ duplicateItem fLasCircle
|
||||
, withItemUpdate' increasecycleLasCircle
|
||||
, useAmmoAmount 1
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItemUpdateFirst increasecycleLasCircle
|
||||
, ammoCheckI
|
||||
]
|
||||
LasWideMod n ->
|
||||
[ withItem $ \it -> duplicateOffsetsV2 (xsLasWide it)
|
||||
, withItemUpdate' (increasecycleLasWide n)
|
||||
, crAtMuzPos
|
||||
, useAmmoAmount 1
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
[ useAmmoAmount 1
|
||||
, withItem $ \it -> duplicateNumBarrels (min
|
||||
(it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded)
|
||||
(it ^?! itParams . lasCycle `div` lasWideRate))
|
||||
, withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, duplicateLoadedBarrels
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, withItemUpdateFirst (increasecycleLasWide n)
|
||||
, ammoCheckI
|
||||
]
|
||||
DualBeamMod ->
|
||||
[ useAmmoAmount 1
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 (- thegapDualBeam it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 (thegapDualBeam it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withCrPosShift (V2 0 (- thegapDualBeam it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
|
||||
, withItem $ \it -> withCrPosShift (V2 0 (thegapDualBeam it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, ammoCheckI
|
||||
]
|
||||
LasMod ->
|
||||
[ useAmmoAmount 1
|
||||
-- , withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
-- , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, duplicateLoadedBarrels
|
||||
, ammoCheckI
|
||||
]
|
||||
@@ -349,11 +349,7 @@ useMod hm = case hm of
|
||||
fLasCircle it = [it & itParams . lasCycle +~ x | x <- [0, 50 .. 1999]]
|
||||
increasecycleLasWide n it = case _heldHammer (_itUse it) of
|
||||
HammerUp -> it & itParams . lasCycle .~ 1
|
||||
_ -> it & itParams . lasCycle %~ (min (n * 5) . (+ 1))
|
||||
xsLasWide it = [V2 ((0.2 * yoff x) ^ (2 :: Int)) (yoff x) | x <- [(0 :: Int) .. n' -1]]
|
||||
where
|
||||
yoff x = fromIntegral x - fromIntegral (n' -1) / 2
|
||||
n' = _lasCycle (_itParams it)
|
||||
_ -> it & itParams . lasCycle %~ (min (n * lasWideRate) . (+ 1))
|
||||
thegapDualBeam = _dbGap . _itParams
|
||||
directedTelPos _ cr w = (p, a)
|
||||
where
|
||||
@@ -364,6 +360,9 @@ useMod hm = case hm of
|
||||
cr & crDir %~ tweenAngles x (_crOldDir cr)
|
||||
& crPos %~ alongSegBy x (_crOldPos cr)
|
||||
|
||||
lasWideRate :: Int
|
||||
lasWideRate = 2
|
||||
|
||||
mcUseHeld :: HeldItemType -> Item -> Machine -> World -> World
|
||||
mcUseHeld hit = case hit of
|
||||
LASGUN -> mcShootLaser
|
||||
|
||||
@@ -21,7 +21,7 @@ import Padding
|
||||
itemDisplayOffset :: Creature -> Item -> (Int,[String])
|
||||
itemDisplayOffset cr itm = case itm ^. itType . iyBase of
|
||||
EQUIP (TARGETINGHAT tt) | targetItemCanAttachAbove cr itm
|
||||
-> ((-1), leftPad 15 ' ' (targetingTypeString tt) :
|
||||
-> (-1, leftPad 15 ' ' (targetingTypeString tt) :
|
||||
(itemDisplay cr itm & ix 0 %~ (\s -> itemDisplayPad s (replicate (length (targetingTypeString tt)) '^') )))
|
||||
EQUIP (TARGETINGHAT tt)
|
||||
-> (0, itemDisplay cr itm & ix 0 %~ (\s -> itemDisplayPad s (targetingTypeString tt)))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Held.BatteryGuns where
|
||||
|
||||
import Dodge.Base
|
||||
import Dodge.Data.Beam
|
||||
import Dodge.Default.Item
|
||||
import Color
|
||||
@@ -40,7 +41,7 @@ lasGun =
|
||||
defaultAutoBatteryGun
|
||||
& itUse . heldConsumption
|
||||
.~ ( defaultLoadable
|
||||
& laSource . _InternalSource . iaMax .~ 200
|
||||
& laSource . _InternalSource . iaMax .~ 200000
|
||||
& laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 10, loadPrime 60]
|
||||
)
|
||||
& itParams
|
||||
@@ -114,6 +115,7 @@ lasWide n =
|
||||
& itParams . lasColor .~ yellow
|
||||
& itParams . lasDamage .~ 2
|
||||
& itUse . heldMods .~ LasWideMod n
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 y) 0 0 | y <- spreadFromCenter n 1]
|
||||
|
||||
defaultBatteryGun :: Item
|
||||
defaultBatteryGun =
|
||||
|
||||
@@ -3,7 +3,7 @@ module Dodge.Item.Weapon.BatteryGuns (
|
||||
flameBeamCombine,
|
||||
teslaBeamCombine,
|
||||
splitBeamCombine,
|
||||
-- shootTeslaArc,
|
||||
-- shootTeslaArc,
|
||||
shootLaser,
|
||||
circleLaser,
|
||||
shootDualLaser,
|
||||
@@ -22,8 +22,6 @@ import Picture
|
||||
|
||||
--import Control.Monad.State
|
||||
|
||||
|
||||
|
||||
--lasPulse :: Item
|
||||
--lasPulse = lasGun
|
||||
-- & itType . iyBase .~ LASPULSE
|
||||
@@ -42,8 +40,6 @@ import Picture
|
||||
-- & itParams . lasColor .~ frac it * orange
|
||||
-- frac it = 0.5 * (1 + sin (pi * fromIntegral (_lasCycle $ _itParams it) * 0.1))
|
||||
|
||||
|
||||
|
||||
--lasWidePulse :: Item
|
||||
--lasWidePulse = lasGun
|
||||
-- & itType . iyBase .~ LASGUNWIDEPULSE
|
||||
@@ -109,7 +105,6 @@ import Picture
|
||||
-- n' = 9 * n
|
||||
-- xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
|
||||
|
||||
--lasSwing :: Item
|
||||
--lasSwing = lasGun
|
||||
-- & itType . iyBase .~ LASGUNSWING
|
||||
@@ -129,16 +124,15 @@ import Picture
|
||||
-- y = 15 * sin (pi * fromIntegral x' * 0.01)
|
||||
-- x' = _lasCycle $ _itParams it
|
||||
|
||||
|
||||
|
||||
shootLaser :: Item -> Creature -> World -> World
|
||||
shootLaser it cr = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
where
|
||||
pos = _crPos cr
|
||||
dir = _crDir cr
|
||||
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
dam = _lasDamage $ _itParams it
|
||||
shootLaser it cr =
|
||||
cWorld . lWorld . lasers
|
||||
.:~ lasRayAt
|
||||
(_lasColor $ _itParams it)
|
||||
(_lasDamage $ _itParams it)
|
||||
(_phaseV $ _itParams it)
|
||||
(_crPos cr)
|
||||
(_crDir cr)
|
||||
|
||||
-- this has the feel of a left click item
|
||||
circleLaser :: Item -> Creature -> World -> World
|
||||
|
||||
@@ -9,16 +9,15 @@ module Dodge.Item.Weapon.TriggerType (
|
||||
useAmmoUpTo,
|
||||
lockInvFor,
|
||||
withMuzFlareI,
|
||||
withMuzPos,
|
||||
withMuzPosShift,
|
||||
crAtMuzPos,
|
||||
withCrPos,
|
||||
withCrPosShift,
|
||||
withOldDir,
|
||||
trigDoAlso,
|
||||
trigDoAlso',
|
||||
withTempLight,
|
||||
withItem,
|
||||
withItemUpdate,
|
||||
withItemUpdate',
|
||||
withItemUpdateFirst,
|
||||
rateIncAB,
|
||||
torqueBefore,
|
||||
torqueBeforeAtLeast,
|
||||
@@ -48,6 +47,7 @@ module Dodge.Item.Weapon.TriggerType (
|
||||
sideEffectOnFrame,
|
||||
duplicateItem,
|
||||
duplicateLoadedBarrels,
|
||||
duplicateNumBarrels,
|
||||
duplicateLoaded,
|
||||
duplicateOffsetsV2,
|
||||
duplicateOffsetsFocus,
|
||||
@@ -429,8 +429,8 @@ withItem :: (Item -> ChainEffect) -> ChainEffect
|
||||
withItem g f it = g it f it
|
||||
|
||||
-- not ideal
|
||||
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
||||
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
||||
withItemUpdateFirst :: (Item -> Item) -> ChainEffect
|
||||
withItemUpdateFirst up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
||||
where
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
|
||||
@@ -475,23 +475,13 @@ withMuzFlareI f it cr w =
|
||||
-- | crInAimStance OneHand cr = 10
|
||||
-- | otherwise = 0
|
||||
|
||||
withMuzPos :: (Point3 -> World -> World) -> ChainEffect
|
||||
withMuzPos = withMuzPosShift (V2 0 0)
|
||||
withCrPos :: (Point3 -> World -> World) -> ChainEffect
|
||||
withCrPos = withCrPosShift (V2 0 0)
|
||||
|
||||
withMuzPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
|
||||
withMuzPosShift p g f it cr = g thepos . f it cr
|
||||
withCrPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
|
||||
withCrPosShift p g f it cr = g thepos . f it cr
|
||||
where
|
||||
thepos = (_crPos cr `v2z` 20)
|
||||
--thepos = (pos `v2z` 20)
|
||||
--pos =
|
||||
-- _crPos cr
|
||||
-- +.+ rotateV dir p
|
||||
-- +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
||||
--dir = _crDir cr
|
||||
|
||||
crAtMuzPos :: ChainEffect
|
||||
--crAtMuzPos f it cr = f it (cr & crPos +.+.~ (aimingMuzzlePos cr it *.* unitVectorAtAngle (_crDir cr)))
|
||||
crAtMuzPos f it cr = f it cr
|
||||
thepos = (_crPos cr +.+ rotateV (_crDir cr) p) `v2z` 20
|
||||
|
||||
-- | Applies the effect to a randomly rotated creature.
|
||||
withRandomDirI ::
|
||||
@@ -641,14 +631,13 @@ duplicateLoaded eff it cr w = foldr f w [1 .. numBul]
|
||||
f _ = eff it cr
|
||||
numBul = it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
|
||||
|
||||
duplicateLoadedBarrels :: ChainEffect
|
||||
duplicateLoadedBarrels eff itm cr w = foldr f w (take numbul $ itm ^?! itUse . heldAim . aimMuzzles)
|
||||
duplicateNumBarrels :: Int -> ChainEffect
|
||||
duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim . aimMuzzles)
|
||||
where
|
||||
numbul = itm ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
|
||||
f brl w' =
|
||||
eff
|
||||
itm
|
||||
( cr & crPos +~ (rotateV (_crDir cr) (_mzPos brl))
|
||||
( cr & crPos +~ rotateV (_crDir cr) (_mzPos brl)
|
||||
& crDir +~ (_mzRot brl + a)
|
||||
)
|
||||
(w' & randGen .~ g)
|
||||
@@ -656,6 +645,11 @@ duplicateLoadedBarrels eff itm cr w = foldr f w (take numbul $ itm ^?! itUse . h
|
||||
inacc = _mzInaccuracy brl
|
||||
(a,g) = randomR (-inacc,inacc) $ _randGen w'
|
||||
|
||||
duplicateLoadedBarrels :: ChainEffect
|
||||
duplicateLoadedBarrels eff itm = duplicateNumBarrels numbul eff itm
|
||||
where
|
||||
numbul = itm ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
|
||||
|
||||
duplicateOffsetsFocus :: [Float] -> ChainEffect
|
||||
duplicateOffsetsFocus xs eff item cr w = foldr f w poss
|
||||
where
|
||||
|
||||
@@ -130,7 +130,7 @@ selSecYint i j sss = do
|
||||
return . (secpos +)
|
||||
. subtract (ss ^. ssOffset)
|
||||
. sum
|
||||
. fmap (_siHeight)
|
||||
. fmap _siHeight
|
||||
. fst
|
||||
$ IM.split j (ss ^. ssItems)
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user