Allow bees to target chase crits
This commit is contained in:
@@ -120,16 +120,16 @@ creatureTurnToward p turnSpeed cr
|
|||||||
vToTarg = p -.- cr ^. crPos . _xy
|
vToTarg = p -.- cr ^. crPos . _xy
|
||||||
dirToTarget = argV vToTarg
|
dirToTarget = argV vToTarg
|
||||||
|
|
||||||
|
-- I feel like this is inefficient
|
||||||
mvTurnToward :: Point2 -> Float -> Creature -> Creature
|
mvTurnToward :: Point2 -> Float -> Creature -> Creature
|
||||||
mvTurnToward p' turnSpeed cr
|
mvTurnToward p' turnSpeed cr
|
||||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
||||||
-- | errorAngleVV 3 vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed =
|
|
||||||
| angleVV vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed =
|
| angleVV vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed =
|
||||||
cr & crDir .~ dirToTarget
|
cr & crDir .~ dirToTarget
|
||||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
||||||
| otherwise = cr & crDir -~ turnSpeed
|
| otherwise = cr & crDir -~ turnSpeed
|
||||||
where
|
where
|
||||||
-- when flying, inertia is high enough that overturning can be usefull
|
-- when flying, inertia is high enough that overturning can be useful
|
||||||
p | Flying {} <- cr ^. crStance . carriage
|
p | Flying {} <- cr ^. crStance . carriage
|
||||||
= let v = flyInertia cr *^ (cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy)
|
= let v = flyInertia cr *^ (cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy)
|
||||||
-- u = normalize $ vNormal $ p' - cxy
|
-- u = normalize $ vNormal $ p' - cxy
|
||||||
@@ -137,5 +137,5 @@ mvTurnToward p' turnSpeed cr
|
|||||||
in p' - v
|
in p' - v
|
||||||
| otherwise = p'
|
| otherwise = p'
|
||||||
cxy = cr ^. crPos . _xy
|
cxy = cr ^. crPos . _xy
|
||||||
vToTarg = p -.- cr ^. crPos . _xy
|
vToTarg = p -.- cxy
|
||||||
dirToTarget = argV vToTarg
|
dirToTarget = argV vToTarg
|
||||||
|
|||||||
@@ -138,8 +138,13 @@ updateAggroBee cr cid w
|
|||||||
vdir = unitVectorAtAngle (cr ^. crDir)
|
vdir = unitVectorAtAngle (cr ^. crDir)
|
||||||
cxy = cr ^. crPos . _xy
|
cxy = cr ^. crPos . _xy
|
||||||
tocr = cWorld . lWorld . creatures . ix cid
|
tocr = cWorld . lWorld . creatures . ix cid
|
||||||
istarget tcr = tcr ^. crID == 0
|
istarget tcr = t (tcr ^. crType)
|
||||||
|
&& isJust (tcr ^? crHP . _HP)
|
||||||
&& hasLOS cxy (tcr ^. crPos . _xy) w
|
&& hasLOS cxy (tcr ^. crPos . _xy) w
|
||||||
|
t = \case
|
||||||
|
Avatar{} -> True
|
||||||
|
ChaseCrit{} -> True
|
||||||
|
_ -> False
|
||||||
|
|
||||||
-- do bees need to be able to see slime targets?
|
-- do bees need to be able to see slime targets?
|
||||||
-- if no path can be made, reset harvest action
|
-- if no path can be made, reset harvest action
|
||||||
|
|||||||
Reference in New Issue
Block a user