mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
fixed cast interrupt
- dont allow targeting of mob moving back to spawn
This commit is contained in:
@@ -113,7 +113,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool CanChangeState()
|
||||
{
|
||||
return GetCurrentState() == null || states.Peek().CanInterrupt();
|
||||
return GetCurrentState() == null || states.Peek().CanChangeState();
|
||||
}
|
||||
|
||||
public void ChangeTarget(Character target)
|
||||
@@ -294,31 +294,40 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
owner.updateFlags |= ActorUpdateFlags.HpTpMp;
|
||||
|
||||
// todo: use the update flags
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
|
||||
|
||||
ChangeTarget(null);
|
||||
ClearStates();
|
||||
}
|
||||
|
||||
public void InternalAbility(Character target, uint abilityId)
|
||||
{
|
||||
|
||||
if (CanChangeState())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalCast(Character target, uint spellId)
|
||||
{
|
||||
ChangeState(new MagicState(owner, target, (ushort)spellId));
|
||||
if (CanChangeState())
|
||||
{
|
||||
ChangeState(new MagicState(owner, target, (ushort)spellId));
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalWeaponSkill(Character target, uint weaponSkillId)
|
||||
{
|
||||
ChangeState(new WeaponSkillState(owner, target, (ushort)weaponSkillId));
|
||||
if (CanChangeState())
|
||||
{
|
||||
ChangeState(new WeaponSkillState(owner, target, (ushort)weaponSkillId));
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalMobSkill(Character target, uint mobSkillId)
|
||||
{
|
||||
if (CanChangeState())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalDie(DateTime tick, uint timeToFadeout)
|
||||
|
@@ -12,7 +12,7 @@ using FFXIVClassic_Map_Server.actors.chara.ai.utils;
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
|
||||
public enum AbilityRequirements : ushort
|
||||
public enum BattleCommandRequirements : ushort
|
||||
{
|
||||
None,
|
||||
DiscipleOfWar = 0x01,
|
||||
@@ -27,7 +27,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
Conjury = 0x200
|
||||
}
|
||||
|
||||
public enum AbilityPositionBonus : byte
|
||||
public enum BattleCommandPositionBonus : byte
|
||||
{
|
||||
None,
|
||||
Front = 0x01,
|
||||
@@ -35,7 +35,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
Flank = 0x04
|
||||
}
|
||||
|
||||
public enum AbilityProcRequirement : byte
|
||||
public enum BattleCommandProcRequirement : byte
|
||||
{
|
||||
None,
|
||||
Evade = 0x01,
|
||||
@@ -50,12 +50,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
public string name;
|
||||
public byte job;
|
||||
public byte level;
|
||||
public AbilityRequirements requirements;
|
||||
public BattleCommandRequirements requirements;
|
||||
public ValidTarget validTarget;
|
||||
public TargetFindAOEType aoeType;
|
||||
public byte numHits;
|
||||
public AbilityPositionBonus positionBonus;
|
||||
public AbilityProcRequirement procRequirement;
|
||||
public BattleCommandPositionBonus positionBonus;
|
||||
public BattleCommandProcRequirement procRequirement;
|
||||
public int range;
|
||||
public uint debuffDurationSeconds;
|
||||
public uint buffDurationSeconds;
|
||||
@@ -158,7 +158,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
}
|
||||
|
||||
// todo: check target requirements
|
||||
if (requirements != AbilityRequirements.None)
|
||||
if (requirements != BattleCommandRequirements.None)
|
||||
{
|
||||
if (false)
|
||||
{
|
||||
|
@@ -248,8 +248,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
private bool IsWithinCone(Character target, bool withPet)
|
||||
{
|
||||
// todo:
|
||||
return false;
|
||||
// todo: make this actual cone
|
||||
return owner.IsFacing(target, angle) && Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, target.positionX, target.positionY, target.positionZ) < extents;
|
||||
}
|
||||
|
||||
private void AddTarget(Character target, bool withPet)
|
||||
|
@@ -76,17 +76,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
// todo: too far, path to player if mob, message if player
|
||||
// owner.ResetMoveSpeeds();
|
||||
owner.moveState = 2;
|
||||
if (owner.currentSubState == SetActorStatePacket.SUB_STATE_MONSTER && owner.GetSpeed() != 0)
|
||||
{
|
||||
// todo: actual stat based range
|
||||
if (Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, target.positionX, target.positionY, target.positionZ) > 10)
|
||||
{
|
||||
owner.aiContainer.pathFind.SetPathFlags(PathFindFlags.None);
|
||||
owner.aiContainer.pathFind.PathInRange(target.positionX, target.positionY, target.positionZ, 1.5f, owner.GetAttackRange());
|
||||
ChangeTarget(target);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
lastActionTime = DateTime.Now;
|
||||
// todo: adjust cooldowns with modifiers
|
||||
}
|
||||
@@ -165,13 +154,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
// todo:
|
||||
waitTime = tick.AddSeconds(10);
|
||||
owner.OnRoam(tick);
|
||||
}
|
||||
|
||||
if (tick >= lastRoamUpdate && !owner.aiContainer.pathFind.IsFollowingPath())
|
||||
{
|
||||
// will move on next tick
|
||||
owner.aiContainer.pathFind.SetPathFlags(PathFindFlags.None);
|
||||
owner.aiContainer.pathFind.PathInRange(owner.spawnX, owner.spawnY, owner.spawnZ, 1.5f, 20.0f);
|
||||
if (!owner.aiContainer.pathFind.IsFollowingPath())
|
||||
{
|
||||
// will move on next tick
|
||||
owner.aiContainer.pathFind.SetPathFlags(PathFindFlags.None);
|
||||
owner.aiContainer.pathFind.PathInRange(owner.spawnX, owner.spawnY, owner.spawnZ, 1.5f, 20.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,10 +170,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
{
|
||||
if (!owner.isMovingToSpawn && owner.aiContainer.pathFind.AtPoint() && owner.aggroType != AggroType.None)
|
||||
{
|
||||
uint levelDifference = (uint)Math.Abs(owner.charaWork.parameterSave.state_mainSkillLevel - ((Player)player).charaWork.parameterSave.state_mainSkillLevel);
|
||||
uint levelDifference = (uint)Math.Abs(owner.charaWork.parameterSave.state_mainSkillLevel - player.charaWork.parameterSave.state_mainSkillLevel);
|
||||
|
||||
if (levelDifference < 10 || (owner.aggroType & AggroType.IgnoreLevelDifference) != 0 && ((BattleNpcController)owner.aiContainer.GetController()).CanAggroTarget((Player)player))
|
||||
owner.hateContainer.AddBaseHate((Player)player);
|
||||
if (levelDifference <= 10 || (owner.aggroType & AggroType.IgnoreLevelDifference) != 0 && CanAggroTarget(player))
|
||||
{
|
||||
owner.hateContainer.AddBaseHate(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,13 +238,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
continue;
|
||||
|
||||
float mobDistance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, chara.positionX, chara.positionY, chara.positionZ);
|
||||
if (mobDistance < 0.70f && (chara.updateFlags & ActorUpdateFlags.Position) == 0)
|
||||
if (mobDistance < 0.50f && (chara.updateFlags & ActorUpdateFlags.Position) == 0)
|
||||
{
|
||||
owner.aiContainer.pathFind.PathInRange(targetPos, 1.3f, 1.8f);
|
||||
owner.aiContainer.pathFind.PathInRange(targetPos, 1.3f, chara.GetAttackRange());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FaceTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,6 +274,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (owner.GetSpeed() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -339,12 +336,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
hasInvisible = hasSneak;
|
||||
}
|
||||
|
||||
if (detectSight && !hasInvisible && isFacing)
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
if ((owner.aggroType & AggroType.LowHp) != 0 && target.GetHPP() < 75)
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
if (detectSight && !hasInvisible && isFacing)
|
||||
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public AttackState(Character owner, Character target) :
|
||||
base(owner, target)
|
||||
{
|
||||
this.canInterrupt = true;
|
||||
this.canInterrupt = false;
|
||||
this.startTime = DateTime.Now;
|
||||
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_ACTIVE);
|
||||
@@ -43,12 +43,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
}
|
||||
*/
|
||||
if (target == null || owner.target != target || owner.target?.actorId != owner.currentLockedTarget)
|
||||
owner.aiContainer.ChangeTarget(target = Server.GetWorldManager().GetActorInWorld(owner.currentLockedTarget == 0xC0000000 ? owner.currentTarget : owner.currentLockedTarget) as Character);
|
||||
owner.aiContainer.ChangeTarget(target = owner.zone.FindActorInArea(owner.currentLockedTarget == 0xC0000000 ? owner.currentTarget : owner.currentLockedTarget) as Character);
|
||||
|
||||
if (target == null || target.IsDead())
|
||||
{
|
||||
//if (owner.currentSubState == SetActorStatePacket.SUB_STATE_MONSTER)
|
||||
// target = ((BattleNpc)owner).hateContainer.GetMostHatedTarget();
|
||||
if (owner.currentSubState == SetActorStatePacket.SUB_STATE_MONSTER)
|
||||
target = ((BattleNpc)owner).hateContainer.GetMostHatedTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -34,8 +34,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
OnStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
errorResult = null;
|
||||
{
|
||||
errorResult = new BattleAction(owner.actorId, 32553, 0);
|
||||
interrupt = true;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (returnCode != 0)
|
||||
{
|
||||
interrupt = true;
|
||||
errorResult = new BattleAction(target.actorId, (ushort)(returnCode == -1 ? 32558 : returnCode), 0, 0, 0, 1);
|
||||
errorResult = new BattleAction(target.actorId, (ushort)(returnCode == -1 ? 32553 : returnCode), 0, 0, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
((Player)owner).SendStartCastbar(spell.id, Utils.UnixTimeStampUTC(DateTime.Now.AddSeconds(spellSpeed)));
|
||||
owner.DoBattleAction(spell.id, 0x6F000002, new BattleAction(target.actorId, 30128, 1, 0, 1)); //You begin casting (6F000002: BLM, 6F000003: WHM)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,25 +97,24 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorResult != null)
|
||||
{
|
||||
//owner.zone.BroadcastPacketAroundActor(owner, errorResult);
|
||||
owner.DoBattleAction(spell.id, errorResult.animation, errorResult);
|
||||
errorResult = null;
|
||||
}
|
||||
owner.DoBattleAction(spell.id, 0x7F000002, new BattleAction(target.actorId, 0, 1, 0, 1));
|
||||
}
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
spell.targetFind.FindWithinArea(target, spell.validTarget);
|
||||
isCompleted = true;
|
||||
|
||||
|
||||
var targets = spell.targetFind.GetTargets();
|
||||
BattleAction[] actions = new BattleAction[targets.Count];
|
||||
List<SubPacket> packets = new List<SubPacket>();
|
||||
var i = 0;
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
var action = new BattleAction(target.actorId, spell.worldMasterTextId, spell.battleAnimation, 0, (byte) HitDirection.None, 1);
|
||||
var action = new BattleAction(target.actorId, spell.worldMasterTextId, spell.battleAnimation, 0, (byte)HitDirection.None, 1);
|
||||
action.amount = (ushort)lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicFinish", owner, chara, spell, action);
|
||||
actions[i++] = action;
|
||||
actions[i++] = action;
|
||||
}
|
||||
|
||||
owner.DoBattleAction(spell.id, spell.battleAnimation, actions);
|
||||
@@ -143,7 +142,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
interrupt = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (HasMoved())
|
||||
{
|
||||
errorResult = new BattleAction(owner.actorId, 30211, 0);
|
||||
errorResult.animation = 0x7F000002;
|
||||
interrupt = true;
|
||||
return;
|
||||
}
|
||||
|
||||
interrupt = !CanCast();
|
||||
}
|
||||
|
||||
@@ -154,7 +161,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
private bool HasMoved()
|
||||
{
|
||||
return (Utils.DistanceSquared(owner.GetPosAsVector3(), startPos) > 4.0f);
|
||||
return (owner.GetPosAsVector3() != startPos);
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
|
@@ -83,7 +83,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorResult != null)
|
||||
{
|
||||
owner.DoBattleAction(skill.id, 0, errorResult);
|
||||
owner.DoBattleAction(skill.id, errorResult.animation, errorResult);
|
||||
errorResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user