Add destroyable lighting

This commit is contained in:
2021-03-27 11:59:34 +01:00
parent 151fa5b6bd
commit 2897c65e9e
7 changed files with 135 additions and 143 deletions
+6 -105
View File
@@ -1,4 +1,8 @@
module Dodge.Creature where
module Dodge.Creature
( module Dodge.Creature
, module Dodge.Creature.Inanimate
)
where
-- imports {{{
import Dodge.Data
import Dodge.AIs
@@ -9,6 +13,7 @@ import Dodge.Item.Weapon
import Dodge.Item.Consumable
import Dodge.WorldEvent.Cloud
import Dodge.Creature.YourControl
import Dodge.Creature.Inanimate
import Picture
import Geometry
@@ -31,42 +36,9 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.Map as M
import Foreign.ForeignPtr
import Control.Concurrent
---}
--colouredEnemy col = pictures [color (greyN 0.8) $ circleSolid 10, color col $ circLine 10]
colouredEnemy col = pictures [color col $ circleSolid 10, circLine 10]
-- armouredSwarmCrit :: Int -> Creature
-- armouredSwarmCrit n = (defaultCreature n)
-- -- { _crUpdate = encircleAI' n
-- { _crUpdate = swarmAI lineOrth n
-- , _crHP = 30
-- , _crPict = equipOnTop goalPict
-- , _crState = defaultState {_goals = [[]], _faction = EncircleFlock}
-- , _crInv = IM.fromList [(0,frontArmour)]
-- }
--
-- swarmCrit :: Int -> Creature
-- swarmCrit n = (defaultCreature n)
-- -- { _crUpdate = encircleAI' n
-- { _crUpdate = swarmAI lineOrth n
-- , _crHP = 30
-- , _crPict = equipOnTop goalPict
-- , _crState = defaultState {_goals = [[]], _faction = EncircleFlock}
-- , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
-- }
--
-- encircleCrit :: Int -> Creature
-- encircleCrit n = (defaultCreature n)
-- -- { _crUpdate = encircleAI' n
-- { _crUpdate = swarmAI lineOrth n
-- , _crHP = 30
-- , _crPict = equipOnTop goalPict
-- , _crState = defaultState {_goals = [[]], _faction = EncircleFlock}
-- , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
-- }
--
spawnerCrit :: Creature
spawnerCrit = defaultCreature
{ _crUpdate = stateUpdate $ spawnerAI chaseCrit
@@ -76,22 +48,11 @@ spawnerCrit = defaultCreature
}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
}
--
-- guardMelee :: Int -> Creature
-- guardMelee n = (defaultCreature n)
-- { _crUpdate = meleeAI' n
-- , _crHP = 30
-- , _crPict = equipOnTop goalPict
-- , _crState = defaultState {_goals = [[InitGuard]]
-- ,_faction = ChaseCritters}
-- , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
-- }
smallChaseCrit :: Creature
smallChaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI
, _crHP = 1
, _crRad = 4
--, _crPict = equipOnTop goalPict
, _crPict = enemyPict green
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters}
@@ -102,12 +63,10 @@ chaseCrit :: Creature
chaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI
, _crHP = 300
-- , _crPict = goalPict -- enemyPict green
, _crPict = enemyPict green
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters}
, _crInv = IM.empty
-- IM.fromList [(0,frontArmour)]
}
armourChaseCrit :: Creature
armourChaseCrit = defaultCreature
@@ -120,78 +79,60 @@ armourChaseCrit = defaultCreature
miniGunCrit :: Creature
miniGunCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate miniAI
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,miniGun)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[InitGuard]]}
, _crHP = 500
}
longCrit :: Creature
longCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate sniperAI
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,longGun),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[InitGuard]]}
, _crHP = 300
}
multGunCrit :: Creature
multGunCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate (twitchMissAI 300 350)
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,multGun),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[InitGuard]]}
, _crHP = 300
}
launcherCrit :: Creature
launcherCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate (launcherAI 150 200)
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,launcher),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[Init]]}
, _crHP = 300
}
spreadGunCrit :: Creature
spreadGunCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate chargeAI
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,spreadGun),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[Init]]}
, _crHP = 300
}
pistolCrit :: Creature
pistolCrit = defaultCreature
{ _crPict = enemyPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate (dodgeAI 150 200)
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
, _crInv = IM.fromList [(0,pistol),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
--, _crState = ShooterWait
, _crState = defaultState {_goals = [[InitGuard]]}
, _crHP = 500
}
@@ -212,46 +153,6 @@ addArmour :: Creature -> Creature
addArmour = over crInv insarmour
where insarmour xs = IM.insert i frontArmour xs
where i = newKey xs
--closeShooterCrit :: Int -> Creature
--closeShooterCrit n = (defaultCreature n)
-- { _crPos = startPos
-- , _crPict = equipOnTop goalPict
-- , _crUpdate = closeShooterAI n
-- , _crInv = IM.fromList [(0,ltAutoGun)]
-- , _crInvSel = 0
-- , _crRad = 10
-- , _crState = defaultState {_goals = [[InitGuard]]}
-- , _crHP = 50
-- }
-- where startPos = (20*fromIntegral n-550,0)
barrel :: Creature
barrel = defaultCreature
{ _crUpdate = updateBarrel
, _crHP = 500
, _crPict = \ _ -> onLayer CrLayer $ pictures [ color orange $ circleSolid 10
, color (greyN 0.5) $ circleSolid 8
]
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters
,_crSpState = Barrel []
}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
}
explosiveBarrel :: Creature
explosiveBarrel = defaultCreature
{ _crUpdate = updateExpBarrel
, _crHP = 400
, _crPict = \ _ -> onLayer CrLayer $ pictures [ color orange $ circleSolid 10
, color red $ circleSolid 8
]
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters
,_crSpState = Barrel []
,_crApplyDamage = \_ c -> (id, c)
}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
}
equipOnTop :: (Creature -> Picture) -> Creature -> Picture
--equipOnTop f cr = onLayer CrLayer $ pictures $ fst (drawEquipment cr) ++ [f cr] ++ snd (drawEquipment cr)