mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
added pool/spawn/genus mod loading
- moved ai helper classes to own folder
This commit is contained in:
@@ -134,7 +134,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool CanFollowPath()
|
||||
{
|
||||
return pathFind != null && (GetCurrentState() != null || GetCurrentState().CanChangeState());
|
||||
return pathFind != null && (GetCurrentState() == null || GetCurrentState().CanChangeState());
|
||||
}
|
||||
|
||||
public bool CanChangeState()
|
||||
@@ -278,6 +278,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
if (controller != null)
|
||||
controller.UseItem(target, slot, itemId);
|
||||
}
|
||||
|
||||
public void InternalChangeTarget(Character target)
|
||||
{
|
||||
// targets are changed in the controller
|
||||
|
@@ -8,6 +8,8 @@ using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.actors.area;
|
||||
using FFXIVClassic_Map_Server.utils;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.state;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
{
|
||||
@@ -132,10 +134,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
Engage(owner.hateContainer.GetMostHatedTarget());
|
||||
return;
|
||||
}
|
||||
//else if (owner.currentLockedTarget != 0)
|
||||
//{
|
||||
// ChangeTarget(Server.GetWorldManager().GetActorInWorld(owner.currentLockedTarget).GetAsCharacter());
|
||||
//}
|
||||
|
||||
if (tick >= waitTime)
|
||||
{
|
||||
@@ -155,7 +153,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
waitTime = tick.AddSeconds(10);
|
||||
owner.OnRoam(tick);
|
||||
|
||||
if (!owner.aiContainer.pathFind.IsFollowingPath())
|
||||
if (!owner.aiContainer.pathFind.IsFollowingPath() && CanMoveForward(0.0f))
|
||||
{
|
||||
// will move on next tick
|
||||
owner.aiContainer.pathFind.SetPathFlags(PathFindFlags.None);
|
||||
@@ -166,22 +164,25 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
|
||||
if (tick >= neutralTime)
|
||||
{
|
||||
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
|
||||
if (!owner.neutral && owner.IsAlive())
|
||||
{
|
||||
if (!owner.isMovingToSpawn && owner.aiContainer.pathFind.AtPoint() && owner.detectionType != DetectionType.None)
|
||||
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
|
||||
{
|
||||
uint levelDifference = (uint)Math.Abs(owner.charaWork.parameterSave.state_mainSkillLevel - player.charaWork.parameterSave.state_mainSkillLevel);
|
||||
|
||||
if (levelDifference <= 10 || (owner.detectionType & DetectionType.IgnoreLevelDifference) != 0 && CanAggroTarget(player))
|
||||
if (!owner.isMovingToSpawn && owner.aiContainer.pathFind.AtPoint() && owner.detectionType != DetectionType.None)
|
||||
{
|
||||
owner.hateContainer.AddBaseHate(player);
|
||||
break;
|
||||
uint levelDifference = (uint)Math.Abs(owner.charaWork.parameterSave.state_mainSkillLevel - player.charaWork.parameterSave.state_mainSkillLevel);
|
||||
|
||||
if (levelDifference <= 10 || (owner.detectionType & DetectionType.IgnoreLevelDifference) != 0 && CanAggroTarget(player))
|
||||
{
|
||||
owner.hateContainer.AddBaseHate(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (owner.aiContainer.pathFind.IsFollowingPath())
|
||||
if (owner.aiContainer.pathFind.IsFollowingPath() && owner.aiContainer.CanFollowPath())
|
||||
{
|
||||
owner.aiContainer.pathFind.FollowPath();
|
||||
}
|
||||
@@ -328,6 +329,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
bool hasInvisible = false;
|
||||
bool isFacing = owner.IsFacing(target);
|
||||
|
||||
// use the mobmod sight range before defaulting to 20 yalms
|
||||
if (detectSight && !hasInvisible && isFacing && distance < owner.GetMobMod((uint)MobModifier.SightRange))
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
// todo: check line of sight and aggroTypes
|
||||
if (distance > 20)
|
||||
{
|
||||
@@ -341,10 +346,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
}
|
||||
|
||||
|
||||
if ((owner.detectionType & DetectionType.LowHp) != 0 && target.GetHPP() < 75)
|
||||
|
||||
if ((owner.detectionType & DetectionType.Sound) != 0 && !hasSneak && distance < owner.GetMobMod((uint)MobModifier.SoundRange))
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
if (detectSight && !hasInvisible && isFacing)
|
||||
if ((owner.detectionType & DetectionType.Magic) != 0 && target.aiContainer.IsCurrentState<MagicState>())
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
if ((owner.detectionType & DetectionType.LowHp) != 0 && target.GetHPP() < 75)
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
return false;
|
||||
|
@@ -73,18 +73,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public override void OnInterrupt()
|
||||
{
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorResult != null)
|
||||
{
|
||||
owner.zone.BroadcastPacketAroundActor(owner, BattleActionX01Packet.BuildPacket(errorResult.targetId, errorResult.animation, 0x765D, errorResult));
|
||||
errorResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
// todo: possible underflow
|
||||
BattleAction action = new BattleAction(target.actorId, 0x765D, (uint) HitEffect.Hit, 0, (byte) HitDirection.None);
|
||||
errorResult = null;
|
||||
|
||||
//var packet = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, (uint)0x19001000, (uint)0x8000604, (ushort)0x765D, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, (byte)0x1);
|
||||
|
||||
// HitDirection (auto attack shouldnt need this afaik)
|
||||
|
||||
// todo: implement auto attack damage bonus in Character.OnAttack
|
||||
/*
|
||||
≪Auto-attack Damage Bonus≫
|
||||
@@ -98,30 +98,22 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
Thaumaturge Mind Piety
|
||||
* The above damage bonus also applies to “Shot” attacks by archers.
|
||||
*/
|
||||
|
||||
// handle paralyze/intimidate/sleep/whatever in Character.OnAttack
|
||||
owner.OnAttack(this, action, ref errorResult);
|
||||
// handle paralyze/intimidate/sleep/whatever in character thing
|
||||
owner.DoBattleAction((ushort)BattleActionX01PacketCommand.Attack, action.animation, errorResult == null ? action : errorResult);
|
||||
|
||||
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, effectId, 0, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, 0);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
{
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction))
|
||||
{
|
||||
// todo: sometimes paralyze can let you attack, get random percentage of actually letting you attack
|
||||
// todo: sometimes paralyze can let you attack, calculate proc rate
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction);
|
||||
uint statusId = 0;
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// todo: actually check proc rate/random chance of whatever effect
|
||||
statusId = list[0].GetStatusId();
|
||||
}
|
||||
// todo: which is actually the swing packet
|
||||
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, statusId, 0, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, 0);
|
||||
//owner.zone.BroadcastPacketAroundActor(owner, errorPacket);
|
||||
//errorPacket = null;
|
||||
interrupt = true;
|
||||
return;
|
||||
}
|
||||
@@ -147,7 +139,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
return false;
|
||||
}
|
||||
// todo: shouldnt need to check if owner is dead since all states would be cleared
|
||||
if (owner.aiContainer.IsDead() || target.aiContainer.IsDead())
|
||||
if (owner.IsDead() || target.IsDead())
|
||||
{
|
||||
if (owner is BattleNpc)
|
||||
((BattleNpc)owner).hateContainer.ClearHate(target);
|
||||
|
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
class InactiveState : State
|
||||
{
|
||||
private DateTime endTime;
|
||||
private uint durationMs;
|
||||
public InactiveState(Character owner, uint durationMs, bool canChangeState) :
|
||||
base(owner, null)
|
||||
{
|
||||
if (!canChangeState)
|
||||
owner.aiContainer.InterruptStates();
|
||||
this.durationMs = durationMs;
|
||||
endTime = DateTime.Now.AddMilliseconds(durationMs);
|
||||
}
|
||||
|
||||
public override bool Update(DateTime tick)
|
||||
{
|
||||
if (durationMs == 0)
|
||||
{
|
||||
if (owner.IsDead())
|
||||
return true;
|
||||
|
||||
if (!owner.statusEffects.HasStatusEffectsByFlag(StatusEffectFlags.PreventAction))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (durationMs != 0 && tick > endTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user