Work on chase crit animations, eating dead bees
This commit is contained in:
@@ -66,7 +66,7 @@ updateLivingCreature cr = case cr ^. crType of
|
||||
. yourControl
|
||||
LampCrit{} -> updateLampoid cr
|
||||
BarrelCrit bt -> updateBarreloid bt cr
|
||||
ChaseCrit{} -> crUpdate cid . performActions cid . updateChaseCrit cid cr
|
||||
ChaseCrit{} -> crUpdate cid . performActions cid . setChaseCritKinematics cid . updateChaseCrit cid cr
|
||||
CrabCrit{} -> crUpdate cid . performActions cid . crabCritInternal cid
|
||||
AutoCrit{} -> crUpdate cid
|
||||
SwarmCrit{} -> crUpdate cid
|
||||
@@ -368,6 +368,66 @@ slinkCritUpdate cid w =
|
||||
. _2
|
||||
*~ Q.axisAngle (V3 0 1 0) (pi / 1000)
|
||||
|
||||
setChaseCritKinematics :: Int -> World -> World
|
||||
setChaseCritKinematics cid w = w
|
||||
& cWorld . lWorld . creatures . ix cid %~ setChaseCritKinematics' w
|
||||
|
||||
ccAngles :: World -> Creature -> (Float,Float,Float,Float)
|
||||
ccAngles w cr
|
||||
| Eat i _ <- cr^?!crActionPlan.apAction = fromMaybe (0,0,0,0) $ do
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||
let tp = tcr ^. crPos + V3 0 0 (crMid tcr)
|
||||
(np,_) = (cr ^. crPos, Q.qz (cr ^. crDir))
|
||||
`Q.comp` (V3 8 0 14, Q.qid)
|
||||
v = tp - np
|
||||
a = angleVV3 v (v & _z .~ 0)
|
||||
return $ f (-a) 0 0
|
||||
| CloseToMelee i<-cr^?!crActionPlan.apStrategy = fromMaybe (0,0,0,0) $ do
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix i
|
||||
let tp = tcr ^. crPos + V3 0 0 (crMid tcr)
|
||||
(np,_) = (cr ^. crPos, Q.qz (cr ^. crDir))
|
||||
`Q.comp` (V3 8 0 14, Q.qid)
|
||||
v = tp - np
|
||||
a = angleVV3 v (v & _z .~ 0)
|
||||
return $ f
|
||||
(0.45*pi - a)
|
||||
(-0.9*pi)
|
||||
(0.45*pi)
|
||||
| otherwise = f (0.6*pi) (-0.2*pi) (-0.4*pi)
|
||||
where
|
||||
f a b c = (0,a,b,c)
|
||||
|
||||
ccKState :: World -> Creature -> ChaseKState
|
||||
ccKState _ cr
|
||||
| Eat i _ <- cr^?!crActionPlan.apAction = PeckingCK i
|
||||
| CloseToMelee i <- cr^?!crActionPlan.apStrategy = AimingCK i
|
||||
| otherwise = UprightCK
|
||||
|
||||
setChaseCritKinematics' :: World -> Creature -> Creature
|
||||
setChaseCritKinematics' w = f . g
|
||||
where
|
||||
g cr | ccKState w cr == cr ^?! crType . chaseKState = cr
|
||||
| PeckingCK i <- ccKState w cr = cr
|
||||
& crType . chaseLerp .~ 3
|
||||
& crType . chaseKState .~ PeckingCK i
|
||||
| otherwise = cr & crType . chaseLerp .~ 20
|
||||
& crType . chaseKState .~ ccKState w cr
|
||||
f cr =
|
||||
let (a,b,c,d) = ccAngles w cr
|
||||
x = cr ^?! crType . chaseLerp
|
||||
in if x <= 1
|
||||
then cr & crType . chaseqy0 .~ a
|
||||
& crType . chaseqy1 .~ b
|
||||
& crType . chaseqy2 .~ c
|
||||
& crType . chaseqy3 .~ d
|
||||
else cr
|
||||
& crType . chaseqy0 %~ h x a
|
||||
& crType . chaseqy1 %~ h x b
|
||||
& crType . chaseqy2 %~ h x c
|
||||
& crType . chaseqy3 %~ h x d
|
||||
& crType . chaseLerp -~ 1
|
||||
h x a b = 1/fromIntegral x * a + (1-1/fromIntegral x) * b
|
||||
|
||||
updateChaseCrit :: Int -> Creature -> World -> World
|
||||
updateChaseCrit cid cr
|
||||
| SearchForFood <- cr ^?! crActionPlan . apGoal = updateFoodSearchChaseCrit cid cr
|
||||
@@ -384,12 +444,21 @@ updateFoodSearchChaseCrit cid cr w
|
||||
= let p = fleePoint cr cxy (20 *^ normalize (cxy - tcr^.crPos._xy)) w
|
||||
in w &tocr.crActionPlan.apAction.~PathTo p NoAction
|
||||
&tocr.crActionPlan.apGoal.~Flee
|
||||
| Eat i 0 <- cr^?! crActionPlan.apAction = w
|
||||
& cWorld .lWorld.creatures . at i .~ Nothing
|
||||
& tocr . crActionPlan.apAction.~NoAction
|
||||
& tocr . crActionPlan.apStrategy.~Search
|
||||
| Eat i x <- cr^?! crActionPlan.apAction = w
|
||||
& tocr .crActionPlan.apAction.acTimer-~1
|
||||
| CloseToMelee i<-cr^?!crActionPlan.apStrategy
|
||||
,Nothing <- w ^?cWorld.lWorld.creatures.ix i = w & tocr . crActionPlan.apStrategy .~ Search
|
||||
| CloseToMelee i<-cr^?!crActionPlan.apStrategy
|
||||
,Just tcr <-w^?cWorld.lWorld.creatures.ix i
|
||||
,distance cxy (tcr^.crPos._xy) < 11 = w
|
||||
& tocr.crActionPlan.apAction.~NoAction
|
||||
& tocr.crActionPlan.apStrategy.~Search
|
||||
& cWorld.lWorld.creatures.at i.~Nothing
|
||||
,distance cxy (tcr^.crPos._xy) < 15 = w
|
||||
& tocr.crActionPlan.apAction.~Eat i 5
|
||||
-- & tocr.crActionPlan.apAction.~NoAction
|
||||
-- & tocr.crActionPlan.apStrategy.~Search
|
||||
-- & cWorld.lWorld.creatures.at i.~Nothing
|
||||
| CloseToMelee{}<-cr^?!crActionPlan.apStrategy
|
||||
,PathTo{}<-cr^?!crActionPlan.apAction= w
|
||||
| xs@(_:_) <- IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
|
||||
|
||||
Reference in New Issue
Block a user