This commit is contained in:
2022-02-21 22:42:19 +00:00
parent f626fce105
commit ff84363a13
11 changed files with 79 additions and 99 deletions
+5 -1
View File
@@ -112,7 +112,7 @@ moduleCombinations =
]
)
, ( ModBulletTarget
, bulletWeapons
, launcher : bulletWeapons
, [amod [TELEPORTMODULE,MICROCHIP] "+TELEPORT" (itUse . useMods .:~ withPositionWallCheck (const . const mouseWorldPos))
,amod [TELEPORTMODULE] "+DIRECTEDTELE" makeDirectedTele
]
@@ -121,7 +121,11 @@ moduleCombinations =
where
makeDirectedTele it = it & itEffect .~ rbSetTarget
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
& itUse . useAim . aimRange .~ 0
-- a better option would be to involve a "scope" centered on the firing
-- position
directedTelPos it cr w = (p,a)
where
p = fromMaybe (_crPos cr) $ do
+2 -2
View File
@@ -58,8 +58,8 @@ wasdWithAiming w speed i cr
isAiming = _posture (_crStance cr) == Aiming
isReloading = _posture (_crStance cr) == Reloading
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
. itAttachment of
Just ItScope{_scopePos = p} -> normalizeAngle $ argV
. itScope . scopePos of
Just p -> normalizeAngle $ argV
$ p +.+ 2 / _cameraZoom w
*.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
+21 -22
View File
@@ -356,28 +356,27 @@ data ItemConsumption
{ _itAmount :: Int
}
| NoConsumption
data Item
= Item
{ _itName :: String
, _itConsumption :: ItemConsumption
, _itUse :: ItemUse
, _itEquipPict :: Creature -> Int -> SPic
, _itScroll :: Float -> Creature -> Item -> Item
, _itType :: CombineType
, _itAttachment :: ItAttachment
, _itID :: Maybe Int
, _itEffect :: ItEffect
, _itInvSize :: Float
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
, _itDimension :: ItemDimension
, _itCurseStatus :: CurseStatus
, _itParams :: ItemParams
, _itTweaks :: ItemTweaks
, _itModules :: M.Map ModuleSlot ItemModule
}
data Item = Item
{ _itName :: String
, _itConsumption :: ItemConsumption
, _itUse :: ItemUse
, _itEquipPict :: Creature -> Int -> SPic
, _itScroll :: Float -> Creature -> Item -> Item
, _itType :: CombineType
, _itAttachment :: ItAttachment
, _itID :: Maybe Int
, _itEffect :: ItEffect
, _itInvSize :: Float
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
, _itDimension :: ItemDimension
, _itCurseStatus :: CurseStatus
, _itParams :: ItemParams
, _itTweaks :: ItemTweaks
, _itModules :: M.Map ModuleSlot ItemModule
, _itScope :: Scope
}
data ModuleSlot
= ModBullet
| ModRifleMag
+2
View File
@@ -156,6 +156,7 @@ defaultEquipment = Item
, _itTweaks = NoTweaks
, _itTargeting = Nothing
, _itModules = M.empty
, _itScope = NoScope
}
defaultItZoom :: ItZoom
defaultItZoom = ItZoom 20 0.2 1
@@ -180,6 +181,7 @@ defaultConsumable = Item
, _itDimension = defItDimCol blue
, _itTweaks = NoTweaks
, _itModules = M.empty
, _itScope = NoScope
}
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
+2 -2
View File
@@ -103,16 +103,15 @@ defaultGun = Item
, _itModules = M.fromList [(ModBullet , DefaultModule)
,(ModBulletTarget,DefaultModule)
]
, _itScope = NoScope
}
defaultCraftable :: Item
defaultCraftable = Item
{ _itName = "default"
, _itType = NoCombineType
, _itCurseStatus = Uncursed
-- , _itIdentity = Generic
, _itConsumption = NoConsumption
, _itUse = NoUse
-- , _itZoom = ItZoom 20 0.2 1
, _itEquipPict = pictureWeaponOnAim
, _itScroll = \_ _ -> id
, _itAttachment = NoItAttachment
@@ -126,6 +125,7 @@ defaultCraftable = Item
, _itDimension = defItDimCol green
, _itTweaks = NoTweaks
, _itModules = M.empty
, _itScope = NoScope
}
defItDim :: ItemDimension
defItDim = ItemDimension
+15 -7
View File
@@ -8,13 +8,7 @@ import Control.Lens
import qualified Data.Sequence as Seq
data ItAttachment
= ItScope
{_scopePos :: Point2 -- ^ a camera offset
,_scopeZoomChange :: Int
,_scopeZoom :: Float
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
}
| ItFuse {_itFuseTime :: Int}
= ItFuse {_itFuseTime :: Int}
| ItMode {_itMode :: Int}
| ItCharMode {_itCharMode :: Seq.Seq Char }
| ItTargetPos { _itTargetPos :: Point2 }
@@ -24,4 +18,18 @@ data ItAttachment
| ItBool { _itBool :: Bool }
| NoItAttachment
data Scope = NoScope
| RemoteScope
{_scopePos :: Point2 -- ^ a camera offset
,_scopeZoom :: Float
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
}
| ZoomScope
{_scopePos :: Point2 -- ^ a camera offset
,_scopeZoomChange :: Int
,_scopeZoom :: Float
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
}
makeLenses ''ItAttachment
makeLenses ''Scope
+5 -11
View File
@@ -429,7 +429,7 @@ multGun = defaultGun
, _itTweaks = defaultBulletSelTweak
}
longGun :: Item
longGun = defaultGun
longGun = defaultGun
{ _itName = "LONGGUN"
, _itType = LONGGUN
, _itConsumption = defaultAmmo
@@ -453,23 +453,17 @@ longGun = defaultGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
-- , _itFloorPict = longGunSPic
-- , _itZoom = defaultItZoom
, _itScroll = zoomLongGun
, _itAttachment = ItScope (V2 0 0) 0 1 False
, _itAttachment = NoItAttachment
, _itScope = ZoomScope (V2 0 0) 0 1 False
, _itEffect = itemLaserScopeEffect
}
zoomLongGun :: Float -> Creature -> Item -> Item
zoomLongGun x _
| x > 0 = startZoomInLongGun
| x < 0 = startZoomOutLongGun
| x > 0 = itScope . scopeZoomChange %~ (max 5 . (+5))
| x < 0 = itScope . scopeZoomChange %~ (min (-5) . subtract 5)
| otherwise = id
startZoomInLongGun :: Item -> Item
startZoomInLongGun = itAttachment . scopeZoomChange %~ \x -> max 5 (x + 5)
startZoomOutLongGun :: Item -> Item
startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5)
autogunSpread :: Float
autogunSpread = 0.07
-26
View File
@@ -27,32 +27,6 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.Set as S
import qualified SDL
{- |
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
--wpRecock :: ItEffect
--wpRecock = ItInvEffect
-- {_itInvEffect = f
-- ,_itEffectCounter = 0
-- }
-- where
-- f _ cr invid = creatures . ix (_crID cr) . crInv . ix invid
-- . itUse . useHammer . hammerPosition %~ moveHammerUp
-- moveHammerUp HammerDown = HammerReleased
-- moveHammerUp HammerReleased = HammerUp
-- moveHammerUp HammerUp = HammerUp
--{- |
--Special recock for the bezier gun.
--Not sure of its purpose at this time... -}
--bezierRecock :: ItEffect
--bezierRecock = ItInvEffect
-- {_itInvEffect = f
-- ,_itEffectCounter = 0
-- }
-- where
-- f _ cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust fOnIt i
-- fOnIt it = case _itHammer it of
-- HammerDown -> it & itHammer .~ HammerUp
-- _ -> it & itAttachment .~ NoItAttachment
{- |
Creates a laser scope and recocks the weapon.
TODO add the laser scope!
-}
+3 -3
View File
@@ -202,7 +202,7 @@ moveRemoteBomb itid time pID w
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itAttachment
-> w' & creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid))
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
@@ -293,7 +293,7 @@ remoteBombUnarmedPic = color (dark $ dark orange) $ circleSolid 5
retireRemoteBomb :: Int -> Int -> Int -> World -> World
retireRemoteBomb itid 0 pjid w = w
& pointToItem (_itemPositions w IM.! itid) %~
( (itAttachment . scopePos .~ V2 0 0)
( (itScope . scopePos .~ V2 0 0)
-- . (itZoom .~ defaultItZoom)
. (itUse . rUse .~ const throwRemoteBomb)
)
@@ -303,7 +303,7 @@ retireRemoteBomb itid t pjid w = setScope w
where
setScope w' = case _itemPositions w' IM.! itid of
InInv cid invid -> w'
& creatures . ix cid . crInv . ix invid . itAttachment
& creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
_ -> w'
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
+4 -4
View File
@@ -282,7 +282,7 @@ remoteLauncher = launcher
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _itAttachment = ItScope (V2 0 0) 0 1 True
, _itScope = RemoteScope (V2 0 0) 1 True
-- , _itParams = ShellLauncher
-- { _tweakSel = 0
-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed
@@ -409,7 +409,7 @@ remoteShellPic t
| otherwise = red
retireRemoteRocket :: Int -> Int -> Int -> World -> World
retireRemoteRocket itid 0 pjid w =
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . scopePos) (V2 0 0)
set (pointToItem (_itemPositions w IM.! itid) . itScope . scopePos) (V2 0 0)
$ set (pointToItem (_itemPositions w IM.! itid) . itUse . rUse) (const fireRemoteLauncher)
(w & props %~ IM.delete pjid)
retireRemoteRocket itid t pjid w = setScope w
@@ -417,7 +417,7 @@ retireRemoteRocket itid t pjid w = setScope w
where
setScope w' = case _itemPositions w' IM.! itid of
InInv cid invid -> w'
& creatures . ix cid . crInv . ix invid . itAttachment
& creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
_ -> w'
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
@@ -425,6 +425,6 @@ retireRemoteRocket itid t pjid w = setScope w
setRemoteScope :: Int -> Prop -> World -> World
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
Just (InInv cid' invid )
-> w' & creatures . ix cid' . crInv . ix invid . itAttachment
-> w' & creatures . ix cid' . crInv . ix invid . itScope
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid'))
_ -> w'
+20 -21
View File
@@ -32,7 +32,7 @@ updateCamera cfig = rotateCamera cfig . autoZoomCamera cfig . moveCamera . updat
{- Updte the center of the screen camera center and where your avatar's view is from in world. -}
moveCamera :: World -> World
moveCamera w = w
& cameraCenter .~ idealPos
& cameraCenter .~ idealPos
& cameraViewFrom .~ sightFrom
where
aimRangeFactor
@@ -45,17 +45,16 @@ moveCamera w = w
idealPos = camCenter
+.+ rotateV (_cameraRot w) (aimRangeFactor * aimingMult *.* _mousePos w)
camCenter = ypos +.+ scopeOffset
scopeOffset = fromMaybe (V2 0 0) $ yourItem w ^? _Just . itAttachment . scopePos
sightFrom
| fromMaybe False $ yourItem w ^? _Just . itAttachment . scopeIsCamera
= camCenter
| otherwise = ypos
scopeOffset = fromMaybe (V2 0 0) $ yourItem w ^? _Just . itScope . scopePos
sightFrom = case yourItem w ^? _Just . itScope . scopeIsCamera of
Just True -> camCenter
_ -> ypos
updateScopeZoom :: World -> World
updateScopeZoom w
| SDL.ButtonRight `S.member` _mouseButtons w
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment . scopeZoomChange of
. itScope . scopeZoomChange of
Just x
| x > 9 -> zoomInLongGun $ zoomInLongGun w
| x > 0 -> zoomInLongGun w
@@ -64,9 +63,9 @@ updateScopeZoom w
| otherwise -> w
_ -> w
| otherwise = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment %~ updateScope
. itScope %~ updateScope
where
updateScope (ItScope _ _ _ bl) = ItScope (V2 0 0) 0 1 bl
updateScope (ZoomScope _ _ _ bl) = ZoomScope (V2 0 0) 0 1 bl
updateScope otherAtt = otherAtt
zoomSpeed :: Float
@@ -74,38 +73,39 @@ zoomSpeed = 39/40
-- TODO unify zoom in and out, use scroll speed
zoomInLongGun :: World -> World
zoomInLongGun w
| currentZoom < 8 = over (wpPointer . itAttachment . scopePos)
| currentZoom < 8 = over (wpPointer . itScope . scopePos)
(\p -> p +.+ (4-(4*zoomSpeed)) / currentZoom *.* mousep)
$ over (wpPointer . itAttachment . scopeZoom) (/ zoomSpeed)
$ over (wpPointer . itScope . scopeZoom) (/ zoomSpeed)
$ decreaseScopeZoomChange
w
| otherwise = decreaseScopeZoomChange w
where
decreaseScopeZoomChange = wpPointer . itAttachment . scopeZoomChange -~ 1
decreaseScopeZoomChange = wpPointer . itScope . scopeZoomChange -~ 1
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
Just currentZoom = wp ^? itAttachment . scopeZoom
Just currentZoom = wp ^? itScope . scopeZoom
mousep = rotateV (_cameraRot w) $ _mousePos w
zoomOutLongGun :: World -> World
zoomOutLongGun w
| currentZoom > 0.5 = over (wpPointer . itAttachment . scopeZoom) (* zoomSpeed)
| currentZoom > 0.5 = over (wpPointer . itScope . scopeZoom) (* zoomSpeed)
$ increaseScopeZoomChange w
| otherwise = increaseScopeZoomChange w
where
increaseScopeZoomChange = wpPointer . itAttachment . scopeZoomChange +~ 1
increaseScopeZoomChange = wpPointer . itScope . scopeZoomChange +~ 1
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
Just currentZoom = wp ^? itAttachment . scopeZoom
Just currentZoom = wp ^? itScope . scopeZoom
ifConfigWallRotate :: Configuration -> World -> World
ifConfigWallRotate cfig w
| _rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
= rotateToOverlappingWall w
= rotateToOverlappingWall w
| otherwise = w
rotateToOverlappingWall :: World -> World
rotateToOverlappingWall w = maybe w dowallrotate theWall
rotateToOverlappingWall w = maybe w dowallrotate
$ overlapCircWallsReturnWall p (_crRad cr + 5) (IM.filter _wlRotateTo $ wallsNearPoint p w)
where
dowallrotate wl' = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl') - _cameraRot w
rotateUsing a
@@ -118,14 +118,13 @@ rotateToOverlappingWall w = maybe w dowallrotate theWall
b' = fromIntegral (round b :: Int)
cr = you w
p = _crPos cr
theWall = overlapCircWallsReturnWall p (_crRad cr + 5) (IM.filter _wlRotateTo $ wallsNearPoint p w)
rotateCameraBy :: Float -> World -> World
rotateCameraBy x w = w
& cameraRot +~ x
& creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment . scopePos %~ rotateV x
. itScope . scopePos %~ rotateV x
rotateCamera :: Configuration -> World -> World
rotateCamera cfig w
@@ -168,7 +167,7 @@ autoZoomCamera cfig w = w & cameraZoom %~ changeZoom
-- these speeds are inverted, larger means slower
zoomInSpeed = 25
zoomOutSpeed = 15
theScopeZoom = fromMaybe 1 $ yourItem w ^? _Just . itAttachment . scopeZoom
theScopeZoom = fromMaybe 1 $ yourItem w ^? _Just . itScope . scopeZoom
farWallDist :: Point2 -> Configuration -> World -> Float
farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps