Tweak melee movement
This commit is contained in:
@@ -25,7 +25,7 @@ import Linear
|
||||
-- note SwitchToItem doesn't necessarily update the root item correctly
|
||||
followImpulse :: Int -> World -> Impulse -> World
|
||||
followImpulse cid w = \case
|
||||
UpdateRandGen -> w & randGen %~ (snd . (randomR (0::Int,0)))
|
||||
UpdateRandGen -> w & randGen %~ (snd . randomR (0::Int,1))
|
||||
ImpulseNothing -> w
|
||||
RandomImpulse rimp ->
|
||||
let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w)
|
||||
@@ -43,11 +43,8 @@ followImpulse cid w = \case
|
||||
ChangePosture post -> crup $ crStance . posture .~ post
|
||||
UseItem -> undefined
|
||||
-- SwitchToItem i -> crup $ crManipulation . manObject .~ SelectedItem (NInt i) (NInt i) mempty
|
||||
Melee cid' ->
|
||||
hitCr cid' $
|
||||
crup
|
||||
( crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) . (crType . meleeCooldown .~ 20)
|
||||
)
|
||||
Melee tid ->
|
||||
hitCr tid $ crup $ meleeMovement w tid . (crType . meleeCooldown .~ 20)
|
||||
MeleeL cid' ->
|
||||
hitCrd (-pi/2) cid' $
|
||||
crup
|
||||
@@ -100,6 +97,16 @@ followImpulse cid w = \case
|
||||
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + a)) (CrMeleeO cid)
|
||||
]
|
||||
|
||||
meleeMovement :: World -> Int -> Creature -> Creature
|
||||
meleeMovement w tid cr = case cr ^. crType of
|
||||
HoverCrit {} -> fromMaybe cr $ do
|
||||
txy <- w ^? cWorld . lWorld . creatures . ix tid . crPos . _xy
|
||||
return $ crMvAbsolute (w ^. cWorld . lWorld) (5 *^ normalizeV (cr ^. crPos . _xy - txy)) cr
|
||||
ChaseCrit {} -> fromMaybe cr $ do
|
||||
txy <- w ^? cWorld . lWorld . creatures . ix tid . crPos . _xy
|
||||
return $ crMvAbsolute (w ^. cWorld . lWorld) (5 *^ normalizeV (txy - cr ^. crPos . _xy)) cr
|
||||
_ -> cr
|
||||
|
||||
setBeeRandomMovement :: Int -> World -> World
|
||||
setBeeRandomMovement cid w = fromMaybe w $ do
|
||||
mff <- w ^? cWorld . lWorld . creatures . ix cid . crType . beeRandomMovement
|
||||
|
||||
Reference in New Issue
Block a user