mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Refactored Demo's battle action code and cleaned things up.
This commit is contained in:
@@ -87,15 +87,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public override void OnComplete()
|
||||
{
|
||||
// todo: possible underflow
|
||||
BattleAction action = new BattleAction();
|
||||
errorPacket = null;
|
||||
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);
|
||||
action.animation = 0x19001000;
|
||||
action.targetId = target.actorId;
|
||||
action.effectId = (uint)HitEffect.Hit;
|
||||
action.worldMasterTextId = 0x765D;
|
||||
action.param = (byte)HitDirection.None; // HitDirection (auto attack shouldnt need this afaik)
|
||||
|
||||
// HitDirection (auto attack shouldnt need this afaik)
|
||||
|
||||
// todo: implement auto attack damage bonus in Character.OnAttack
|
||||
/*
|
||||
@@ -111,14 +108,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
* The above damage bonus also applies to “Shot” attacks by archers.
|
||||
*/
|
||||
|
||||
owner.OnAttack(this, action, ref errorPacket);
|
||||
owner.OnAttack(this, action, ref errorResult);
|
||||
// handle paralyze/intimidate/sleep/whatever in character thing
|
||||
if (errorPacket == null)
|
||||
owner.zone.BroadcastPacketAroundActor(owner, BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, action.targetId, action.animation,
|
||||
0x8000000 | action.effectId, action.worldMasterTextId, (ushort)BattleActionX01PacketCommand.Attack, action.amount, action.param)
|
||||
);
|
||||
else
|
||||
owner.zone.BroadcastPacketAroundActor(owner, errorPacket);
|
||||
owner.DoBattleAction((ushort)BattleActionX01PacketCommand.Attack, 0x19001000, errorResult != null ? action : errorResult);
|
||||
|
||||
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, effectId, 0, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, 0);
|
||||
}
|
||||
|
||||
|
@@ -28,22 +28,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicPrepare", owner, target, spell);
|
||||
|
||||
// todo: check recast
|
||||
if (returnCode == 0 && owner.CanCast(target, spell, ref errorPacket))
|
||||
if (returnCode == 0 && owner.CanCast(target, spell))
|
||||
{
|
||||
// todo: Azia can fix, check the recast time and send error
|
||||
OnStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (owner is Player)
|
||||
{
|
||||
// "Your battle command fails to activate"
|
||||
if (errorPacket == null)
|
||||
errorPacket = owner.CreateGameMessagePacket(Server.GetWorldManager().GetActor(), (ushort)(returnCode == -1 ? 32410 : returnCode), 0x20, owner.actorId);
|
||||
|
||||
((Player)owner).QueuePacket(errorPacket);
|
||||
}
|
||||
errorPacket = null;
|
||||
{
|
||||
errorResult = null;
|
||||
interrupt = true;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +47,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (returnCode != 0)
|
||||
{
|
||||
interrupt = true;
|
||||
errorPacket = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, owner.actorId, 0, 0, (ushort)(returnCode == -1 ? 32558 : returnCode), spell.id, 0, 1);
|
||||
errorResult = new BattleAction(target.actorId, (ushort)(returnCode == -1 ? 32558 : returnCode), 0, 0, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,9 +98,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public override void OnInterrupt()
|
||||
{
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorPacket != null)
|
||||
if (errorResult != null)
|
||||
{
|
||||
owner.zone.BroadcastPacketAroundActor(owner, errorPacket);
|
||||
//owner.zone.BroadcastPacketAroundActor(owner, errorResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,23 +115,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
var i = 0;
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
var action = new BattleAction();
|
||||
action.effectId = spell.effectAnimation;
|
||||
action.param = (byte)HitDirection.None; // HitDirection (magic shouldnt need this afaik)
|
||||
action.unknown = 1;
|
||||
action.targetId = chara.actorId;
|
||||
action.worldMasterTextId = spell.worldMasterTextId;
|
||||
action.animation = spell.battleAnimation;
|
||||
var action = new BattleAction(target.actorId, spell.worldMasterTextId, spell.effectAnimation, 0, (byte) HitDirection.None, 1);
|
||||
action.amount = (ushort)lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicFinish", owner, chara, spell, action);
|
||||
actions[i++] = action;
|
||||
|
||||
//packets.Add(BattleActionX01Packet.BuildPacket(chara.actorId, owner.actorId, action.targetId, spell.battleAnimation, action.effectId, action.worldMasterTextId, spell.id, action.amount, action.param));
|
||||
}
|
||||
owner.zone.BroadcastPacketAroundActor(owner,
|
||||
spell.aoeType != TargetFindAOEType.None ? (BattleActionX10Packet.BuildPacket(owner.actorId, owner.actorId, actions[0].animation, spell.id, actions)) :
|
||||
BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, spell.battleAnimation, actions[0].effectId, actions[0].worldMasterTextId, spell.id, actions[0].amount, actions[0].param)
|
||||
);
|
||||
//owner.zone.BroadcastPacketsAroundActor(owner, packets);
|
||||
|
||||
owner.DoBattleAction(spell.id, spell.effectAnimation, actions);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
@@ -170,7 +153,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
private bool CanCast()
|
||||
{
|
||||
return owner.CanCast(target, spell, ref errorPacket) && !HasMoved();
|
||||
return owner.CanCast(target, spell) && !HasMoved();
|
||||
}
|
||||
|
||||
private bool HasMoved()
|
||||
|
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
protected DateTime startTime;
|
||||
|
||||
protected SubPacket errorPacket;
|
||||
protected BattleAction errorResult;
|
||||
|
||||
protected bool isCompleted;
|
||||
|
||||
|
@@ -25,22 +25,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillPrepare", owner, target, skill);
|
||||
|
||||
// todo: check recast
|
||||
if (returnCode == 0 && owner.CanWeaponSkill(target, skill, ref errorPacket))
|
||||
if (returnCode == 0 && owner.CanWeaponSkill(target, skill))
|
||||
{
|
||||
// todo: Azia can fix, check the recast time and send error
|
||||
OnStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (owner is Player)
|
||||
{
|
||||
// "Your battle command fails to activate"
|
||||
if (errorPacket == null)
|
||||
errorPacket = owner.CreateGameMessagePacket(Server.GetWorldManager().GetActor(), (ushort)(returnCode == -1 ? 32410 : returnCode), 0x20, owner.actorId, owner.actorId, owner.actorId, owner.actorId);
|
||||
|
||||
((Player)owner).QueuePacket(errorPacket);
|
||||
}
|
||||
errorPacket = null;
|
||||
errorResult = null;
|
||||
interrupt = true;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +44,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (returnCode != 0)
|
||||
{
|
||||
interrupt = true;
|
||||
errorPacket = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, owner.actorId, 0, 0, (ushort)(returnCode == -1 ? 32558 : returnCode), skill.id, 0, 1);
|
||||
errorResult = new BattleAction(owner.actorId, (ushort)(returnCode == -1 ? 32558 : returnCode), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,9 +81,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public override void OnInterrupt()
|
||||
{
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorPacket != null)
|
||||
if (errorResult != null)
|
||||
{
|
||||
owner.zone.BroadcastPacketAroundActor(owner, errorPacket);
|
||||
owner.DoBattleAction(skill.id, 0, errorResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,13 +99,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
var i = 0;
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
var action = new BattleAction();
|
||||
action.effectId = (uint)HitEffect.Hit;
|
||||
action.param = 1; // HitDirection
|
||||
action.unknown = 1;
|
||||
action.targetId = chara.actorId;
|
||||
action.worldMasterTextId = skill.worldMasterTextId;
|
||||
action.animation = skill.battleAnimation;
|
||||
var action = new BattleAction(chara.actorId, skill.worldMasterTextId, (uint)HitEffect.Hit, 0, 1, 1);
|
||||
// evasion, miss, dodge, etc to be handled in script, calling helpers from scripts/weaponskills.lua
|
||||
action.amount = (ushort)lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillFinish", owner, target, skill, action);
|
||||
actions[i++] = action;
|
||||
@@ -121,10 +107,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
//packets.Add(BattleActionX01Packet.BuildPacket(chara.actorId, owner.actorId, action.targetId, skill.battleAnimation, action.effectId, action.worldMasterTextId, skill.id, action.amount, action.param));
|
||||
}
|
||||
|
||||
owner.zone.BroadcastPacketAroundActor(owner,
|
||||
skill.aoeType != TargetFindAOEType.None ? (BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, actions[0].animation, skill.id, actions)) :
|
||||
BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, skill.battleAnimation, actions[0].effectId, actions[0].worldMasterTextId, skill.id, actions[0].amount, actions[0].param)
|
||||
);
|
||||
owner.DoBattleAction(skill.id, 0, actions);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
@@ -155,7 +138,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
private bool CanUse()
|
||||
{
|
||||
return owner.CanWeaponSkill(target, skill, ref errorPacket);
|
||||
return owner.CanWeaponSkill(target, skill);
|
||||
}
|
||||
|
||||
public BattleCommand GetWeaponSkill()
|
||||
|
Reference in New Issue
Block a user