mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Combat changes and bug fixes
Added the combo and proc systems Added scripts for most weaponskill and spells as well as some abilities and status effects Added support for multihit attacks Added AbilityState for abilities Added hiteffects that change based on an attack's parameters Added positionals Changed how targeting works for battlecommands Fixed bug that occurred when moving or swapping hotbar commands Fixed bug that occurred when losing status effects
This commit is contained in:
172
FFXIVClassic Map Server/actors/chara/ai/state/AbilityState.cs
Normal file
172
FFXIVClassic Map Server/actors/chara/ai/state/AbilityState.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor.battle;
|
||||
using FFXIVClassic_Map_Server.packets.send;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
class AbilityState : State
|
||||
{
|
||||
|
||||
private BattleCommand skill;
|
||||
|
||||
public AbilityState(Character owner, Character target, ushort skillId) :
|
||||
base(owner, target)
|
||||
{
|
||||
this.startTime = DateTime.Now;
|
||||
this.skill = Server.GetWorldManager().GetBattleCommand(skillId);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "ability", "onAbilityPrepare", owner, target, skill);
|
||||
|
||||
this.target = skill.GetMainTarget(owner, target);
|
||||
|
||||
if (returnCode == 0)
|
||||
{
|
||||
OnStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
errorResult = null;
|
||||
interrupt = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "ability", "onAbilityStart", owner, target, skill);
|
||||
|
||||
if (returnCode != 0)
|
||||
{
|
||||
interrupt = true;
|
||||
errorResult = new BattleAction(owner.actorId, (ushort)(returnCode == -1 ? 32558 : returnCode), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//owner.LookAt(target);
|
||||
|
||||
//If owner already has this status effect and it's a stance that gets removed on reuse, remove it and don't continue
|
||||
var effect = owner.statusEffects.GetStatusEffectById(skill.statusId);
|
||||
if (effect!= null && (effect.GetFlags() & (uint) StatusEffectFlags.Stance) != 0)
|
||||
{
|
||||
owner.statusEffects.RemoveStatusEffect(effect);
|
||||
interrupt = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Update(DateTime tick)
|
||||
{
|
||||
if (skill != null)
|
||||
{
|
||||
TryInterrupt();
|
||||
|
||||
if (interrupt)
|
||||
{
|
||||
OnInterrupt();
|
||||
return true;
|
||||
}
|
||||
|
||||
// todo: check weapon delay/haste etc and use that
|
||||
var actualCastTime = skill.castTimeMs;
|
||||
|
||||
if ((tick - startTime).Milliseconds >= skill.castTimeMs)
|
||||
{
|
||||
OnComplete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnInterrupt()
|
||||
{
|
||||
// todo: send paralyzed/sleep message etc.
|
||||
if (errorResult != null)
|
||||
{
|
||||
owner.DoBattleAction(skill.id, errorResult.animation, errorResult);
|
||||
errorResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
bool hitTarget = false;
|
||||
|
||||
skill.targetFind.FindWithinArea(target, skill.validTarget, skill.aoeTarget);
|
||||
isCompleted = true;
|
||||
var targets = skill.targetFind.GetTargets();
|
||||
|
||||
List<BattleAction> actions = new List<BattleAction>();
|
||||
List<StatusEffect> effects = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.ActivateOnAttack);
|
||||
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
for (int hitNum = 0; hitNum < skill.numHits; hitNum++)
|
||||
{
|
||||
//30328 - Your [ability] grants you the effect of [status]
|
||||
//30320 - You use [ability]. You recover x HP.
|
||||
var action = new BattleAction(chara.actorId, skill.worldMasterTextId, 0, 0, 1, 1);
|
||||
|
||||
//uncached
|
||||
lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "ability", "onAbilityFinish", owner, target, skill, action);
|
||||
//cached
|
||||
//skill.CallLuaFunction(owner, "onAbilityFinish", owner, target, skill, action);
|
||||
|
||||
//if hit type isn't evade or miss
|
||||
if (((action.hitType & HitType.Evade) | (action.hitType & HitType.Miss)) == 0)
|
||||
hitTarget = true;
|
||||
|
||||
actions.AddRange(action.GetAllActions());
|
||||
}
|
||||
}
|
||||
// todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action
|
||||
BattleAction[] errors = (BattleAction[])actions.ToArray().Clone();
|
||||
owner.OnAbility(this, actions.ToArray(), skill, ref errors);
|
||||
owner.DoBattleAction(skill.id, skill.battleAnimation, actions);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
{
|
||||
if (interrupt)
|
||||
return;
|
||||
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAbility))
|
||||
{
|
||||
// todo: sometimes paralyze can let you attack, get random percentage of actually letting you attack
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAbility);
|
||||
uint effectId = 0;
|
||||
if (list.Count > 0)
|
||||
{
|
||||
// todo: actually check proc rate/random chance of whatever effect
|
||||
effectId = list[0].GetStatusEffectId();
|
||||
}
|
||||
interrupt = true;
|
||||
return;
|
||||
}
|
||||
|
||||
interrupt = !CanUse();
|
||||
}
|
||||
|
||||
private bool CanUse()
|
||||
{
|
||||
return skill.IsValidMainTarget(owner, target);
|
||||
}
|
||||
|
||||
public BattleCommand GetWeaponSkill()
|
||||
{
|
||||
return skill;
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
owner.aiContainer.UpdateLastActionTime(skill.animationDurationSeconds);
|
||||
}
|
||||
}
|
||||
}
|
@@ -82,7 +82,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
BattleAction action = new BattleAction(target.actorId, 0x765D, (uint) HitEffect.Hit, 0, (byte) HitDirection.None);
|
||||
//BattleAction action = new BattleAction(target.actorId, 0x765D, (uint) HitEffect.Hit, 0, (byte) HitDirection.None);
|
||||
errorResult = null;
|
||||
|
||||
// todo: implement auto attack damage bonus in Character.OnAttack
|
||||
@@ -99,16 +99,35 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
* 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);
|
||||
owner.DoBattleAction((ushort)BattleActionX01PacketCommand.Attack, action.animation, errorResult == null ? action : errorResult);
|
||||
|
||||
|
||||
List<BattleAction> actions = new List<BattleAction>();
|
||||
|
||||
var i = 0;
|
||||
for (int hitNum = 0; hitNum < owner.GetMod((uint) Modifier.HitCount); hitNum++)
|
||||
{
|
||||
BattleAction action = new BattleAction(target.actorId, 0x765D, (uint)HitEffect.Hit, 100, (byte)HitDirection.None, (byte) hitNum);
|
||||
action.battleActionType = BattleActionType.AttackPhysical;
|
||||
// evasion, miss, dodge, etc to be handled in script, calling helpers from scripts/weaponskills.lua
|
||||
// temporary evade/miss/etc function to test hit effects
|
||||
utils.BattleUtils.CalcHitType(owner, target, null, action);
|
||||
actions.AddRange(action.GetAllActions());
|
||||
}
|
||||
|
||||
// todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action
|
||||
BattleAction[] errors = (BattleAction[])actions.ToArray().Clone();
|
||||
|
||||
owner.OnAttack(this, actions[0], ref errorResult);
|
||||
owner.DoBattleAction(22104, 0x19001000, actions);
|
||||
target.SetMod((uint) Modifier.MinimumHpLock, 0);
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
{
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction))
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAttack))
|
||||
{
|
||||
// todo: sometimes paralyze can let you attack, calculate proc rate
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction);
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAttack);
|
||||
uint statusId = 0;
|
||||
if (list.Count > 0)
|
||||
{
|
||||
@@ -124,7 +143,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
private bool IsAttackReady()
|
||||
{
|
||||
// todo: this enforced delay should really be changed if it's not retail..
|
||||
return Program.Tick >= attackTime && Program.Tick >= owner.aiContainer.GetLastActionTime().AddSeconds(1);
|
||||
return Program.Tick >= attackTime && Program.Tick >= owner.aiContainer.GetLastActionTime();
|
||||
}
|
||||
|
||||
private bool CanAttack()
|
||||
|
@@ -15,9 +15,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
: base(owner, null)
|
||||
{
|
||||
owner.Disengage();
|
||||
//owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
|
||||
var deathStatePacket = SetActorStatePacket.BuildPacket(owner.actorId, SetActorStatePacket.MAIN_STATE_DEAD, owner.currentSubState);
|
||||
owner.zone.BroadcastPacketAroundActor(owner, deathStatePacket);
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
|
||||
owner.statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnDeath, true);
|
||||
//var deathStatePacket = SetActorStatePacket.BuildPacket(owner.actorId, SetActorStatePacket.MAIN_STATE_DEAD2, owner.currentSubState);
|
||||
//owner.zone.BroadcastPacketAroundActor(owner, deathStatePacket);
|
||||
canInterrupt = false;
|
||||
startTime = tick;
|
||||
despawnTime = startTime.AddSeconds(timeToFadeOut);
|
||||
|
@@ -27,7 +27,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (owner.IsDead())
|
||||
return true;
|
||||
|
||||
if (!owner.statusEffects.HasStatusEffectsByFlag(StatusEffectFlags.PreventAction))
|
||||
if (!owner.statusEffects.HasStatusEffectsByFlag(StatusEffectFlags.PreventMovement))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
this.spell = Server.GetWorldManager().GetBattleCommand(spellId);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicPrepare", owner, target, spell);
|
||||
|
||||
if (returnCode == 0 && owner.CanCast(target, spell))
|
||||
this.target = spell.GetMainTarget(owner, target);
|
||||
|
||||
if (returnCode == 0 && owner.CanCast(this.target, spell))
|
||||
{
|
||||
OnStart();
|
||||
}
|
||||
@@ -51,16 +53,28 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
// todo: check within attack range
|
||||
float[] baseCastDuration = { 1.0f, 0.25f };
|
||||
|
||||
float spellSpeed = spell.castTimeSeconds;
|
||||
//Check combo stuff here because combos can impact spell cast times
|
||||
|
||||
// command casting duration
|
||||
if (owner is Player)
|
||||
float spellSpeed = spell.castTimeMs;
|
||||
|
||||
//There are no positional spells, so just check onCombo, need to check first because certain spells change aoe type/accuracy
|
||||
//If owner is a player and the spell being used is part of the current combo
|
||||
if (spell.comboStep == 1 || ((owner is Player p) && (p.playerWork.comboNextCommandId[0] == spell.id || p.playerWork.comboNextCommandId[1] == spell.id)))
|
||||
{
|
||||
// todo: modify spellSpeed based on modifiers and stuff
|
||||
((Player)owner).SendStartCastbar(spell.id, Utils.UnixTimeStampUTC(DateTime.Now.AddSeconds(spellSpeed)));
|
||||
lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onCombo", owner, target, spell);
|
||||
spell.isCombo = true;
|
||||
}
|
||||
if (!spell.IsInstantCast())
|
||||
{
|
||||
// command casting duration
|
||||
if (owner is Player)
|
||||
{
|
||||
// todo: modify spellSpeed based on modifiers and stuff
|
||||
((Player)owner).SendStartCastbar(spell.id, Utils.UnixTimeStampUTC(DateTime.Now.AddMilliseconds(spellSpeed)));
|
||||
}
|
||||
owner.SendChant(0xf, 0x0);
|
||||
owner.DoBattleAction(spell.id, (uint) 0x6F000000 | spell.castType, new BattleAction(target.actorId, 30128, 1, 0, 1)); //You begin casting (6F000002: BLM, 6F000003: WHM, 0x6F000008: BRD)
|
||||
}
|
||||
owner.SendChant(0xF, 0x0);
|
||||
owner.DoBattleAction(spell.id, 0x6F000002, new BattleAction(target.actorId, 30128, 1, 0, 1)); //You begin casting (6F000002: BLM, 6F000003: WHM)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +91,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
}
|
||||
|
||||
// todo: check weapon delay/haste etc and use that
|
||||
var actualCastTime = spell.castTimeSeconds;
|
||||
var actualCastTime = spell.castTimeMs;
|
||||
|
||||
if ((tick - startTime).TotalSeconds >= spell.castTimeSeconds)
|
||||
if ((tick - startTime).TotalMilliseconds >= spell.castTimeMs)
|
||||
{
|
||||
OnComplete();
|
||||
return true;
|
||||
@@ -102,24 +116,58 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
//How do combos/hitdirs work for aoe abilities or does that not matter for aoe?
|
||||
HitDirection hitDir = owner.GetHitDirection(target);
|
||||
bool hitTarget = false;
|
||||
|
||||
spell.targetFind.FindWithinArea(target, spell.validTarget, spell.aoeTarget);
|
||||
isCompleted = true;
|
||||
|
||||
var targets = spell.targetFind.GetTargets();
|
||||
BattleAction[] actions = new BattleAction[targets.Count];
|
||||
var i = 0;
|
||||
foreach (var chara in targets)
|
||||
|
||||
|
||||
List<BattleAction> actions = new List<BattleAction>();
|
||||
if (targets.Count > 0)
|
||||
{
|
||||
var action = new BattleAction(chara.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;
|
||||
List<StatusEffect> effects = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.ActivateOnSpell);
|
||||
|
||||
//modify skill based on status effects
|
||||
foreach (var effect in effects)
|
||||
lua.LuaEngine.CallLuaStatusEffectFunction(owner, effect, "onWeaponSkill", owner, effect, spell);
|
||||
|
||||
//Now that combos and positionals bonuses are done, we can calculate hits/crits/etc and damage
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
for (int hitNum = 0; hitNum < spell.numHits; hitNum++)
|
||||
{
|
||||
var action = new BattleAction(chara.actorId, spell.worldMasterTextId, 0, 0, (byte) hitDir, (byte) hitNum);
|
||||
lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicFinish", owner, chara, spell, action);
|
||||
|
||||
//if hit type isn't evade or miss
|
||||
if (action.hitType > HitType.Evade)
|
||||
hitTarget = true;
|
||||
|
||||
actions.AddRange(action.GetAllActions());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//No targets hit, cast failed
|
||||
actions.Add(new BattleAction(target.actorId, 30202, (uint) (0)));
|
||||
}
|
||||
|
||||
// todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action
|
||||
var errors = (BattleAction[])actions.Clone();
|
||||
owner.OnCast(this, actions, ref errors);
|
||||
owner.DoBattleAction(spell.id, spell.battleAnimation, actions);
|
||||
|
||||
// todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action
|
||||
BattleAction[] errors = (BattleAction[])actions.ToArray().Clone();
|
||||
owner.OnCast(this, actions.ToArray(), spell, ref errors);
|
||||
owner.DoBattleAction(spell.id, spell.battleAnimation, actions);
|
||||
owner.statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnCasting);
|
||||
//Now that we know if we hit the target we can check if the combo continues
|
||||
if (owner is Player player)
|
||||
if (spell.isCombo && hitTarget)
|
||||
player.SetCombos(spell.comboNextCommandId);
|
||||
else
|
||||
player.SetCombos();
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
@@ -127,10 +175,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (interrupt)
|
||||
return;
|
||||
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction))
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventSpell))
|
||||
{
|
||||
// todo: sometimes paralyze can let you attack, get random percentage of actually letting you attack
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction);
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventSpell);
|
||||
uint effectId = 0;
|
||||
if (list.Count > 0)
|
||||
{
|
||||
@@ -154,7 +202,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
private bool CanCast()
|
||||
{
|
||||
return owner.CanCast(target, spell) && spell.IsValidTarget(owner, target) && !HasMoved();
|
||||
return owner.CanCast(target, spell) && spell.IsValidMainTarget(owner, target) && !HasMoved();
|
||||
}
|
||||
|
||||
private bool HasMoved()
|
||||
@@ -170,7 +218,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
((Player)owner).SendEndCastbar();
|
||||
}
|
||||
owner.aiContainer.UpdateLastActionTime();
|
||||
owner.aiContainer.UpdateLastActionTime(spell.animationDurationSeconds);
|
||||
}
|
||||
|
||||
public BattleCommand GetSpell()
|
||||
|
@@ -15,11 +15,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
|
||||
private BattleCommand skill;
|
||||
|
||||
private HitDirection hitDirection;
|
||||
public WeaponSkillState(Character owner, Character target, ushort skillId) :
|
||||
base(owner, target)
|
||||
{
|
||||
this.startTime = DateTime.Now;
|
||||
//this.target = skill.targetFind.
|
||||
this.skill = Server.GetWorldManager().GetBattleCommand(skillId);
|
||||
var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillPrepare", owner, target, skill);
|
||||
|
||||
@@ -46,6 +47,37 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
else
|
||||
{
|
||||
owner.LookAt(target);
|
||||
hitDirection = owner.GetHitDirection(target);
|
||||
|
||||
//Do positionals and combo effects first because these can influence accuracy and amount of targets/numhits, which influence the rest of the steps
|
||||
//If there is no positon required or if the position bonus should be activated
|
||||
if ((skill.positionBonus & utils.BattleUtils.ConvertHitDirToPosition(hitDirection)) == skill.positionBonus)
|
||||
{
|
||||
//If there is a position bonus
|
||||
if (skill.positionBonus != BattleCommandPositionBonus.None)
|
||||
//lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onPositional", owner, target, skill);
|
||||
skill.CallLuaFunction(owner, "onPositional", owner, target, skill);
|
||||
|
||||
//Combo stuff
|
||||
if (owner is Player p)
|
||||
{
|
||||
//If skill is part of owner's class/job, it can be used in a combo
|
||||
if (skill.job == p.GetClass() || skill.job == p.GetCurrentClassOrJob())
|
||||
{
|
||||
//If owner is a player and the skill being used is part of the current combo
|
||||
if (p.playerWork.comboNextCommandId[0] == skill.id || p.playerWork.comboNextCommandId[1] == skill.id)
|
||||
{
|
||||
lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onCombo", owner, target, skill);
|
||||
skill.CallLuaFunction(owner, "onCombo", owner, target, skill);
|
||||
skill.isCombo = true;
|
||||
}
|
||||
//or if this just the start of a combo
|
||||
else if (skill.comboStep == 1)
|
||||
skill.isCombo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +94,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
}
|
||||
|
||||
// todo: check weapon delay/haste etc and use that
|
||||
var actualCastTime = skill.castTimeSeconds;
|
||||
var actualCastTime = skill.castTimeMs;
|
||||
|
||||
if ((tick - startTime).TotalSeconds >= skill.castTimeSeconds)
|
||||
if ((tick - startTime).Milliseconds >= skill.castTimeMs)
|
||||
{
|
||||
OnComplete();
|
||||
return true;
|
||||
@@ -86,28 +118,55 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
bool hitTarget = false;
|
||||
|
||||
skill.targetFind.FindWithinArea(target, skill.validTarget, skill.aoeTarget);
|
||||
isCompleted = true;
|
||||
var targets = skill.targetFind.GetTargets();
|
||||
|
||||
BattleAction[] actions = new BattleAction[targets.Count];
|
||||
//Need a variable size list of actions because status effects may add extra actions
|
||||
//BattleAction[] actions = new BattleAction[targets.Count * skill.numHits];
|
||||
List<BattleAction> actions = new List<BattleAction>();
|
||||
List<StatusEffect> effects = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.ActivateOnAttack);
|
||||
|
||||
var i = 0;
|
||||
//modify skill based on status effects
|
||||
foreach (var effect in effects)
|
||||
effect.CallLuaFunction(owner, "onWeaponSkill", skill);
|
||||
|
||||
//Now that combos and positionals bonuses are done, we can calculate hits/crits/etc and damage for each action
|
||||
foreach (var chara in targets)
|
||||
{
|
||||
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;
|
||||
chara.Engage(chara.actorId, 1);
|
||||
for (int hitNum = 0; hitNum < skill.numHits; hitNum++)
|
||||
{
|
||||
var action = new BattleAction(chara.actorId, skill.worldMasterTextId, 0, 0, (byte) hitDirection, 1);
|
||||
//For older versions this will need to be in the database for magic weaponskills
|
||||
action.battleActionType = BattleActionType.AttackPhysical;
|
||||
//uncached script
|
||||
lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillFinish", owner, target, skill, action);
|
||||
|
||||
//cached script
|
||||
//skill.CallLuaFunction(owner, "onSkillFinish", owner, target, skill, action);
|
||||
action.hitNum = (byte)hitNum;
|
||||
|
||||
if (action.hitType > HitType.Evade)
|
||||
hitTarget = true;
|
||||
|
||||
actions.AddRange(action.GetAllActions());
|
||||
}
|
||||
}
|
||||
|
||||
// todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action
|
||||
var errors = (BattleAction[])actions.Clone();
|
||||
owner.OnWeaponSkill(this, actions, ref errors);
|
||||
BattleAction[] errors = (BattleAction[]) actions.ToArray().Clone();
|
||||
owner.OnWeaponSkill(this, actions.ToArray(), skill, ref errors);
|
||||
owner.DoBattleAction(skill.id, skill.battleAnimation, actions);
|
||||
|
||||
owner.statusEffects.RemoveStatusEffectsByFlags((uint) StatusEffectFlags.LoseOnAttacking);
|
||||
|
||||
//Now that we know if we hit the target we can check if the combo continues
|
||||
if (owner is Player player)
|
||||
if (skill.isCombo && hitTarget)
|
||||
player.SetCombos(skill.comboNextCommandId);
|
||||
else
|
||||
player.SetCombos();
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
@@ -115,10 +174,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
if (interrupt)
|
||||
return;
|
||||
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction))
|
||||
if (owner.statusEffects.HasStatusEffectsByFlag((uint)StatusEffectFlags.PreventWeaponSkill))
|
||||
{
|
||||
// todo: sometimes paralyze can let you attack, get random percentage of actually letting you attack
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventAction);
|
||||
var list = owner.statusEffects.GetStatusEffectsByFlag((uint)StatusEffectFlags.PreventWeaponSkill);
|
||||
uint effectId = 0;
|
||||
if (list.Count > 0)
|
||||
{
|
||||
@@ -134,7 +193,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
private bool CanUse()
|
||||
{
|
||||
return owner.CanWeaponSkill(target, skill) && skill.IsValidTarget(owner, target);
|
||||
return owner.CanWeaponSkill(target, skill) && skill.IsValidMainTarget(owner, target);
|
||||
}
|
||||
|
||||
public BattleCommand GetWeaponSkill()
|
||||
@@ -144,7 +203,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
owner.aiContainer.UpdateLastActionTime();
|
||||
owner.aiContainer.UpdateLastActionTime(skill.animationDurationSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user