Bug fixes

Fixed LookAt resetting rotation when looking at self
Fixed BattleNpcs running to their target's exact position instead of the closest position they can attack from
This commit is contained in:
yogurt 2018-07-03 04:46:34 -05:00
parent cf30eef39e
commit 1579aa3d6a
4 changed files with 25 additions and 14 deletions

View File

@ -633,7 +633,7 @@ namespace FFXIVClassic_Map_Server.Actors
public void LookAt(Actor actor) public void LookAt(Actor actor)
{ {
if (actor != null) if (actor != null && actor != this)
{ {
LookAt(actor.positionX, actor.positionZ); LookAt(actor.positionX, actor.positionZ);
} }

View File

@ -439,7 +439,7 @@ namespace FFXIVClassic_Map_Server.Actors
public virtual uint GetAttackRange() public virtual uint GetAttackRange()
{ {
return (uint)GetMod((uint)Modifier.AttackRange); return (uint)(GetMod((uint)Modifier.AttackRange) == 0 ? 3 : GetMod((uint)Modifier.AttackRange));
} }
public virtual bool Engage(uint targid = 0, ushort newMainState = 0xFFFF) public virtual bool Engage(uint targid = 0, ushort newMainState = 0xFFFF)

View File

@ -51,9 +51,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
{ {
DoCombatTick(tick); DoCombatTick(tick);
} }
//Only move if owner isn't dead and is either too far away from their spawn point or is meant to roam and isn't in combat
//Only move if owner isn't dead and is either too far away from their spawn point or is meant to roam else if (!owner.IsDead() && (owner.isMovingToSpawn || owner.GetMobMod((uint)MobModifier.Roams) > 0))
if (!owner.IsDead() && (owner.isMovingToSpawn || owner.GetMobMod((uint)MobModifier.Roams) > 0))
{ {
DoRoamTick(tick); DoRoamTick(tick);
} }
@ -238,9 +237,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
return; return;
} }
var targetPos = new Vector3(owner.target.positionX, owner.target.positionY, owner.target.positionZ); var vecToTarget = owner.target.GetPosAsVector3() - owner.GetPosAsVector3();
var distance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, targetPos.X, targetPos.Y, targetPos.Z); vecToTarget /= vecToTarget.Length();
if (distance > owner.GetAttackRange() - 0.2f && owner.aiContainer.CanFollowPath()) vecToTarget = (Utils.Distance(owner.GetPosAsVector3(), owner.target.GetPosAsVector3()) - owner.GetAttackRange() + 0.2f) * vecToTarget;
var targetPos = vecToTarget + owner.GetPosAsVector3();
var distance = Utils.Distance(owner.GetPosAsVector3(), owner.target.GetPosAsVector3());
if (distance > owner.GetAttackRange() - 0.2f)
{ {
if (CanMoveForward(distance)) if (CanMoveForward(distance))
{ {

View File

@ -1,6 +1,5 @@
require("global"); require("global");
require("modifiers"); require("modifiers");
properties = { properties = {
permissions = 0, permissions = 0,
parameters = "ssss", parameters = "ssss",
@ -129,6 +128,8 @@ function onTrigger(player, argc, id, level, weight)
end; end;
]] ]]
function onTrigger(player, argc, width, height, blockCount) function onTrigger(player, argc, width, height, blockCount)
local messageId = MESSAGE_TYPE_SYSTEM_ERROR; local messageId = MESSAGE_TYPE_SYSTEM_ERROR;
local sender = "yolo"; local sender = "yolo";
@ -149,18 +150,25 @@ function onTrigger(player, argc, width, height, blockCount)
local rot = tonumber(pos[3]); local rot = tonumber(pos[3]);
local zone = pos[4]; local zone = pos[4];
local w = tonumber(width) or 0; local w = tonumber(width) or 0;
local h = tonumber(height) or 0; local h = tonumber(height) or 0;
local blocks = tonumber(blockCount) or 0; local blocks = tonumber(blockCount) or 0;
printf("%f %f %f", x, y, z); printf("%f %f %f", x, y, z);
--local x, y, z = player.GetPos(); --local x, y, z = player.GetPos();
for i = 0, blocks do for b = 0, blocks do
for i = 0, w do for i = 0, w do
for j = 0, h do for j = 0, h do
local actor = player.GetZone().SpawnActor(2104001, 'ass', x + (i - (w / 2) * 3), y, z + (j - (h / 2) * 3), rot, 0, 0, true); local actor = player.GetZone().SpawnActor(2104001, 'ass', x + (i * 1), y, z + (j * 1), rot, 0, 0, true);
actor.ChangeNpcAppearance(1001149); actor.ChangeNpcAppearance(2200905);
actor.SetMaxHP(10000); actor.SetMaxHP(5000);
actor.SetHP(10000); actor.SetHP(5000);
actor.SetMod(modifiersGlobal.HasShield, 1); actor.SetMod(modifiersGlobal.HasShield, 1);
actor.SetMod(modifiersGlobal.AttackRange, 3);
actor.SetMod(modifiersGlobal.Speed, 5);
actor.SetMobMod(mobModifiersGlobal.Roams, 1);
actor.SetMobMod(mobModifiersGlobal.RoamDelay, 3);
actor.moveState = 3;
end end
end end