1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-06-08 17:27:45 +00:00

fixed finding random point retardation

This commit is contained in:
Tahir Akhlaq 2017-06-07 02:01:22 +01:00
parent a62475e81e
commit e09cb197b3
3 changed files with 28 additions and 22 deletions

View file

@ -89,6 +89,9 @@ namespace FFXIVClassic_Map_Server.Actors
this.moveSpeeds[1] = SetActorSpeedPacket.DEFAULT_WALK; this.moveSpeeds[1] = SetActorSpeedPacket.DEFAULT_WALK;
this.moveSpeeds[2] = SetActorSpeedPacket.DEFAULT_RUN; this.moveSpeeds[2] = SetActorSpeedPacket.DEFAULT_RUN;
this.moveSpeeds[3] = SetActorSpeedPacket.DEFAULT_ACTIVE; this.moveSpeeds[3] = SetActorSpeedPacket.DEFAULT_ACTIVE;
// todo: make this halal
this.moveState = this.oldMoveState;
hasMoved = true; hasMoved = true;
} }
@ -559,7 +562,7 @@ namespace FFXIVClassic_Map_Server.Actors
} }
else else
{ {
Program.Log.Error("Actor.LookAt() unable to find actor!"); Program.Log.Error("{0} {1} Actor.LookAt() unable to find actor!", actorId, actorName);
} }
} }

View file

@ -163,6 +163,9 @@ namespace FFXIVClassic_Map_Server.Actors
if (this.target != player) if (this.target != player)
{ {
#region super important performance critical code #region super important performance critical code
this.ChangeState(SetActorStatePacket.MAIN_STATE_MOUNTED);
var chatMode = Program.Random.Next(13); var chatMode = Program.Random.Next(13);
var emphasis = Program.Random.Next(9); var emphasis = Program.Random.Next(9);
var drag = Program.Random.Next(7); var drag = Program.Random.Next(7);
@ -184,7 +187,7 @@ namespace FFXIVClassic_Map_Server.Actors
// imouto aggro // imouto aggro
player.SendMessage((uint)chatMode, "Rowena", oni + chan); player.SendMessage((uint)chatMode, "Rowena", oni + chan);
// sing for onii // sing for onii
this.PlayAnimation(Program.Random.Next(0,2) == 1 ? (uint)67111904 : (uint)67108902); this.PlayAnimation(Program.Random.Next(0, 2) == 1 ? (uint)67111904 : (uint)67108902);
#endregion #endregion
@ -241,7 +244,6 @@ namespace FFXIVClassic_Map_Server.Actors
// target zoned, deaggro // target zoned, deaggro
target = null; target = null;
// tell player to despawn us and we can move back to spawn // tell player to despawn us and we can move back to spawn
if (player != null) if (player != null)
{ {
@ -277,6 +279,10 @@ namespace FFXIVClassic_Map_Server.Actors
continue; continue;
} }
// dont aggro if moving to spawn
if (this.isMovingToSpawn)
continue;
// find distance between self and target // find distance between self and target
var distance = Utils.Distance(positionX, positionY, positionZ, player.positionX, player.positionY, player.positionZ); var distance = Utils.Distance(positionX, positionY, positionZ, player.positionX, player.positionY, player.positionZ);
@ -291,7 +297,7 @@ namespace FFXIVClassic_Map_Server.Actors
{ {
if (distance >= 3) if (distance >= 3)
{ {
FollowTarget(player, 2.0f); FollowTarget(player, 2.4f, 5);
} }
// too close, spread out // too close, spread out
else if (distance <= 0.64f) else if (distance <= 0.64f)
@ -343,7 +349,7 @@ namespace FFXIVClassic_Map_Server.Actors
{ {
// this shit gets hit every time, but it wont path to it? // this shit gets hit every time, but it wont path to it?
Program.Log.Error("{0} Picking random point to walk to!", actorId); Program.Log.Error("{0} Picking random point to walk to!", actorId);
PathTo(oldPositionX, oldPositionY, oldPositionZ, 2.5f, 15, 20.5f); PathTo(oldPositionX, oldPositionY, oldPositionZ, 2.5f, 7, 15.5f);
// face destination // face destination
if (positionUpdates.Count > 0) if (positionUpdates.Count > 0)
@ -351,12 +357,12 @@ namespace FFXIVClassic_Map_Server.Actors
var destinationPos = positionUpdates[positionUpdates.Count - 1]; var destinationPos = positionUpdates[positionUpdates.Count - 1];
LookAt(destinationPos.X, destinationPos.Y); LookAt(destinationPos.X, destinationPos.Y);
} }
this.isMovingToSpawn = false; if (this.isMovingToSpawn)
} {
// already at spawn, dont recalculate distance on next ai update this.isMovingToSpawn = false;
else this.ResetMoveSpeedsToDefault();
{ this.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD2);
this.isMovingToSpawn = false; }
} }
} }
} }

