Move creature mass out of record
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Damage where
|
||||
|
||||
import Dodge.Creature.Mass
|
||||
import Color
|
||||
import Data.List
|
||||
import Dodge.Creature.Test
|
||||
@@ -35,9 +36,9 @@ applyDamageEffect dm de cr = case de of
|
||||
where
|
||||
pushAmount
|
||||
| dist (_crPos cr) fromDir == 0 = 0
|
||||
| otherwise = min 5 $ (push * 5 * pushRad / (dist (_crPos cr) fromDir * _crMass cr)) ** pushexp
|
||||
| otherwise = min 5 $ (push * 5 * pushRad / (dist (_crPos cr) fromDir * crMass (_crType cr))) ** pushexp
|
||||
PushBackDamage pback ->
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos .+.+~ (pback / _crMass cr) *.* (_dmTo dm -.- fromDir)
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos .+.+~ (pback / crMass (_crType cr)) *.* (_dmTo dm -.- fromDir)
|
||||
TorqueDamage rot ->
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crDir +~ rot
|
||||
NoDamageEffect -> id
|
||||
|
||||
@@ -16,7 +16,6 @@ colorLamp col h =
|
||||
{ _crHP = 100
|
||||
, _crType = LampCrit h col Nothing
|
||||
, _crRad = 3
|
||||
, _crMass = 3
|
||||
}
|
||||
|
||||
lamp :: Float -> Creature
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Creature.Mass (crMass) where
|
||||
import Dodge.Data.Creature.Misc
|
||||
|
||||
crMass :: CreatureType -> Float
|
||||
crMass = \case
|
||||
Avatar {} -> 10
|
||||
AvatarDead -> 10
|
||||
ChaseCrit -> 10
|
||||
SwarmCrit -> 2
|
||||
AutoCrit -> 10
|
||||
BarrelCrit{} -> 10
|
||||
LampCrit {} -> 3
|
||||
@@ -12,8 +12,6 @@ swarmCrit =
|
||||
defaultCreature
|
||||
{ _crHP = 1
|
||||
, _crRad = 2
|
||||
, _crMass = 2
|
||||
-- , _crCorpse = MakeDefaultCorpse
|
||||
, _crFaction = ColorFaction yellow
|
||||
, _crMeleeCooldown = 0
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ data Creature = Creature
|
||||
, _crType :: CreatureType
|
||||
, _crID :: Int
|
||||
, _crRad :: Float
|
||||
, _crMass :: Float
|
||||
-- , _crMass :: Float
|
||||
, _crHP :: Int
|
||||
, _crMaxHP :: Int
|
||||
, _crInv :: IM.IntMap Item
|
||||
|
||||
@@ -67,12 +67,7 @@ data Pulse = PulseStatus
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data CreatureType
|
||||
= Avatar
|
||||
-- { _skinHead :: Color
|
||||
-- , _skinUpper :: Color
|
||||
-- , _skinLower :: Color
|
||||
{ _avatarPulse :: Pulse
|
||||
}
|
||||
= Avatar { _avatarPulse :: Pulse }
|
||||
| AvatarDead
|
||||
| ChaseCrit
|
||||
| SwarmCrit
|
||||
|
||||
@@ -84,7 +84,7 @@ applySetTerminalString var = case key' of
|
||||
"" -> showTerminalError ("set " ++ var) ("Unable to read as argument as float: " ++ val)
|
||||
"hp" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crHP .~ round (fromJust val')
|
||||
"invcap" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
|
||||
"mass" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMass .~ fromJust val'
|
||||
-- "mass" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMass .~ fromJust val'
|
||||
"mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMvType . mvSpeed .~ fromJust val'
|
||||
_ -> showTerminalError ("set " ++ var) ("Invalid set command: " ++ key) -- never reached?
|
||||
where
|
||||
|
||||
@@ -21,7 +21,6 @@ defaultCreature =
|
||||
, _crID = 1
|
||||
, _crType = ChaseCrit
|
||||
, _crRad = 10
|
||||
, _crMass = 10
|
||||
, _crHP = 100
|
||||
, _crMaxHP = 150
|
||||
, _crInv = IM.empty
|
||||
|
||||
@@ -10,6 +10,7 @@ module Dodge.HeldUse (
|
||||
heldEffectMuzzles,
|
||||
) where
|
||||
|
||||
import Dodge.Creature.Mass
|
||||
import Dodge.Data.Muzzle
|
||||
import Dodge.Data.UseDelay
|
||||
import Dodge.Item.UseDelay
|
||||
@@ -455,7 +456,7 @@ applySoundCME itm cr = fromMaybe id $ do
|
||||
applyRecoil :: Item -> Creature -> World -> World
|
||||
applyRecoil itm cr =
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos
|
||||
+~ rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0)
|
||||
+~ rotateV (_crDir cr) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0)
|
||||
|
||||
recoilAmount :: Item -> Float
|
||||
recoilAmount itm
|
||||
@@ -559,7 +560,7 @@ applySidePush maxSide cr w =
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
push = rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr))
|
||||
push = rotateV (_crDir cr) (V2 0 (pushAmount / crMass (_crType cr)))
|
||||
(pushAmount, g) = randomR (- maxSide, maxSide) $ _randGen w
|
||||
|
||||
applyTorqueCME :: Item -> Creature -> World -> World
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@ Description : Simulation update
|
||||
-}
|
||||
module Dodge.Update (updateUniverse) where
|
||||
|
||||
import Dodge.Creature.Mass
|
||||
import Dodge.Damage
|
||||
import RandomHelp
|
||||
import Dodge.Data.CrWlID
|
||||
@@ -793,9 +794,9 @@ crCrSpring c1 c2
|
||||
vec = _crPos c1 -.- _crPos c2
|
||||
diff = magV vec
|
||||
comRad = _crRad c1 + _crRad c2
|
||||
overlap1 = ((comRad - diff) * _crMass c2 * 0.5 / massT) *.* errorNormalizeV 55 vec
|
||||
overlap2 = ((comRad - diff) * _crMass c1 * 0.5 / massT) *.* errorNormalizeV 56 vec
|
||||
massT = _crMass c1 + _crMass c2
|
||||
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec
|
||||
overlap2 = ((comRad - diff) * crMass (_crType c1) * 0.5 / massT) *.* errorNormalizeV 56 vec
|
||||
massT = crMass (_crType c1) + crMass (_crType c2)
|
||||
|
||||
updateDelayedEvents :: World -> World
|
||||
updateDelayedEvents w =
|
||||
|
||||
Reference in New Issue
Block a user