From 1579aa3d6a8e9978ef0e2812e31b037d7869b490 Mon Sep 17 00:00:00 2001 From: yogurt Date: Tue, 3 Jul 2018 04:46:34 -0500 Subject: [PATCH] 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 --- FFXIVClassic Map Server/actors/Actor.cs | 2 +- .../actors/chara/Character.cs | 2 +- .../ai/controllers/BattleNpcController.cs | 15 ++++++++------ data/scripts/commands/gm/yolo.lua | 20 +++++++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/FFXIVClassic Map Server/actors/Actor.cs b/FFXIVClassic Map Server/actors/Actor.cs index bd4097fe..5dab3e52 100644 --- a/FFXIVClassic Map Server/actors/Actor.cs +++ b/FFXIVClassic Map Server/actors/Actor.cs @@ -633,7 +633,7 @@ namespace FFXIVClassic_Map_Server.Actors public void LookAt(Actor actor) { - if (actor != null) + if (actor != null && actor != this) { LookAt(actor.positionX, actor.positionZ); } diff --git a/FFXIVClassic Map Server/actors/chara/Character.cs b/FFXIVClassic Map Server/actors/chara/Character.cs index 06fccefe..e6735553 100644 --- a/FFXIVClassic Map Server/actors/chara/Character.cs +++ b/FFXIVClassic Map Server/actors/chara/Character.cs @@ -439,7 +439,7 @@ namespace FFXIVClassic_Map_Server.Actors 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) diff --git a/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs b/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs index 258956ce..a2ebeb87 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs @@ -51,9 +51,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers { DoCombatTick(tick); } - - //Only move if owner isn't dead and is either too far away from their spawn point or is meant to roam - if (!owner.IsDead() && (owner.isMovingToSpawn || owner.GetMobMod((uint)MobModifier.Roams) > 0)) + //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 + else if (!owner.IsDead() && (owner.isMovingToSpawn || owner.GetMobMod((uint)MobModifier.Roams) > 0)) { DoRoamTick(tick); } @@ -238,9 +237,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers return; } - var targetPos = new Vector3(owner.target.positionX, owner.target.positionY, owner.target.positionZ); - var distance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, targetPos.X, targetPos.Y, targetPos.Z); - if (distance > owner.GetAttackRange() - 0.2f && owner.aiContainer.CanFollowPath()) + var vecToTarget = owner.target.GetPosAsVector3() - owner.GetPosAsVector3(); + vecToTarget /= vecToTarget.Length(); + 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)) { diff --git a/data/scripts/commands/gm/yolo.lua b/data/scripts/commands/gm/yolo.lua index 42018e7c..724694c7 100644 --- a/data/scripts/commands/gm/yolo.lua +++ b/data/scripts/commands/gm/yolo.lua @@ -1,6 +1,5 @@ require("global"); require("modifiers"); - properties = { permissions = 0, parameters = "ssss", @@ -129,6 +128,8 @@ function onTrigger(player, argc, id, level, weight) end; ]] + + function onTrigger(player, argc, width, height, blockCount) local messageId = MESSAGE_TYPE_SYSTEM_ERROR; local sender = "yolo"; @@ -149,18 +150,25 @@ function onTrigger(player, argc, width, height, blockCount) local rot = tonumber(pos[3]); local zone = pos[4]; local w = tonumber(width) or 0; + local h = tonumber(height) or 0; local blocks = tonumber(blockCount) or 0; + printf("%f %f %f", x, y, z); --local x, y, z = player.GetPos(); - for i = 0, blocks do + for b = 0, blocks do for i = 0, w 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); - actor.ChangeNpcAppearance(1001149); - actor.SetMaxHP(10000); - actor.SetHP(10000); + local actor = player.GetZone().SpawnActor(2104001, 'ass', x + (i * 1), y, z + (j * 1), rot, 0, 0, true); + actor.ChangeNpcAppearance(2200905); + actor.SetMaxHP(5000); + actor.SetHP(5000); 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