Add lasCircle

This commit is contained in:
2022-07-08 22:14:44 +01:00
parent 68cb191063
commit ce533c22cb
8 changed files with 91 additions and 21 deletions
+4 -3
View File
@@ -32,7 +32,7 @@ itemCombinations =
-- , po [cr PIPE, cr HARDWARE] (volleyGun 1)
, po [BANGSTICK 1,cr PLANK] rifle
, p [p 3 $ BANGSTICK 1] (volleyGun 3)
, po [BANGSTICK 1,BANGSTICK 1,BANGSTICK 1] (volleyGun 3)
, po [RIFLE,cr TIN] repeater
, po [REPEATER,cr SPRING] autoRifle
, po [REPEATER,cr CAN] burstRifle
@@ -63,9 +63,10 @@ itemCombinations =
-- , p [o LASGUN,o $ cr PRISM] lasSway
-- , p [o LASGUN,o $ cr HARDWARE] lasSwing
-- , p [o LASGUN,o PIPE] lasGunPulse
, p [p 2 LASGUN,p 1 $ cr HARDWARE] dualBeam
, po [LASGUN,LASGUN,cr HARDWARE] dualBeam
-- , p [o LASGUN,o $ cr PIPE, o $ cr PRISM] lasWidePulse
, p [o LASGUN,o $ cr TRANSFORMER] (lasWide 2)
, po [LASGUN, cr TRANSFORMER] (lasWide 2)
, po [LASGUN,LASGUN,LASGUN,cr HARDWARE] lasCircle
, p [o $ cr TRANSFORMER,p 2 $ cr CAN] sparkGun
, p [o SPARKGUN,p 2 $ cr PIPE] teslaGun
+1
View File
@@ -108,6 +108,7 @@ data ItemBaseType
| SPARKGUN
| TESLAGUN
| LASGUN
| LASCIRCLE
| LASPULSE
| DUALBEAM
| LASGUNSWING
+3 -3
View File
@@ -25,7 +25,7 @@ useItem cr' w = fromMaybe (f w) $ do
itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^? itUse of
Just RightUse {_rUse = eff,_useMods = usemods}
-> hammerTest $ tryClickReload cr it w $ foldr ($) eff usemods it cr
-> hammerTest $ tryReload cr it w $ foldr ($) eff usemods it cr
Just LeftUse {} -> doequipmentchange
Just EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected
@@ -40,8 +40,8 @@ itemEffect cr it w = case it ^? itUse of
doequipmentchange = setuhamdown $ hammerTest (toggleEquipmentAt (_rbOptions w) (crSel cr) cr
. activateEquipmentAt (_rbOptions w) cr)
tryClickReload :: Creature -> Item -> World -> (World -> World) -> World -> World
tryClickReload cr it w f
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
tryReload cr it w f
| _crID cr == _yourID w && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False
= crToggleReloading cr
| otherwise
+8 -2
View File
@@ -17,6 +17,7 @@ import Control.Lens
import Text.Read (readMaybe)
import Data.List --(isPrefixOf, isInfixOf, intercalate)
import Data.Maybe
import Control.Applicative
import LensHelp
import qualified Data.Text as T
import qualified IntMapHelp as IM
@@ -61,10 +62,15 @@ applyTerminalCommand s = case s of
applyTerminalCommandArguments :: String -> [String] -> Universe -> Universe
applyTerminalCommandArguments command args u = case command of
"ITEM" -> fromMaybe u $ do
ibt <- safeHead args >>= readMaybe
return $ u & uvWorld %~ (snd . createPutItem (itemFromBase ibt))
ibt <- (safeHead args >>= readMaybe) <|> (safeTake2 args >>= (readMaybe . unwords))
n <- (args ^? ix 1 >>= readMaybe) <|> Just 1
return $ u & uvWorld %~ (flip (foldr ($)) $ replicate n (snd . createPutItem (itemFromBase ibt)))
_ -> u
safeTake2 :: [a] -> Maybe [a]
safeTake2 (x:y:_) = Just (x:y:[])
safeTake2 _ = Nothing
showTerminalError :: String -> String -> Universe -> Universe
showTerminalError cmd s = menuLayers .:~ InputScreen (T.pack cmd) s
+2
View File
@@ -59,6 +59,7 @@ itemFromBase ibt = case ibt of
SPARKGUN -> sparkGun
TESLAGUN -> teslaGun
LASGUN -> lasGun
LASCIRCLE -> lasCircle
LASPULSE -> lasPulse
DUALBEAM -> dualBeam
LASGUNSWING -> lasSwing
@@ -200,6 +201,7 @@ baseToFamily ibt = case ibt of
SPARKGUN -> HeldFamily
TESLAGUN -> HeldFamily
LASGUN -> HeldFamily
LASCIRCLE -> HeldFamily
LASPULSE -> HeldFamily
DUALBEAM -> HeldFamily
LASGUNSWING -> HeldFamily
+50 -11
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Weapon.BatteryGuns
( lasGun
, lasCircle
, dualBeam
, lasWide
-- , lasWidePulse
@@ -122,14 +123,16 @@ lasPulse = lasGun
& itParams . lasDamage .~ ceiling ((22 :: Float) * frac it)
& itParams . lasColor .~ frac it * orange
frac it = 0.5 * (1 + sin (pi * fromIntegral (_lasCycle $ _itParams it) * 0.1))
lasWide :: Int -> Item
lasWide n = lasGun
& itType . iyBase .~ LASWIDE n
lasCircle :: Item
lasCircle = lasGun
& itType . iyBase .~ LASCIRCLE
& itParams . lasColor .~ orange
& itParams . lasDamage .~ 2
& itConsumption . laMax .~ 10000
& itUse . rUse .~ shootLaser
& itUse . useDelay .~ NoDelay
& itUse . rUse .~ circleLaser
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
@@ -137,11 +140,31 @@ lasWide n = lasGun
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, withItemUpdate' increasecycle
, withItem $ \it -> duplicateOffsetsV2 (xs it)
, duplicateItem f
]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
where
increasecycle it = it & itParams . lasCycle %~ (flip mod 2000 . (+ 1))
--f it = [it & itParams . lasCycle +~ x | x <- [0,100 .. 1900] ]
f it = [it & itParams . lasCycle +~ x | x <- [0,50 .. 1999] ]
lasWide :: Int -> Item
lasWide n = lasGun
& itType . iyBase .~ LASWIDE n
& itParams . lasColor .~ yellow
& itParams . lasDamage .~ 2
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, crAtMuzPos
, withItemUpdate' increasecycle
, withItem $ \it -> duplicateOffsetsV2 (xs it)
]
where
increasecycle it = case _useHammer (_itUse it) of
HammerUp -> it & itParams . lasCycle .~ 1
@@ -265,27 +288,27 @@ lasSwing = lasGun
x' = _lasCycle $ _itParams it
lasGun :: Item
lasGun = defaultAutoBatteryGun
{ _itConsumption = defaultLoadable
& itConsumption .~ ( defaultLoadable
& laMax .~ 200
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
, _itParams = Refracting
)
& itParams .~ Refracting
{ _phaseV = 1
, _lasColor = yellow
, _lasColor2 = yellow
, _lasCycle = 0
, _lasDamage = 11
}
, _itTweaks = Tweakable
& itTweaks .~ Tweakable
{ _tweakParams = IM.fromList [(0,lasGunTweak)]
, _tweakSel = 0
}
, _itDimension = ItemDimension
& itDimension .~ ItemDimension
{ _dimRad = 10
, _dimCenter = V3 15 0 0
, _dimPortage = HeldItem 5 30
, _dimSPic = lasGunPic
}
}
& itUse . rUse .~ shootLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
@@ -294,6 +317,7 @@ lasGun = defaultAutoBatteryGun
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, useAmmoAmount 1
, crAtMuzPos
]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
@@ -413,11 +437,26 @@ shootTeslaArc it cr w = w'
shootLaser :: Item -> Creature -> World -> World
shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
where
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
--pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
pos = _crPos cr
dir = _crDir cr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
dam = _lasDamage $ _itParams it
-- this has the feel of a left click item
circleLaser :: Item -> Creature -> World -> World
circleLaser it cr w
| hasLOSIndirect cpos pos w = w
& instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
| otherwise = w
where
cpos = _crPos cr
mwp = mouseWorldPos w
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
dam = _lasDamage $ _itParams it
shootDualLaser :: Item -> Creature -> World -> World
shootDualLaser it cr w = w'
& newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
+22 -2
View File
@@ -9,6 +9,7 @@ module Dodge.Item.Weapon.TriggerType
, withMuzFlareI
, withMuzPos
, withMuzPosShift
, crAtMuzPos
, withOldDir
, trigDoAlso
, withTempLight
@@ -46,10 +47,12 @@ module Dodge.Item.Weapon.TriggerType
, spreadLoaded
, repeatOnFrames
, sideEffectOnFrame
, duplicateItem
, duplicateLoadedBarrels
, duplicateLoaded
, duplicateOffsets
, duplicateOffsetsV2
, duplicateOffsetsV2Dir
, duplicateOffsetsFocus
, hammerCheckI
, hammerCheckL
@@ -403,10 +406,13 @@ withMuzPosShift p g f it cr w = g (pos `v2z` 20)
$ f it cr w
where
pos = _crPos cr
+.+ rotateV dir p
+.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
+.+ 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)))
{- | Applies the effect to a randomly rotated creature,
- rotation amount given by inaccuracy in itParams -}
applyInaccuracy :: ChainEffect
@@ -587,6 +593,11 @@ duplicateOffsetsFocus xs eff item cr w = foldr f w poss
-.- (_crPos cr +.+ pos))
| otherwise = argV (mouseWorldPos w -.- (_crPos cr +.+ pos))
duplicateItem :: (Item -> [Item]) -> ChainEffect
duplicateItem fit eff itm cr w = foldr f w (fit itm)
where
f itm' = eff itm' cr
duplicateOffsetsV2 :: [Point2] -> ChainEffect
duplicateOffsetsV2 xs eff item cr w = foldr f w poss
where
@@ -599,3 +610,12 @@ duplicateOffsets xs eff item cr w = foldr f w poss
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0 ) xs
f pos = eff item (cr & crPos +.+.~ pos)
duplicateOffsetsV2Dir :: [(Point2,Float)] -> ChainEffect
duplicateOffsetsV2Dir xs eff item cr w = foldr f w
-- $ xs
$ map (over _1 (rotateV (_crDir cr))) xs
where
f (pos,dir) = eff item $ cr
& crPos +.+.~ pos
& crDir +~ dir
+1
View File
@@ -5,6 +5,7 @@ module Geometry.Zone
, xIntercepts
, yIntercepts
, divTo
, modTo
, zoneOfPoint
, zoneOfSeg
, zoneInsideCirc