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 split = split.ToArray(); // Ignore case on commands
if (split.Length > 0)
{
var cmd = split[0]; var cmd = split[0];
if (cmd.Any())
{
// if client isnt null, take player to be the player actor // if client isnt null, take player to be the player actor
Player player = null; Player player = null;
if (session != null) if (session != null)

View File

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

View File

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

View File

@ -35,13 +35,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
this.owner = owner; 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); PreparePath(dest.X, dest.Y, dest.Z, stepSize, maxPath, polyRadius);
} }
// todo: is this class even needed? // 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 pos = new Vector3(owner.positionX, owner.positionY, owner.positionZ);
var dest = new Vector3(x, y, z); var dest = new Vector3(x, y, z);
@ -123,7 +123,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{ {
path.Remove(point); path.Remove(point);
owner.OnPath(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) if (distanceFromPoint == 0)
return owner.positionX == point.X && owner.positionZ == point.Z; return owner.positionX == point.X && owner.positionZ == point.Z;
else 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) public void StepTo(Vector3 point, bool run = false)
{ {
float speed = GetSpeed(); 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); float distanceTo = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, point.X, point.Y, point.Z);
owner.LookAt(point.X, point.Y); 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); owner.QueuePositionUpdate(point);
} }

View File

@ -104,9 +104,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
var target = owner.target; var target = owner.target;
base.Disengage(); base.Disengage();
// todo: // todo:
lastActionTime = lastUpdate; lastActionTime = lastUpdate.AddSeconds(5);
owner.isMovingToSpawn = true; owner.isMovingToSpawn = true;
neutralTime = lastUpdate; neutralTime = lastActionTime;
owner.hateContainer.ClearHate(); owner.hateContainer.ClearHate();
owner.moveState = 1; owner.moveState = 1;
lua.LuaEngine.CallLuaBattleAction(owner, "onDisengage", owner, target); lua.LuaEngine.CallLuaBattleAction(owner, "onDisengage", owner, target);
@ -164,6 +164,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
waitTime = tick.AddSeconds(10); waitTime = tick.AddSeconds(10);
owner.OnRoam(tick); owner.OnRoam(tick);
} }
if (owner.aiContainer.pathFind.IsFollowingPath())
{
owner.aiContainer.pathFind.FollowPath();
}
} }
private void DoCombatTick(DateTime tick) private void DoCombatTick(DateTime tick)
@ -200,12 +205,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
{ {
if (CanMoveForward(distance)) if (CanMoveForward(distance))
{ {
owner.LookAt(targetPos.X, targetPos.Y);
if (!owner.aiContainer.pathFind.IsFollowingPath() && distance > 3) if (!owner.aiContainer.pathFind.IsFollowingPath() && distance > 3)
{ {
// pathfind if too far otherwise jump to target // pathfind if too far otherwise jump to target
owner.aiContainer.pathFind.SetPathFlags(distance > 5 ? PathFindFlags.None : PathFindFlags.IgnoreNav ); 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(); owner.aiContainer.pathFind.FollowPath();
if (!owner.aiContainer.pathFind.IsFollowingPath()) if (!owner.aiContainer.pathFind.IsFollowingPath())
@ -282,7 +286,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
if (verticalDistance > 8) if (verticalDistance > 8)
return false; 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 detectSight = forceSight || (owner.aggroType & AggroType.Sight) != 0;
bool hasSneak = false; bool hasSneak = false;
@ -301,7 +305,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
hasInvisible = hasSneak; hasInvisible = hasSneak;
} }
if (detectSight && !hasInvisible && owner.IsFacing(target)) if (detectSight && !hasInvisible && isFacing)
return CanSeePoint(target.positionX, target.positionY, target.positionZ); return CanSeePoint(target.positionX, target.positionY, target.positionZ);
if ((owner.aggroType & AggroType.LowHp) != 0 && target.GetHPP() < 75) 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); utils.BattleUtils.DamageTarget(owner, target, damage);
lua.LuaEngine.CallLuaBattleAction(owner, "onAttack", false, owner, target, damage); lua.LuaEngine.CallLuaBattleAction(owner, "onAttack", false, owner, target, damage);
{
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50)) 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) var packet = BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, target.actorId, 0, 537094006, 0, 27260, (ushort)damage, 0);
// ((Player)target).SendPacket("139.bin"); player.QueuePacket(packet);
Program.Log.Error("asudyaisydaisydaioysdaisydaiosdyaiosuydaisydiaosydioasydaiusdyaisduy");
packet.DebugPrintSubPacket();
}
if (target is Player)
((Player)target).SendPacket("139_attack");
}
target.AddHP((short)damage); target.AddHP((short)damage);
attackTime = attackTime.AddMilliseconds(owner.GetAttackDelayMs()); attackTime = attackTime.AddMilliseconds(owner.GetAttackDelayMs());
owner.LookAt(target); owner.LookAt(target);

View File

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