View file

@ -112,7 +112,6 @@ namespace FFXIVClassic_Map_Server.utils
if (navMesh == null || (startVec.X == endVec.X && startVec.Y == endVec.Y && startVec.Z == endVec.Z && polyRadius == 0.0f)) if (navMesh == null || (startVec.X == endVec.X && startVec.Y == endVec.Y && startVec.Z == endVec.Z && polyRadius == 0.0f))
{ {
Program.Log.Error("ass");
return null; return null;
} }
@ -122,7 +121,6 @@ namespace FFXIVClassic_Map_Server.utils
// no point pathing if in range // no point pathing if in range
if (distanceSquared < 4 && Math.Abs(startVec.Y - endVec.Y) < 1.1f) if (distanceSquared < 4 && Math.Abs(startVec.Y - endVec.Y) < 1.1f)
{ {
Program.Log.Error("shit");
return null; return null;
} }
@ -154,10 +152,14 @@ namespace FFXIVClassic_Map_Server.utils
navMeshQuery.ClosestPointOnPoly(startPt.Polygon, startPt.Position, ref iterPos); navMeshQuery.ClosestPointOnPoly(startPt.Polygon, startPt.Position, ref iterPos);
navMeshQuery.ClosestPointOnPoly(path[npolys - 1], endPt.Position, ref targetPos); navMeshQuery.ClosestPointOnPoly(path[npolys - 1], endPt.Position, ref targetPos);
smoothPath.Add(new Vector3(iterPos)); // set target to random point at end of path
if (polyRadius != 0.0f)
{
var randPoly = navMeshQuery.FindRandomPointAroundCircle(endPt, polyRadius);
targetPos = randPoly.Position;
}
if (npolys <= 1) smoothPath.Add(new Vector3(iterPos));
System.Diagnostics.Debugger.Break();
//float STEP_SIZE = 0.70f; //float STEP_SIZE = 0.70f;
float SLOP = 0.15f; float SLOP = 0.15f;
@ -201,17 +203,12 @@ namespace FFXIVClassic_Map_Server.utils
iterPos = result; iterPos = result;
//handle end of path when close enough //handle end of path when close enough
if (endOfPath && InRange(iterPos, steerPos, SLOP, 10.0f)) if (endOfPath && InRange(iterPos, steerPos, SLOP, 1000.0f))
{ {
//reached end of path //reached end of path
iterPos = targetPos; iterPos = targetPos;
if (smoothPath.Count < smoothPath.Capacity) if (smoothPath.Count < smoothPath.Capacity)
{ {
if (polyRadius != 0.0f)
{
var randPoly = navMeshQuery.FindRandomPointAroundCircle(endPt, polyRadius);
iterPos = randPoly.Position;
}
smoothPath.Add(new Vector3(iterPos)); smoothPath.Add(new Vector3(iterPos));
} }
break; break;