Tweak walk cycle parameters

This commit is contained in:
jgk
2021-06-09 00:01:56 +02:00
parent fb7a90df71
commit 3371e2ae79
16 changed files with 112 additions and 81 deletions
+2 -1
View File
@@ -158,7 +158,8 @@ startCr = defaultCreature
startInventory :: IM.IntMap Item
startInventory = IM.fromList (zip [0..20]
(
[autoGun
[longGun
,autoGun
,hvAutoGun
,pistol
,teslaGun
+3 -2
View File
@@ -24,7 +24,7 @@ yourControl w (f,g) cr =
, Just . mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed 0 cr
)
where
speed = 3
speed = 4
{- | Turn key presses into creature movement. -}
wasdWithAiming
:: World
@@ -35,12 +35,13 @@ wasdWithAiming
wasdWithAiming w speed i cr
| isAiming = set crDir mouseDir $ crMvBy (speed *.* mov) cr
| isMoving = crMvAbsolute (speed *.* movAbs) $ turnAction cr
-- | isMoving = crMvAbsolute (speed *.* movAbs) cr
-- | isMoving = crMvForward speed $ over crDir (`fromMaybe` dir) cr
| otherwise = cr
where
(mov',dir') = wasdComp (view keys w) w
dir = fmap (_cameraRot w +) dir'
turnAction cr' = maybe cr (\d -> creatureTurnTowardDir d 0.2 cr') dir
turnAction cr' = maybe cr' (\d -> creatureTurnTowardDir d 0.2 cr') dir
movAbs = rotateV (_cameraRot w) mov'
mov = rotateV (negate $ _crDir cr - _cameraRot w) mov'
isAiming = _posture (_crStance cr) == Aiming
+1 -2
View File
@@ -222,8 +222,7 @@ data Item
, _itAimingRange :: Float
, _itZoom :: ItZoom
, _itEquipPict :: Creature -> Int -> Picture
, _itScrollUp :: Int -> World -> World
, _itScrollDown :: Int -> World -> World
, _itScroll :: Float -> Creature -> World -> World
, _itIdentity :: ItemIdentity
, _itAttachment :: Maybe ItAttachment
, _itID :: Maybe Int
+1 -1
View File
@@ -112,7 +112,7 @@ defaultCreature = Creature
, _crStance = Stance
{_carriage=Walking 0 WasLeftForward
,_posture=AtEase
,_strideLength = 20
,_strideLength = 40
}
, _crActionPlan = ActionPlan [] [] WatchAndWait [LiveLongAndProsper]
, _crMeleeCooldown = Nothing
+2 -7
View File
@@ -29,8 +29,7 @@ defaultGun = Weapon
, _itAimingRange = 0
, _itZoom = ItZoom 20 0.2 1 20 0.2 1
, _itEquipPict = \_ _ -> blank
, _itScrollUp = const id
, _itScrollDown = const id
, _itScroll = \_ _ -> id
, _itAttachment = Nothing
, _itID = Nothing
, _itEffect = wpRecock
@@ -40,15 +39,11 @@ defaultGun = Weapon
, _itWorldTrigger = Nothing
, _itAimStance = OneHand
}
defaultAutoGun :: Item
defaultAutoGun = defaultGun
{ _itScrollUp = const id
, _itScrollDown = const id
, _itInvDisplay = basicWeaponDisplay
{ _itInvDisplay = basicWeaponDisplay
, _itAimStance = TwoHandTwist
}
defaultShellAmmo :: Ammo
defaultShellAmmo = ShellAmmo
{ _amPayload = \_ -> id
+4 -3
View File
@@ -91,13 +91,14 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
| rbDown -> w & carteZoom %~ min 0.75 . max 0.05 . ((1+y*0.1) * )
| otherwise -> w & selLocation %~ (`mod` numLocs) . (+ yi)
(_, TopInventory)
| rbDown -> fromMaybe (closeObjScrollDir y w) $ (yourItem w ^? itScrollUp)
<*> pure (_crInvSel (you w))
| rbDown -> fromMaybe (closeObjScrollDir y w) $ (yourItem w ^? itScroll)
<*> pure y
<*> pure (you w)
<*> pure w
| lbDown -> w & cameraZoom +~ y
| invKeyDown -> swapInvDir yi $ dirInvPos yi w
| otherwise -> dirInvPos yi w
(_, TweakInventory)
(_, TweakInventory)
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
| invKeyDown -> dirInvPos yi w
| rbDown -> w & moveYourAmmoParam yi
+10
View File
@@ -20,6 +20,16 @@ decCharMode' = itCharMode %~ cycleR
cycleR (xs :|> x) = x <| xs
cycleR xs = xs
scrollCharMode
:: Float -- ^ Amount scrolled
-> Creature
-> World
-> World
scrollCharMode x cr
| x > 0 = incCharMode (_crInvSel cr)
| x < 0 = decCharMode (_crInvSel cr)
| otherwise = id
incCharMode
:: Int -- ^ Inventory selection
-> World
+3 -5
View File
@@ -15,11 +15,9 @@ pictureWeaponOnAim
-> Int -- ^ Position of item in inventory
-> Picture
pictureWeaponOnAim p cr posInInv
| isSelected && _posture (_crStance cr) == Aiming
&& isTwisting
| isSelected && _posture (_crStance cr) == Aiming && isTwisting
= onLayer PtLayer twistWep
| isSelected && _posture (_crStance cr) == Aiming
&& isOneHand
| isSelected && _posture (_crStance cr) == Aiming && isOneHand
= onLayer PtLayer oneHandWep
| isSelected && _posture (_crStance cr) == Aiming
= onLayer PtLayer drawnWep
@@ -34,7 +32,7 @@ pictureWeaponOnAim p cr posInInv
twistWep = uncurry translate (0.5 * _crRad cr,0) p
--twistWep = uncurry translate (0.5 * _crRad cr,negate 0.5 * _crRad cr) p
oneHandWep = uncurry translate (1.5 * _crRad cr,0) p
holsteredWep = uncurry translate (_crRad cr,0) (rotate (sRot + 1) p)
holsteredWep = uncurry translate (_crRad cr ,0) (rotate (sRot + 1.2) p)
holsteredOneHandWep = uncurry translate (_crRad cr * 0.7 + handPos,_crRad cr * negate 0.7) p
handPos = case cr^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50
+53 -40
View File
@@ -66,15 +66,13 @@ pistol = defaultGun
, _wpSpread = 0.02
, _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer $ color green $ polygon $ rectNESW 3 3 (-3) (-3)
, _itFloorPict = onLayer FlItLayer pistolPic
, _itAmount = 1
, _itMaxStack = 1
, _itAimingSpeed = 1
, _itAimingRange = 0
, _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim $ color green $ polygon $ rectNESW 3 3 (-3) (-3)
, _itScrollUp = const id
, _itScrollDown = const id
, _itEquipPict = pictureWeaponOnAim pistolPic
, _itAttachment = Nothing
, _itID = Nothing
, _itEffect = wpRecock
@@ -82,8 +80,10 @@ pistol = defaultGun
, _itInvColor = white
, _itTargeting = Nothing
, _itWorldTrigger = Nothing
, _wpAmmo = basicBullet
, _wpAmmo = basicBullet
}
pistolPic :: Picture
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
@@ -135,18 +135,21 @@ teslaGun = defaultGun
, _itUse = \_ -> shoot aTeslaArc
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color blue $ pictures
[polygon $ rectNESW 7 3 1 (-3)
,polygon $ rectNESW (-1) 3 (-7) (-3)
]
, _itFloorPict = onLayer FlItLayer teslaGunPic
, _itAimingSpeed = 0.4
, _itZoom = defaultItZoom
, _itAimingRange = 0
, _itEquipPict = pictureWeaponOnAim $ color blue $ pictures
[polygon $ rectNESW 7 3 1 (-3)
,polygon $ rectNESW (-1) 3 (-7) (-3)
]
, _itEquipPict = pictureWeaponOnAim teslaGunPic
}
teslaGunPic :: Picture
teslaGunPic = color blue $ pictures
[polygon $ rectNESW xb y xa (-y)
,polygon $ rectNESW (-xa) y (-xb) (-y)
]
where
xa = 1
xb = 9
y = 4
lasGun :: Item
lasGun = defaultAutoGun
{ _itName = "LASGUN ////"
@@ -165,8 +168,7 @@ lasGun = defaultAutoGun
, _itAimingRange = 1
, _itEquipPict = pictureWeaponOnAim lasGunPic
, _itAttachment = Just $ ItCharMode $ Seq.fromList "/VZ"
, _itScrollUp = incCharMode
, _itScrollDown = decCharMode
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
}
lasGunPic :: Picture
@@ -264,22 +266,19 @@ hvAutoGun = defaultAutoGun
, _itUse = \it -> rateIncAB 24 10 (torqueBeforeForced 0.1 (mkHvBul it))
(torqueAfter 0.2 (mkHvBul it))
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color orange $ polygon $ rectNESW 5 5 (-5) (-5)
, _itFloorPict = onLayer FlItLayer hvAutoGunPic
, _itAimingSpeed = 0.2
, _itAimingRange = 1
, _itEquipPict = pictureWeaponOnAim $ color orange $ polygon $ rectNESW 5 5 (-5) (-5)
, _wpAmmo = BulletAmmo
{_amString = "HVBULLET"
, _amBulEff = penWalls hvBulHitCr' hvBulHitWall' bulHitFF'
, _amBulWth = 6
, _amBulVel = (80,0)
}
, _itEquipPict = pictureWeaponOnAim hvAutoGunPic
, _wpAmmo = hvBullet
}
where
mkHvBul it = withSound (fromIntegral longGunSound)
. withThinSmoke
. withMuzFlare
$ useAmmoParams it
hvAutoGunPic :: Picture
hvAutoGunPic = color orange $ polygon $ rectNESW 5 12 (-5) (-12)
ltAutoGun :: Item
ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
@@ -288,22 +287,24 @@ ltAutoGun = defaultAutoGun
, _wpLoadedAmmo = 25
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 4
, _itUseRate = 3
, _itUseTime = 0
, _itUse = \_ -> shootWithSound 0 . withRandomDir 0.3 . withSidePush 50
. withMuzFlare $ withVelWthHiteff (30,0) 2 basicBulletEffect
, _wpSpread = 0.5
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color green $ pictures [polygon $ rectNSWE 4 (-4) (-4) 0
,circleSolid 4
]
, _itFloorPict = onLayer FlItLayer ltAutoGunPic
, _itAimingSpeed = 1
, _itAimingRange = 0
, _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim $ color green $ pictures [polygon $ rectNSWE 4 (-4) (-4) 0
,circleSolid 4
]
, _itEquipPict = pictureWeaponOnAim ltAutoGunPic
, _itAimStance = OneHand
}
ltAutoGunPic :: Picture
ltAutoGunPic = color green $ pictures
[polygon $ rectNSWE 5 (-5) (-5) 0
,circleSolid 5
]
miniGun :: Item
miniGun = defaultAutoGun
{ _itName = "MINI-G"
@@ -398,23 +399,31 @@ longGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 100
, _itUseTime = 0
, _itUse = \_ -> shootWithSound (fromIntegral longGunSound)
, _itUse = shootWithSound (fromIntegral longGunSound)
. withThickSmoke
. torqueAfter 0.05
. withMuzFlare
. withVelWthHiteff (60,0) 6
$ penWalls hvBulHitCr' hvBulHitWall' bulHitFF'
. useAmmoParams
, _wpRange = 200
, _itFloorPict = onLayer FlItLayer $ pictures [color orange $ polygon $ rectNESW 3 6 (-3) (-6) ]
, _itFloorPict = onLayer FlItLayer longGunPic
, _itAimingSpeed = 0.2
, _itAimingRange = 1
, _itZoom = defaultItZoom {_itAimZoomMax = 0.5, _itAimZoomMin = 0.5}
, _itEquipPict = pictureWeaponOnAim $ pictures [color orange $ polygon $ rectNESW 3 6 (-3) (-6) ]
, _itScrollUp = startZoomInLongGun
, _itScrollDown = startZoomOutLongGun
, _itEquipPict = pictureWeaponOnAim longGunPic
, _itScroll = zoomLongGun
, _itAttachment = Just $ ItScope (0,0) 0 1 False
, _itEffect = itemLaserScopeEffect
, _wpAmmo = hvBullet
, _itAimStance = TwoHandTwist
}
longGunPic :: Picture
longGunPic = pictures [color orange $ polygon $ rectNESW 2 12 (-2) (-12) ]
zoomLongGun :: Float -> Creature -> World -> World
zoomLongGun x cr
| x > 0 = startZoomInLongGun (_crInvSel cr)
| x < 0 = startZoomOutLongGun (_crInvSel cr)
| otherwise = id
startZoomInLongGun :: Int -> World -> World
startZoomInLongGun _ w = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
@@ -422,7 +431,6 @@ startZoomInLongGun _ w = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatur
startZoomOutLongGun :: Int -> World -> World
startZoomOutLongGun _ w = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment . _Just . scopeZoomChange %~ \x -> min (-5) (x-5)
poisonSprayer :: Item
poisonSprayer = defaultAutoGun
{ _itName = "POISON"
@@ -455,13 +463,18 @@ flamer = defaultAutoGun
, _itUse = \_ -> shoot $ withSidePush 5 $ withSidePushAfter 10 $ randWalkAngle 0.2 0.01 aFlame
, _wpSpread = 0
, _wpRange = 8
, _itFloorPict = onLayer FlItLayer $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
, _itFloorPict = onLayer FlItLayer flamerPic
, _itAimingSpeed = 0.5
, _itAimingRange = 0
, _itZoom = defaultItZoom {_itAimZoomMax = 5, _itAimZoomMin = 1.5}
, _itEquipPict = pictureWeaponOnAim $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
, _itEquipPict = pictureWeaponOnAim flamerPic
, _itAttachment = Nothing
}
flamerPic :: Picture
flamerPic = color yellow $ pictures
[ translate (negate 5) (negate 7) $ circleSolid 5
, polygon $ rectNESW 2 9 (-2) (-9)
]
blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
+6 -7
View File
@@ -28,7 +28,7 @@ autoGun = defaultAutoGun
, _wpLoadedAmmo = 30
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 6
, _itUseRate = 5
, _itUseTime = 0
, _itUse = \_ -> charFiringStrat
[('M',autoFireMode)
@@ -37,15 +37,14 @@ autoGun = defaultAutoGun
, _wpSpread = autogunSpread
, _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer autoGunPict
, _itFloorPict = onLayer FlItLayer autoGunPic
, _itAimingSpeed = 0.4
, _itAimingRange = 1
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim autoGunPict
, _itEquipPict = pictureWeaponOnAim autoGunPic
, _itEffect = wpRecock
, _itAttachment = Just $ ItCharMode $ Seq.fromList "MS"
, _itScrollUp = incCharMode
, _itScrollDown = decCharMode
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
, _wpAmmo = basicBullet
}
@@ -60,8 +59,8 @@ autoGunNonTwistEff = withRecoil 40
. withVelWthHiteff (50,0) 3
$ destroyOnImpact bulHitCr bulHitWall' bulHitFF'
autoGunPict :: Picture
autoGunPict = color red $ polygon $ rectNESW 4 12 (-4) (-12)
autoGunPic :: Picture
autoGunPic = color red $ polygon $ rectNESW 4 12 (-4) (-12)
autogunSpread :: Float
autogunSpread = 0.07
+10 -2
View File
@@ -4,6 +4,7 @@ import Dodge.Data
import Dodge.Base
import Dodge.Default.Weapon
import Dodge.Item.Data
import Dodge.Item.Draw
import Dodge.Item.Weapon.Targeting
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.ExtraEffect
@@ -12,6 +13,7 @@ import Dodge.Particle.Bullet.Spawn
import Dodge.Particle.Bullet.HitEffect
import Dodge.WorldEvent.HitEffect
import Dodge.RandomHelp
import Dodge.Picture.Layer
import Picture
import Geometry
@@ -28,14 +30,20 @@ bezierGun = defaultGun
. withRecoil 40
. torqueBefore 0.05 -- I believe that this doesn't affect
$ shootBezier $ fromJust p -- <- the start point
, _itFloorPict = onLayer FlItLayer bezierGunPic
, _itEquipPict = pictureWeaponOnAim bezierGunPic
, _itAttachment = Nothing
, _itScrollUp = removeItTarget 0
, _itScrollDown = removeItTarget 0
, _itScroll = removeItTarget 0
, _itHammer = HammerUp
, _itEffect = rbSetTarget
, _itZoom = defaultItZoom
, _itAimingRange = 0
, _wpMaxAmmo = 50
, _itUseRate = 6
, _itAimStance = TwoHandTwist
}
bezierGunPic :: Picture
bezierGunPic = color red $ polygon $ rectNESW 4 12 (-4) (-12)
shootBezier :: Point2 -> Creature -> World -> World
shootBezier targetp cr w = w & particles %~ (theBullet :)
+7
View File
@@ -10,3 +10,10 @@ basicBullet = BulletAmmo
, _amBulWth = 2
, _amBulVel = (30,0)
}
hvBullet :: Ammo
hvBullet = BulletAmmo
{ _amString = "HVBULLET"
, _amBulEff = penWalls hvBulHitCr hvBulHitWall' bulHitFF'
, _amBulWth = 6
, _amBulVel = (80,0)
}
+2 -1
View File
@@ -13,6 +13,7 @@ import Dodge.Item.Weapon.UseEffect
import Dodge.WorldEvent.Flash
import Dodge.WorldEvent.ThingsHit
import Dodge.Picture.Layer
import Dodge.Creature.Test
import Picture
import Geometry.Vector
@@ -58,7 +59,7 @@ itemLaserScopeEffect
moveHammerUp !HammerDown = HammerReleased
moveHammerUp !_ = HammerUp
f _ cr invid w
| invid == _crInvSel cr = w
| invid == _crInvSel cr && crIsAiming' cr = w
& particles %~ (:) (makeLaserScope sp ep reloadFrac)
& creatures . ix (_crID cr) . crInv . ix invid . itHammer %~ moveHammerUp
& laserScopeTargetGlow col glowPoint
+2 -2
View File
@@ -13,8 +13,8 @@ useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . _Just
Nothing -> w
Just (g,_) -> f (g w) cr w
removeItTarget :: Int -> Int -> World -> World
removeItTarget i _ w = w & creatures . ix i . crInv . ix itRef . itTargeting .~ Nothing
removeItTarget :: Int -> Float -> Creature -> World -> World
removeItTarget i _ _ w = w & creatures . ix i . crInv . ix itRef . itTargeting .~ Nothing
where
cr = _creatures w IM.! i
itRef = _crInvSel cr
+2 -2
View File
@@ -88,8 +88,8 @@ bulPenCr' bt p cr w
) {_btTimer' = _btTimer' bt - 1}
{- | Heavy bullet effects when hitting creature:
piercing, blunt, twisting and pushback damage all applied. -}
hvBulHitCr' :: Particle -> Point2 -> Creature -> World -> World
hvBulHitCr' bt p cr w
hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
hvBulHitCr bt p cr w
= over (creatures . ix cid . crState . crDamage)
([Piercing 200 sp p ep
,Blunt 100 sp p ep
+4 -6
View File
@@ -45,12 +45,10 @@ customMouseCursor w =
$ pictures [ line [(-5,0),(5,0)] , line [(0,-5),(0,5)] ]
testPic :: World -> [Picture]
testPic _ = []
--testPic w =
-- [ setDepth (-1) . translate 0 0.8
-- . scale 0.001 0.001 . text . show . length . IM.elems
-- . IM.filter ( (== 3) . _crRad ) $ _creatures w
-- ]
testPic w =
[ setDepth (-1) . translate 0 0.8
. scale 0.001 0.001 . text . show $ _cameraRot w
]
crDraw :: World -> Creature -> Picture
crDraw w c = (_crPict c c w)