Add twisting weapons and feet

This commit is contained in:
jgk
2021-06-07 15:03:15 +02:00
parent edd947a857
commit c9ca94e82e
16 changed files with 226 additions and 117 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 431 KiB

+16 -16
View File
@@ -16,20 +16,20 @@ invert = M.foldrWithKey (\k val -> M.insertWith (++) val [k]) M.empty
combineList :: [([ItemType], ItemType)]
combineList =
[ ( [ Pistol, Pipe, Hardware ] , Rifle )
, ( [ Rifle, Hardware ] , Pistol )
, ( [ Pistol, Pistol, Hardware ] , SpreadGun 2 )
, ( [ SpreadGun 2, Pistol, Hardware ] , SpreadGun 3 )
, ( [ SpreadGun 3, Pistol, Hardware ] , SpreadGun 4 )
, ( [ SpreadGun 4, Pistol, Hardware ] , SpreadGun 5 )
, ( [ Pistol, AutoGun, Hardware ] , LtAutoGun )
, ( [ LtAutoGun, Pipe, Hardware ] , AutoGun )
, ( [ Rifle, Rifle, Hardware ] , MultGun 2 )
, ( [ MultGun 2, Rifle, Hardware ] , MultGun 3 )
, ( [ MultGun 3, Rifle, Hardware ] , MultGun 4 )
, ( [ MultGun 4, Rifle, Hardware ] , MultGun 5 )
, ( [ LtAutoGun, Pipe, Hardware ] , AutoGun )
, ( [ Pistol, BigTube, Hardware] , Launcher 1 )
, ( [ Launcher 1, BigTube, Pistol, Hardware] , Launcher 2)
, ( [ Launcher 2, BigTube, Pistol, Hardware] , Launcher 3)
[ ( [ TPistol, TPipe, THardware ] , TRifle )
, ( [ TRifle, THardware ] , TPistol )
, ( [ TPistol, TPistol, THardware ] , TSpreadGun 2 )
, ( [ TSpreadGun 2, TPistol, THardware ] , TSpreadGun 3 )
, ( [ TSpreadGun 3, TPistol, THardware ] , TSpreadGun 4 )
, ( [ TSpreadGun 4, TPistol, THardware ] , TSpreadGun 5 )
, ( [ TPistol, TAutoGun, THardware ] , TLtAutoGun )
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
, ( [ TRifle, TRifle, THardware ] , TMultGun 2 )
, ( [ TMultGun 2, TRifle, THardware ] , TMultGun 3 )
, ( [ TMultGun 3, TRifle, THardware ] , TMultGun 4 )
, ( [ TMultGun 4, TRifle, THardware ] , TMultGun 5 )
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
, ( [ TPistol, TBigTube, THardware] , TLauncher 1 )
, ( [ TLauncher 1, TBigTube, TPistol, THardware] , TLauncher 2)
, ( [ TLauncher 2, TBigTube, TPistol, THardware] , TLauncher 3)
]
+30 -30
View File
@@ -1,34 +1,34 @@
module Dodge.Combine.Data
where
data ItemType
= Pipe
| BigTube
| Plate
| MChip
| Magnet
| Motor
| LED
| Hardware
| Nailbox
| Plank
| Prism
| LightSensor
| SoundSensor
| HeatSensor
| CopperWire
| EmptyCan
| Pistol
| AutoGun
| Rifle
| LtAutoGun
| HvAutoGun
| HvRifle
| MultGun Int
| SpreadGun Int
| Launcher Int
| Battery
| PortableFusion
| AutoFiringMech
| FiringMech
| TargetingModule
= TPipe
| TBigTube
| TPlate
| TMChip
| TMagnet
| TMotor
| TLED
| THardware
| TNailbox
| TPlank
| TPrism
| TLightSensor
| TSoundSensor
| THeatSensor
| TCopperWire
| TEmptyCan
| TPistol
| TAutoGun
| TRifle
| TLtAutoGun
| THvAutoGun
| THvRifle
| TMultGun Int
| TSpreadGun Int
| TLauncher Int
| TBattery
| TPortableFusion
| TAutoFiringMech
| TFiringMech
| TTargetingModule
deriving (Eq,Ord)
+2
View File
@@ -30,6 +30,7 @@ import Dodge.Data
import Dodge.Default
import Dodge.Item.Weapon
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.AutoGun
import Dodge.Item.Weapon.Bezier
import Dodge.Item.Equipment
import Dodge.Item.Consumable
@@ -158,6 +159,7 @@ startInventory :: IM.IntMap Item
startInventory = IM.fromList (zip [0..20]
(
[hvAutoGun
,pistol
,teslaGun
,blinkGun
,miniGun
+6 -2
View File
@@ -15,7 +15,9 @@ crMvBy
:: Point2 -- ^ Movement translation vector, will be made relative to creature direction
-> Creature
-> Creature
crMvBy p' cr = advanceStepCounter (magV p) $ over crPos (+.+ p) cr
crMvBy p' cr = advanceStepCounter (magV p) cr
& crPos %~ (+.+ p)
& crMvDir .~ argV p
where
p = (*.*) (equipFactor * aimingFactor) $ rotateV (_crDir cr) p'
equipFactor
@@ -31,7 +33,9 @@ crMvAbsolute
:: Point2 -- ^ Movement translation vector
-> Creature
-> Creature
crMvAbsolute p' cr = advanceStepCounter (magV p) $ over crPos (+.+ p) cr
crMvAbsolute p' cr = advanceStepCounter (magV p) cr
& crPos %~ (+.+ p)
& crMvDir .~ argV p
where
p = (*.*) (equipFactor * aimingFactor) p'
equipFactor
+1 -1
View File
@@ -9,7 +9,7 @@ import Dodge.Creature.SentinelAI
import Dodge.Creature.Rationality
import Dodge.Creature.State
--import Dodge.Creature.State.Data
import Dodge.Item.Weapon
import Dodge.Item.Weapon.AutoGun
import Dodge.Item.Consumable
--import Geometry
import Picture
+61 -14
View File
@@ -9,8 +9,11 @@ module Dodge.Creature.Picture
import Dodge.Data
--import Dodge.Creature.Stance.Data
import Dodge.Creature.State.Data
import Dodge.Creature.Stance.Data
import Dodge.Creature.Test
--import Dodge.Creature.AlertLevel.Data
import Dodge.Picture.Layer
import Dodge.Item.Data
import Picture
import Geometry
@@ -24,27 +27,16 @@ basicCrPict
-> Picture
basicCrPict col cr w = pictures $
targetingPic ++
[ tr . onLayer CrLayer . piercingMod $ bluntScale $ naked
-- , drawAwakeLevel cr
[ tr . piercingMod $ bluntScale $ naked col cr
, trFeet $ feet cr
, tr $ drawEquipment cr
]
where
targetingPic = IM.elems $ IM.mapMaybeWithKey f $ _crInv cr
f invid it = fmap ((\g -> g invid it cr w) . snd) (it ^? itTargeting . _Just)
tr = uncurry translate (_crPos cr) . rotate (_crDir cr)
trFeet = uncurry translate (_crPos cr) . rotate (_crMvDir cr)
cdir = _crDir cr
naked
| strikeMelee = color white $ circleSolid $ _crRad cr
| pdam > 200 = color red $ circleSolid $ _crRad cr
| pdam > 99 = color white $ circleSolid $ _crRad cr
| otherwise = pictures
[ translate (0.25 * crad) 0 $ circleSolid (crad * 0.5)
, scale 0.5 1 $ color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr
]
crad = _crRad cr
pastDams = _crPastDamage $ _crState cr
pdam = sum $ concatMap (map _dmAmount) pastDams
col' = light . light . light $ light col
bluntDam :: Maybe Point2
bluntDam = find isBluntDam (concat pastDams) >>= (\dm -> (-.-) <$> dm ^? dmFrom <*> dm ^? dmTo)
bluntScale = case fmap argV bluntDam of
@@ -58,9 +50,64 @@ basicCrPict col cr w = pictures $
piercingMod = case fmap argV piercingDam of
Just a -> rotate (a + cdir) . scale 0.8 1.2 . rotate (negate $ cdir + a)
_ -> id
pastDams = _crPastDamage $ _crState cr
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 _ RightForward) -> setL
[ translate (-up) off $ circleSolid 5
, translate (up) (-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
off = 5
up = 5
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
[ 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
]
| 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
]
where
aboveIt = onLayer HPtLayer
onCrL = onLayer CrLayer
twistA = negate 1
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
pdam = sum $ concatMap (map _dmAmount) pastDams
crad = _crRad cr
pastDams = _crPastDamage $ _crState cr
col' = light . light . light $ light col
--drawAwakeLevel
-- :: Creature
+1
View File
@@ -144,6 +144,7 @@ data Creature = Creature
, _crOldPos :: Point2
, _crVel :: Point2
, _crDir :: Float
, _crMvDir :: Float
, _crID :: Int
, _crPict :: Creature -> World -> Picture
, _crUpdate
+1
View File
@@ -95,6 +95,7 @@ defaultCreature = Creature
, _crOldPos = (0,0)
, _crVel = (0,0)
, _crDir = 0
, _crMvDir = 0
, _crID = 1
, _crPict = \_ _ -> onLayer CrLayer $ circleSolid 10
, _crUpdate = \ _ f cr -> (f , Just cr)
+2
View File
@@ -45,3 +45,5 @@ data AimStance
| TwoHand
| OneHand
| LeaveHolstered
deriving
(Eq,Show,Ord,Enum)
+13 -4
View File
@@ -1,25 +1,34 @@
module Dodge.Item.Draw
where
import Dodge.Data
import Dodge.Item.Data
import Dodge.Picture.Layer
import Dodge.Creature.Stance.Data
import Picture
{- |
Places an item picture onto a creature when the item is selected. -}
import qualified Data.IntMap.Strict as IM
{- | Places an item picture onto a creature when the item is selected. -}
pictureWeaponOnAim
:: Picture
-> Creature
-> Int -- ^ Position of item in inventory
-> Picture
pictureWeaponOnAim p cr posInInv
| _crInvSel cr == posInInv && _posture (_crStance cr) == Aiming
| isSelected && _posture (_crStance cr) == Aiming
&& isTwisting
= onLayer PtLayer twistWep
| isSelected && _posture (_crStance cr) == Aiming
= onLayer PtLayer drawnWep
| _crInvSel cr == posInInv
| isSelected
= onLayer PtLayer 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)
theIt = _crInv cr IM.! posInInv
isTwisting = _itAimStance theIt == TwoHandTwist
pictureItem
:: Picture
+10 -49
View File
@@ -20,6 +20,7 @@ import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.UseEffect
import Dodge.Item.Weapon.Laser
import Dodge.Item.Weapon.Shell
import Dodge.Item.Weapon.Bullet
import Dodge.Default.Weapon
import Dodge.Item.Weapon.Booster
import Dodge.Item.Weapon.Grenade
@@ -83,13 +84,6 @@ pistol = defaultGun
, _itWorldTrigger = Nothing
, _wpAmmo = basicBullet
}
basicBullet :: Ammo
basicBullet = BulletAmmo
{ _amString = "BULLET"
, _amBulEff = destroyOnImpact bulHitCr bulHitWall' bulHitFF'
, _amBulWth = 2
, _amBulVel = (30,0)
}
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
@@ -105,45 +99,6 @@ autoEffectGun name eff = defaultAutoGun
{ _itName = name ++ "Gun"
, _itUse = \_ -> eff
}
autoGun :: Item
autoGun = defaultGun
{ _itName = "AUTOGUN"
, _itIdentity = AutoGun
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 6
, _itUseTime = 0
, _itUse = \_ -> charFiringStrat
[('M',autoFireMode)
,('S',singleFireMode)
]
, _wpSpread = autogunSpread
, _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer $ color red $ pictures [polygon [(-4,-4),(-4,4),(4,4),(4,-4)]]
, _itAimingSpeed = 0.4
, _itAimingRange = 1
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim $ color red $ polygon $ rectNESW 4 4 (-4) (-4)
, _itEffect = wpRecock
, _itAttachment = Just $ ItCharMode $ Seq.fromList "MS"
, _itScrollUp = incCharMode
, _itScrollDown = decCharMode
, _itInvDisplay = basicWeaponDisplay
, _wpAmmo = basicBullet
}
autoFireMode, singleFireMode, autoGunNonTwistEff :: Creature -> World -> World
autoFireMode = shootWithSound (fromIntegral autoGunSound)
. torqueBefore 0.05
$ autoGunNonTwistEff
singleFireMode = hammerCheck $ shootWithSound (fromIntegral autoGunSound) autoGunNonTwistEff
autoGunNonTwistEff = withRecoil 40
. withRandomDir (autogunSpread/2)
. withMuzFlare
. withVelWthHiteff (50,0) 3
$ destroyOnImpact bulHitCr bulHitWall' bulHitFF'
rezGun :: Item
rezGun = defaultGun
{ _itName = "REANIMATOR"
@@ -364,11 +319,17 @@ miniGun = defaultAutoGun
. withVelWthHiteff (30,0) 2
$ destroyOnImpact bulBounceArmCr' bulHitWall' bulHitFF'
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
, _itFloorPict = onLayer FlItLayer miniGunPict
, _itAimingSpeed = 0.4
, _itAimingRange = 1
, _itEquipPict = pictureWeaponOnAim $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
, _itEquipPict = pictureWeaponOnAim miniGunPict
}
miniGunPict :: Picture
miniGunPict = pictures
[ translate 5 0 . color red $ polygon $ rectNESW 9 7 (-9) (-5)
, color red . polygon $ rectNESW 4 12 (-4) (-12)
]
spreadGun :: Item
spreadGun = defaultGun
{ _itName = "SPREAD"
@@ -1023,7 +984,7 @@ spawnGun cr = defaultGun
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 100
, _itUse = \_ -> spawnCrNextTo cr
, _itUse = \_ -> hammerCheck $ spawnCrNextTo cr
}
spawnCrNextTo
:: Creature -- ^ Creature to spawn
+68
View File
@@ -0,0 +1,68 @@
module Dodge.Item.Weapon.AutoGun
where
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Default
import Dodge.Item.Attachment
import Dodge.Item.Attachment.Data
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Data
import Dodge.Picture.Layer
import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.Synonyms
import Dodge.WorldEvent.HitEffect
import Dodge.Particle.Bullet.HitEffect
import Picture
import Geometry
import qualified Data.Sequence as Seq
autoGun :: Item
autoGun = defaultAutoGun
{ _itName = "AUTOGUN"
, _itIdentity = AutoGun
, _wpMaxAmmo = 30
, _wpLoadedAmmo = 30
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 6
, _itUseTime = 0
, _itUse = \_ -> charFiringStrat
[('M',autoFireMode)
,('S',singleFireMode)
]
, _wpSpread = autogunSpread
, _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer autoGunPict
, _itAimingSpeed = 0.4
, _itAimingRange = 1
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim autoGunPict
, _itEffect = wpRecock
, _itAttachment = Just $ ItCharMode $ Seq.fromList "MS"
, _itScrollUp = incCharMode
, _itScrollDown = decCharMode
, _itInvDisplay = basicWeaponDisplay
, _wpAmmo = basicBullet
}
autoFireMode, singleFireMode, autoGunNonTwistEff :: Creature -> World -> World
autoFireMode = shootWithSound (fromIntegral autoGunSound)
. torqueBefore 0.05
$ autoGunNonTwistEff
singleFireMode = hammerCheck $ shootWithSound (fromIntegral autoGunSound) autoGunNonTwistEff
autoGunNonTwistEff = withRecoil 40
. withRandomDir (autogunSpread/2)
. withMuzFlare
. withVelWthHiteff (50,0) 3
$ destroyOnImpact bulHitCr bulHitWall' bulHitFF'
autoGunPict :: Picture
autoGunPict = color red $ polygon $ rectNESW 4 12 (-4) (-12)
autogunSpread :: Float
autogunSpread = 0.07
+12
View File
@@ -0,0 +1,12 @@
module Dodge.Item.Weapon.Bullet
where
import Dodge.Data
import Dodge.WorldEvent.HitEffect
import Dodge.Particle.Bullet.HitEffect
basicBullet :: Ammo
basicBullet = BulletAmmo
{ _amString = "BULLET"
, _amBulEff = destroyOnImpact bulHitCr bulHitWall' bulHitFF'
, _amBulWth = 2
, _amBulVel = (30,0)
}
+1
View File
@@ -7,6 +7,7 @@ module Dodge.Room
) where
import Dodge.Data
import Dodge.Item.Weapon
import Dodge.Item.Weapon.AutoGun
import Dodge.Item.Weapon.Launcher
import Dodge.Creature
--import Dodge.Creature.Inanimate
+2 -1
View File
@@ -78,7 +78,8 @@ preloadRender = do
_ <- F.foldM (pokeShader grayscaleShad) [()] -- fix fullscreen vertex positions now
-- background shader
bgShad <- makeShader "background" [vert,geom,frag] [(0,4),(1,2)] Points pokeBGStrat
>>= addTexture "data/texture/smudgedDirt.png"
>>= addTexture "data/texture/marbleSlabs.png"
-- >>= addTexture "data/texture/smudgedDirt.png"
-- blank wallShader
wlBlank <- makeShader "wall/blank" [vert,geom,frag] [(0,4),(1,4)] Points pokeWPColStrat
-- >>= addTexture "data/texture/grayscaleDirt.png"