public override void Enter(SteeringBlender steering, Actor owner, IAgentStateManager agent) { ZombieSkillSet zss = owner.GetBehaviorThatImplementsType <ZombieSkillSet>(); //zss.RangedSkill.CurrentOperation = WeaponFunctions.Neutral; BipedControllerComponent bcc = owner.GetComponent <BipedControllerComponent>(ActorComponent.ComponentType.Control); zss.RangedSkill.UpdateInputState(false, bcc); zss.MeleeSkill.UpdateInputState(false, bcc); int opponentId = agent.GetProperty <int>(AgentPropertyName.ActiveOpponent); Actor opponent = GameResources.ActorManager.GetActorById(opponentId); BipedControllerComponent opponentBcc = opponent.GetComponent <BipedControllerComponent>(ActorComponent.ComponentType.Control); BepuVec3 towardOpponent = opponentBcc.Controller.Body.Position - bcc.Controller.Body.Position; towardOpponent.Y = 0.0f; towardOpponent.Normalize(); const float MOVE_SECS_MAX = 2.5f; const float MOVE_SECS_MIN = 0.5f; float moveRand = SlagMath.Get0To1UpperFloat(GameResources.ActorManager.Random); switch (mMovementType) { case MovementType.Lateral: BepuVec3 right = BepuVec3.Cross(towardOpponent, BepuVec3.Up); // Make the random symmetrical about 0.5f so that we can divide it into two equal segments for right and left. moveRand = Math.Abs(moveRand - 0.5f); mDurationTicks = (long)(TimeSpan.TicksPerSecond * (moveRand * 2.0f * (MOVE_SECS_MAX - MOVE_SECS_MIN) + MOVE_SECS_MIN)); steering.Target = BepuConverter.Convert(bcc.Controller.Body.Position + (moveRand > 0.5f ? right : -right) * 100.0f); break; case MovementType.Close: steering.Target = BepuConverter.Convert(opponentBcc.Controller.Body.Position + towardOpponent * 100.0f); mDurationTicks = (long)(TimeSpan.TicksPerSecond * (moveRand * (MOVE_SECS_MAX - MOVE_SECS_MIN) + MOVE_SECS_MIN)); break; case MovementType.Retreat: steering.Target = BepuConverter.Convert(opponentBcc.Controller.Body.Position - towardOpponent * 100.0f); mDurationTicks = (long)(TimeSpan.TicksPerSecond * (moveRand * (MOVE_SECS_MAX - MOVE_SECS_MIN) + MOVE_SECS_MIN)); break; default: steering.Target = BepuConverter.Convert(towardOpponent * 100.0f); mDurationTicks = 0; break; } steering.Weights[(int)SteeringBlender.WeightType.Arrive] = 0.0f; steering.Weights[(int)SteeringBlender.WeightType.Seek] = 0.67f; steering.Weights[(int)SteeringBlender.WeightType.Wander] = 0.33f; steering.Weights[(int)SteeringBlender.WeightType.Wait] = 0.0f; steering.Urgency = 1.0f; steering.ForceScale = 1.0f; }
public override void Enter(SteeringBlender steering, Actor owner, IAgentStateManager agent) { float theta = SlagMath.Get0To1UpperFloat(GameResources.ActorManager.Random) * MathHelper.TwoPi; BipedControllerComponent bcc = owner.GetComponent <BipedControllerComponent>(ActorComponent.ComponentType.Control); steering.Weights[(int)SteeringBlender.WeightType.Arrive] = 0.0f; steering.Weights[(int)SteeringBlender.WeightType.Seek] = 1.0f; steering.Weights[(int)SteeringBlender.WeightType.Wander] = 0.0f; steering.Weights[(int)SteeringBlender.WeightType.Wait] = 0.0f; steering.Urgency = 1.0f; steering.Target = BepuConverter.Convert(bcc.Controller.Body.Position) + new Vector3((float)(Math.Sin(theta)), 0.0f, (float)(Math.Cos(theta))); steering.ForceScale = Single.Epsilon; }