Cleanup creature update slightly, add show instance for impulses
This commit is contained in:
@@ -34,7 +34,7 @@ tryMeleeAttack cr tcr
|
||||
| _crMeleeCooldown cr == 0
|
||||
&& dist (_crPos tcr) cpos < _crRad cr + _crRad tcr + 5
|
||||
&& abs (_crDir cr - argV (_crPos tcr -.- cpos)) < pi/4
|
||||
= cr & crActionPlan . crImpulse .~ [Melee $ _crID tcr]
|
||||
= cr & crActionPlan . crImpulse .~ [Melee $ _crID tcr]
|
||||
| otherwise = cr
|
||||
where
|
||||
cpos = _crPos cr
|
||||
@@ -59,27 +59,27 @@ setTargetMv targFunc w cr = maybe
|
||||
(\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
|
||||
(targFunc w cr)
|
||||
|
||||
-- fugly
|
||||
-- ugly
|
||||
flockACC :: World -> Creature -> Creature
|
||||
flockACC w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Nothing -> cr
|
||||
Just tcr ->
|
||||
let tpos = _crPos tcr
|
||||
cpos = _crPos cr
|
||||
isFarACC cr' = _crGroup cr' == _crGroup cr
|
||||
&& _crID cr' /= _crID cr
|
||||
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||
nearACCs = IM.filter isFarACC $ creaturesNearPointI 5 cpos w
|
||||
macr = safeMinimumOn (dist cpos . _crPos) nearACCs
|
||||
in case macr of
|
||||
Nothing -> cr
|
||||
Just acr ->
|
||||
let r = _crRad acr + _crRad cr + 10
|
||||
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||
horShift = if isLHS tpos cpos (_crPos acr)
|
||||
then r *.* horDir
|
||||
else negate r *.* horDir
|
||||
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
||||
Nothing -> cr
|
||||
Just tcr ->
|
||||
let tpos = _crPos tcr
|
||||
cpos = _crPos cr
|
||||
isFarACC cr' = _crGroup cr' == _crGroup cr
|
||||
&& _crID cr' /= _crID cr
|
||||
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||
nearACCs = IM.filter isFarACC $ creaturesNearPointI 5 cpos w
|
||||
macr = safeMinimumOn (dist cpos . _crPos) nearACCs
|
||||
in case macr of
|
||||
Nothing -> cr
|
||||
Just acr ->
|
||||
let r = _crRad acr + _crRad cr + 10
|
||||
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||
horShift = if isLHS tpos cpos (_crPos acr)
|
||||
then r *.* horDir
|
||||
else negate r *.* horDir
|
||||
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
|
||||
|
||||
goToTarget :: World -> Creature -> Creature
|
||||
goToTarget w cr =
|
||||
|
||||
Reference in New Issue
Block a user