From 1ae15df64cc0c54bfc1a21c90f7a50d268c53781 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Sat, 26 Aug 2017 06:47:07 +0100 Subject: [PATCH] add ion's fix for BattleActionX10Packet crashing client - add blizzara spell lua --- FFXIVClassic Common Class Lib/Vector3.cs | 2 +- .../actors/chara/ai/TargetFind.cs | 2 +- .../actors/chara/ai/state/DeathState.cs | 13 +------------ .../actors/chara/ai/state/MagicState.cs | 9 ++++----- .../actors/chara/ai/state/State.cs | 2 +- .../actors/chara/ai/state/WeaponSkillState.cs | 9 ++++----- .../Actor/battle/BattleActionX10Packet.cs | 2 +- data/scripts/commands/EquipAbilityCommand.lua | 2 +- data/scripts/spells/blizzara.lua | 19 +++++++++++++++++++ 9 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 data/scripts/spells/blizzara.lua diff --git a/FFXIVClassic Common Class Lib/Vector3.cs b/FFXIVClassic Common Class Lib/Vector3.cs index 17dec44b..863aeb69 100644 --- a/FFXIVClassic Common Class Lib/Vector3.cs +++ b/FFXIVClassic Common Class Lib/Vector3.cs @@ -78,7 +78,7 @@ namespace FFXIVClassic.Common public static float GetAngle(float x, float z, float x2, float z2) { - var angle = (float)Math.Atan((z2 - z) / (x2 - x)); + var angle = (float)(Math.Atan((z2 - z) / (x2 - x)) * - Math.PI); return x > x2 ? angle + (float)Math.PI : angle; } diff --git a/FFXIVClassic Map Server/actors/chara/ai/TargetFind.cs b/FFXIVClassic Map Server/actors/chara/ai/TargetFind.cs index 8e14b724..2e42be88 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/TargetFind.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/TargetFind.cs @@ -354,7 +354,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai return false; // hit everything within zone or within aoe region - if (extents == 255.0f || aoeType == TargetFindAOEType.Circle && target.GetPosAsVector3().IsWithinCircle(targetPosition, extents)) + if (extents == 255.0f || aoeType == TargetFindAOEType.Circle && target.GetPosAsVector3().IsWithinCircle(targetPosition ?? target.GetPosAsVector3(), extents)) return true; if (aoeType == TargetFindAOEType.Cone && IsWithinCone(target, withPet)) diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/DeathState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/DeathState.cs index 6b78eb0b..bd2983e6 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/DeathState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/DeathState.cs @@ -25,18 +25,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state // todo: handle raise etc if (tick >= despawnTime) { - if (owner.currentSubState == SetActorStatePacket.SUB_STATE_PLAYER) - { - // todo: mark for zoning and remove after main loop - owner.Spawn(Program.Tick); - //Server.GetWorldManager().DoZoneChange(((Player)owner), 244, null, 0, 15, -160.048f, 0, -165.737f, 0.0f); - } - else - { - owner.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE); - // todo: fadeout animation and crap - //owner.zone.DespawnActor(owner); - } + owner.Spawn(Program.Tick); return true; } return false; diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/MagicState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/MagicState.cs index 9415ddb6..c7098b5b 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/MagicState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/MagicState.cs @@ -32,8 +32,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state // todo: Azia can fix, check the recast time and send error OnStart(); } - - if (interrupt || errorPacket != null) + else if (interrupt || errorPacket != null) { if (owner is Player && errorPacket != null) ((Player)owner).QueuePacket(errorPacket); @@ -50,7 +49,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 ? 32539 : returnCode), spell.id, 0, 1); + errorPacket = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, owner.actorId, 0, 0, (ushort)(returnCode == -1 ? 32558 : returnCode), spell.id, 0, 1); } else { @@ -120,9 +119,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state action.amount = (ushort)lua.LuaEngine.CallLuaAbilityFunction(owner, spell, "spells", "onSpellFinish", 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(BattleActionX01Packet.BuildPacket(chara.actorId, owner.actorId, action.targetId, spell.battleAnimation, action.effectId, action.worldMasterTextId, spell.id, action.amount, action.param)); } - //packets.Add(BattleActionX10Packet.BuildPacket(player.actorId, owner.actorId, spell.battleAnimation, spell.id, actions)); + packets.Add(BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, spell.battleAnimation, spell.id, actions)); owner.zone.BroadcastPacketsAroundActor(owner, packets); } diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/State.cs b/FFXIVClassic Map Server/actors/chara/ai/state/State.cs index dc5da1d6..a1ca89f4 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/State.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/State.cs @@ -14,7 +14,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state protected Character target; protected bool canInterrupt; - protected bool interrupt; + protected bool interrupt = false; protected DateTime startTime; diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs index abf1b67e..53d6ac79 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs @@ -30,8 +30,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state // todo: Azia can fix, check the recast time and send error OnStart(); } - - if (interrupt || errorPacket != null) + else if (interrupt || errorPacket != null) { if (owner is Player && errorPacket != null) ((Player)owner).QueuePacket(errorPacket); @@ -48,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, skill.id, 0, 1); + errorPacket = BattleActionX01Packet.BuildPacket(owner.actorId, owner.actorId, owner.actorId, 0, 0, (ushort)(returnCode == -1 ? 32558 : returnCode), skill.id, 0, 1); } else { @@ -112,9 +111,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state action.amount = (ushort)lua.LuaEngine.CallLuaAbilityFunction(owner, skill, "skills", "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(BattleActionX01Packet.BuildPacket(chara.actorId, owner.actorId, action.targetId, skill.battleAnimation, action.effectId, action.worldMasterTextId, skill.id, action.amount, action.param)); } - //packets.Add(BattleActionX10Packet.BuildPacket(player.actorId, owner.actorId, spell.battleAnimation, spell.id, actions)); + packets.Add(BattleActionX10Packet.BuildPacket(owner.target.actorId, owner.actorId, skill.battleAnimation, skill.id, actions)); owner.zone.BroadcastPacketsAroundActor(owner, packets); } diff --git a/FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX10Packet.cs b/FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX10Packet.cs index b1d0056a..ae0017e5 100644 --- a/FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX10Packet.cs +++ b/FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX10Packet.cs @@ -29,7 +29,7 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.battle binWriter.Write((UInt16)commandId); binWriter.Write((UInt16)0x810); //? - binWriter.Seek(0x20, SeekOrigin.Begin); + //binWriter.Seek(0x20, SeekOrigin.Begin); foreach (BattleAction action in actionList) binWriter.Write((UInt32)action.targetId); diff --git a/data/scripts/commands/EquipAbilityCommand.lua b/data/scripts/commands/EquipAbilityCommand.lua index 51569a2d..946c5a2a 100644 --- a/data/scripts/commands/EquipAbilityCommand.lua +++ b/data/scripts/commands/EquipAbilityCommand.lua @@ -8,7 +8,7 @@ require ("global") function onEventStarted(player, equipAbilityWidget, triggername, slot, ability, unkown, arg1, arg2, arg3, arg4, arg5, arg6) if ability then - player:EquipAbility(slot, ability); + player:EquipAbility(slot, ability, 1); end player:endEvent(); end \ No newline at end of file diff --git a/data/scripts/spells/blizzara.lua b/data/scripts/spells/blizzara.lua new file mode 100644 index 00000000..72ccc0bd --- /dev/null +++ b/data/scripts/spells/blizzara.lua @@ -0,0 +1,19 @@ +function onSpellPrepare(caster, target, spell) + return 0; +end; + +function onSpellStart(caster, target, spell) + return 0; +end; + +function onSpellFinish(caster, target, spell, action) + local damage = math.random(10, 100); + print("fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuckkk") + + action.param = damage; + if target.hateContainer then + target.hateContainer.AddBaseHate(caster); + target.hateContainer.UpdateHate(caster, damage); + end; + return damage; +end; \ No newline at end of file