Compare commits

...

12 Commits

Author SHA1 Message Date
justin 29017e6b06 Move handle positions 2023-05-28 15:02:23 +01:00
justin 7fc36ab028 Improve weapon handle offsets 2023-05-28 13:59:58 +01:00
justin 4b35a683af Tweak muzzle flare 2023-05-28 11:14:05 +01:00
justin 10c9e2261f Held item rclick use, tweak reload on lclick 2023-05-28 10:17:32 +01:00
justin ec8317c14e Work on held item usage 2023-05-27 12:32:09 +01:00
justin 4cfb7d431a Explicitly store list of barrels for weapons 2023-05-20 17:48:51 +01:00
justin 03611c6b95 Move towards unifying weapon barrels 2023-05-20 15:29:46 +01:00
justin f2183e9954 Cleanup 2023-05-20 15:06:05 +01:00
justin 6c71e1d5bb Cleanup 2023-05-20 00:44:54 +01:00
justin 938809a3a1 Continue to work on targeting inventory items 2023-05-20 00:34:23 +01:00
justin 6053bb059b Move targeting strings, broke targeting usage 2023-05-20 00:02:50 +01:00
justin 2d3b76dfd4 Move towards positional item targeting 2023-05-19 23:03:52 +01:00
61 changed files with 418 additions and 445 deletions
+18
View File
@@ -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
@@ -146,3 +147,20 @@ dbArg f x = f x x
-- TODO check whether this is simply the reader monad, flipped
dbArgChain :: (a -> b -> b) -> (a -> b -> b) -> a -> b -> b
dbArgChain f g x = f x . g x
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 | 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]]
+1 -1
View File
@@ -11,7 +11,7 @@ drawBeam bd = case bd of
basicDrawBeam :: Beam -> Picture
basicDrawBeam bm =
setLayer BloomNoZWrite $
pictures
fold
[ setDepth 19 . color (brightX 0 0.5 col) $ thickLine 20 ps
, setDepth 19.5 . color (brightX 10 1 col) $ thickLine 3 ps
]
+3 -2
View File
@@ -3,6 +3,7 @@ module Dodge.Bullet (
useAmmoParams,
) where
import Linear
import Dodge.Item.Weapon.Bullet
import System.Random
import Data.Foldable
@@ -59,13 +60,13 @@ useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it cr w =
w & cWorld . lWorld . instantBullets
.:~ ( _amBullet bultype
& buPos .~ sp
& buPos .~ _crPos cr
& buTrajectory %~ settrajectory
& buVel %~ (rotateV dir . (muzvel *.*))
& buDrag *~ _rifling (_itParams it)
)
where
sp = _crPos cr +.+ (muzlength + 10) *.* unitVectorAtAngle dir
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
dir = _crDir cr
bultype = _laAmmoType $ _heldConsumption $ _itUse it
muzvel = _muzVel $ _itParams it
+2 -2
View File
@@ -17,7 +17,7 @@ moduleModification imt = case imt of
. (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3)
BULPAY thepayload -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ thepayload
BULBODY thebody -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ thebody
TARGET t -> itUse . useTargeting ?~ t
TARGET {} -> id -- itUse . useTargeting ?~ t
BULTRAJ BasicBulletTrajectoryType -> id
BULTRAJ MagnetTrajectoryType ->
(itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0)
@@ -38,7 +38,7 @@ moduleModification imt = case imt of
where
makeDirectedTele it =
it
& itUse . useTargeting ?~ TargetRBPress
-- & itUse . useTargeting ?~ TargetRBPress
& itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . heldAim . aimZoom . izFac .~ 1
+1
View File
@@ -259,6 +259,7 @@ stackedInventory =
, flatShield
, spawnGun (lamp 5)
, lasGun
, lasWide 20
, flameThrower
, poisonSprayer
, launcher
+4 -11
View File
@@ -37,7 +37,7 @@ import qualified Data.Map as M
import Foreign.ForeignPtr
import Control.Concurrent
colouredEnemy col = pictures [color col $ circleSolid 10, circLine 10]
colouredEnemy col = color col $ circleSolid 10, circLine 10
spawnerCrit :: Creature
spawnerCrit = defaultCreature
@@ -155,22 +155,15 @@ addArmour = over crInv insarmour
where i = newKey xs
equipOnTop :: (Creature -> Picture) -> Creature -> Picture
--equipOnTop f cr = onLayer CrLayer $ pictures $ fst (drawEquipment cr) ++ [f cr] ++ snd (drawEquipment cr)
equipOnTop f cr = pictures [onLayer CrLayer (f cr) , drawEquipment cr]
equipOnTop f cr = onLayer CrLayer (f cr) <> drawEquipment cr
drawEquipment :: Creature -> Picture
drawEquipment cr = pictures $ map f $ IM.toList (_crInv cr)
drawEquipment cr = foldMap f $ IM.toList (_crInv cr)
where f (i,it) = case it ^? itEquipPict of
Just g -> g cr i
_ -> blank
--drawEquipment :: Creature -> ([Picture],[Picture])
--drawEquipment cr = (map fst p1, map fst p2)
-- where f (k,it) = join $ (it ^? itEquipPict) <*> (pure cr) <*> (pure k)
-- picts = sortBy (compare `on` snd) $ mapMaybe f $ IM.toList (_crInv cr)
-- (p1,p2) = partition (\ x -> snd x < 0) picts
frontArmouredPict = const $ pictures [ color (greyN 0.8) $ circleSolid 20
frontArmouredPict = const $ fold [ color (greyN 0.8) $ circleSolid 20
, color red $ circLine 20
]
+20 -10
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.HandPos where
import Linear
import Control.Lens
import Data.Maybe
import Dodge.Creature.Test
@@ -8,22 +9,31 @@ import Geometry
import ShapePicture
-- the position of a weapon handle
aimingWeaponHandlePos :: Creature -> Item -> Float
aimingWeaponHandlePos cr it = case it ^? itUse . heldAim . aimStance of
Just TwoHandTwist -> -5
Just OneHand -> 14
Just TwoHandFlat -> 1.2 * _crRad cr
aimingWeaponHandlePos :: Creature -> Item -> Point2
aimingWeaponHandlePos _ it = case it ^? itUse . heldAim . aimStance of
Just TwoHandUnder -> 0
Just TwoHandOver -> V2 (-7) 0
Just OneHand -> V2 10 (-2)
Just TwoHandFlat -> V2 10 0
Nothing -> 0
aimingWeaponZeroPos :: Creature -> Item -> Float
aimingWeaponZeroPos :: Creature -> Item -> Point2
aimingWeaponZeroPos cr it =
aimingWeaponHandlePos cr it
- fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos)
aimingMuzzlePos :: Creature -> Item -> Float
aimingMuzzlePos cr it =
aimingWeaponZeroPos cr it
+ fromMaybe 0 (it ^? itUse . heldAim . aimMuzPos)
aimingMuzzlePos :: Creature -> Item -> [Point2]
aimingMuzzlePos cr it = fmap ((+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded)
where
zp = aimingWeaponZeroPos cr it
aimingMuzzleOff :: Creature -> Item -> [Point2]
aimingMuzzleOff cr it = fmap (rotateV (_crDir cr) . (+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded)
where
zp = aimingWeaponZeroPos cr it
aimingMuzzleLength :: Creature -> Item -> Float
aimingMuzzleLength cr it = head (aimingMuzzlePos cr it) ^. _x
translatePointToRightHand :: Creature -> Point3 -> Point3
translatePointToRightHand cr = translatePointToRightHand' cr . mirrorV3xz
+4 -2
View File
@@ -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
+9 -23
View File
@@ -3,6 +3,8 @@ module Dodge.Creature.State (
doDamage,
) where
import Dodge.Item.Display -- this should not really be imported... TODO move canAttachTargetingBelow
import Control.Applicative
import Data.Foldable
import Data.Maybe
import Dodge.Base
@@ -15,7 +17,7 @@ import Dodge.Creature.Test
import Dodge.Damage
import Dodge.Data.World
import Dodge.EnergyBall
import Dodge.Equipment
--import Dodge.Equipment
import Dodge.Euse
import Dodge.Hammer
import Dodge.ItEffect
@@ -271,14 +273,12 @@ updateAutoRecharge it = case it ^? itUse . leftConsumption of
crGetTargeting :: Creature -> Maybe TargetType
crGetTargeting cr = do
itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr)
itm ^? itUse . useTargeting . _Just
where
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
helditem = fromMaybe [] $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
itm <- cr ^? crInv . ix i
return [itm]
i <- cr ^? crManipulation . manObject . inInventory . ispItem
itm <- cr ^? crInv . ix i
--(cr ^? crInv . ix (i+1) . itUse . equipTargeting . _Just)
itm ^? itType . iyModules . ix ModTarget . imtTargetType
<|> (guard (canAttachTargetingBelow itm)
>> cr ^? crInv . ix (i+1) . itUse . equipTargeting . _Just)
weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
@@ -291,20 +291,6 @@ weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory .
w
_ -> w
where
-- PassiveReload stype | Just (_laReloadTime am) == am ^? laTransfer . transferTime
-- -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
-- PassiveReload _ -> w
-- ActiveClear | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
-- ActiveClear | _laTransfer am == NoTransfer -> w
-- ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
-- ActivePartial{} | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
-- ActivePartial{} | _laTransfer am == NoTransfer -> w
-- ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
-- Just ChargeableAmmo {} -> w
-- Just NoConsumption {} -> w
-- Just ItemItselfConsumable {} -> w
-- Nothing -> w
cid = _crID cr
updateMovement :: Creature -> Creature
+3 -2
View File
@@ -103,7 +103,7 @@ twoFlat :: Creature -> Bool
twoFlat = crInAimStance TwoHandFlat
twists :: Creature -> Bool
twists = crInAimStance TwoHandTwist
twists cr = crInAimStance TwoHandUnder cr || crInAimStance TwoHandOver cr
-- the use of crOldPos is because the damage position is calculated on the
-- previous frame
@@ -124,7 +124,8 @@ hasFrontArmour p cr = fromMaybe False $ do
frontarmdirection
| crInAimStance OneHand cr = 0.5
| crInAimStance TwoHandTwist cr = negate 1
| crInAimStance TwoHandUnder cr = negate 1
| crInAimStance TwoHandOver cr = negate 1
| otherwise = 0
--crOnSeg :: Point2 -> Point2 -> Creature -> Bool
+5 -1
View File
@@ -117,7 +117,11 @@ wasdWithAiming w speed cr
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
let currenttwistamount = cr ^. crTwist
case (astance, currenttwistamount) of
(TwoHandTwist, 0) ->
(TwoHandUnder, 0) ->
return $
(crTwist .~ twistamount * pi)
. (crDir -~ twistamount * pi)
(TwoHandOver, 0) ->
return $
(crTwist .~ twistamount * pi)
. (crDir -~ twistamount * pi)
+3 -2
View File
@@ -190,8 +190,8 @@ data ItemModuleType
| MAGNETMAG
| BULPAY BulletSpawn
| BULBODY BulletEffect
| BULTRAJ BulletTrajectoryType
| TARGET TargetType
| BULTRAJ {_imtBulletTrajectoryType :: BulletTrajectoryType}
| TARGET {_imtTargetType :: TargetType}
| INCENDLAS
| SPLITLAS
| STATICLAS
@@ -224,6 +224,7 @@ data ModuleSlot
makeLenses ''ItemType
makeLenses ''ItemBaseType
makeLenses ''HeldItemType
makeLenses ''ItemModuleType
deriveJSON defaultOptions ''Stack
deriveJSON defaultOptions ''CraftType
deriveJSON defaultOptions ''ConsumableItemType
+9 -22
View File
@@ -48,7 +48,6 @@ data ItemParams
{ _muzVel :: Float
, _rifling :: Float
, _bore :: Float
, _gunBarrels :: GunBarrels
, _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
@@ -76,17 +75,15 @@ data ShrinkGunStatus = FullSize | Shrunk
data PreviousArcEffect = NoPreviousArcEffect | PerturbTillBreakPreviousArc
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data GunBarrels
= MultiBarrel
{ _brlSpread :: BarrelSpread
, _brlNum :: Int
, _brlInaccuracy :: Float
}
| RotBarrel
{ _brlNum :: Int
, _brlInaccuracy :: Float
}
| SingleBarrel {_brlInaccuracy :: Float}
--data GunBarrels
---- = MultiBarrel
---- { _brlSpread :: BarrelSpread
---- , _brlNum :: Int
---- , _brlInaccuracy :: Float
---- }
-- = BarrelList
-- { _brlList :: [GunBarrel]
-- }
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Nozzle = Nozzle
@@ -99,19 +96,9 @@ data Nozzle = Nozzle
}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data BarrelSpread
= AlignedBarrels
| SpreadBarrels {_spreadAngle :: Float}
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''BarrelSpread
makeLenses ''ItemParams
makeLenses ''Nozzle
makeLenses ''GunBarrels
deriveJSON defaultOptions ''ShrinkGunStatus
deriveJSON defaultOptions ''PreviousArcEffect
deriveJSON defaultOptions ''Nozzle
deriveJSON defaultOptions ''BarrelSpread
deriveJSON defaultOptions ''GunBarrels
deriveJSON defaultOptions ''ItemParams
+16 -5
View File
@@ -14,6 +14,7 @@ module Dodge.Data.Item.Use (
module Dodge.Data.Item.Targeting,
) where
import Linear
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
@@ -34,7 +35,7 @@ data ItemUse
, _heldAim :: AimParams
, _heldScroll :: HeldScroll
, _heldConsumption :: HeldConsumption
, _useTargeting :: Maybe TargetType
-- , _useTargeting :: Maybe TargetType
}
| LeftUse
{ _leftUse :: Luse
@@ -49,7 +50,7 @@ data ItemUse
}
| EquipUse
{ _equipEffect :: EquipEffect
, _useTargeting :: Maybe TargetType
, _equipTargeting :: Maybe TargetType
}
| CraftUse
{_useAmount :: ItAmount}
@@ -71,13 +72,21 @@ data AimParams = AimParams
, _aimRange :: Float
, _aimZoom :: ItZoom
, _aimStance :: AimStance
, _aimHandlePos :: Float
, _aimMuzPos :: Float
, _aimHandlePos :: V2 Float
, _aimMuzzles :: [Muzzle]
}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Muzzle = Muzzle
{ _mzPos :: V2 Float
, _mzRot :: Float
, _mzInaccuracy :: Float
}
data AimStance
= TwoHandTwist
= TwoHandUnder
| TwoHandOver
| TwoHandFlat
| OneHand
-- | LeaveHolstered
@@ -94,6 +103,8 @@ data ItZoom = ItZoom
makeLenses ''ItemUse
makeLenses ''AimParams
makeLenses ''ItZoom
makeLenses ''Muzzle
deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AimStance
deriveJSON defaultOptions ''ItZoom
deriveJSON defaultOptions ''AimParams
+2 -2
View File
@@ -22,13 +22,13 @@ addRoomLinkDecorations rms w =
%~ IM.insertWithNewKeys (map roomLinkDecorations rms)
roomLinkDecorations :: Room -> Picture
roomLinkDecorations rm = pictures . map (linkDecoration . lnkPosDir) $ _rmLinks rm
roomLinkDecorations rm = foldMap (linkDecoration . lnkPosDir) $ _rmLinks rm
linkDecoration :: (Point2, Float) -> Picture
linkDecoration (p, a) = setLayer DebugLayer . color red $ line [p, p +.+ 20 *.* unitVectorAtAngle (a - pi / 2)]
roomPolyDecorations :: Room -> Picture
roomPolyDecorations rm = pictures . map polyWireFrame $ _rmPolys rm
roomPolyDecorations rm = foldMap polyWireFrame $ _rmPolys rm
polyWireFrame :: [Point2] -> Picture
polyWireFrame (x : xs) = setLayer DebugLayer . setDepth 50 . color green $ line $ (x : xs) ++ [x]
+3 -3
View File
@@ -33,13 +33,13 @@ import Dodge.Render.Label
import Dodge.WorldEvent.ThingsHit
printPoint :: Point2 -> Picture
printPoint p = color white $ uncurryV translate p $ pictures [circle 3, scale 0.05 0.05 $ text (show p)]
printPoint p = color white $ uncurryV translate p $ fold [circle 3, scale 0.05 0.05 $ text (show p)]
printRotPoint :: Float -> Point2 -> Picture
printRotPoint r p =
color white
. uncurryV translate p
$ pictures [circle 3, rotate (negate r) $ scale 0.1 0.1 $ text (show p)]
$ fold [circle 3, rotate (negate r) $ scale 0.1 0.1 $ text (show p)]
outsideScreenPolygon :: Configuration -> Camera -> [Point2]
outsideScreenPolygon cfig w = [tr, tl, bl, br]
@@ -150,7 +150,7 @@ debugDraw' cfig w bl = case bl of
Show_zone_near_point_cursor -> drawZoneNearPointCursor w
Inspect_wall -> drawInspectWalls w
Cr_awareness -> drawCreatureDisplayTexts w
Show_sound -> pictures $ M.map (soundPic cfig w) $ _playingSounds w
Show_sound -> fold $ M.map (soundPic cfig w) $ _playingSounds w
Cr_status -> drawCrInfo cfig w
Mouse_position -> drawMousePosition w
Walls_info -> drawWlIDs w
+2 -2
View File
@@ -23,7 +23,7 @@ defaultLeftUse =
defaultEquipUse :: ItemUse
defaultEquipUse = EquipUse
{ _equipEffect = defaultEquip
, _useTargeting = Nothing
, _equipTargeting = Nothing
}
defaultHeldUse :: ItemUse
@@ -36,5 +36,5 @@ defaultHeldUse =
, _heldAim = defaultAimParams
, _heldScroll = HeldScrollDoNothing
, _heldConsumption = defaultLoadable
, _useTargeting = Nothing
-- , _useTargeting = Nothing
}
+5 -2
View File
@@ -1,6 +1,7 @@
module Dodge.Default.Item.Use.AimParams where
import Dodge.Data.Item.Use
import Linear
defaultAimParams :: AimParams
defaultAimParams =
@@ -10,6 +11,8 @@ defaultAimParams =
, _aimRange = 0
, _aimZoom = ItZoom 20 0.2 1
, _aimStance = OneHand
, _aimHandlePos = 10
, _aimMuzPos = 20
--, _aimHandlePos = 10
, _aimHandlePos = V2 3 0
, _aimMuzzles = [Muzzle (V2 20 0) 0 0]
-- , _aimMuzPos = 20
}
+1 -1
View File
@@ -22,7 +22,7 @@ drawStaticBall pt =
drawFlamelet :: EnergyBall -> Picture
drawFlamelet pt =
pictures
fold
[ setLayer BloomLayer pic
, setLayer BloomNoZWrite piu
, setLayer BloomNoZWrite pi2
+1 -1
View File
@@ -8,7 +8,7 @@ drawFlame ::
Flame ->
Picture
drawFlame pt =
pictures
fold
[ glow
, aPic BloomNoZWrite prot2 25 (V2 (scaleChange + 1) 2) $ V4 2 (-1) (-1) 0.5
, aPic BloomNoZWrite prot 22 (V2 (scaleChange + 0.5) 1) $ V4 1 0.5 0 2
+39 -41
View File
@@ -72,36 +72,37 @@ 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))
, 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 ->
[ crAtMuzPos
, useAmmoAmount 1
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
[ useAmmoAmount 1
, withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, duplicateLoadedBarrels
, ammoCheckI
]
LauncherXMod i ->
@@ -130,7 +131,7 @@ useMod hm = case hm of
[ withMuzFlareI
, withSmoke 1 black 20 200 5
, withRecoil
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart tap3S
@@ -141,7 +142,6 @@ useMod hm = case hm of
VolleyGunMod ->
[ withRecoil
, withMuzFlareI
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAllAmmo
@@ -155,7 +155,7 @@ useMod hm = case hm of
[ withMuzFlareI
, withSmoke 1 black 20 200 5
, withRecoil
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart tap3S
@@ -166,7 +166,7 @@ useMod hm = case hm of
[ withRecoil
, withMuzFlareI
, withThickSmokeI
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
@@ -178,7 +178,7 @@ useMod hm = case hm of
[ withRecoil
, withMuzFlareI
, withThickSmokeI
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
@@ -190,7 +190,7 @@ useMod hm = case hm of
[ withRecoil
, withMuzFlareI
, withThickSmokeI
, applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
@@ -208,22 +208,21 @@ useMod hm = case hm of
reverse $ withPosDirWallCheck directedTelPos : useMod hm'
BangStickMod ->
[ withRecoil
-- , applyInaccuracy
, spreadLoaded
, withTorqueAfter
, withMuzFlareI
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, duplicateLoadedBarrels
, withTorqueAfter
, withMuzFlareI
, useTimeCheck
, ammoCheckI
, blCheck
]
PistolMod ->
[ withMuzFlareI
, withSidePushI 50
[ withSidePushI 50
, withRecoil
, withMuzFlareI
, withTorqueAfter
, applyInaccuracy
, duplicateLoadedBarrels
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
@@ -235,7 +234,7 @@ useMod hm = case hm of
, withSidePushI 50
, withRecoil
, withTorqueAfter
, applyInaccuracy
, duplicateLoadedBarrels
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
@@ -246,7 +245,7 @@ useMod hm = case hm of
, withRecoil
, withSidePushI 50
, withTorqueAfter
, applyInaccuracy
, duplicateLoadedBarrels
, withSoundStart tap1S
, useAmmoAmount 1
, useTimeCheck
@@ -255,7 +254,7 @@ useMod hm = case hm of
BurstRifleMod ->
[ withRecoil
, withMuzFlareI
, applyInaccuracy
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, repeatOnFrames [3, 6] BurstRifleRepeatMod
@@ -268,7 +267,7 @@ useMod hm = case hm of
BurstRifleRepeatMod ->
[ withRecoil
, withMuzFlareI
, applyInaccuracy
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
@@ -295,7 +294,7 @@ useMod hm = case hm of
, withSidePushI 30
, withRecoil
, withTorqueAfter
, applyInaccuracy
, duplicateLoadedBarrels
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
@@ -306,7 +305,7 @@ useMod hm = case hm of
, withTorqueAfter
-- , spreadLoaded
, withMuzFlareI
, applyInaccuracy
, duplicateLoadedBarrels
, useAmmoUpTo 1
, withSoundStart tap3S
, repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod
@@ -321,7 +320,7 @@ useMod hm = case hm of
[ withRecoil
, withTorqueAfter
, withMuzFlareI
, applyInaccuracy
, duplicateLoadedBarrels
, useAmmoUpTo 1
, withSoundStart tap3S
, ammoCheckI
@@ -330,9 +329,9 @@ useMod hm = case hm of
[ withRandomItemParams coneRandItemParams
, withRandomItemUpdate coneRandItemUpdate
, withRandomOffset
, applyInaccuracy
, withMuzFlareI
, duplicateLoadedBarrels
, duplicateLoaded
, withMuzFlareI
, withRecoil
, withTorqueAfter
, useAllAmmo
@@ -350,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
@@ -365,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
@@ -512,7 +510,7 @@ shootTeslaArc it cr w =
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
(w', ip) = makeTeslaArc (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
pos = _crPos cr +.+ aimingMuzzleLength cr it *.* unitVectorAtAngle dir
dir = _crDir cr
-- I believe because the targeting returns to nothing straight after you release
+4 -5
View File
@@ -20,17 +20,16 @@ invSelectionItem cr i it =
, _siIsSelectable = True
, _siColor = col
, _siOffX = 0
, _siOffY = 0
, _siOffY = yoff
, _siPayload = ()
}
where
anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i)
anyequippos = maybe [] (rightPad 8 ' ' . (' ':) . eqPosText) (cr ^? crInvEquipped . ix i)
col = _itInvColor it
pics = case _itCurseStatus it of
UndroppableIdentified -> itemDisplay cr it
-- _ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
_ -> itemDisplay cr it
(yoff,pics) = case _itCurseStatus it of
UndroppableIdentified -> itemDisplayOffset cr it
_ -> itemDisplayOffset cr it
hotkeyToString :: Hotkey -> String
hotkeyToString x = case x of
+39 -2
View File
@@ -1,5 +1,7 @@
module Dodge.Item.Display (
itemDisplay,
--itemDisplay,
itemDisplayOffset,
canAttachTargetingBelow,
-- selectedItemDisplay,
itemString,
itemBaseName,
@@ -16,6 +18,36 @@ import Dodge.Module
import LensHelp
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) :
(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)))
_ -> (0, itemDisplay cr itm)
targetItemCanAttachAbove :: Creature -> Item -> Bool
targetItemCanAttachAbove cr itm = fromMaybe False $ do
i <- itm ^? itLocation . ipInvID
itm' <- cr ^? crInv . ix (i - 1)
return $ canAttachTargetingBelow itm'
canAttachTargetingBelow :: Item -> Bool
canAttachTargetingBelow itm =
isJust (itm ^? itType . iyModules . ix ModBulletTrajectory . imtBulletTrajectoryType)
|| Just LAUNCHHOME == (itm ^? itType . iyModules . ix ModLauncherHoming)
targetingTypeString :: TargetType -> String
targetingTypeString tt = case tt of
TargetLaser -> "LASER"
TargetRBPress -> "POS"
TargetRBLine -> ""
TargetRBCreature -> "LIFEFORM"
TargetCursor -> "CURSOR"
itemDisplay :: Creature -> Item -> [String]
itemDisplay cr itm = --itemDisplayWithNumber (showConsumption cr it) it
zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr itm)
@@ -52,9 +84,14 @@ itemBaseName it = case _iyBase $ _itType it of
Just i -> takeWhile (/= ' ') (show hit) ++ show i
Nothing -> show hit
LEFT lit -> show lit
EQUIP eit -> show eit
EQUIP eit -> showEquipItem eit
Consumable cit -> show cit
showEquipItem :: EquipItemType -> String
showEquipItem eit = case eit of
TARGETINGHAT _ -> "TARG.HAT"
_ -> show eit
showAutoRechargeProgress :: LeftConsumption -> String
showAutoRechargeProgress lc = case lc of
AutoRecharging{}
+8 -15
View File
@@ -32,7 +32,7 @@ equipItemSPic et _ = case et of
FRONTARMOUR ->
( mempty
, setDepth 20 $
pictures
fold
[ color yellow $ thickArc 0 (pi / 2) 10 5
, color yellow $ thickArc (3 * pi / 2) (2 * pi) 10 5
]
@@ -118,14 +118,10 @@ ammoPosition itm hit = case hit of
rhs = Q.axisAngle (V3 1 0 0) 0
bangStickAmmoPos :: Int -> Item -> AmmoPosition
bangStickAmmoPos i itm =
bangStickAmmoPos _ itm =
Bullets
[(rotate3z a (V3 5 0 3), Q.axisAngle (V3 0 0 1) a) | a <- map f [0 .. i - 1]]
where
f n =
barrelspread * fromIntegral n
- 0.5 * barrelspread * fromIntegral (_brlNum (_gunBarrels (_itParams itm)) -1)
barrelspread = itm ^?! itParams . gunBarrels . brlSpread . spreadAngle
[(rotate3z a (V3 5 0 3), Q.axisAngle (V3 0 0 1) a)
| a <- map _mzRot (itm ^?! itUse . heldAim . aimMuzzles)]
volleygunAmmoPos :: Int -> AmmoPosition
volleygunAmmoPos i =
@@ -212,12 +208,9 @@ modulesSPic it _ imt = case imt of
_ -> mempty
baseStickShapeX :: Item -> Int -> Shape
baseStickShapeX it i = foldMap f [0 .. i -1]
baseStickShapeX it _ = foldMap f (it ^?! itUse . heldAim . aimMuzzles)
where
f j = rotateSH ang baseStickShape
where
ang = fromIntegral j * barrelspread - (fromIntegral i - 1) * barrelspread * 0.5
barrelspread = it ^?! itParams . gunBarrels . brlSpread . spreadAngle
f brl = rotateSH (_mzRot brl) baseStickShape
baseStickShape :: Shape
baseStickShape = colorSH green $ xCylinderST 3 10
@@ -226,7 +219,7 @@ bangConeShape :: Float -> Shape
bangConeShape x =
colorSH cyan $
xCylinderST 3 x
<> upperPrismPolyST 6 (reverse $ rectNSWE 4 (-4) x (10 + x))
<> upperPrismPolyST 6 ( rectNSWE 4 (-4) x (10 + x))
defSPic :: SPic
defSPic = noPic $ colorSH green $ upperPrismPolyST 3 $ square 4
@@ -498,7 +491,7 @@ detectorColor dt = case dt of
keyPic :: Picture
keyPic =
color green $
pictures
fold
[ translate (-4) 0 $ thickCircle 4 2
, thickLine 2 $ map toV2 [(0, 0), (8, 0), (8, -4)]
, thickLine 2 $ map toV2 [(4, 0), (4, -4)]
+1 -1
View File
@@ -111,7 +111,7 @@ targetingHat tt =
defaultEquipment
& itUse . equipEffect . eeSite .~ GoesOnHead
& itType . iyBase .~ EQUIP (TARGETINGHAT tt)
& itUse . useTargeting ?~ tt
& itUse . equipTargeting ?~ tt
headLamp :: Item
headLamp =
+11 -11
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Held.BatteryGuns where
import Dodge.Base
import Dodge.Data.Beam
import Dodge.Default.Item
import Color
@@ -30,8 +31,8 @@ teslaGun =
& itUse . heldMods .~ TeslaMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimHandlePos .~ 4
& itUse . heldAim . aimMuzPos .~ 4
-- & itUse . heldAim . aimMuzPos .~ 4
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0]
& itType . iyBase .~ HELD TESLAGUN
lasGun :: Item
@@ -39,7 +40,7 @@ lasGun =
defaultAutoBatteryGun
& itUse . heldConsumption
.~ ( defaultLoadable
& laSource . _InternalSource . iaMax .~ 200
& laSource . _InternalSource . iaMax .~ 200000
& laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 10, loadPrime 60]
)
& itParams
@@ -61,9 +62,10 @@ lasGun =
& itUse . heldMods .~ LasMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimStance .~ TwoHandUnder
-- & itUse . heldAim . aimHandlePos .~ 5
-- & itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itType . iyBase .~ HELD LASGUN
lasGunTweak :: TweakParam
@@ -92,9 +94,7 @@ tractorGun =
& itUse . heldMods .~ AmmoCheckMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itType . iyBase .~ HELD TRACTORGUN
tractorGunTweak :: TweakParam
@@ -112,6 +112,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 =
@@ -143,13 +144,12 @@ lasCircle =
& itUse . heldMods .~ CircleLaserMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
dualBeam :: Item
dualBeam =
lasGun
& itType . iyBase .~ HELD DUALBEAM
& itUse . heldAim . aimMuzPos .~ 0
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itParams
.~ DualBeam
{ _phaseV = 1
+11 -28
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Held.Cane (
miniGunX,
) where
import Dodge.Base
import Dodge.Data.Item
import Dodge.Default
import Dodge.Reloading.Action
@@ -21,10 +22,6 @@ defaultBangCane =
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
@@ -34,8 +31,8 @@ defaultBangCane =
& itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ BangCaneMod
& itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
@@ -48,41 +45,32 @@ volleyGun i =
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels
.~ MultiBarrel
{ _brlSpread = AlignedBarrels
, _brlNum = i
, _brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle =
defaultBangCane
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimStance .~ TwoHandUnder
& itType . iyBase .~ HELD RIFLE
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 25 0) 0 0.01]
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
@@ -105,7 +93,7 @@ burstRifle :: Item
burstRifle =
repeater
& itType . iyBase .~ HELD BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 18
& itUse . heldMods .~ BurstRifleMod
@@ -117,9 +105,9 @@ miniGunUse i =
& heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100}
& heldAim . aimWeight .~ 6
& heldAim . aimRange .~ 1
& heldAim . aimStance .~ TwoHandTwist
& heldAim . aimStance .~ TwoHandUnder
& heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& heldAim . aimHandlePos .~ 5
-- & heldAim . aimHandlePos .~ 5
& heldConsumption
.~ (defaultBulletLoadable & laSource .~ AboveSource)
--(defaultBulletLoadable
@@ -133,17 +121,12 @@ miniGunX i =
autoRifle
& itUse .~ miniGunUse i
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 15 0) 0 0.05)
& itParams
.~ BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
MultiBarrel
{ _brlSpread = RotatingBarrels 0.01
, _brlNum = i
, _brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
+11 -11
View File
@@ -1,10 +1,11 @@
module Dodge.Item.Held.Cone
where
import Dodge.Default.Item
import Dodge.Data.Item
import Dodge.Reloading.Action
module Dodge.Item.Held.Cone where
import Control.Lens
import Dodge.Data.Item
import Dodge.Default.Item
import Dodge.Reloading.Action
import Geometry.Data
import Linear
bangCone :: Item
bangCone =
@@ -14,7 +15,6 @@ bangCone =
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 5
, _gunBarrels = SingleBarrel 0.5
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
@@ -24,8 +24,8 @@ bangCone =
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 20
& itUse . heldMods .~ BangConeMod
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5]
& itType . iyBase .~ HELD BANGCONE
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 5
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 20, loadPrime 5]
@@ -35,10 +35,10 @@ blunderbuss =
bangCone
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 25
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 30, loadPrime 5]
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 30
& itType . iyBase .~ HELD BLUNDERBUSS
grapeCannon :: Int -> Item
+4 -3
View File
@@ -28,9 +28,10 @@ launcher =
& itUse . heldMods .~ LauncherMod
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 20
& itUse . heldAim . aimStance .~ TwoHandOver
-- & itUse . heldAim . aimHandlePos .~ V2 3 0
-- & itUse . heldAim . aimMuzPos .~ 20
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0]
& itUse . heldConsumption . laAmmoType
.~ ProjectileAmmo
{ _amPayload = ExplosionPayload
+8 -8
View File
@@ -22,7 +22,6 @@ bangRod =
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _gunBarrels = SingleBarrel 0.1
, _recoil = 50
, _torqueAfter = 0.3
, _randomOffset = 0
@@ -38,16 +37,16 @@ bangRod =
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1]
& itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
elephantGun :: Item
elephantGun =
bangRod
& itType . iyBase .~ HELD ELEPHANTGUN
& itUse . heldAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldMods .~ ElephantGunMod
& itParams . recoil .~ 50
& itParams . torqueAfter .~ 0.1
@@ -68,11 +67,12 @@ sniperRifle :: Item
sniperRifle =
elephantGun
& itType . iyBase .~ HELD SNIPERRIFLE
& itParams . gunBarrels .~ SingleBarrel 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1}
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itScope .~ ZoomScope (V2 0 0) 1 0.5 False
& itUse . useTargeting ?~ TargetLaser
& itType . iyModules . at ModTarget ?~ TARGET TargetLaser
-- & itUse . useTargeting ?~ TargetLaser
machineGun :: Item
machineGun =
@@ -82,7 +82,7 @@ machineGun =
& itUse . heldMods .~ MachineGunMod
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 100
+3 -3
View File
@@ -91,9 +91,9 @@ flameThrower =
& itUse . heldMods .~ FlameThrowerMod
& itUse . heldAim . aimWeight .~ 5
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzPos .~ 18
& itUse . heldAim . aimStance .~ TwoHandUnder
-- & itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0]
& itUse . heldConsumption
.~ ( defaultLoadable
& laSource . _InternalSource . iaMax .~ 250
+6 -11
View File
@@ -8,6 +8,7 @@ module Dodge.Item.Held.Stick (
revolverX,
) where
import Dodge.Base
import Dodge.Data.Item
import Dodge.Default.Item
import Dodge.Reloading.Action
@@ -22,12 +23,6 @@ bangStick i =
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels =
MultiBarrel
{ _brlNum = i
, _brlSpread = SpreadBarrels baseStickSpread
, _brlInaccuracy = 0.01
}
, _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0
@@ -38,8 +33,7 @@ bangStick i =
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 8
& itUse . heldMods .~ BangStickMod
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) a 0.01 | a <- spreadAroundCenter i baseStickSpread]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
@@ -66,11 +60,11 @@ pistol =
)
& itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05]
& itParams
%~ ( (muzVel .~ 0.8)
. (rifling .~ 0.8)
. (bore .~ 2)
. (gunBarrels .~ SingleBarrel 0.05)
. (recoil .~ 10)
. (torqueAfter .~ 0.2)
)
@@ -97,8 +91,9 @@ smg =
autoPistol -- & some parameter affecting stability
& itUse . heldMods .~ SmgMod --(ammoCheckI : smgAfterHamMods)
& itType . iyBase .~ HELD SMG
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 2
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0]
-- & itUse . heldAim . aimHandlePos .~ 2
& itParams . torqueAfter .~ 0.05
revolverX :: Int -> Item
+9 -8
View File
@@ -1,10 +1,11 @@
module Dodge.Item.Held.Utility where
import Linear
import Dodge.Default.Item
import Color
import Control.Lens
import Dodge.Data.Item
import Geometry.Data
--import Geometry.Data
flatShield :: Item
flatShield =
@@ -13,8 +14,7 @@ flatShield =
& itUse . heldAim . aimWeight .~ 5
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzPos .~ 0
-- & itUse . heldAim . aimHandlePos .~ 0
& itInvSize .~ 3
& itType . iyBase .~ HELD FLATSHIELD
@@ -34,8 +34,8 @@ binoculars =
defaultHeldItem
& itScope .~ ZoomScope (V2 0 0) 1 0.5 False
& itType . iyBase .~ HELD BINOCULARS
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
-- & itUse . heldAim . aimHandlePos .~ 5
-- & itUse . heldAim . aimMuzPos .~ 10
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5, _izFac = 1}
@@ -46,13 +46,14 @@ torch =
defaultHeldItem
& itEffect . ieInv .~ EffectWhileHeld CreateHeldLight
& itType . iyBase .~ HELD TORCH
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 10
forceFieldGun :: Item
forceFieldGun =
defaultWeapon
& itUse . useTargeting ?~ TargetRBLine
-- & itUse . useTargeting ?~ TargetRBLine
& itType . iyModules . at ModTarget ?~ TARGET TargetRBLine
& itParams .~ ParamMID Nothing
& itUse . heldUse .~ HeldForceField --useForceFieldGun
& itUse . heldDelay .~ NoDelay
+3 -3
View File
@@ -14,13 +14,13 @@ turretItemOffset it tu mc =
transToHandle :: Item -> Point3 -> Point3
transToHandle itm = fromMaybe id $ do
x <- itm ^? itUse . heldAim . aimHandlePos
return (-.-.- V3 x 0 0)
V2 x y <- itm ^? itUse . heldAim . aimHandlePos
return (-.-.- V3 x y 0)
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr
| isSelected && _posture (_crStance cr) == Aiming =
(+.+.+ V3 (aimingWeaponZeroPos cr itm) 0 shoulderHeight)
(+.+.+ aimingWeaponZeroPos cr itm `v2z` shoulderHeight)
| isSelected && isTwoHandFlat =
(+.+.+ V3 (_crRad cr) 0 handD)
. rotate3 (twoFlatHRot cr)
+2 -1
View File
@@ -231,7 +231,8 @@ heldPositionInfo = maybe undefined aimStanceInfo . (^? itUse . heldAim . aimStan
aimStanceInfo :: AimStance -> String
aimStanceInfo as = case as of
TwoHandTwist -> "It is held in two hands along its length."
TwoHandUnder -> "It is held in two hands and tucked under the shoulder."
TwoHandOver -> "It is held in two hands and over the shoulder."
TwoHandFlat -> "It is held in two hands at its sides."
OneHand -> "It is held in one hand."
+10 -16
View File
@@ -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
@@ -165,7 +159,7 @@ shootDualLaser it cr w =
itid = _itID it
dir = _crDir cr
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
aimlength = aimingMuzzlePos cr it
aimlength = aimingMuzzleLength cr it
gap = _dbGap . _itParams $ it
posl = pos +.+ (- gap) *.* vNormal (unitVectorAtAngle dir)
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
+1 -1
View File
@@ -15,7 +15,7 @@ droneLauncher =
& itUse . heldMods .~ AmmoUseCheckMod
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimStance .~ TwoHandOver
& itUse . heldConsumption . laAmmoType .~ DroneAmmo{_amString = "LASDRONE"}
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 2
& itType . iyBase .~ HELD DRONELAUNCHER
+1 -3
View File
@@ -59,11 +59,9 @@ import Shape
grenadePic :: Int -> SPic
grenadePic time =
( colorSH (dark $ dark green) $ upperPrismPolyHalf Small Typical 5 $ polyCirc 3 5
, pictures
[ color green $ arc (degToRad $ (179 * fromIntegral time / 50) - 180 )
, color green $ arc (degToRad $ (179 * fromIntegral time / 50) - 180 )
(degToRad $ 180 - (179 * fromIntegral time / 50) )
5
]
)
--grenadeDraw :: Float -> Prop -> SPic
+1 -1
View File
@@ -19,7 +19,7 @@ shootShatter it cr w =
Opaque {} -> True
SeeThrough -> True
_ -> False
sp = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
sp = _crPos cr +.+ aimingMuzzleLength cr it *.* unitVectorAtAngle dir
dir = _crDir cr
ep = sp +.+ 200 *.* unitVectorAtAngle dir
+69 -106
View File
@@ -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,
@@ -44,30 +43,26 @@ module Dodge.Item.Weapon.TriggerType (
withSidePushAfterI,
withSidePushI,
withWarmUp,
spreadNumI,
spreadLoaded,
repeatOnFrames,
sideEffectOnFrame,
duplicateItem,
duplicateLoadedBarrels,
duplicateNumBarrels,
duplicateLoaded,
duplicateOffsets,
duplicateOffsetsV2,
duplicateOffsetsFocus,
hammerCheckL,
shootL,
useTimeCheck,
ammoCheckI,
applyInaccuracy,
modClock,
blCheck,
) where
import qualified SDL
import Dodge.Creature.HandPos
import Data.Foldable
import Data.Maybe
import Dodge.Base
import Dodge.Creature.HandPos
import Dodge.Creature.Test
import Dodge.Data.World
import Dodge.Inventory.Lock
@@ -76,10 +71,11 @@ import Dodge.Reloading
import Dodge.SoundLogic
import Dodge.WorldEvent
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import RandomHelp
import qualified SDL
import Sound.Data
import qualified IntMapHelp as IM
type ChainEffect =
(Item -> Creature -> World -> World) ->
@@ -137,14 +133,16 @@ withThickSmokeI eff item cr w =
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
Just (InternalSource ia) | _iaLoaded ia <= 0 || not (_iaPrimed ia)
-> failsound w
Just AboveSource | fromMaybe True $ do
Just (InternalSource ia)
| _iaLoaded ia <= 0 || not (_iaPrimed ia) ->
failsound w
Just AboveSource
| fromMaybe True $ do
invid <- itm ^? itLocation . ipInvID
x <- cr ^? crInv . ix (invid - 1) . itUse . equipEffect . eeUse . euseAmmoAmount
return $ x <= 0
-> failsound w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
return $ x <= 0 ->
failsound w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
@@ -360,11 +358,12 @@ useAmmoAmount amAmount eff item cr =
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
useAmmoAmount' itref x inv = case inv ^? ix itref . itUse . heldConsumption . laSource of
Just InternalSource{}
-> inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just AboveSource
-> inv & ix (itref - 1) . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
Just InternalSource{} ->
inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just AboveSource ->
inv & ix (itref - 1) . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
_ -> inv
-- . crInv . ix itRef . itUse . heldConsumption . laSource
{- |
@@ -380,7 +379,6 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
blCheck :: ChainEffect
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
@@ -432,8 +430,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
@@ -456,48 +454,32 @@ modClock n chainEff eff it cr w
| otherwise = eff it cr w
withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) flashPos
. muzFlareAt (V4 5 5 0 2) flarePos cdir
$ f it cr w
withMuzFlareI f it cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. f it cr
where
flarePos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset cr it +.+.+ V3 0 0 20)
flashPos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset cr it +.+.+ V3 5 0 20)
-- muzzleOffset = V3 (_muzPos (_dimPortage (_itDimension it))) 0 0
cdir = _crDir cr
cpos = _crPos cr
muzzleOffset :: Creature -> Item -> Point3
muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0
--muzzleOffset :: Creature -> Item -> Point3
--muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0
-- where
-- dimPort = _heldAim $ _itUse it
-- holdOffset
-- | crInAimStance OneHand cr = 10
-- | otherwise = 0
withCrPos :: (Point3 -> World -> World) -> ChainEffect
withCrPos = withCrPosShift (V2 0 0)
withCrPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
withCrPosShift p g f it cr = g thepos . f it cr
where
dimPort = _heldAim $ _itUse it
holdOffset
| crInAimStance OneHand cr = 10
| otherwise = 0
withMuzPos :: (Point3 -> World -> World) -> ChainEffect
withMuzPos = withMuzPosShift (V2 0 0)
withMuzPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
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
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
applyInaccuracy f it = withRandomDirI acc f it
where
acc = _brlInaccuracy . _gunBarrels $ _itParams it
thepos = (_crPos cr +.+ rotateV (_crDir cr) p) `v2z` 20
-- | Applies the effect to a randomly rotated creature.
withRandomDirI ::
@@ -612,27 +594,6 @@ withTorqueAfter feff item cr w
(rot, g) = randomR (- torque, torque) $ _randGen w
torque = fromMaybe 0 $ item ^? itParams . torqueAfter
spreadNumI :: ChainEffect
spreadNumI eff item cr w = foldr f w dirs
where
dirs =
zipWith
(+)
[- spread, - spread + (2 * spread / fromIntegral numBul) .. spread]
(randomRs (0, spread / fromIntegral numBul) (_randGen w))
f dir = eff item (cr & crDir +~ dir)
spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
numBul = _brlNum . _gunBarrels $ _itParams item
spreadLoaded :: ChainEffect
spreadLoaded eff item cr w = foldr f w dirs
where
cd = 0.5 * spread * fromIntegral (numBulLoaded -1)
dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
f dir = eff item (cr & crDir +~ dir)
spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
numBulLoaded = item ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
sideEffectOnFrame ::
Int ->
(Item -> Creature -> WdWd) ->
@@ -668,16 +629,24 @@ 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 item cr w = foldr f w poss
duplicateNumBarrels :: Int -> ChainEffect
duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim . aimMuzzles)
where
cp :: Float
cp = -0.5 * (fromIntegral numBar - 1)
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0 . (* 5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
f pos = eff item (cr & crPos %~ (+.+ pos))
numBar = _brlNum . _gunBarrels $ _itParams item
numBul = item ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
f brl w' =
eff
itm
( cr & crPos +~ rotateV (_crDir cr) (_mzPos brl + aimingWeaponZeroPos cr itm)
& crDir +~ (_mzRot brl + a)
)
(w' & randGen .~ g)
where
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
@@ -689,13 +658,14 @@ duplicateOffsetsFocus xs eff item cr w = foldr f w poss
cr
& crPos %~ (+.+ pos)
& crDir .~ thedir pos
thedir pos
| dist (mouseWorldPos (w ^. input) (w ^. wCam)) (_crPos cr) < aimingMuzzlePos cr item =
argV
( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
-.- (_crPos cr +.+ pos)
)
| otherwise = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
--thedir pos
-- | dist (mouseWorldPos (w ^. input) (w ^. wCam)) (_crPos cr) < aimingMuzzlePos cr item =
-- argV
-- ( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
-- -.- (_crPos cr +.+ pos)
-- )
-- | otherwise = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
thedir pos = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
duplicateItem :: (Item -> [Item]) -> ChainEffect
duplicateItem fit eff itm cr w = foldr f w (fit itm)
@@ -707,10 +677,3 @@ duplicateOffsetsV2 xs eff item cr w = foldr f w poss
where
poss = map (rotateV (_crDir cr)) xs
f pos = eff item (cr & crPos +.+.~ pos)
duplicateOffsets :: [Float] -> ChainEffect
duplicateOffsets xs eff item cr w = foldr f w poss
where
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0) xs
f pos = eff item (cr & crPos +.+.~ pos)
+1 -3
View File
@@ -6,9 +6,7 @@ import Picture
drawLaser :: Laser -> Picture
drawLaser pt =
setLayer BloomNoZWrite $
pictures
[ setDepth 19.5 . color (brightX 10 1 col) $ thickLine 3 ps
]
setDepth 19.5 . color (brightX 10 1 col) $ thickLine 3 ps
where
col = _lzColor pt
ps = _lzPoints pt
+1 -1
View File
@@ -11,7 +11,7 @@ drawLinearShockwave :: LinearShockwave -> Picture
drawLinearShockwave lw =
setLayer BloomLayer $
setDepth 20 $
pictures $
fold $
theArc
++ [ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0, 0.05 ..]
, lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0, 0.05 ..]
+1 -1
View File
@@ -6,7 +6,7 @@ import Picture
drawTargetLaser :: Laser -> Picture
drawTargetLaser pt =
setLayer BloomNoZWrite $
pictures
fold
[ setDepth 19 . color (brightX 0 0.5 col) $ thickLine 5 (sp : ps)
, setDepth 19.5 . color (brightX 5 1 col) $ thickLine 1 (sp : ps)
]
+2 -2
View File
@@ -9,7 +9,7 @@ import Picture
wedgeOfThickness :: Float -> Point2 -> Point2 -> Picture
wedgeOfThickness t x y
| x == y = blank
| otherwise = pictures
| otherwise = fold
[uncurryV translate x $ circleSolid (0.5*t)
,polygon [x +.+ n x y, x -.- n x y, y]
]
@@ -17,7 +17,7 @@ wedgeOfThickness t x y
n a b = (t*0.5) *.* errorNormalizeV 4200 (vNormal (a -.- b))
verticalPipe :: Float -> Color -> Point2 -> Float -> Float -> Picture
verticalPipe w col (V2 xx xy) za zb = pictures $ map (poly3Col . f) ps
verticalPipe w col (V2 xx xy) za zb = foldMap (poly3Col . f) ps
where
x = V3 xx xy 0
xs = map ((\(V2 a b) -> x +.+.+ V3 a b za) . toV2) [(w,0),(0,w),(-w,0),(0,-w)]
+1 -1
View File
@@ -65,7 +65,7 @@ fixedSizePicClampArrow ::
World ->
Picture
fixedSizePicClampArrow xbord ybord pic p cfig w =
pictures
fold
[ setLayer DebugLayer . translate x y . scale theScale theScale $ pic
, setLayer DebugLayer . color white . setDepth 20 $ arrowPic
]
+5 -6
View File
@@ -5,16 +5,15 @@ import Geometry
import Picture
drawRadarSweep :: RadarSweep -> Picture
drawRadarSweep pt = setLayer DebugLayer $ pictures sweepPics
where
col = rsObjectColor $ _rsObject pt
p = _rsPos pt
r = _rsRad pt
sweepPics =
drawRadarSweep pt = setLayer DebugLayer $ fold
[ colHelper 0.1 $ uncurryV translate p $ thickCircle r 15
, colHelper 0.06 $ uncurryV translate p $ thickCircle (r -5) 5
, colHelper 0.03 $ uncurryV translate p $ thickCircle (r -10) 5
]
where
col = rsObjectColor $ _rsObject pt
p = _rsPos pt
r = _rsRad pt
colHelper y = color (withAlpha (y * globalAlpha) col)
globalAlpha
| x > 10 = 1
+1 -1
View File
@@ -13,7 +13,7 @@ import Picture
drawCarte :: Configuration -> World -> Picture
drawCarte cfig w =
pictures $
fold $
toTopLeft cfig (renderListAt 0 0 locs) :
mapOverlay w
++ [mainListCursor white iPos cfig]
+1 -1
View File
@@ -23,7 +23,7 @@ drawInputMenu ::
String ->
Picture
drawInputMenu cfig title footer =
pictures
fold
[ darkenBackground cfig
, drawTitle cfig title
, drawFooterText cfig red footer
+3 -3
View File
@@ -3,12 +3,12 @@ module Dodge.Render.Outline
import Picture
hackOutline :: Color -> Float -> Picture -> Picture
hackOutline col x pic = pictures
(map (color col)
hackOutline col x pic = foldMap
(color col)
[ translate x 0 pic
, translate (-x) 0 pic
, translate 0 x pic
, translate 0 (-x) pic
]
) <> pic
<> pic
+2 -2
View File
@@ -78,7 +78,7 @@ mouseCursorType u
- w ^. wCam . camRot
mousePlus :: Picture
mousePlus = pictures [line [V2 (-5) 0, V2 5 0], line [V2 0 (-5), V2 0 5]]
mousePlus = fold [line [V2 (-5) 0, V2 5 0], line [V2 0 (-5), V2 0 5]]
drawPlus :: Float -> Picture
drawPlus x = pictures [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
+18 -18
View File
@@ -80,7 +80,7 @@ drawCreature cr = case _crType cr of
Barreloid{} ->
picAtCrPos1
( setDepth 20 $
pictures
fold
[ color orange $ circleSolid 10
, setDepth 0.049 . color (greyN 0.5) $ circleSolid 8
, color (greyN 0.5) $ circleSolid 8
@@ -119,25 +119,25 @@ cullPoint cfig w p
extraPics :: Configuration -> Universe -> Picture
extraPics cfig u =
pictures (_decorations lw)
fold (_decorations lw)
<> setLayer FixedCoordLayer (fixedCoordPictures u)
<> concatMapPic drawTractorBeam (_tractorBeams lw)
<> concatMapPic drawLinearShockwave (_linearShockwaves lw)
<> concatMapPic drawShockwave (_shockwaves lw)
<> concatMapPic drawLaser (_lasersToDraw lw)
<> concatMapPic drawTeslaArc (_teslaArcs lw)
<> concatMapPic drawRadarSweep (_radarSweeps lw)
<> concatMapPic drawFlame (_flames lw)
<> concatMapPic drawEnergyBall (_energyBalls lw)
<> concatMapPic drawSpark (_sparks lw)
<> concatMapPic drawBul (_bullets lw)
<> concatMapPic drawBlip (_radarBlips lw)
<> concatMapPic drawFlare (_flares lw)
<> concatMapPic (dbArg (drawBeam . _bmDraw)) (_positronBeams $ _beams lw)
<> concatMapPic (dbArg (drawBeam . _bmDraw)) (_electronBeams $ _beams lw)
<> concatMapPic (dbArg (drawLightSource . _lsPict)) (_lightSources lw)
<> foldMap drawTractorBeam (_tractorBeams lw)
<> foldMap drawLinearShockwave (_linearShockwaves lw)
<> foldMap drawShockwave (_shockwaves lw)
<> foldMap drawLaser (_lasersToDraw lw)
<> foldMap drawTeslaArc (_teslaArcs lw)
<> foldMap drawRadarSweep (_radarSweeps lw)
<> foldMap drawFlame (_flames lw)
<> foldMap drawEnergyBall (_energyBalls lw)
<> foldMap drawSpark (_sparks lw)
<> foldMap drawBul (_bullets lw)
<> foldMap drawBlip (_radarBlips lw)
<> foldMap drawFlare (_flares lw)
<> foldMap (dbArg (drawBeam . _bmDraw)) (_positronBeams $ _beams lw)
<> foldMap (dbArg (drawBeam . _bmDraw)) (_electronBeams $ _beams lw)
<> foldMap (dbArg (drawLightSource . _lsPict)) (_lightSources lw)
<> testPic cfig w
<> concatMapPic ppDraw (_pressPlates lw)
<> foldMap ppDraw (_pressPlates lw)
<> viewClipBounds cfig w
<> debugDraw cfig w
<> foldMap (`_debugPic` u) (_uvDebug u)
+1 -1
View File
@@ -42,7 +42,7 @@ highDiagonalMesh ::
Picture
highDiagonalMesh pa pb w d =
setDepth 100 $
pictures $
fold $
map (thickLine 2 . tflat2) (diagonalLinesRect pb pa w d (3 * pi / 4))
++ map (thickLine 2 . tflat2) (diagonalLinesRect pb pc (negate h) d (pi / 4))
where
+1 -1
View File
@@ -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
+2 -2
View File
@@ -47,7 +47,7 @@ targetDraw f cr _ _ = fromMaybe mempty $ do
activeTargetCursorPic :: Picture
activeTargetCursorPic =
pictures
fold
[rotate a $ line [V2 15 0, V2 10 0] <> targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
transMidLine :: Point2 -> Point2 -> Picture -> Picture
@@ -73,4 +73,4 @@ targCorner = line [V2 (x - y) x, V2 x x, V2 x (x - y)]
y = 5
targetCursorPic :: Picture
targetCursorPic = pictures [rotate a targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
targetCursorPic = fold [rotate a targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
+1 -1
View File
@@ -7,7 +7,7 @@ import Picture
drawTeslaArc :: TeslaArc -> Picture
drawTeslaArc pt =
setLayer BloomNoZWrite $
pictures
fold
[ setDepth 20.5 $ color (brightX 2 1 $ _taColor pt) $ thickLine 3 ps
, setDepth 20 $ color (V4 0 0 0 0.5) $ thickLine 10 ps
]
+8 -1
View File
@@ -1,6 +1,7 @@
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.TestString where
import Dodge.Item.Display
import AesonHelp
import Dodge.SmoothScroll
import HelpNum
@@ -18,7 +19,13 @@ import Dodge.Data.Universe
--import qualified Data.Map.Strict as M
--import qualified IntMapHelp as IM
testStringInit :: Universe -> [String]
testStringInit _ = mempty
testStringInit u = [fromMaybe "" $ do
cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
i <- cr ^? crManipulation . manObject . inInventory . ispItem
fmap (show . canAttachTargetingBelow) (cr ^? crInv . ix i)
]
-- getPrettyShort (u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crHotkeys)
-- <> ["---"]
-- <> getPrettyShort ( u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInvHotkeys)
+2 -1
View File
@@ -2,6 +2,7 @@ module Dodge.Update.Input.ScreenLayer (
updateUseInputOnScreen,
) where
import Data.Char
import Control.Monad
import qualified Data.Map.Strict as M
import Data.Maybe
@@ -30,7 +31,7 @@ doInputScreenInput s u =
checkEndStatus
| ispressed ScancodeReturn =
(uvScreenLayers %~ tail)
. applyTerminalString (words s)
. applyTerminalString (words $ map toUpper s)
. (uvWorld . worldEventFlags . at InventoryChange ?~ ())
| ispressed ScancodeEscape = uvScreenLayers %~ tail
| otherwise = id
+6 -4
View File
@@ -16,16 +16,17 @@ module Dodge.WorldEvent.Flash (
import Dodge.Data.World
import Dodge.LightSource
--import Dodge.Default
import Control.Monad
import Geometry
import LensHelp
import Picture
import System.Random
import Control.Monad.Trans.State.Strict
muzFlareAt :: Color -> Point3 -> Float -> World -> World
muzFlareAt col tranv dir w =
w & cWorld . lWorld . flares
w & randGen .~ g
& cWorld . lWorld . flares
.:~ MuzFlare
{ _flarePoly =
map
@@ -39,7 +40,8 @@ muzFlareAt col tranv dir w =
, _flareTime = 2
}
where
(a : b : c : d : _) = randomRs (2, 20) (_randGen w)
thestate = replicateM 4 $ state $ randomR (2,20)
((a : b : c : d : _), g) = runState thestate $ _randGen w -- randomRs (2, 20) (_randGen w)
flareCircleAt :: Color -> Float -> Point3 -> World -> World
flareCircleAt col alphax tranv =
+4 -18
View File
@@ -33,9 +33,6 @@ module Picture.Base (
drawText,
centerText,
stackText,
pictures,
concatMapPic,
appendPic,
tranRot,
translate,
translate3,
@@ -50,6 +47,7 @@ module Picture.Base (
mirrorxz,
overPos,
picMap,
fold,
) where
import Color
@@ -156,18 +154,6 @@ rotate :: Float -> Picture -> Picture
{-# INLINE rotate #-}
rotate = picMap . overPos . rotate3
concatMapPic :: Foldable t => (a -> Picture) -> t a -> Picture
{-# INLINE concatMapPic #-}
concatMapPic = foldMap
appendPic :: Picture -> Picture -> Picture
{-# INLINE appendPic #-}
appendPic = (<>)
pictures :: Foldable t => t Picture -> Picture
{-# INLINEABLE pictures #-}
pictures = fold
makeArc :: Float -> Point2 -> [Point2]
{-# INLINE makeArc #-}
makeArc rad (V2 a b) = map (`rotateV` V2 0 rad) angles
@@ -246,7 +232,7 @@ lineCol = thickLineCol 1
lineThick :: Float -> [Point2] -> Picture
{-# INLINE lineThick #-}
lineThick t = pictures . f
lineThick t = fold . f
where
f (x : y : ys)
| x == y = f (x : ys)
@@ -256,7 +242,7 @@ lineThick t = pictures . f
thickLine :: Float -> [Point2] -> Picture
{-# INLINE thickLine #-}
thickLine t = pictures . f
thickLine t = fold . f
where
f (x : y : ys)
| x == y = f (x : ys)
@@ -267,7 +253,7 @@ thickLine t = pictures . f
thickLineCol :: Float -> [(Point2, RGBA)] -> Picture
{-# INLINE thickLineCol #-}
thickLineCol t = pictures . f
thickLineCol t = fold . f
where
f ((x, c) : (y, c') : ys)
| x == y = f ((x, c) : ys)
+1 -1
View File
@@ -127,7 +127,7 @@ helpPoly3D = picFormat . map f . polyToTris
f (pos,col) = Verx pos col [] BottomLayer polyNum
polysToPic :: [Polyhedra] -> Picture
polysToPic = pictures . concatMap polyToPics
polysToPic = fold . concatMap polyToPics
polyToEdges :: Polyhedra -> [(Point3,Point3,Point3,Point3)]
polyToEdges = map denormalEdges . constructEdges . map (map fst) . _pyFaces
+3 -4
View File
@@ -35,7 +35,6 @@ module Shape (
overPosSH,
upperCylinder,
upperRounded,
xCylinder',
) where
import Color
@@ -130,10 +129,10 @@ upperPrismPoly ::
upperPrismPoly size shad h ps = prismPoly size shad (map (addZ h) ps) (map (addZ 0) ps)
xCylinderST :: Float -> Float -> Shape
xCylinderST = xCylinder' Small Typical
xCylinderST = xCylinder Small Typical
xCylinder' :: Size -> Importance -> Float -> Float -> Shape
xCylinder' size shad r x =
xCylinder :: Size -> Importance -> Float -> Float -> Shape
xCylinder size shad r x =
translateSHz r . rotateSHq (V3 0 1 0) (pi / 2) . upperCylinder size shad x $
[ V2 r r
, V2 (- r / 2) (r / 2)