1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-22 04:37:47 +00:00

fixed mobs not pathing

- fixed roaming (todo: should probably move to attackstate too or something)
This commit is contained in:
Tahir Akhlaq 2017-08-23 19:31:03 +01:00
parent 54af893570
commit cbbfa4ed95
8 changed files with 31 additions and 15 deletions

View file

@ -41,7 +41,7 @@ namespace FFXIVClassic_Map_Server
private Server mServer;
private const int MILIS_LOOPTIME = 333;
private const int MILIS_LOOPTIME = 250;
private Timer mZoneTimer;
//Content Groups
@ -1156,10 +1156,10 @@ namespace FFXIVClassic_Map_Server
abilityList = Database.LoadGlobalAbilityList();
}
public Ability GetAbility(ushort id)
public Ability GetAbility(uint id)
{
Ability ability;
return abilityList.TryGetValue(id, out ability) ? ability.Clone() : null;
return abilityList.TryGetValue((ushort)id, out ability) ? ability.Clone() : null;
}
}

View file

@ -310,6 +310,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public void InternalDie(DateTime tick, uint timeToFadeout)
{
if (true) return;
ClearStates();
Disengage();
ForceChangeState(new DeathState(owner, tick, timeToFadeout));

View file

@ -131,8 +131,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
}
}
public bool AtPoint(Vector3 point)
public bool AtPoint(Vector3 point = null)
{
if (point == null && path != null && path.Count > 0)
{
point = path[path.Count - 1];
}
if (distanceFromPoint == 0)
return owner.positionX == point.X && owner.positionZ == point.Z;
else

View file

@ -97,7 +97,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
// todo: send packet to client with effect added message
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
player.QueuePacket(packets.send.actor.battle.BattleActionX01Packet.BuildPacket(player.actorId, newEffect.GetSource().actorId, owner.actorId, 0, newEffect.GetStatusEffectId(), 0, newEffect.GetStatusId(), 0, 0));
player.QueuePacket(packets.send.actor.battle.BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, owner.actorId, 0, newEffect.GetStatusEffectId(), 0, newEffect.GetStatusId(), 0, 0));
}
// wont send a message about losing effect here

View file

@ -157,7 +157,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
{
if (tick >= lastActionTime)
{
var battlenpc = owner as BattleNpc;
owner.aiContainer.pathFind.PathInRange(battlenpc.spawnX, battlenpc.spawnY, battlenpc.spawnZ, 1.5f, 15.0f);
}
}
// todo:
@ -208,7 +209,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
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.SetPathFlags(PathFindFlags.None);
owner.aiContainer.pathFind.PreparePath(targetPos, 1.5f, 5);
}
owner.aiContainer.pathFind.FollowPath();
@ -221,8 +222,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
if (battlenpc == owner)
continue;
float mobDistance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, battlenpc.positionX, battlenpc.positionY, battlenpc.positionZ);
if (mobDistance < 0.3f && (battlenpc.updateFlags & ActorUpdateFlags.Position) == 0)
battlenpc.aiContainer.pathFind.PathInRange(targetPos, 1.5f, 1.5f);
if (mobDistance < 0.25f && (battlenpc.updateFlags & ActorUpdateFlags.Position) == 0)
battlenpc.aiContainer.pathFind.PathInRange(targetPos, 1.3f, 1.8f);
}
}
}
@ -278,6 +279,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
public bool CanDetectTarget(Character target, bool forceSight = false)
{
// todo: this should probably be changed to only allow detection at end of path?
if (owner.aiContainer.pathFind.IsFollowingScriptedPath() || owner.aiContainer.pathFind.IsFollowingPath() && !owner.aiContainer.pathFind.AtPoint())
{
return false;
}
// todo: handle sight/scent/hp etc
if (target.IsDead() || target.currentMainState == SetActorStatePacket.MAIN_STATE_MOUNTED)
return false;

View file

@ -89,15 +89,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
{
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
{
var packet = BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, target.actorId, 0, 537094006, 0, 27260, (ushort)damage, 0);
/*var packet = BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, owner.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");
//if (target is Player)
// ((Player)target).SendPacket("139_attack");
}
target.DelHP((short)damage);
//target.DelHP((short)damage);
attackTime = attackTime.AddMilliseconds(owner.GetAttackDelayMs());
owner.LookAt(target);
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, effectId, 0, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, 0);

View file

@ -27,8 +27,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
{
if (owner.currentSubState == SetActorStatePacket.SUB_STATE_PLAYER)
{
// todo: mark for zoning and remove after main loop
owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
Server.GetWorldManager().DoZoneChange(((Player)owner), 244, null, 0, 15, -160.048f, 0, -165.737f, 0.0f);
//Server.GetWorldManager().DoZoneChange(((Player)owner), 244, null, 0, 15, -160.048f, 0, -165.737f, 0.0f);
}
else
{

View file

@ -34,7 +34,7 @@ namespace FFXIVClassic_Map_Server.Actors
private uint despawnTime;
private uint spawnDistance;
private float spawnX, spawnY, spawnZ;
public float spawnX, spawnY, spawnZ;
public BattleNpc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot,
ushort actorState, uint animationId, string customDisplayName)
: base(actorNumber, actorClass, uniqueId, spawnedArea, posX, posY, posZ, rot, actorState, animationId, customDisplayName)
@ -85,6 +85,7 @@ namespace FFXIVClassic_Map_Server.Actors
propPacketUtil.AddProperty("charaWork.battleTemp.castGauge_speed[1]");
packets.AddRange(propPacketUtil.Done());
}
base.PostUpdate(tick);
}
public override bool CanAttack()