From a996797bebcf435359bd70ea6307653750f33173 Mon Sep 17 00:00:00 2001 From: Yogurt Date: Sat, 8 Jun 2019 21:44:06 -0700 Subject: [PATCH] Level 0 class fixes Add level 1 abilities when switching to level 0 class Fix client error when switching to level 0 class --- .../actors/chara/player/Player.cs | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 3eba884d..150057d0 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -991,11 +991,7 @@ namespace FFXIVClassic_Map_Server.Actors } public void PrepareClassChange(byte classId) - { - //If new class, init abilties and level - if (charaWork.battleSave.skillLevel[classId - 1] <= 0) - UpdateClassLevel(classId, 1); - + { SendCharaExpInfo(); } @@ -1037,6 +1033,13 @@ namespace FFXIVClassic_Map_Server.Actors charaWork.commandCategory[i] = 0; } + //If new class, init abilties and level + if (charaWork.battleSave.skillLevel[classId - 1] <= 0) + { + UpdateClassLevel(classId, 1); + EquipAbilitiesAtLevel(classId, 1); + } + ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this); propertyBuilder.AddProperty("charaWork.parameterSave.state_mainSkill[0]"); @@ -1071,7 +1074,7 @@ namespace FFXIVClassic_Map_Server.Actors { Database.PlayerCharacterUpdateClassLevel(this, classId, level); charaWork.battleSave.skillLevel[classId - 1] = level; - ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/exp", this); + ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this); propertyBuilder.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId-1)); List packets = propertyBuilder.Done(); QueuePackets(packets); @@ -2453,12 +2456,10 @@ namespace FFXIVClassic_Map_Server.Actors //Set exp to current class to 0 so that exp is added correctly charaWork.battleSave.skillPoint[classId - 1] = 0; //send new level - ActorPropertyPacketUtil expPropertyPacket2 = new ActorPropertyPacketUtil("charaWork/exp", this); - ActorPropertyPacketUtil expPropertyPacket3 = new ActorPropertyPacketUtil("charaWork/stateForAll", this); - expPropertyPacket2.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1)); - expPropertyPacket2.AddProperty("charaWork.parameterSave.state_mainSkillLevel"); - QueuePackets(expPropertyPacket2.Done()); - QueuePackets(expPropertyPacket3.Done()); + ActorPropertyPacketUtil levelPropertyPacket = new ActorPropertyPacketUtil("charaWork/stateForAll", this); + levelPropertyPacket.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1)); + levelPropertyPacket.AddProperty("charaWork.parameterSave.state_mainSkillLevel"); + QueuePackets(levelPropertyPacket.Done()); Database.SetLevel(this, classId, GetLevel()); Database.SavePlayerCurrentClass(this); @@ -2475,6 +2476,27 @@ namespace FFXIVClassic_Map_Server.Actors return actionList; } + //Equips any abilities for the given classId at the given level. If actionList is not null, adds a "You learn Command" message + private void EquipAbilitiesAtLevel(byte classId, short level, List actionList = null) + { + //If there's any abilites that unlocks at this level, equip them. + List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); + foreach (ushort commandId in commandIds) + { + EquipAbilityInFirstOpenSlot(classId, commandId, false); + byte jobId = ConvertClassIdToJobId(classId); + if (jobId != classId) + EquipAbilityInFirstOpenSlot(jobId, commandId, false); + + //33926: You learn [command]. + if (actionList != null) + { + if (classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) + actionList.Add(new CommandResult(actorId, 33926, 0, commandId)); + } + } + } + //Increaess level of current class and equips new abilities earned at that level public void LevelUp(byte classId, List actionList = null) { @@ -2488,22 +2510,7 @@ namespace FFXIVClassic_Map_Server.Actors if (actionList != null) actionList.Add(new CommandResult(actorId, 33909, 0, (ushort)charaWork.battleSave.skillLevel[classId - 1])); - //If there's any abilites that unlocks at this level, equip them. - List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); - foreach (ushort commandId in commandIds) - { - EquipAbilityInFirstOpenSlot(classId, commandId, false); - byte jobId = ConvertClassIdToJobId(classId); - if (jobId != classId) - EquipAbilityInFirstOpenSlot(jobId, commandId, false); - - //33926: You learn [command]. - if (actionList != null) - { - if (classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) - actionList.Add(new CommandResult(actorId, 33926, 0, commandId)); - } - } + EquipAbilitiesAtLevel(classId, GetLevel(), actionList); } }