From d7c383d04ad2b6164e0d9136543345dbd9e9a0b6 Mon Sep 17 00:00:00 2001 From: Yogurt Date: Wed, 29 May 2019 20:06:31 -0700 Subject: [PATCH] Use a static BattleCommand for auto attacks This is temporary until all mob skills are added, including mob auto attacks. --- .../actors/chara/ai/state/AttackState.cs | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs index b1cd3cc1..df042941 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs @@ -104,26 +104,35 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state //List actions = new List(); CommandResultContainer actions = new CommandResultContainer(); - - var i = 0; - for (int hitNum = 0; hitNum < 1 /* owner.GetMod((uint) Modifier.HitCount)*/; hitNum++) - { - CommandResult action = new CommandResult(target.actorId, 0x765D, (uint)HitEffect.Hit, 100, (byte)HitDirection.None, (byte) hitNum); - action.commandType = CommandType.AutoAttack; - action.actionType = ActionType.Physical; - action.actionProperty = (ActionProperty) owner.GetMod(Modifier.AttackType); - // evasion, miss, dodge, etc to be handled in script, calling helpers from scripts/weaponskills.lua - // temporary evade/miss/etc function to test hit effects - action.DoAction(owner, target, null, actions); - } - // todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action - CommandResult[] errors = (CommandResult[])actions.GetList().ToArray().Clone(); - CommandResult error = null;// new BattleAction(0, null, 0, 0); - //owner.DoActions(null, actions.GetList(), ref error); - //owner.OnAttack(this, actions[0], ref errorResult); - var anim = (uint)(17 << 24 | 1 << 12); - owner.DoBattleAction(22104, anim, actions.GetList()); + //This is all temporary until the skill sheet is finishd and the different auto attacks are added to the database + //Some mobs have multiple unique auto attacks that they switch between as well as ranged auto attacks, so we'll need a way to handle that + //For now, just use a temporary hardcoded BattleCommand that's the same for everyone. + BattleCommand attackCommand = new BattleCommand(22104, "Attack"); + attackCommand.range = 5; + attackCommand.rangeHeight = 10; + attackCommand.worldMasterTextId = 0x765D; + attackCommand.mainTarget = (ValidTarget)384; + attackCommand.validTarget = (ValidTarget)384; + attackCommand.commandType = CommandType.AutoAttack; + attackCommand.numHits = (byte)owner.GetMod(Modifier.HitCount); + attackCommand.basePotency = 100; + ActionProperty property = (owner.GetMod(Modifier.AttackType) != 0) ? (ActionProperty)owner.GetMod(Modifier.AttackType) : ActionProperty.Slashing; + attackCommand.actionProperty = property; + attackCommand.actionType = ActionType.Physical; + + uint anim = (17 << 24 | 1 << 12); + + if (owner is Player) + anim = (25 << 24 | 1 << 12); + + attackCommand.battleAnimation = anim; + + if (owner.CanUse(target, attackCommand)) + { + attackCommand.targetFind.FindWithinArea(target, attackCommand.validTarget, attackCommand.aoeTarget); + owner.DoBattleCommand(attackCommand, "autoattack"); + } } public override void TryInterrupt()