fix crash in gm command thing, commit stupid shit i havent figured out yet

This commit is contained in:
Tahir Akhlaq 2017-08-21 00:40:41 +01:00
parent 1856cc0634
commit a89fc64555
7 changed files with 52 additions and 31 deletions

View File

@ -47,10 +47,10 @@ namespace FFXIVClassic_Map_Server
split = split.ToArray(); // Ignore case on commands
if (split.Length > 0)
{
var cmd = split[0];
if (cmd.Any())
{
// if client isnt null, take player to be the player actor
Player player = null;
if (session != null)

View File

@ -402,11 +402,12 @@ namespace FFXIVClassic_Map_Server.Actors
if (positionUpdates != null && positionUpdates.Count > 0)
{
// push latest for player
var pos = positionUpdates?[currentSubState == SetActorStatePacket.SUB_STATE_PLAYER ? positionUpdates.Count - 1 : 0];
var pos = positionUpdates[currentSubState == SetActorStatePacket.SUB_STATE_PLAYER ? positionUpdates.Count - 1 : 0];
oldPositionX = positionX;
oldPositionY = positionY;
oldPositionZ = positionZ;
oldRotation = rotation;
positionX = pos.X;
positionY = pos.Y;
@ -414,11 +415,11 @@ namespace FFXIVClassic_Map_Server.Actors
//Program.Server.GetInstance().mLuaEngine.OnPath(actor, position, positionUpdates)
positionUpdates.RemoveAt(0);
}
positionUpdates.Remove(pos);
lastMoveUpdate = DateTime.Now;
packets.Add(CreatePositionUpdatePacket());
}
}
if ((updateFlags & ActorUpdateFlags.Speed) != 0)
{
@ -651,7 +652,7 @@ namespace FFXIVClassic_Map_Server.Actors
var dRot = Math.PI - rot2 + Math.PI / 2;
// pending move, dont need to unset it
this.updateFlags = (rotation != (float)dRot) ? updateFlags |= ActorUpdateFlags.Position : updateFlags;
this.updateFlags |= ActorUpdateFlags.Position;
rotation = (float)dRot;
}

View File

@ -284,12 +284,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
pathFind?.Clear();
GetTargetFind()?.Reset();
owner.updateFlags |= (ActorUpdateFlags.State | ActorUpdateFlags.HpTpMp);
owner.updateFlags |= ActorUpdateFlags.HpTpMp;
// todo: use the update flags
owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
ChangeTarget(null);
ClearStates();
}
public void InternalCast(Character target, uint spellId)

View File

