Destroying mounted lights flashes, move equipment datatype

This commit is contained in:
2022-07-13 19:45:23 +01:00
parent cede677560
commit 33e9b5b1f0
16 changed files with 118 additions and 96 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import Dodge.Base.Collide
import Dodge.Material
import Dodge.Block.Debris
import Dodge.Zone
import Dodge.LightSource
import Dodge.Wall.Zone
import Dodge.WorldEvent.Sound
import Dodge.Wall.Delete
@@ -87,7 +88,7 @@ destroyMounts mos w = foldr destroyMount w mos
destroyMount :: MountedObject -> World -> World
destroyMount mo = case mo of
MountedLS lsid -> lightSources . at lsid .~ Nothing
MountedLS lsid -> destroyLS lsid
MountedProp prid -> props . at prid .~ Nothing
stopPushing :: Maybe Int -> World -> World
+1 -1
View File
@@ -70,7 +70,7 @@ itemCombinations =
, p [o (HELD SPARKGUN),p 2 $ cr PIPE] teslaGun
, p [o $ cr TELEPORTMODULE,p 2 $ cr MICROCHIP] blinkGun
, p [o BLINKER, p 2 $ cr MICROCHIP] unsafeBlinkGun
, p [o $ LEFT BLINKER, p 2 $ cr MICROCHIP] unsafeBlinkGun
, po [cr MAGNET,cr TIN] magShield
+23 -15
View File
@@ -73,19 +73,22 @@ data ItemBaseType
| AUTOEFFGUN String
-- Weapons
| HELD {_ibtHeld :: HeldItemType}
| LEFT {_ibtLeft :: LeftItemType}
| EQUIP {_ibtEquip :: EquipItemType}
-- | GRENADE
-- | REMOTEBOMB
-- Utility items
| BOOSTER
| REWINDER
| BLINKER
| BLINKERUNSAFE
| SHRINKER
| SPAWNER
-- Equipment
| CLICKDETECTOR Detector
| AUTODETECTOR Detector
| MAGSHIELD
--
| KEYCARD Int
--
| MEDKIT Int
| CRAFT CraftType
--
deriving (Eq,Ord,Show,Read)
data EquipItemType
= MAGSHIELD
| FLAMESHIELD
| FRONTARMOUR
| WRISTARMOUR
@@ -98,12 +101,15 @@ data ItemBaseType
| JUMPLEGS
| FLATSHIELD
| JETPACK
--
| KEYCARD Int
--
| MEDKIT Int
| CRAFT CraftType
--
| AUTODETECTOR Detector
deriving (Eq,Ord,Show,Read)
data LeftItemType
= BOOSTER
| REWINDER
| BLINKER
| BLINKERUNSAFE
| SHRINKER
| SPAWNER
deriving (Eq,Ord,Show,Read)
data HeldItemType
@@ -163,6 +169,8 @@ data HeldItemType
| SHATTERGUN
| FORCEFIELDGUN
| HELDDETECTOR Detector
deriving (Eq,Ord,Show,Read)
data ItemModuleType
+1 -1
View File
@@ -184,7 +184,7 @@ movementSideEff cr w
_ -> w
| otherwise = footstepSideEffect cr w
where
hasJetPack = any (\it -> it ^? itType . iyBase == Just JETPACK) $ _crInv cr
hasJetPack = any (\it -> it ^? itType . iyBase == Just (EQUIP JETPACK)) $ _crInv cr
oldPos = _crOldPos cr
momentum' = 0.97 *.* (_crPos cr -.- _crOldPos cr)
momentum'' | magV momentum' > 3 = 3 *.* normalizeV momentum'
+2 -2
View File
@@ -21,8 +21,8 @@ strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
equipmentStrValue :: Item -> Int
equipmentStrValue itm = case _iyBase $ _itType itm of
FRONTARMOUR -> negate 3
POWERLEGS -> 3
EQUIP FRONTARMOUR -> negate 3
EQUIP POWERLEGS -> 3
_ -> 0
crCurrentEquipment :: Creature -> IM.IntMap Item
+1 -1
View File
@@ -100,7 +100,7 @@ hasFrontArmour :: Point2 -> Creature -> Bool
hasFrontArmour p cr = fromMaybe False $ do
invid <- cr ^? crEquipment . ix OnChest
ittype <- cr ^? crInv . ix invid . itType . iyBase
return $ FRONTARMOUR == ittype
return $ EQUIP FRONTARMOUR == ittype
&& p /= _crOldPos cr
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi/2
-- even though angleVV can generate NaN, the comparison seems to deal with it
+22 -34
View File
@@ -23,18 +23,16 @@ itemFromBase ibt = case ibt of
AUTOEFFGUN _ -> undefined
-- Weapons
HELD ht -> itemFromHeldType ht
LEFT lt -> itemFromLeftType lt
EQUIP et -> itemFromEquipType et
--GRENADE
--REMOTEBOMB
-- Utility items
BOOSTER -> boosterGun
REWINDER -> rewindGun
BLINKER -> blinkGun
BLINKERUNSAFE -> unsafeBlinkGun
SHRINKER -> shrinkGun
SPAWNER -> error "need to datify creatures first"
-- Equipment
CLICKDETECTOR d -> clickDetector d
AUTODETECTOR d -> autoDetector d
CRAFT cr -> makeTypeCraft cr
KEYCARD i -> keyCard i
MEDKIT i -> medkit i
itemFromEquipType :: EquipItemType -> Item
itemFromEquipType et = case et of
MAGSHIELD -> magShield
FLAMESHIELD -> flameShield
FRONTARMOUR -> frontArmour
@@ -49,9 +47,16 @@ itemFromBase ibt = case ibt of
JUMPLEGS -> jumpLegs
FLATSHIELD -> flatShield
JETPACK -> jetPack
CRAFT cr -> makeTypeCraft cr
KEYCARD i -> keyCard i
MEDKIT i -> medkit i
AUTODETECTOR d -> autoDetector d
itemFromLeftType :: LeftItemType -> Item
itemFromLeftType lt = case lt of
BOOSTER -> boosterGun
REWINDER -> rewindGun
BLINKER -> blinkGun
BLINKERUNSAFE -> unsafeBlinkGun
SHRINKER -> shrinkGun
SPAWNER -> error "need to datify creatures first"
-- Equipment
itemFromHeldType :: HeldItemType -> Item
itemFromHeldType ht = case ht of
SHATTERGUN -> shatterGun
@@ -109,34 +114,17 @@ itemFromHeldType ht = case ht of
POISONSPRAYER -> poisonSprayer
DRONELAUNCHER -> droneLauncher
FORCEFIELDGUN -> forceFieldGun
HELDDETECTOR d -> clickDetector d
baseToFamily :: ItemBaseType -> ItemFamily
baseToFamily ibt = case ibt of
NOTDEFINED -> undefined
EFFGUN _ -> undefined
AUTOEFFGUN _ -> undefined
HELD _ -> HeldFamily
BOOSTER -> LeftClickFamily
REWINDER -> LeftClickFamily
BLINKER -> LeftClickFamily
BLINKERUNSAFE -> LeftClickFamily
SHRINKER -> LeftClickFamily
SPAWNER -> LeftClickFamily
CLICKDETECTOR _ -> HeldFamily
AUTODETECTOR _ -> LeftClickFamily
MAGSHIELD -> EquipmentFamily
FLAMESHIELD -> EquipmentFamily
FRONTARMOUR -> EquipmentFamily
WRISTARMOUR -> EquipmentFamily
INVISIBILITYEQUIPMENT _ -> EquipmentFamily
BRAINHAT -> EquipmentFamily
HEADLAMP -> EquipmentFamily
HEADLAMP1 -> EquipmentFamily
POWERLEGS -> EquipmentFamily
SPEEDLEGS -> EquipmentFamily
JUMPLEGS -> EquipmentFamily
FLATSHIELD -> EquipmentFamily
JETPACK -> EquipmentFamily
CRAFT _ -> CraftingFamily
LEFT _ -> LeftClickFamily
EQUIP _ -> EquipmentFamily
CRAFT _ -> CraftingFamily
KEYCARD _ -> HeldFamily
+16 -14
View File
@@ -13,19 +13,21 @@ import Data.Maybe
itemSPic :: Item -> SPic
itemSPic it = modulesSPic it <> case it ^. itType . iyBase of
HELD ht -> heldItemSPic ht it
LEFT lt -> leftItemSPic lt it
EQUIP et -> equipItemSPic et it
NOTDEFINED -> defSPic
EFFGUN _ -> defSPic
AUTOEFFGUN _ -> defSPic
BOOSTER -> defSPic
REWINDER -> defSPic
BLINKER -> defSPic
BLINKERUNSAFE -> defSPic
SHRINKER -> defSPic
SPAWNER -> defSPic
--
CLICKDETECTOR dt -> (noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2))
AUTODETECTOR dt -> (noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2))
--
KEYCARD _ -> noShape (setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic)
--
MEDKIT _ -> defSPic
CRAFT _ -> defSPic
equipItemSPic :: EquipItemType -> Item -> SPic
equipItemSPic et _ = case et of
MAGSHIELD -> defSPic
FLAMESHIELD -> defSPic
FRONTARMOUR -> (emptySH , setDepth 20 $ pictures
@@ -44,12 +46,11 @@ itemSPic it = modulesSPic it <> case it ^. itType . iyBase of
JETPACK -> ((,) emptySH $ setDepth 20
$ pictures [color yellow $ polygon $ reverse $ rectNSWE 5 (-5) (-11) (-3) ]
)
--
KEYCARD _ -> noShape (setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic)
--
MEDKIT _ -> defSPic
CRAFT _ -> defSPic
AUTODETECTOR dt -> (noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2))
leftItemSPic :: LeftItemType -> Item -> SPic
leftItemSPic lt _ = case lt of
BLINKER -> defSPic
_ -> defSPic
heldItemSPic :: HeldItemType -> Item -> SPic
heldItemSPic ht it = case ht of
FORCEFIELDGUN -> defSPic
@@ -98,6 +99,7 @@ heldItemSPic ht it = case ht of
POISONSPRAYER -> flamerPic it
DRONELAUNCHER -> defSPic
SHATTERGUN -> shatterGunSPic
HELDDETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
modulesSPic :: Item -> SPic
modulesSPic _ = mempty
+13 -13
View File
@@ -38,7 +38,7 @@ magShield = defaultEquipment
}
& itUse . eqEq . eqUse .~ useMagShield
& itUse . eqEq . eqSite .~ GoesOnWrist
& itType . iyBase .~ MAGSHIELD
& itType . iyBase .~ EQUIP MAGSHIELD
useMagShield :: Item -> Creature -> World -> World
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
where
@@ -57,14 +57,14 @@ flameShield :: Item
flameShield = defaultEquipment
{ _itID = Nothing
} & itUse . eqEq . eqSite .~ GoesOnChest
& itType . iyBase .~ FLAMESHIELD
& itType . iyBase .~ EQUIP FLAMESHIELD
{- | Slows you down, blocks forward projectiles. -}
frontArmour :: Item
frontArmour = defaultEquipment
{ _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnChest
& itType . iyBase .~ FRONTARMOUR
& itType . iyBase .~ EQUIP FRONTARMOUR
wristArmour :: Item
wristArmour = defaultEquipment
@@ -74,7 +74,7 @@ wristArmour = defaultEquipment
& itUse . eqEq . eqOnEquip .~ onEquipWristShield
& itUse . eqEq . eqUse .~ setWristShieldPos
& itUse . eqEq . eqOnRemove .~ onRemoveWristShield
& itType . iyBase .~ WRISTARMOUR
& itType . iyBase .~ EQUIP WRISTARMOUR
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w = w
@@ -128,7 +128,7 @@ flatShield = defaultEquipment
}
, _itInvSize = 3
}
& itType . iyBase .~ FLATSHIELD
& itType . iyBase .~ EQUIP FLATSHIELD
shieldWall :: Int -> Wall
shieldWall crid = defaultWall
@@ -196,7 +196,7 @@ jetPack = defaultEquipment
{ _itEffect = NoItEffect
, _itID = Nothing
} & itUse . eqEq . eqSite .~ GoesOnBack
& itType . iyBase .~ JETPACK
& itType . iyBase .~ EQUIP JETPACK
brainHat :: Item
brainHat = defaultEquipment
@@ -204,7 +204,7 @@ brainHat = defaultEquipment
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ BRAINHAT
& itType . iyBase .~ EQUIP BRAINHAT
headLamp1 :: Item
headLamp1 = defaultEquipment
@@ -213,7 +213,7 @@ headLamp1 = defaultEquipment
}
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ HEADLAMP1
& itType . iyBase .~ EQUIP HEADLAMP1
headLamp :: Item
headLamp = defaultEquipment
{ _itEffect = NoItEffect
@@ -221,7 +221,7 @@ headLamp = defaultEquipment
}
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ HEADLAMP
& itType . iyBase .~ EQUIP HEADLAMP
createHeadLamp :: Item -> Creature -> World -> World
@@ -234,13 +234,13 @@ powerLegs = defaultEquipment
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnLegs
& itType . iyBase .~ POWERLEGS
& itType . iyBase .~ EQUIP POWERLEGS
speedLegs :: Item
speedLegs = powerLegs
& itType . iyBase .~ SPEEDLEGS
& itType . iyBase .~ EQUIP SPEEDLEGS
jumpLegs :: Item
jumpLegs = powerLegs
& itType . iyBase .~ JUMPLEGS
& itType . iyBase .~ EQUIP JUMPLEGS
wristInvisibility :: Item
wristInvisibility = defaultEquipment
@@ -249,7 +249,7 @@ wristInvisibility = defaultEquipment
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqEq . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
& itType . iyBase .~ INVISIBILITYEQUIPMENT GoesOnWrist
& itType . iyBase .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
overCID f _ cr = creatures . ix (_crID cr) %~ f
+1 -1
View File
@@ -115,7 +115,7 @@ boosterGun = defaultLeftItem
, _itUse = luseInstantNoH $ boostSelfL 10
, _itEffect = resetAttachmentID
}
& itType . iyBase .~ BOOSTER
& itType . iyBase .~ LEFT BOOSTER
resetAttachmentID :: ItEffect
resetAttachmentID = ItInvEffect f 0
where
+2 -2
View File
@@ -22,7 +22,7 @@ clickDetector dt = defaultWeapon
]
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
& itType . iyBase .~ CLICKDETECTOR dt
& itType . iyBase .~ HELD (HELDDETECTOR dt)
autoDetector :: Detector -> Item
autoDetector dt = defaultEquipment
@@ -30,7 +30,7 @@ autoDetector dt = defaultEquipment
& itUse . eqEq . eqUse .~ autoEffect (detectorEffect dt) 100 click1S
& itUse . eqEq . eqParams .~ EquipCounter 0
& itUse . eqEq . eqViewDist ?~ 350
& itType . iyBase .~ AUTODETECTOR dt
& itType . iyBase .~ EQUIP (AUTODETECTOR dt)
-- , _itEffect = autoRadarEffect
detectorEffect :: Detector -> Item -> Creature -> World -> World
+1 -1
View File
@@ -22,7 +22,7 @@ spawnGun cr = defaultWeapon
[ ammoCheckI
, hammerCheckI
]
& itType . iyBase .~ SPAWNER
& itType . iyBase .~ LEFT SPAWNER
spawnCrNextTo
:: Creature -- ^ Creature to spawn
-> Creature -- ^ existing creature that will be spawned next to
+4 -4
View File
@@ -33,7 +33,7 @@ rewindGun = defaultLeftItem
& lUse .~ useRewindGun
& eqEq . eqSite .~ GoesOnChest
}
& itType . iyBase .~ REWINDER
& itType . iyBase .~ LEFT REWINDER
rewindEffect :: Item -> Creature -> World -> World
rewindEffect itm cr w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
@@ -68,7 +68,7 @@ shrinkGun = defaultLeftItem
-- , _itFloorPict = shrinkGunPic
, _itAttachment = AttachBool True
}
& itType . iyBase .~ SHRINKER
& itType . iyBase .~ LEFT SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
@@ -94,11 +94,11 @@ blinkGun = defaultLeftItem
& eqEq . eqSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
& itType . iyBase .~ BLINKER
& itType . iyBase .~ LEFT BLINKER
unsafeBlinkGun :: Item
unsafeBlinkGun = blinkGun
& itType . iyBase .~ BLINKERUNSAFE
& itType . iyBase .~ LEFT BLINKERUNSAFE
& itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . eqEq . eqViewDist ?~ 400
+22
View File
@@ -10,11 +10,16 @@ module Dodge.LightSource
, lsPosRad
, lsColPosID
, makeTlsTimeRadColPos
, destroyLS
) where
import Dodge.Data
import Geometry.Data
import Geometry.Vector
import Geometry.Vector3D
import Dodge.Default.LightSource
import LensHelp
import Dodge.WorldEvent.Sound
import Dodge.Material
lsPosRad :: Point3 -> Float -> LightSource
lsPosRad = lsColPosRad 0.75
@@ -85,3 +90,20 @@ tlsTimeRadColPos t rmax col (V3 x y z) = TLS
makeTlsTimeRadColPos :: Int -> Float -> Point3 -> Point3 -> World -> World
makeTlsTimeRadColPos i rad (V3 r g b) p = tempLightSources .:~ tlsTimeRadColPos i rad (V3 r g b) p
destroyLS :: Int -> World -> World
destroyLS lsid w = w
& lightSources . at lsid .~ Nothing
& destroyLSFlashAt p3
& originsIDsAt [MaterialSound Glass n | n <- [0,1,2]] (destroyMatS Glass) (xyV3 p3)
where
ls = w ^?! lightSources . ix lsid
p3 = _lsPos $ _lsParam ls
destroyLSFlashAt :: Point3 -> World -> World
destroyLSFlashAt (V3 x' y' z') = tempLightSources .:~ tlsTimeRadFunPos 20 150 intensityFunc (addZ z' p)
where
p = V2 x' y'
intensityFunc x
| x < 10 = 1 / (10 - fromIntegral x)
| otherwise = 1
+6 -6
View File
@@ -19,22 +19,22 @@ bossKeyItems = [(return . cleatOnward <$> bossRoom autoCrit, takeOne [HELD PISTO
lockRoomMultiItems :: RandomGen g => [ ( State g (MetaTree Room String) , State g [ItemBaseType] ) ]
lockRoomMultiItems =
[ (blinkAcrossChallenge, takeOne [[BLINKERUNSAFE,AUTODETECTOR WALLDETECTOR]
,[BLINKERUNSAFE,CLICKDETECTOR WALLDETECTOR]
[ (blinkAcrossChallenge, takeOne [[LEFT BLINKERUNSAFE,EQUIP $ AUTODETECTOR WALLDETECTOR]
,[LEFT BLINKERUNSAFE,HELD $ HELDDETECTOR WALLDETECTOR]
]
)
]
lockRoomKeyItems :: RandomGen g => [ (Int -> State g (MetaTree Room String) , State g ItemBaseType ) ]
lockRoomKeyItems =
[(lasCenSensEdge, takeOne [HELD LAUNCHER,HELD LASGUN,HELD SPARKGUN,FLATSHIELD,HELD FORCEFIELDGUN] )
[(lasCenSensEdge, takeOne [HELD LAUNCHER,HELD LASGUN,HELD SPARKGUN,EQUIP FLATSHIELD,HELD FORCEFIELDGUN] )
,(sensorRoomRunPast ELECTRICAL, takeOne [CRAFT STATICMODULE,HELD SPARKGUN] )
,(sensorRoomRunPast FLAMING, takeOne [HELD FLAMESPITTER, CRAFT INCENDIARYMODULE] )
,(sensorRoomRunPast LASERING, return $ HELD LASGUN )
,(const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
,(const longRoomRunPast, takeOne [HELD SNIPERRIFLE,FLATSHIELD])
,(const longRoomRunPast, takeOne [HELD SNIPERRIFLE,EQUIP FLATSHIELD])
,(const glassLessonRunPast, takeOne [HELD LASGUN])
,(const $ lasTunnelRunPast 400, takeOne [FLATSHIELD,HELD FORCEFIELDGUN])
,(const $ lasTunnelRunPast 400, takeOne [EQUIP FLATSHIELD,HELD FORCEFIELDGUN])
,(keyCardRoomRunPast 0, return (KEYCARD 0))
]
keyCardRunPastRand :: RandomGen g => [ (Int -> State g (MetaTree Room String) , State g ItemBaseType ) ]
@@ -63,7 +63,7 @@ itemRooms =
[rc $ map makeTypeCraft [LIGHTER,PUMP,CAN]
]
)
, (FLATSHIELD , join $ takeOne
, (EQUIP FLATSHIELD , join $ takeOne
[rc $ map makeTypeCraft [PLATE,PLATE]
,rc $ map makeTypeCraft [DRUM,DRUM,PLATE]
]
+1
View File
@@ -45,6 +45,7 @@ flareCircleAt col alphax tranv = flares .:~ CircFlare
, _flareTran3 = tranv
}
explosionFlashAt :: Point2 -> World -> World
explosionFlashAt p = tempLightSources .:~ tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p)
where