Tweak equipment draw

This commit is contained in:
2021-11-19 14:24:31 +00:00
parent 4ef1811dd6
commit 6f518d720c
13 changed files with 33 additions and 41 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ startCr = defaultCreature
{- | Items you start with. -} {- | Items you start with. -}
startInvList :: [Item] startInvList :: [Item]
startInvList = startInvList =
[shrinkGun [
] ]
startInventory :: IM.IntMap Item startInventory :: IM.IntMap Item
startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem
+2 -10
View File
@@ -225,20 +225,12 @@ youDropItem w = case yourItem w ^? itCurseStatus of
where where
cr = you w cr = you w
{- | Copy an inventory item to the floor. -} {- | Copy an inventory item to the floor. -}
copyInvItemToFloor copyInvItemToFloor :: Creature -> Int -> World -> World
:: Creature
-> Int -- ^ Inventory position
-> World
-> World
copyInvItemToFloor cr i w = case _crInv cr IM.! i of copyInvItemToFloor cr i w = case _crInv cr IM.! i of
NoItem -> w NoItem -> w
it -> copyItemToFloor (_crPos cr) it w it -> copyItemToFloor (_crPos cr) it w
{- | Copy an item to the floor. -} {- | Copy an item to the floor. -}
copyItemToFloor copyItemToFloor :: Point2 -> Item -> World -> World
:: Point2
-> Item
-> World
-> World
copyItemToFloor pos it w = w' copyItemToFloor pos it w = w'
& floorItems %~ IM.insert flid theflit & floorItems %~ IM.insert flid theflit
& updateLocation & updateLocation
+9 -2
View File
@@ -3,8 +3,12 @@ module Dodge.Default.Weapon
import Dodge.Data import Dodge.Data
import Dodge.Item.Weapon.ExtraEffect import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.InventoryDisplay import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Draw
import Picture import Picture
import ShapePicture import ShapePicture
import Shape
import Geometry.Vector3D
import Geometry
import Linear.V3 import Linear.V3
defaultGun :: Item defaultGun :: Item
@@ -30,12 +34,15 @@ defaultGun = Weapon
, _wpSpread = 0.02 , _wpSpread = 0.02
, _wpRange = 20 , _wpRange = 20
, _itHammer = HammerUp , _itHammer = HammerUp
, _itFloorPict = const emptyBlank , _itFloorPict = const $ noPic $ colorSH green (prismPoly
(map (addZ 3) $ rectNESW 3 3 (-3) (-3))
(map (addZ 0) $ rectNESW 5 3 (-5) (-7))
)
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
, _itZoom = ItZoom 20 0.2 1 , _itZoom = ItZoom 20 0.2 1
, _itAimZoom = ItZoom 20 0.2 1 , _itAimZoom = ItZoom 20 0.2 1
, _itEquipPict = \_ _ -> emptyBlank , _itEquipPict = pictureWeaponOnAim
, _itScroll = \_ _ -> id , _itScroll = \_ _ -> id
, _itAttachment = NoItAttachment , _itAttachment = NoItAttachment
, _itID = Nothing , _itID = Nothing
+10 -1
View File
@@ -8,11 +8,20 @@ import ShapePicture
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import Control.Lens import Control.Lens
pictureWeaponOnAim pictureWeaponOnAim
:: Creature
-> Int -- ^ Position of item in inventory
-> SPic
pictureWeaponOnAim cr i = pictureWeaponOnAimItem pic cr i
where
it = _crInv cr IM.! i
pic = _itFloorPict it it
pictureWeaponOnAim'
:: (Item -> SPic) :: (Item -> SPic)
-> Creature -> Creature
-> Int -- ^ Position of item in inventory -> Int -- ^ Position of item in inventory
-> SPic -> SPic
pictureWeaponOnAim f cr i = pictureWeaponOnAimItem pic cr i pictureWeaponOnAim' f cr i = pictureWeaponOnAimItem pic cr i
where where
pic = f (_crInv cr IM.! i) pic = f (_crInv cr IM.! i)
+1 -1
View File
@@ -50,7 +50,7 @@ frontArmour = defaultEquipment
} }
flatShield :: Item flatShield :: Item
flatShield = defaultEquipment flatShield = defaultEquipment
{ _itEquipPict = pictureWeaponOnAim flatShieldEquipSPic { _itEquipPict = pictureWeaponOnAim' flatShieldEquipSPic
, _itAimStance = TwoHandFlat , _itAimStance = TwoHandFlat
, _itEffect = effectOnOffEquip createShieldWall removeShieldWall , _itEffect = effectOnOffEquip createShieldWall removeShieldWall
, _itName = "SHIELD" , _itName = "SHIELD"
+4 -4
View File
@@ -164,7 +164,7 @@ remoteBomb = defaultThrowable
[ hammerCheckI [ hammerCheckI
] ]
, _itAttachment = ItScope (V2 0 0) 0 1 True , _itAttachment = ItScope (V2 0 0) 0 1 True
, _itEquipPict = pictureWeaponOnAim $ \_ -> (,) emptySH remoteBombUnarmedPic , _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH remoteBombUnarmedPic
} }
@@ -219,7 +219,7 @@ explodeRemoteBomb itid pjid cr w
cid = _crID cr cid = _crID cr
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEBOMB" resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEBOMB"
resetPict = set (creatures . ix cid . crInv . ix j . itEquipPict ) resetPict = set (creatures . ix cid . crInv . ix j . itEquipPict )
(pictureWeaponOnAim $ \_ -> (,) emptySH remoteBombUnarmedPic) (pictureWeaponOnAim' $ \_ -> (,) emptySH remoteBombUnarmedPic)
-- resetScope = creatures . ix cid . crInv . ix j . itScope . _Just . scopePos .~ (0,0) -- resetScope = creatures . ix cid . crInv . ix j . itScope . _Just . scopePos .~ (0,0)
j = _crInvSel $ _creatures w IM.! cid j = _crInvSel $ _creatures w IM.! cid
remoteBombPic remoteBombPic
@@ -269,7 +269,7 @@ radar = defaultGun
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom { _itZoomMax = 1} , _itZoom = defaultItZoom { _itZoomMax = 1}
, _itAimZoom = defaultItZoom { _itZoomMax = 1} , _itAimZoom = defaultItZoom { _itZoomMax = 1}
, _itEquipPict = pictureWeaponOnAim $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5) , _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
} }
{- | {- |
Sends out pulses that display creatures. -} Sends out pulses that display creatures. -}
@@ -293,7 +293,7 @@ sonar = defaultGun
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom {_itZoomMax = 1} , _itZoom = defaultItZoom {_itZoomMax = 1}
, _itAimZoom = defaultItZoom {_itZoomMax = 1} , _itAimZoom = defaultItZoom {_itZoomMax = 1}
, _itEquipPict = pictureWeaponOnAim $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5) , _itEquipPict = pictureWeaponOnAim' $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
} }
{- | {- |
Automatically sends out pulses that display creatures. -} Automatically sends out pulses that display creatures. -}
-3
View File
@@ -59,7 +59,6 @@ teslaGun = defaultGun
, _itAimingSpeed = 0.4 , _itAimingSpeed = 0.4
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimingRange = 0 , _itAimingRange = 0
, _itEquipPict = pictureWeaponOnAim teslaGunPic
} }
teslaGunPic :: Item -> SPic teslaGunPic :: Item -> SPic
teslaGunPic _ = teslaGunPic _ =
@@ -95,7 +94,6 @@ lasGun = defaultAutoGun
, _itFloorPict = lasGunPic , _itFloorPict = lasGunPic
, _itAimingSpeed = 0.4 , _itAimingSpeed = 0.4
, _itAimingRange = 1 , _itAimingRange = 1
, _itEquipPict = pictureWeaponOnAim lasGunPic
, _itAttachment = ItCharMode $ Seq.fromList "/VZ" , _itAttachment = ItCharMode $ Seq.fromList "/VZ"
, _itScroll = scrollCharMode , _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay , _itInvDisplay = basicWeaponDisplay
@@ -132,7 +130,6 @@ tractorGun = defaultAutoGun
, _itFloorPict = tractorGunSPic , _itFloorPict = tractorGunSPic
, _itAimingSpeed = 0.4 , _itAimingSpeed = 0.4
, _itAimingRange = 0.5 , _itAimingRange = 0.5
, _itEquipPict = pictureWeaponOnAim tractorGunSPic
} }
-- TODO own picture for tractor gun -- TODO own picture for tractor gun
tractorGunSPic :: Item -> SPic tractorGunSPic :: Item -> SPic
-1
View File
@@ -35,7 +35,6 @@ bezierGun = defaultGun
. torqueBefore 0.05 . torqueBefore 0.05
] ]
, _itFloorPict = bezierGunSPic , _itFloorPict = bezierGunSPic
, _itEquipPict = pictureWeaponOnAim bezierGunSPic
, _itAttachment = NoItAttachment , _itAttachment = NoItAttachment
, _itScroll = \_ _ -> removeItTarget , _itScroll = \_ _ -> removeItTarget
, _itHammer = HammerUp , _itHammer = HammerUp
+2 -10
View File
@@ -66,7 +66,7 @@ autoGun = defaultAutoGun
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomFac = 1.5} , _itAimZoom = defaultItZoom {_itZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim autoGunPic , _itEquipPict = pictureWeaponOnAim
, _itAttachment = ItCharMode $ Seq.fromList "MS" , _itAttachment = ItCharMode $ Seq.fromList "MS"
, _itScroll = scrollCharMode , _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay , _itInvDisplay = basicWeaponDisplay
@@ -118,14 +118,11 @@ pistol = defaultGun
, _wpAmmo = basicBullet , _wpAmmo = basicBullet
} }
pistolPic :: Item -> SPic pistolPic :: Item -> SPic
pistolPic it = pistolPic it = noPic $ colorSH green (prismPoly
( colorSH green (prismPoly
(map (addZ 3) $ rectNESW 3 3 (-3) (-3)) (map (addZ 3) $ rectNESW 3 3 (-3) (-3))
(map (addZ 0) $ rectNESW 5 3 (-5) (-7)) (map (addZ 0) $ rectNESW 5 3 (-5) (-7))
) )
<> translateSH (V3 (-4) 5.5 4) (rotateSH pi $ bulletClip am) <> translateSH (V3 (-4) 5.5 4) (rotateSH pi $ bulletClip am)
, mempty
)
where where
am = loadedAmmo it am = loadedAmmo it
@@ -156,7 +153,6 @@ hvAutoGun = defaultAutoGun
, _itFloorPict = hvAutoGunPic , _itFloorPict = hvAutoGunPic
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 1 , _itAimingRange = 1
, _itEquipPict = pictureWeaponOnAim hvAutoGunPic
, _wpAmmo = hvBullet , _wpAmmo = hvBullet
} }
hvAutoGunPic :: Item -> SPic hvAutoGunPic :: Item -> SPic
@@ -197,7 +193,6 @@ ltAutoGun = defaultAutoGun
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim ltAutoGunPic
, _itAimStance = OneHand , _itAimStance = OneHand
, _wpAmmo = ltBullet , _wpAmmo = ltBullet
} }
@@ -330,7 +325,6 @@ spreadGun = defaultGun
, _itFloorPict = spreadGunPic , _itFloorPict = spreadGunPic
, _itAimingSpeed = 1 , _itAimingSpeed = 1
, _itAimingRange = 0 , _itAimingRange = 0
, _itEquipPict = pictureWeaponOnAim spreadGunPic
, _wpAmmo = basicBullet , _wpAmmo = basicBullet
, _wpNumBarrels = 50 , _wpNumBarrels = 50
} }
@@ -370,7 +364,6 @@ multGun = defaultGun
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomFac = 1.5} , _itAimZoom = defaultItZoom {_itZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim multGunSPic
, _itAimStance = TwoHandTwist , _itAimStance = TwoHandTwist
, _wpAmmo = basicBullet , _wpAmmo = basicBullet
, _wpNumBarrels = 5 , _wpNumBarrels = 5
@@ -418,7 +411,6 @@ longGun = defaultGun
, _itAimingRange = 1 , _itAimingRange = 1
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5} , _itAimZoom = defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
, _itEquipPict = pictureWeaponOnAim longGunSPic
, _itScroll = zoomLongGun , _itScroll = zoomLongGun
, _itAttachment = ItScope (V2 0 0) 0 1 False , _itAttachment = ItScope (V2 0 0) 0 1 False
, _itEffect = itemLaserScopeEffect , _itEffect = itemLaserScopeEffect
+2 -2
View File
@@ -39,7 +39,7 @@ grenade = Throwable
, _itAimingRange = 0 , _itAimingRange = 0
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomMax = f fuseTime, _itZoomMin = f fuseTime} , _itAimZoom = defaultItZoom {_itZoomMax = f fuseTime, _itZoomMin = f fuseTime}
, _itEquipPict = pictureWeaponOnAim $ \_ -> grenadePic fuseTime , _itEquipPict = pictureWeaponOnAim' $ \_ -> grenadePic fuseTime
, _itID = Nothing , _itID = Nothing
, _itUseRate = 25 , _itUseRate = 25
, _itUseTime = 0 , _itUseTime = 0
@@ -131,7 +131,7 @@ throwArmReset x = ItInvEffect {_itInvEffect = f ,_itEffectCounter = x }
counterDown it counterDown it
| _itEffectCounter (_itEffect it) == 0 = it | _itEffectCounter (_itEffect it) == 0 = it
& itHammer .~ HammerUp & itHammer .~ HammerUp
& itEquipPict .~ pictureWeaponOnAim (\_ -> grenadePic 50) & itEquipPict .~ pictureWeaponOnAim' (\_ -> grenadePic 50)
| otherwise = it & itEffect . itEffectCounter -~ 1 | otherwise = it & itEffect . itEffectCounter -~ 1
--flameGrenade :: Item --flameGrenade :: Item
-2
View File
@@ -56,7 +56,6 @@ launcher = defaultGun
, _itFloorPict = launcherPic , _itFloorPict = launcherPic
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 0.5 , _itAimingRange = 0.5
, _itEquipPict = pictureWeaponOnAim launcherPic
, _itHammer = NoHammer , _itHammer = NoHammer
, _itEffect = NoItEffect , _itEffect = NoItEffect
, _wpAmmo = defaultShellAmmo , _wpAmmo = defaultShellAmmo
@@ -256,7 +255,6 @@ remoteLauncher = defaultGun
, _itFloorPict = launcherPic , _itFloorPict = launcherPic
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 0.5 , _itAimingRange = 0.5
, _itEquipPict = pictureWeaponOnAim launcherPic
, _itAttachment = ItScope (V2 0 0) 0 1 True , _itAttachment = ItScope (V2 0 0) 0 1 True
, _itAimStance = TwoHandTwist , _itAimStance = TwoHandTwist
} }
-2
View File
@@ -54,7 +54,6 @@ poisonSprayer = defaultAutoGun
, _itAimingSpeed = 0.2 , _itAimingSpeed = 0.2
, _itAimingRange = 0 , _itAimingRange = 0
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponOnAim flamerPic
, _wpSpread = 0.1 , _wpSpread = 0.1
, _wpNumBarrels = 3 , _wpNumBarrels = 3
} }
@@ -82,7 +81,6 @@ flamer = defaultAutoGun
, _itAimingRange = 0 , _itAimingRange = 0
, _itZoom = defaultItZoom , _itZoom = defaultItZoom
, _itAimZoom = defaultItZoom {_itZoomMax = 5, _itZoomMin = 1.5} , _itAimZoom = defaultItZoom {_itZoomMax = 5, _itZoomMin = 1.5}
, _itEquipPict = pictureWeaponOnAim flamerPic
, _itAttachment = NoItAttachment , _itAttachment = NoItAttachment
} }
flamerPic :: Item -> SPic flamerPic :: Item -> SPic
+2 -2
View File
@@ -37,8 +37,8 @@ keyholeCorridor = corridor
, midWall $ rectNSEW top bot 25 40] , midWall $ rectNSEW top bot 25 40]
} }
where where
top = 55 top = 65
bot = 25 bot = 15
corridorN :: Room corridorN :: Room
corridorN = defaultRoom corridorN = defaultRoom