@ -35,13 +35,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
this.owner = owner;
}
public void PreparePath(Vector3 dest, float stepSize = 0.70f, int maxPath = 40, float polyRadius = 0.0f)
public void PreparePath(Vector3 dest, float stepSize = 1.25f, int maxPath = 40, float polyRadius = 0.0f)
{
PreparePath(dest.X, dest.Y, dest.Z, stepSize, maxPath, polyRadius);
}
// todo: is this class even needed?
public void PreparePath(float x, float y, float z, float stepSize = 0.70f, int maxPath = 40, float polyRadius = 0.0f)
public void PreparePath(float x, float y, float z, float stepSize = 1.25f, int maxPath = 40, float polyRadius = 0.0f)
{
var pos = new Vector3(owner.positionX, owner.positionY, owner.positionZ);
var dest = new Vector3(x, y, z);
@ -123,7 +123,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
path.Remove(point);
owner.OnPath(point);
Program.Log.Error($"{owner.actorName} arrived at point {point.X} {point.Y} {point.Z}");
}
if (path.Count == 0 && owner.target != null)
owner.LookAt(owner.target);
}
}
@ -132,21 +136,21 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
if (distanceFromPoint == 0)
return owner.positionX == point.X && owner.positionZ == point.Z;
else
return Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, point.X, point.Y, point.Z) <= (distanceFromPoint + 1.5f);
return Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, point.X, point.Y, point.Z) <= (distanceFromPoint + 4.5f);
}
public void StepTo(Vector3 point, bool run = false)
{
float speed = GetSpeed();
float stepDistance = (speed / 10) / 2;
float stepDistance = speed;
float distanceTo = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, point.X, point.Y, point.Z);
owner.LookAt(point.X, point.Y);
if (distanceTo <= distanceFromPoint + stepDistance + 1.5f)
if (distanceTo <= distanceFromPoint + stepDistance)
{
if (distanceFromPoint == 0)
if (distanceFromPoint <= 1.5f)
{
owner.QueuePositionUpdate(point);
}

View File

@ -104,9 +104,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
var target = owner.target;
base.Disengage();
// todo:
lastActionTime = lastUpdate;
lastActionTime = lastUpdate.AddSeconds(5);
owner.isMovingToSpawn = true;
neutralTime = lastUpdate;
neutralTime = lastActionTime;
owner.hateContainer.ClearHate();
owner.moveState = 1;
lua.LuaEngine.CallLuaBattleAction(owner, "onDisengage", owner, target);
@ -164,6 +164,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
waitTime = tick.AddSeconds(10);
owner.OnRoam(tick);
}
if (owner.aiContainer.pathFind.IsFollowingPath())
{
owner.aiContainer.pathFind.FollowPath();
}
}
private void DoCombatTick(DateTime tick)
@ -200,12 +205,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
{
if (CanMoveForward(distance))
{
owner.LookAt(targetPos.X, targetPos.Y);
if (!owner.aiContainer.pathFind.IsFollowingPath() && distance > 3)
{
// pathfind if too far otherwise jump to target
owner.aiContainer.pathFind.SetPathFlags(distance > 5 ? PathFindFlags.None : PathFindFlags.IgnoreNav );
owner.aiContainer.pathFind.PreparePath(targetPos, 0.5f, 5);
owner.aiContainer.pathFind.PreparePath(targetPos, 1.2f, 5);
}
owner.aiContainer.pathFind.FollowPath();
if (!owner.aiContainer.pathFind.IsFollowingPath())
@ -282,7 +286,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
if (verticalDistance > 8)
return false;
var distance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, target.oldPositionX, target.oldPositionY, target.oldPositionZ);
var distance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, target.positionX, target.positionY, target.positionZ);
bool detectSight = forceSight || (owner.aggroType & AggroType.Sight) != 0;
bool hasSneak = false;
@ -301,7 +305,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
hasInvisible = hasSneak;
}
if (detectSight && !hasInvisible && owner.IsFacing(target))
if (detectSight && !hasInvisible && isFacing)
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
if ((owner.aggroType & AggroType.LowHp) != 0 && target.GetHPP() < 75)

View File

@ -86,11 +86,17 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
utils.BattleUtils.DamageTarget(owner, target, damage);
lua.LuaEngine.CallLuaBattleAction(owner, "onAttack", false, owner, target, damage);
{
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
player.QueuePacket(BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, target.actorId, 0, 537094006, 0, 27260, (ushort)damage, 0));
//if (target is Player)
// ((Player)target).SendPacket("139.bin");
{
var packet = BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, target.actorId, 0, 537094006, 0, 27260, (ushort)damage, 0);
player.QueuePacket(packet);
Program.Log.Error("asudyaisydaisydaioysdaisydaiosdyaiosuydaisydiaosydioasydaiusdyaisduy");
packet.DebugPrintSubPacket();
}
if (target is Player)
((Player)target).SendPacket("139_attack");
}
target.AddHP((short)damage);
attackTime = attackTime.AddMilliseconds(owner.GetAttackDelayMs());
owner.LookAt(target);

View File

@ -116,8 +116,16 @@ namespace FFXIVClassic_Map_Server.Actors
// leash back to spawn
if (!IsCloseToSpawn())
{
isMovingToSpawn = true;
if (!isMovingToSpawn)
{
aiContainer.Reset();
isMovingToSpawn = true;
}
else
{
if (target == null && !aiContainer.pathFind.IsFollowingPath())
aiContainer.pathFind.PathInRange(spawnX, spawnY, spawnZ, 1.0f, 15.0f);
}
}
else
{
@ -135,9 +143,6 @@ namespace FFXIVClassic_Map_Server.Actors
hateContainer.AddBaseHate(player);
}
}
if (target == null)
aiContainer.pathFind.PathInRange(spawnX, spawnY, spawnZ, 1.0f, 35.0f);
}
public uint GetDespawnTime()