From c16c09a9cea7b5548cb8259aec694a62f4207c17 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 5 Sep 2021 11:24:15 +0100 Subject: [PATCH] Move creature speed parameters into explicit data --- src/Dodge/Creature/ArmourChase.hs | 10 +++++++++- src/Dodge/Creature/ChaseCrit.hs | 8 ++++++++ src/Dodge/Creature/Picture.hs | 20 ++++++++++---------- src/Dodge/Creature/ReaderUpdate.hs | 17 +++++++++-------- src/Dodge/Data.hs | 8 ++++++++ src/Dodge/Default.hs | 1 + 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/Dodge/Creature/ArmourChase.hs b/src/Dodge/Creature/ArmourChase.hs index 349447f17..88a84c910 100644 --- a/src/Dodge/Creature/ArmourChase.hs +++ b/src/Dodge/Creature/ArmourChase.hs @@ -42,7 +42,15 @@ armourChaseCrit = defaultCreature ] , _crMeleeCooldown = 0 , _crGroup = ShieldGroup - } + , _crMvType = ChaseMvType + { _chaseSpeed = 2.5 + , _chaseTurnRad = f + , _chaseTurnJit = 0.2 + } + } + where + f x | x > pi / 4 = 0.2 + | otherwise = 0.05 flockACCR :: Creature -> Reader World Creature flockACCR = reader . flockACC diff --git a/src/Dodge/Creature/ChaseCrit.hs b/src/Dodge/Creature/ChaseCrit.hs index 8230ca6a6..3f379ca67 100644 --- a/src/Dodge/Creature/ChaseCrit.hs +++ b/src/Dodge/Creature/ChaseCrit.hs @@ -48,4 +48,12 @@ chaseCrit = defaultCreature , _crInv = IM.fromList [(0,medkit 200)] , _crMeleeCooldown = 0 , _crFaction = ColorFaction green + , _crMvType = ChaseMvType + { _chaseSpeed = 2.5 + , _chaseTurnRad = f + , _chaseTurnJit = 0.2 + } } + where + f x | x > pi / 4 = 0.2 + | otherwise = 0.05 diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index 3aaa7e964..f31254baf 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -145,16 +145,16 @@ upperBody col cr = color (light4 col) $ pictures , shoulderH $ torso cr ] -naked :: Color -> Creature -> Picture -naked _ cr - | strikeMelee = shoulderH . color white $ circleSolid $ _crRad cr - | pdam > 200 = shoulderH . color red $ circleSolid $ _crRad cr - | pdam > 99 = shoulderH . color white $ circleSolid $ _crRad cr - | otherwise = [] - where - strikeMelee = _crMeleeCooldown cr > 5 - pdam = sum $ concatMap (map _dmAmount) pastDams - pastDams = _crPastDamage $ _crState cr +--naked :: Color -> Creature -> Picture +--naked _ cr +-- | strikeMelee = shoulderH . color white $ circleSolid $ _crRad cr +-- | pdam > 200 = shoulderH . color red $ circleSolid $ _crRad cr +-- | pdam > 99 = shoulderH . color white $ circleSolid $ _crRad cr +-- | otherwise = [] +-- where +-- strikeMelee = _crMeleeCooldown cr > 5 +-- pdam = sum $ concatMap (map _dmAmount) pastDams +-- pastDams = _crPastDamage $ _crState cr shoulderH :: Picture -> Picture shoulderH = setDepth 20 diff --git a/src/Dodge/Creature/ReaderUpdate.hs b/src/Dodge/Creature/ReaderUpdate.hs index cbe080bbc..59d5f2321 100644 --- a/src/Dodge/Creature/ReaderUpdate.hs +++ b/src/Dodge/Creature/ReaderUpdate.hs @@ -41,17 +41,18 @@ chaseTargetR targFunc cr = reader $ \w -> case targFunc cr w of Just crTarg -> cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg chaseTarg :: Creature -> Creature -> [Impulse] -chaseTarg cr crT - | dist tpos cpos < combinedRad + 5 - && abs (_crDir cr - argV (tpos -.- cpos)) < pi/4 - = [ TurnToward tpos 0.05 ] - | abs (_crDir cr - argV (tpos -.- cpos)) < pi/4 - = [MoveForward 2.5 , TurnToward tpos 0.2, RandomTurn 0.2 ] - | otherwise = [MoveForward 2.5 , TurnToward tpos 0.05, RandomTurn 0.2 ] +chaseTarg cr crT = [MoveForward speed, TurnToward tpos (trad dirOffset), RandomTurn jit] where cpos = _crPos cr tpos = _crPos crT - combinedRad = _crRad cr + _crRad crT + mvType = _crMvType cr + speed = _chaseSpeed mvType + trad = _chaseTurnRad mvType + jit = _chaseTurnJit mvType + dirOffset = abs (_crDir cr - argV (tpos -.- cpos)) +-- | abs (_crDir cr - argV (tpos -.- cpos)) < pi/4 +-- = [MoveForward 2.5 , TurnToward tpos 0.2, RandomTurn 0.2 ] +-- | otherwise = [MoveForward 2.5 , TurnToward tpos 0.05, RandomTurn 0.2 ] doStrategyActionsR :: Creature diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 40c2832a5..bf4e1917e 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -220,7 +220,15 @@ data Creature = Creature , _crFaction :: Faction , _crGroup :: CrGroup , _crTarget :: Maybe Creature + , _crMvType :: CrMvType } +data CrMvType + = DefCrMvType + | ChaseMvType + { _chaseSpeed :: Float + , _chaseTurnRad :: Float -> Float + , _chaseTurnJit :: Float + } data WorldState = DoorNumOpen Int | CrNumAlive Int diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index ac33edf00..3969b073e 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -56,6 +56,7 @@ defaultCreature = Creature , _crFaction = NoFaction , _crTarget = Nothing , _crGroup = LoneWolf + , _crMvType = DefCrMvType } defaultState :: CreatureState defaultState = CrSt