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