mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04: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:
@@ -11,6 +11,7 @@ using System.Collections.Generic;
|
||||
using FFXIVClassic_Map_Server.actors.chara;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
using FFXIVClassic_Map_Server.packets.send;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.state;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
@@ -177,6 +178,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
zone.BroadcastPacketAroundActor(this, PlayAnimationOnActorPacket.BuildPacket(actorId, animId));
|
||||
}
|
||||
|
||||
#region ai stuff
|
||||
public void PathTo(float x, float y, float z, float stepSize = 0.70f, int maxPath = 40, float polyRadius = 0.0f)
|
||||
{
|
||||
aiContainer?.pathFind?.PreparePath(x, y, z, stepSize, maxPath, polyRadius);
|
||||
@@ -265,17 +267,17 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool CanCast(Character target, Ability spell, ref SubPacket errorPacket)
|
||||
public virtual bool CanCast(Character target, BattleCommand spell, ref SubPacket errorPacket)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanWeaponSkill(Character target, Ability skill, ref SubPacket errorPacket)
|
||||
public virtual bool CanWeaponSkill(Character target, BattleCommand skill, ref SubPacket errorPacket)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanUseAbility(Character target, Ability ability, ref SubPacket errorPacket)
|
||||
public virtual bool CanUseAbility(Character target, BattleCommand ability, ref SubPacket errorPacket)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -470,6 +472,27 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
// todo: for battlenpc/player calculate speed
|
||||
return moveSpeeds[2] + GetMod((uint)Modifier.Speed);
|
||||
}
|
||||
|
||||
public virtual void OnAttack(State state, BattleAction action)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnCast(State state, BattleAction action)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnWeaponSkill(State state, BattleAction action)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnAbility(State state, BattleAction action)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using FFXIVClassic_Map_Server.actors.chara.player;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.utils;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
@@ -43,7 +44,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
Miss = 0x08
|
||||
}
|
||||
|
||||
class Ability
|
||||
class BattleCommand
|
||||
{
|
||||
public ushort id;
|
||||
public string name;
|
||||
@@ -70,20 +71,20 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public uint battleAnimation;
|
||||
public ushort worldMasterTextId;
|
||||
public uint param;
|
||||
public int aoeRange;
|
||||
|
||||
public TargetFind targetFind;
|
||||
|
||||
public Ability(ushort id, string name)
|
||||
public BattleCommand(ushort id, string name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.range = 0;
|
||||
}
|
||||
|
||||
public Ability Clone()
|
||||
public BattleCommand Clone()
|
||||
{
|
||||
return (Ability)MemberwiseClone();
|
||||
return (BattleCommand)MemberwiseClone();
|
||||
}
|
||||
|
||||
public bool IsSpell()
|
||||
@@ -104,15 +105,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
if (aoeType == TargetFindAOEType.Box)
|
||||
{
|
||||
// todo: read box width from sql
|
||||
targetFind.SetAOEBox(validTarget, range, 3);
|
||||
targetFind.SetAOEBox(validTarget, range, aoeRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetFind.SetAOEType(validTarget, aoeType, range, 40);
|
||||
targetFind.SetAOEType(validTarget, aoeType, range, aoeRange);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
worldMasterTextId
|
||||
32512 cannot be performed on a KO'd target.
|
||||
32513 can only be performed on a KO'd target.
|
||||
32514 cannot be performed on yourself.
|
||||
@@ -143,8 +145,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
}
|
||||
|
||||
// todo: calculate cost based on modifiers also (probably in BattleUtils)
|
||||
|
||||
if (mpCost > 0 && (mpCost = CalculateCost((ushort)user.charaWork.parameterSave.state_mainSkillLevel)) > user.GetMP())
|
||||
|
||||
if (BattleUtils.CalculateSpellCost(user, target, this) > user.GetMP())
|
||||
{
|
||||
// todo: error message
|
||||
errorPacket = user.CreateGameMessagePacket(Server.GetWorldManager().GetActor(), 32545, 0x20, (uint)id);
|
||||
@@ -215,7 +217,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
else
|
||||
cost = (ushort)(8000 + (level - 70) * 500);
|
||||
|
||||
return (ushort)Math.Ceiling((cost * ((mpCost == 0 ? tpCost : mpCost) * 0.001)));
|
||||
if (mpCost != 0)
|
||||
return (ushort)Math.Ceiling((cost * mpCost * 0.001));
|
||||
|
||||
return tpCost;
|
||||
}
|
||||
}
|
||||
}
|
@@ -137,6 +137,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
point = path[path.Count - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (distanceFromPoint == 0)
|
||||
return owner.positionX == point.X && owner.positionZ == point.Z;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -368,6 +369,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
private StatusEffectOverwrite overwrite; // how to handle adding an effect with same id (see StatusEfectOverwrite)
|
||||
private bool silent = false; // do i send a message on losing effect
|
||||
|
||||
HitEffect animationEffect;
|
||||
|
||||
public StatusEffect(Character owner, uint id, UInt64 magnitude, uint tickMs, uint durationMs, byte tier = 0)
|
||||
{
|
||||
this.owner = owner;
|
||||
@@ -566,5 +569,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
this.silent = silent;
|
||||
}
|
||||
|
||||
public void SetAnimation(uint hitEffect)
|
||||
{
|
||||
animationEffect = (HitEffect)hitEffect;
|
||||
}
|
||||
|
||||
public uint GetAnimation()
|
||||
{
|
||||
return (uint)animationEffect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,6 +68,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool AddStatusEffect(StatusEffect newEffect, Character source, bool silent = false)
|
||||
{
|
||||
/*
|
||||
worldMasterTextId
|
||||
32001 [@2B([@IF($E4($EB(1),$EB(2)),you,[@IF($E9(7),[@SHEETEN(xtx/displayName,2,$E9(7),1,1)],$EB(2))])])] [@IF($E4($EB(1),$EB(2)),resist,resists)] the effect of [@SHEET(xtx/status,$E8(11),3)].
|
||||
32002 [@SHEET(xtx/status,$E8(11),3)] fails to take effect.
|
||||
*/
|
||||
// todo: check flags/overwritable and add effect to list
|
||||
var effect = GetStatusEffectById(newEffect.GetStatusEffectId());
|
||||
bool canOverwrite = false;
|
||||
@@ -85,8 +90,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
if (!silent || !effect.GetSilent() || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
{
|
||||
// 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, newEffect.GetOwner().actorId, 0x7678, 0, 0, newEffect.GetStatusId(), 0, 0));
|
||||
}
|
||||
|
||||
// wont send a message about losing effect here
|
||||
@@ -119,11 +122,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
if (effects.ContainsKey(effect.GetStatusEffectId()))
|
||||
{
|
||||
// send packet to client with effect remove message
|
||||
if (!silent || !effect.GetSilent() || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
if (!silent && !effect.GetSilent() || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
{
|
||||
// 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, owner.actorId, owner.actorId, 0x7679, 0, 0, effect.GetStatusId(), 0, 0));
|
||||
|
||||
}
|
||||
|
||||
// todo: this is retarded..
|
||||
@@ -147,7 +149,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
if (effect.GetStatusEffectId() == effectId)
|
||||
{
|
||||
RemoveStatusEffect(effect, silent);
|
||||
RemoveStatusEffect(effect, effect.GetSilent() || silent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -309,11 +309,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
private void AddAllInHateList()
|
||||
{
|
||||
if (!(owner is BattleNpc))
|
||||
Program.Log.Error($"TargetFind.AddAllInHateList() owner [{owner.actorId}] {owner.customDisplayName} {owner.actorName} is not a BattleNpc");
|
||||
|
||||
foreach (var hateEntry in ((BattleNpc)owner).hateContainer.GetHateList())
|
||||
{
|
||||
AddTarget(hateEntry.Value.actor, false);
|
||||
Program.Log.Error($"TargetFind.AddAllInHateList() owner [{owner.actorId}] {owner.customDisplayName} {owner.actorName} is not a BattleNpc");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var hateEntry in ((BattleNpc)owner).hateContainer.GetHateList())
|
||||
{
|
||||
AddTarget(hateEntry.Value.actor, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -66,6 +66,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
owner.aiContainer.InternalCast(target, spellId);
|
||||
}
|
||||
|
||||
public override void WeaponSkill(Character target, uint weaponSkillId)
|
||||
{
|
||||
owner.aiContainer.InternalWeaponSkill(target, weaponSkillId);
|
||||
}
|
||||
|
||||
public override void Ability(Character target, uint abilityId)
|
||||
{
|
||||
owner.aiContainer.InternalAbility(target, abilityId);
|
||||
|
@@ -11,8 +11,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
class AttackState : State
|
||||
{
|
||||
private int damage = 0;
|
||||
private bool tooFar = false;
|
||||
private DateTime attackTime;
|
||||
|
||||
public AttackState(Character owner, Character target) :
|
||||
@@ -31,8 +29,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
public override void OnStart()
|
||||
{
|
||||
// todo: check within attack range
|
||||
|
||||
owner.LookAt(target);
|
||||
}
|
||||
|
||||
public override bool Update(DateTime tick)
|
||||
@@ -46,7 +42,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
if (owner.target != target || owner.target?.actorId != owner.currentLockedTarget)
|
||||
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);
|
||||
|
||||
if (target == null || target.IsDead())
|
||||
@@ -90,22 +86,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
damage = utils.AttackUtils.CalculateDamage(owner, target);
|
||||
// todo: possible underflow
|
||||
BattleAction action = new BattleAction();
|
||||
//var packet = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, (uint)0x19001000, (uint)0x8000604, (ushort)0x765D, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, (byte)0x1);
|
||||
|
||||
// onAttack(actor, target, damage)
|
||||
utils.BattleUtils.DamageTarget(owner, target, damage);
|
||||
lua.LuaEngine.CallLuaBattleAction(owner, "onAttack", false, owner, target, damage);
|
||||
|
||||
{
|
||||
var actors = owner.zone.GetActorsAroundActor<Player>(owner, 50);
|
||||
foreach (var player in actors)
|
||||
{
|
||||
var packet = BattleActionX01Packet.BuildPacket(player.actorId, owner.actorId, target.actorId, (uint)0x19001000, (uint)0x8000604, (ushort)0x765D, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, (byte)0x1);
|
||||
player.QueuePacket(packet);
|
||||
}
|
||||
}
|
||||
target.DelHP((short)damage);
|
||||
owner.LookAt(target);
|
||||
action.targetId = target.actorId;
|
||||
action.effectId = (uint)HitEffect.Hit;
|
||||
action.worldMasterTextId = 0x765D;
|
||||
action.param = 1; // todo: hit effect doesnt display without this?
|
||||
owner.OnAttack(this, action);
|
||||
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, effectId, 0, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, 0);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -59,5 +59,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public Character GetTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
class WeaponSkillState : State
|
||||
{
|
||||
|
||||
private Ability skill;
|
||||
private BattleCommand skill;
|
||||
|
||||
public WeaponSkillState(Character owner, Character target, ushort skillId) :
|
||||
base(owner, target)
|
||||
@@ -22,19 +22,24 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
this.startTime = DateTime.Now;
|
||||
// todo: lookup skill from global table
|
||||
this.skill = Server.GetWorldManager().GetAbility(skillId);
|
||||
var returnCode = lua.LuaEngine.CallLuaAbilityFunction(owner, skill, "weaponskills", "onSkillPrepare", owner, target, skill);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillPrepare", owner, target, skill);
|
||||
|
||||
// todo: check recast
|
||||
if (owner.CanWeaponSkill(target, skill, ref errorPacket))
|
||||
if (returnCode == 0 && owner.CanWeaponSkill(target, skill, 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, owner.actorId, owner.actorId, owner.actorId);
|
||||
|
||||
((Player)owner).QueuePacket(errorPacket);
|
||||
}
|
||||
errorPacket = null;
|
||||
interrupt = true;
|
||||
}
|
||||
@@ -42,7 +47,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
var returnCode = lua.LuaEngine.CallLuaAbilityFunction(owner, skill, "weaponskills", "onSkillStart", owner, target, skill);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillStart", owner, target, skill);
|
||||
|
||||
if (returnCode != 0)
|
||||
{
|
||||
@@ -96,25 +101,29 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
isCompleted = true;
|
||||
|
||||
var targets = skill.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();
|
||||
action.effectId = 0;
|
||||
action.effectId = (uint)HitEffect.Hit;
|
||||
action.param = 1;
|
||||
action.unknown = 1;
|
||||
action.targetId = chara.actorId;
|
||||
action.worldMasterTextId = skill.worldMasterTextId;
|
||||
action.amount = (ushort)lua.LuaEngine.CallLuaAbilityFunction(owner, skill, "skills", "onSkillFinish", owner, target, skill, action);
|
||||
// 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;
|
||||
|
||||
//packets.Add(BattleActionX01Packet.BuildPacket(chara.actorId, owner.actorId, action.targetId, skill.battleAnimation, action.effectId, action.worldMasterTextId, skill.id, action.amount, action.param));
|
||||
}
|
||||
packets.Add(BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, skill.battleAnimation, skill.id, actions));
|
||||
owner.zone.BroadcastPacketsAroundActor(owner, packets);
|
||||
|
||||
owner.zone.BroadcastPacketAroundActor(owner,
|
||||
skill.aoeType != TargetFindAOEType.None ? (BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, skill.battleAnimation, 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)
|
||||
);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
@@ -147,5 +156,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
return owner.CanWeaponSkill(target, skill, ref errorPacket);
|
||||
}
|
||||
|
||||
public BattleCommand GetWeaponSkill()
|
||||
{
|
||||
return skill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,12 +5,66 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
{
|
||||
static class BattleUtils
|
||||
{
|
||||
public static void DamageTarget(Character attacker, Character defender, int damage)
|
||||
public static void TryAttack(Character attacker, Character defender, BattleAction action)
|
||||
{
|
||||
// todo: get hit rate, hit count, set hit effect
|
||||
action.effectId |= (uint)(HitEffect.RecoilLv2 | HitEffect.Hit | HitEffect.HitVisual1);
|
||||
|
||||
}
|
||||
|
||||
public static ushort CalculateAttackDamage(Character attacker, Character defender, BattleAction action)
|
||||
{
|
||||
ushort damage = (ushort)(Program.Random.Next(10) * 10);
|
||||
|
||||
// todo: handle all other crap before protect/stoneskin
|
||||
|
||||
// todo: handle crit etc
|
||||
if (defender.statusEffects.HasStatusEffect(StatusEffectId.Protect) || defender.statusEffects.HasStatusEffect(StatusEffectId.Protect2))
|
||||
{
|
||||
if (action != null)
|
||||
action.effectId |= (uint)HitEffect.Protect;
|
||||
}
|
||||
|
||||
if (defender.statusEffects.HasStatusEffect(StatusEffectId.Stoneskin))
|
||||
{
|
||||
if (action != null)
|
||||
action.effectId |= (uint)HitEffect.Stoneskin;
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static ushort CalculateSpellDamage(Character attacker, Character defender, BattleAction action)
|
||||
{
|
||||
ushort damage = 0;
|
||||
|
||||
// todo: handle all other crap before shell/stoneskin
|
||||
|
||||
if (defender.statusEffects.HasStatusEffect(StatusEffectId.Shell))
|
||||
{
|
||||
// todo: shell probably only shows on magic..
|
||||
if (defender.statusEffects.HasStatusEffect(StatusEffectId.Shell))
|
||||
{
|
||||
if (action != null)
|
||||
action.effectId |= (uint)HitEffect.Shell;
|
||||
}
|
||||
}
|
||||
|
||||
if (defender.statusEffects.HasStatusEffect(StatusEffectId.Stoneskin))
|
||||
{
|
||||
if (action != null)
|
||||
action.effectId |= (uint)HitEffect.Stoneskin;
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static void DamageTarget(Character attacker, Character defender, BattleAction action)
|
||||
{
|
||||
// todo: other stuff too
|
||||
if (defender is BattleNpc)
|
||||
@@ -19,15 +73,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils
|
||||
{
|
||||
((BattleNpc)defender).hateContainer.AddBaseHate(attacker);
|
||||
}
|
||||
((BattleNpc)defender).hateContainer.UpdateHate(attacker, damage);
|
||||
((BattleNpc)defender).hateContainer.UpdateHate(attacker, action.amount);
|
||||
}
|
||||
defender.DelHP((short)damage);
|
||||
defender.DelHP((short)action.amount);
|
||||
}
|
||||
|
||||
public static int CalculateSpellDamage(Character attacker, Character defender, Ability spell)
|
||||
public static int CalculateSpellDamage(Character attacker, Character defender, BattleCommand spell)
|
||||
{
|
||||
// todo: spell formulas and stuff (stoneskin, mods, stats, etc)
|
||||
return 69;
|
||||
}
|
||||
|
||||
public static uint CalculateSpellCost(Character caster, Character target, BattleCommand spell)
|
||||
{
|
||||
var scaledCost = spell.CalculateCost((uint)caster.charaWork.parameterSave.state_mainSkillLevel);
|
||||
|
||||
// todo: calculate cost for mob/player
|
||||
if (caster.currentSubState == SetActorStatePacket.SUB_STATE_MONSTER)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
return scaledCost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@ using FFXIVClassic_Map_Server.actors.chara.ai.controllers;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.state;
|
||||
using FFXIVClassic_Map_Server.utils;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.utils;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
@@ -95,19 +97,19 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanCast(Character target, Ability spell, ref SubPacket errorPacket)
|
||||
public override bool CanCast(Character target, BattleCommand spell, ref SubPacket errorPacket)
|
||||
{
|
||||
// todo:
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanWeaponSkill(Character target, Ability skill, ref SubPacket errorPacket)
|
||||
public override bool CanWeaponSkill(Character target, BattleCommand skill, ref SubPacket errorPacket)
|
||||
{
|
||||
// todo:
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanUseAbility(Character target, Ability ability, ref SubPacket errorPacket)
|
||||
public override bool CanUseAbility(Character target, BattleCommand ability, ref SubPacket errorPacket)
|
||||
{
|
||||
// todo:
|
||||
return false;
|
||||
@@ -183,7 +185,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
}
|
||||
|
||||
// dont bother checking for any in-range players if going back to spawn
|
||||
if (!this.isMovingToSpawn && this.aggroType != AggroType.None)
|
||||
if (!this.isMovingToSpawn && this.aiContainer.pathFind.AtPoint() && this.aggroType != AggroType.None)
|
||||
{
|
||||
foreach (var player in zone.GetActorsAroundActor<Player>(this, 50))
|
||||
{
|
||||
@@ -199,5 +201,18 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
return this.isAtSpawn = Utils.DistanceSquared(positionX, positionY, positionZ, spawnX, spawnY, spawnZ) <= 2500.0f;
|
||||
}
|
||||
|
||||
public override void OnAttack(State state, BattleAction action)
|
||||
{
|
||||
// player melee animation
|
||||
uint battleAnimation = 0x19001000;
|
||||
// todo: get hitrate and shit, handle protect effect and whatever
|
||||
BattleUtils.TryAttack(this, state.GetTarget(), action);
|
||||
|
||||
zone.BroadcastPacketAroundActor(this,
|
||||
BattleActionX01Packet.BuildPacket(actorId, actorId, target.actorId, (uint)battleAnimation,
|
||||
(uint)action.effectId, (ushort)action.worldMasterTextId, (ushort)BattleActionX01PacketCommand.Attack, (ushort)action.amount, (byte)action.param)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@ using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.controllers;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.utils;
|
||||
using FFXIVClassic_Map_Server.actors.chara.ai.state;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
@@ -2016,7 +2018,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanCast(Character target, Ability spell, ref SubPacket errorPacket)
|
||||
public override bool CanCast(Character target, BattleCommand spell, ref SubPacket errorPacket)
|
||||
{
|
||||
// todo: move the ability specific stuff to ability.cs
|
||||
if (target == null)
|
||||
@@ -2039,7 +2041,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanWeaponSkill(Character target, Ability skill, ref SubPacket errorPacket)
|
||||
public override bool CanWeaponSkill(Character target, BattleCommand skill, ref SubPacket errorPacket)
|
||||
{
|
||||
// todo: see worldmaster ids 32558~32557 for proper ko message and stuff
|
||||
if (target == null)
|
||||
@@ -2061,5 +2063,24 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnAttack(State state, BattleAction action)
|
||||
{
|
||||
// melee attack animation
|
||||
uint battleAnimation = 0x19001000;
|
||||
|
||||
// todo: change animation based on equipped weapon
|
||||
action.effectId |= (uint)HitEffect.HitVisual1; // melee
|
||||
|
||||
// todo: get hitrate and shit, handle protect effect and whatever
|
||||
BattleUtils.TryAttack(this, state.GetTarget(), action);
|
||||
action.amount = BattleUtils.CalculateAttackDamage(this, state.GetTarget(), action);
|
||||
//var packet = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, target.actorId, (uint)0x19001000, (uint)0x8000604, (ushort)0x765D, (ushort)BattleActionX01PacketCommand.Attack, (ushort)damage, (byte)0x1);
|
||||
|
||||
zone.BroadcastPacketAroundActor(this, BattleActionX01Packet.BuildPacket(actorId, actorId, action.targetId, (uint)battleAnimation,
|
||||
0x8000000 | action.effectId, (ushort)action.worldMasterTextId, (ushort)BattleActionX01PacketCommand.Attack, (ushort)action.amount, (byte)action.param)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user