From fb7a90df71c7a204c334fc2b3746f2d32602af68 Mon Sep 17 00:00:00 2001 From: jgk Date: Mon, 7 Jun 2021 20:28:54 +0200 Subject: [PATCH] Add different weapon positions based on handedness --- src/Dodge/Creature.hs | 4 +- src/Dodge/Creature/Picture.hs | 67 +++++++++++++++++++-------- src/Dodge/Creature/State/WalkCycle.hs | 4 +- src/Dodge/Default.hs | 2 +- src/Dodge/Item/Draw.hs | 25 ++++++++-- src/Dodge/Item/Weapon.hs | 14 ++++-- src/Dodge/Item/Weapon/Launcher.hs | 8 +++- 7 files changed, 90 insertions(+), 34 deletions(-) diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 336238160..37b0141b6 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -158,7 +158,8 @@ startCr = defaultCreature startInventory :: IM.IntMap Item startInventory = IM.fromList (zip [0..20] ( - [hvAutoGun + [autoGun + ,hvAutoGun ,pistol ,teslaGun ,blinkGun @@ -170,7 +171,6 @@ startInventory = IM.fromList (zip [0..20] ,grenade ,spawnGun lamp ,lasGun - ,autoGun ,flamer ,poisonSprayer ,launcher diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index 8e08ef84e..5288d75c7 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -29,6 +29,7 @@ basicCrPict col cr w = pictures $ targetingPic ++ [ tr . piercingMod $ bluntScale $ naked col cr , trFeet $ feet cr + , tr $ arms col cr , tr $ drawEquipment cr ] where @@ -54,41 +55,68 @@ basicCrPict col cr w = pictures $ feet :: Creature -> Picture feet cr = case cr ^? crStance . carriage of - Just (Walking _ LeftForward) -> setL - [ translate up off $ circleSolid 5 - , translate (-up) (-off) $ circleSolid 5 + Just (Walking sa LeftForward) -> setL + [ translate (f sa) off $ circleSolid 5 + , translate (-f sa) (-off) $ circleSolid 5 ] - Just (Walking _ RightForward) -> setL - [ translate (-up) off $ circleSolid 5 - , translate (up) (-off) $ circleSolid 5 + Just (Walking sa RightForward) -> setL + [ translate (-f sa) off $ circleSolid 5 + , translate (f sa) (-off) $ circleSolid 5 ] _ -> setL [ translate 0 off $ circleSolid 5 , translate 0 (-off) $ circleSolid 5 ] where - setL = onLayerL [levLayer CrLayer, (-2)] . color (greyN 0.2) . pictures + setL = onLayerL [levLayer CrLayer, (-5)] . color (greyN 0.3) . pictures off = 5 - up = 5 + sLen = _strideLength $ _crStance cr + f i = 6 * fromIntegral (sLen - i) / fromIntegral sLen + +arms :: Color -> Creature -> Picture +arms col cr + | aimingTwist = blank + | otherwise = case cr ^? crStance . carriage of + Just (Walking sa LeftForward) -> setL + [ translate (-f sa) (-off) . sc $ circleSolid 4 + ] + Just (Walking sa RightForward) -> setL + [ translate (-f sa) off . sc $ circleSolid 4 + ] + _ -> blank + where + sc = scale 1 1 + setL = onLayerL [levLayer CrLayer, (-4)] . color (light4 col) . pictures + off = 8 + sLen = _strideLength $ _crStance cr + f i = negate 2 + negate 6 * fromIntegral (sLen - i) / fromIntegral sLen + aimingTwist = crIsAiming' cr -- && crIt ^? itAimStance == Just TwoHandTwist + --crIt = _crInv cr IM.! _crInvSel cr + naked :: Color -> Creature -> Picture naked col cr | strikeMelee = onCrL . color white $ circleSolid $ _crRad cr | pdam > 200 = onCrL . color red $ circleSolid $ _crRad cr | pdam > 99 = onCrL . color white $ circleSolid $ _crRad cr - | aimingTwist = rotate twistA $ pictures + | aimingOneHand = rotate (negate twistA * 0.5) $ pictures + [ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5) + , onCrL . translate 8 (-8) . color col' $ circleSolid 4 + , translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr + , translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr + ] + | aimingTwist = translate 0 (0.5* crad) . rotate twistA $ pictures [ aboveIt . translate (negate 0.25 * crad) 0.25 $ circleSolid (crad * 0.5) - , onCrL . translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr - , onCrL . translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr - --, shoulderRot . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr + , onCrL . translate 12 (4) . color col' $ circleSolid 4 + , onCrL . translate 4 (-10) . color col' $ circleSolid 4 + , onCrL . rotate (negate 0.2) . translate 2 3 . rotate (negate 0.4) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr + , onCrL . rotate (negate 0.2) . translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr ] - | otherwise = onCrL $ pictures [ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5) - , translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr - , translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr - --, shoulderRot . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr + , translate 0 3 . rotate (negate 0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr + , translate 0 (negate 3) . rotate (0.2) . scale 0.5 1 $ color col' $ circleSolid $ _crRad cr ] where aboveIt = onLayer HPtLayer @@ -97,10 +125,6 @@ naked col cr aimingOneHand = crIsAiming' cr && crIt ^? itAimStance == Just OneHand aimingTwist = crIsAiming' cr && crIt ^? itAimStance == Just TwoHandTwist crIt = _crInv cr IM.! _crInvSel cr - shoulderRot = case cr ^? crStance . carriage of - Just (Walking _ LeftForward) -> rotate 0.1 - Just (Walking _ RightForward) -> rotate $ negate 0.1 - _ -> id strikeMelee = case _crMeleeCooldown cr of Nothing -> False Just x -> x > 5 @@ -109,6 +133,9 @@ naked col cr pastDams = _crPastDamage $ _crState cr col' = light . light . light $ light col +light4 :: Color -> Color +light4 = light . light . light . light + --drawAwakeLevel -- :: Creature -- -> Picture diff --git a/src/Dodge/Creature/State/WalkCycle.hs b/src/Dodge/Creature/State/WalkCycle.hs index 50a295e2a..d7bb77f14 100644 --- a/src/Dodge/Creature/State/WalkCycle.hs +++ b/src/Dodge/Creature/State/WalkCycle.hs @@ -14,9 +14,9 @@ updateWalkCycle cr = case cr ^? crStance . carriage of maxStride = _strideLength $ _crStance cr normalGait :: FootForward -> FootForward -normalGait LeftForward = WasLeftForward +normalGait LeftForward = RightForward normalGait WasLeftForward = RightForward -normalGait RightForward = WasRightForward +normalGait RightForward = LeftForward normalGait WasRightForward = LeftForward footstepSideEffect :: Creature -> World -> World diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 08cf35594..37cf81923 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -112,7 +112,7 @@ defaultCreature = Creature , _crStance = Stance {_carriage=Walking 0 WasLeftForward ,_posture=AtEase - ,_strideLength = 9 + ,_strideLength = 20 } , _crActionPlan = ActionPlan [] [] WatchAndWait [LiveLongAndProsper] , _crMeleeCooldown = Nothing diff --git a/src/Dodge/Item/Draw.hs b/src/Dodge/Item/Draw.hs index 7bedbf900..b0a477cd3 100644 --- a/src/Dodge/Item/Draw.hs +++ b/src/Dodge/Item/Draw.hs @@ -7,6 +7,7 @@ import Dodge.Creature.Stance.Data import Picture import qualified Data.IntMap.Strict as IM +import Control.Lens {- | Places an item picture onto a creature when the item is selected. -} pictureWeaponOnAim :: Picture @@ -17,18 +18,36 @@ pictureWeaponOnAim p cr posInInv | isSelected && _posture (_crStance cr) == Aiming && isTwisting = onLayer PtLayer twistWep + | isSelected && _posture (_crStance cr) == Aiming + && isOneHand + = onLayer PtLayer oneHandWep | isSelected && _posture (_crStance cr) == Aiming = onLayer PtLayer drawnWep + | isSelected && isOneHand + = onLayerL [levLayer CrLayer, -3] holsteredOneHandWep | isSelected - = onLayer PtLayer holsteredWep + = onLayerL [levLayer CrLayer, -3] holsteredWep | otherwise = blank where isSelected = _crInvSel cr == posInInv drawnWep = uncurry translate (_crRad cr,0) p - twistWep = uncurry translate (0.5 * _crRad cr,negate 0.5 * _crRad cr) p - holsteredWep = uncurry translate (_crRad cr,0) (scale 0.1 1 p) + 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) + 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 + _ -> 0 theIt = _crInv cr IM.! posInInv isTwisting = _itAimStance theIt == TwoHandTwist + isOneHand = _itAimStance theIt == OneHand + sRot = case cr ^? crStance . carriage of + Just (Walking x LeftForward) -> f x + Just (Walking x RightForward) -> - f x + _ -> 0 + f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen + sLen = _strideLength $ _crStance cr pictureItem :: Picture diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index 5002f7d44..d3334a951 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -160,15 +160,17 @@ lasGun = defaultAutoGun , _itUse = \_ -> shoot aLaser , _wpSpread = 0.001 , _wpRange = 20 - , _itFloorPict = onLayer FlItLayer $ color blue $ polygon $ rectNESW 3 3 (-3) (-3) + , _itFloorPict = onLayer FlItLayer lasGunPic , _itAimingSpeed = 0.4 , _itAimingRange = 1 - , _itEquipPict = pictureWeaponOnAim $ color blue $ polygon $ rectNESW 3 3 (-3) (-3) + , _itEquipPict = pictureWeaponOnAim lasGunPic , _itAttachment = Just $ ItCharMode $ Seq.fromList "/VZ" , _itScrollUp = incCharMode , _itScrollDown = decCharMode , _itInvDisplay = basicWeaponDisplay } +lasGunPic :: Picture +lasGunPic = color blue . polygon $ rectNESW 3 15 (-3) (-15) forceFieldGun :: Item forceFieldGun = defaultGun { _itName = "FORCEFIELD" @@ -372,9 +374,12 @@ multGun = defaultGun , _itAimingRange = 1 , _itZoom = defaultItZoom {_itAimZoomFac = 1.5} , _itEquipPict = pictureWeaponOnAim multGunPic + , _itAimStance = TwoHandTwist } - where - multGunPic = color red $ pictures +multGunPic :: Picture +multGunPic = color red $ pictures + [ polygon $ rectNESW 4 8 (-4) (-12) + , translate 8 0 $ pictures [ polygon $ rectNSEW 12 8 2 (-2) , polygon $ rectNSEW 7 3 2 (-2) , polygon $ rectNSEW 2 (-2) 2 (-2) @@ -382,6 +387,7 @@ multGun = defaultGun , polygon $ rectNSEW (-8) (-12) 2 (-2) , polygon [(-1.5,12),(-2,12),(-2,-12),(-1.5,-12)] ] + ] longGun :: Item longGun = defaultGun { _itName = "LONGGUN" diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index a1c167477..b4fb4de27 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -38,10 +38,10 @@ launcher = defaultGun , _itUse = \it -> shootWithSound (fromIntegral launcherSound) $ aRocketWithItemParams it , _wpSpread = 0.02 , _wpRange = 20 - , _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5) + , _itFloorPict = onLayer FlItLayer launcherPic , _itAimingSpeed = 0.2 , _itAimingRange = 0.5 - , _itEquipPict = pictureWeaponOnAim $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5) + , _itEquipPict = pictureWeaponOnAim launcherPic , _itHammer = NoHammer , _itEffect = NoItEffect , _wpAmmo = defaultShellAmmo @@ -50,8 +50,12 @@ launcher = defaultGun , _amPjParams = basicAmPjMoves , _amPjDraw = shellPic } + , _itAimStance = TwoHandTwist } +launcherPic :: Picture +launcherPic = color cyan $ polygon $ rectNESW 5 10 (-5) (-10) + basicAmPjMoves :: [PjParam] basicAmPjMoves = [spinDrag