mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-07-20 17:45:57 +02:00
renamed ability to battlecommand
- moved spells to scripts/commands/ - added aoe range field to battle_commands.sql - changed AttackState to use character's onAttack
This commit is contained in:
parent
6f5a480cbd
commit
6c74222b68
23 changed files with 658 additions and 335 deletions
|
@ -15,29 +15,34 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
class MagicState : State
|
||||
{
|
||||
|
||||
private Ability spell;
|
||||
private uint cost;
|
||||
private BattleCommand spell;
|
||||
private Vector3 startPos;
|
||||
|
||||
public MagicState(Character owner, Character target, ushort spellId) :
|
||||
base(owner, target)
|
||||
{
|
||||
this.startPos = owner.GetPosAsVector3();
|
||||
this.startTime = DateTime.Now;
|
||||
// todo: lookup spell from global table
|
||||
this.spell = Server.GetWorldManager().GetAbility(spellId);
|
||||
var returnCode = lua.LuaEngine.CallLuaAbilityFunction(owner, spell, "spells", "onSpellPrepare", owner, target, spell);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicPrepare", owner, target, spell);
|
||||
|
||||
// todo: check recast
|
||||
if (owner.CanCast(target, spell, ref errorPacket))
|
||||
if (returnCode == 0 && owner.CanCast(target, spell, ref errorPacket))
|
||||
{
|
||||
// todo: Azia can fix, check the recast time and send error
|
||||
OnStart();
|
||||
}
|
||||
else if (interrupt || errorPacket != null)
|
||||
else
|
||||
{
|
||||
if (owner is Player && errorPacket != null)
|
||||
((Player)owner).QueuePacket(errorPacket);
|
||||
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;
|
||||
interrupt = true;
|
||||
}
|
||||
|
@ -45,7 +50,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
|
||||
public override void OnStart()
|
||||
{
|
||||
var returnCode = lua.LuaEngine.CallLuaAbilityFunction(owner, spell, "spells", "onSpellStart", owner, target, spell);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicStart", owner, target, spell);
|
||||
|
||||
if (returnCode != 0)
|
||||
{
|
||||
|
@ -55,8 +60,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
else
|
||||
{
|
||||
// todo: check within attack range
|
||||
startPos = owner.GetPosAsVector3();
|
||||
owner.LookAt(target);
|
||||
float[] baseCastDuration = { 1.0f, 0.25f };
|
||||
|
||||
float spellSpeed = spell.castTimeSeconds;
|
||||
|
@ -126,12 +129,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
action.unknown = 1;
|
||||
action.targetId = chara.actorId;
|
||||
action.worldMasterTextId = spell.worldMasterTextId;
|
||||
action.amount = (ushort)lua.LuaEngine.CallLuaAbilityFunction(owner, spell, "spells", "onSpellFinish", owner, chara, spell, action);
|
||||
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));
|
||||
}
|
||||
packets.Add(BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, spell.battleAnimation, spell.id, actions));
|
||||
owner.zone.BroadcastPacketAroundActor(owner,
|
||||
spell.aoeType != TargetFindAOEType.None ? (BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, spell.battleAnimation, 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);
|
||||
}
|
||||
|
||||
|
@ -181,5 +187,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
}
|
||||
owner.zone.BroadcastPacketsAroundActor(owner, packets);
|
||||
}
|
||||
|
||||
public BattleCommand GetSpell()
|
||||
{
|
||||
return spell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue