Stun turrets with electrical damage directly
This commit is contained in:
@@ -44,7 +44,7 @@ data MachineType
|
||||
| McTerminal
|
||||
| McDamSensor DamageSensor
|
||||
| McProxSensor ProximitySensor
|
||||
| McTurret {_mctTurret :: Turret}
|
||||
| McTurret {_mctTurret :: Turret, _mctTurretStun :: Int}
|
||||
| McStorage {_mcsType :: AmmoType, _mcsAmount :: Int}
|
||||
| McDistributer {_mcdStorageMachine :: Maybe Int}
|
||||
| McTrigger {_mcTriggerID :: Int}
|
||||
|
||||
@@ -1159,7 +1159,7 @@ mcShootLaser _ mc =
|
||||
shootLaser (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
|
||||
where
|
||||
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
|
||||
dir = mc ^?! mcType . _McTurret . tuDir
|
||||
dir = mc ^?! mcType . mctTurret . tuDir
|
||||
|
||||
mcShootAuto :: Item -> Machine -> World -> World
|
||||
mcShootAuto itm mc w
|
||||
|
||||
@@ -21,7 +21,7 @@ destroyMachine mc =
|
||||
|
||||
destroyMcType :: MachineType -> Machine -> World -> World
|
||||
destroyMcType mt mc w = case mt of
|
||||
McTurret tu -> fromMaybe w $ do
|
||||
McTurret tu _ -> fromMaybe w $ do
|
||||
itm <- w ^? cWorld . lWorld . items . ix (tu ^. tuWeapon)
|
||||
return $ copyItemToFloor (_mcPos mc) itm w
|
||||
McTrigger i -> w & cWorld . lWorld . triggers . ix i %~ not
|
||||
|
||||
@@ -18,7 +18,7 @@ drawMachine :: CWorld -> Machine -> SPic
|
||||
drawMachine cw mc = case _mcType mc of
|
||||
McStatic -> mempty
|
||||
McTerminal -> terminalSPic lw mc
|
||||
McTurret tu -> drawBaseMachine 20 mc <> drawTurret lw tu mc
|
||||
McTurret tu _ -> drawBaseMachine 20 mc <> drawTurret lw tu mc
|
||||
McDamSensor se -> drawBaseMachine 25 mc <> drawDamSensor gp se
|
||||
McProxSensor{} -> drawBaseMachine 25 mc
|
||||
McStorage{} -> noPic $ colorSH (mcColor mc) storageShape
|
||||
|
||||
+28
-29
@@ -5,7 +5,7 @@ module Dodge.Machine.Update (updateMachine) where
|
||||
import Control.Monad
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.List (partition)
|
||||
--import Data.List (partition)
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Base.You
|
||||
@@ -22,9 +22,7 @@ import Linear
|
||||
import Sound.Data
|
||||
|
||||
updateMachine :: Machine -> World -> World
|
||||
updateMachine mc
|
||||
= mcPlaySound mc
|
||||
. mcTypeUpdate mc (_mcType mc)
|
||||
updateMachine mc = mcPlaySound mc . mcTypeUpdate mc (_mcType mc)
|
||||
-- | _mcHP mc < 1 = destroyMachine mc
|
||||
-- | otherwise =
|
||||
-- mcApplyDamage (_mcDamage mc) mc
|
||||
@@ -35,7 +33,7 @@ mcTypeUpdate :: Machine -> MachineType -> World -> World
|
||||
mcTypeUpdate mc = \case
|
||||
McStatic -> id
|
||||
McTerminal -> terminalScreenGlow mc
|
||||
McTurret tu -> updateTurret (_tuTurnSpeed tu) mc
|
||||
McTurret tu _ -> updateTurret (_tuTurnSpeed tu) mc
|
||||
McDamSensor se -> mcDamSensorTriggerUpdate se mc . mcDamSensorUpdate se mc
|
||||
McProxSensor se -> mcProxSensorTriggerUpdate se mc . mcProxSensorUpdate se mc
|
||||
McStorage{} -> id
|
||||
@@ -57,28 +55,36 @@ terminalScreenGlow mc w = fromMaybe w $ do
|
||||
updateTurret :: Float -> Machine -> World -> World
|
||||
updateTurret rotSpeed mc w =
|
||||
w
|
||||
& dodamage
|
||||
& decreasestun
|
||||
-- & dodamage
|
||||
& mcUseItem mc
|
||||
& elecDamBranch
|
||||
where
|
||||
dodamage =
|
||||
decreasestun =
|
||||
cWorld
|
||||
. lWorld
|
||||
. machines
|
||||
. ix mcid
|
||||
%~ ( (mcDamage .~ [Electrical (min 2500 $ max 0 (elecDam - 10))])
|
||||
. (mcHP -~ dam)
|
||||
)
|
||||
. mcType
|
||||
. mctTurretStun %~ (max 0 . subtract 1)
|
||||
-- dodamage =
|
||||
-- cWorld
|
||||
-- . lWorld
|
||||
-- . machines
|
||||
-- . ix mcid
|
||||
-- %~ ( (mcDamage .~ [Electrical (min 2500 $ max 0 (elecDam - 10))])
|
||||
-- . (mcHP -~ dam)
|
||||
-- )
|
||||
elecDamBranch
|
||||
| elecDam < 10 = updateFiringStatus . doTurn
|
||||
| mc ^?! mcType . mctTurretStun < 1 = updateFiringStatus . doTurn
|
||||
| otherwise = id
|
||||
mcid = _mcID mc
|
||||
ypos = you w ^. crPos . _xy
|
||||
mcpos = _mcPos mc
|
||||
seesYou = hasLOSIndirect mcpos ypos w
|
||||
(elecDams, dams) = partition isElectrical $ _mcDamage mc
|
||||
dam = sum $ map _dmAmount dams
|
||||
elecDam = sum $ map _dmAmount elecDams
|
||||
-- (elecDams, dams) = partition isElectrical $ _mcDamage mc
|
||||
-- dam = sum $ map _dmAmount dams
|
||||
-- elecDam = sum $ map _dmAmount elecDams
|
||||
doTurn
|
||||
| seesYou =
|
||||
cWorld
|
||||
@@ -86,32 +92,32 @@ updateTurret rotSpeed mc w =
|
||||
. machines
|
||||
. ix mcid
|
||||
. mcType
|
||||
. _McTurret
|
||||
. mctTurret
|
||||
. tuDir
|
||||
%~ turnTo rotSpeed mcpos ypos
|
||||
| otherwise = id
|
||||
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
|
||||
updateFiringStatus
|
||||
| closeFireAngle =
|
||||
cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime .~ 20
|
||||
cWorld . lWorld . machines . ix mcid . mcType . mctTurret . tuFireTime .~ 20
|
||||
| otherwise =
|
||||
cWorld
|
||||
. lWorld
|
||||
. machines
|
||||
. ix mcid
|
||||
. mcType
|
||||
. _McTurret
|
||||
. mctTurret
|
||||
. tuFireTime
|
||||
%~ (max 0 . subtract 1)
|
||||
|
||||
isElectrical :: Damage -> Bool
|
||||
isElectrical dm = case dm of
|
||||
Electrical{} -> True
|
||||
_ -> False
|
||||
--isElectrical :: Damage -> Bool
|
||||
--isElectrical dm = case dm of
|
||||
-- Electrical{} -> True
|
||||
-- _ -> False
|
||||
|
||||
mcUseItem :: Machine -> World -> World
|
||||
mcUseItem mc w = fromMaybe w $ do
|
||||
tu <- mc ^? mcType . _McTurret
|
||||
tu <- mc ^? mcType . mctTurret
|
||||
let i = tu ^. tuWeapon
|
||||
it <- w ^? cWorld . lWorld . items . ix i
|
||||
hit <- it ^? itType
|
||||
@@ -165,13 +171,6 @@ mcBackgroundSound mc = case mc ^. mcType of
|
||||
McDistributer{} -> Just (lowWhirS,1)
|
||||
McTrigger{} -> Just (throb1S,0.5)
|
||||
|
||||
mcApplyDamage :: [Damage] -> Machine -> World -> World
|
||||
mcApplyDamage ds mc = case mc ^? mcType . _McDamSensor of
|
||||
Nothing -> mcpointer %~ ((mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds)))
|
||||
_ -> mcpointer . mcDamage .~ []
|
||||
where
|
||||
mcpointer = cWorld . lWorld . machines . ix (_mcID mc)
|
||||
|
||||
mcDamSensorUpdate :: DamageSensor -> Machine -> World -> World
|
||||
mcDamSensorUpdate se = senseDamage (damageTypeThreshold (se ^. sensType)) (se ^. sensType)
|
||||
|
||||
|
||||
@@ -27,16 +27,17 @@ putLasTurret rotSpeed =
|
||||
(reverse $ square 10)
|
||||
( defaultMachine
|
||||
-- & mcColor .~ blue
|
||||
& mcType .~ (lasTurret & _McTurret . tuTurnSpeed .~ rotSpeed)
|
||||
& mcType .~ (lasTurret & mctTurret . tuTurnSpeed .~ rotSpeed)
|
||||
& mcHP .~ 50000
|
||||
)
|
||||
(Just laser)
|
||||
|
||||
lasTurret :: MachineType
|
||||
lasTurret = McTurret $
|
||||
lasTurret = McTurret
|
||||
Turret
|
||||
{ _tuWeapon = 0
|
||||
, _tuTurnSpeed = 0.1
|
||||
, _tuFireTime = 0
|
||||
, _tuDir = 0
|
||||
}
|
||||
}
|
||||
0
|
||||
|
||||
@@ -48,14 +48,17 @@ damageMachine dam x mcid w = case w ^? cWorld . lWorld . machines . ix mcid of
|
||||
Just mc | Just se <- mc ^? mcType . _McDamSensor
|
||||
, sensorTypeDamages (se ^. sensType) dam
|
||||
-> (mempty,mcDamSensorUpdate' (_dmAmount dam) se mc w)
|
||||
Just mc | McTurret{} <- mc ^. mcType
|
||||
, Electrical edam <- dam
|
||||
-> (mempty, w & cWorld . lWorld . machines . ix mcid . mcType . mctTurretStun %~ (min 100 . (+ edam)))
|
||||
Just mc | _mcHP mc < x -> destroyMachine' mc w
|
||||
_ -> (mempty, w & cWorld . lWorld . machines . ix mcid . mcHP -~ x)
|
||||
|
||||
mcDamSensorUpdate' :: Int -> DamageSensor -> Machine -> World -> World
|
||||
mcDamSensorUpdate' x se = senseDamage' x (damageTypeThreshold' (se ^. sensType)) (se ^. sensType)
|
||||
mcDamSensorUpdate' x se = senseDamage' x (damageTypeThreshold' (se ^. sensType))
|
||||
|
||||
senseDamage' :: Int -> Int -> SensorType -> Machine -> World -> World
|
||||
senseDamage' x threshold dt mc =
|
||||
senseDamage' :: Int -> Int -> Machine -> World -> World
|
||||
senseDamage' x threshold mc =
|
||||
(cWorld . lWorld . machines . ix mcid %~ upmc)
|
||||
. updatels
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user