private void RestoreRoleCustomData(GameClient client, RoleCustomData customData) { RoleCustomDataItem roleCustomData = null; if (customData != null && customData.customDataList != null && customData.customDataList.Count > 0) { roleCustomData = customData.customDataList.Find((RoleCustomDataItem x) => x.Occupation == client.ClientData.Occupation); } if (null == roleCustomData) { roleCustomData = new RoleCustomDataItem(); } client.ClientData.MainQuickBarKeys = roleCustomData.Main_quick_keys; GameManager.DBCmdMgr.AddDBCmd(10010, string.Format("{0}:{1}:{2}", client.ClientData.RoleID, 0, roleCustomData.Main_quick_keys), null, client.ServerId); int[] rolePoint = new int[4]; for (int i = 0; i < 4; i++) { if (roleCustomData.RolePointList != null && i < roleCustomData.RolePointList.Count) { rolePoint[i] = roleCustomData.RolePointList[i]; } } client.ClientData.PropStrength = Global.GetRoleParamsInt32FromDB(client, "PropStrengthChangeless") + rolePoint[0]; Global.SaveRoleParamsInt32ValueToDB(client, "PropStrength", client.ClientData.PropStrength, true); client.ClientData.PropIntelligence = Global.GetRoleParamsInt32FromDB(client, "PropIntelligenceChangeless") + rolePoint[1]; Global.SaveRoleParamsInt32ValueToDB(client, "PropIntelligence", client.ClientData.PropIntelligence, true); client.ClientData.PropDexterity = Global.GetRoleParamsInt32FromDB(client, "PropDexterityChangeless") + rolePoint[2]; Global.SaveRoleParamsInt32ValueToDB(client, "PropDexterity", client.ClientData.PropDexterity, true); client.ClientData.PropConstitution = Global.GetRoleParamsInt32FromDB(client, "PropConstitutionChangeless") + rolePoint[3]; Global.SaveRoleParamsInt32ValueToDB(client, "PropConstitution", client.ClientData.PropConstitution, true); TalentManager.DBTalentEffectClear(client.ClientData.RoleID, client.ClientData.ZoneID, client.ServerId); foreach (TalentEffectItem item in roleCustomData.EffectList) { TalentManager.ModifyEffect(client, item.ID, item.TalentType, item.Level); } client.ClientData.DefaultSkillLev = roleCustomData.DefaultSkillLev; Global.SaveRoleParamsInt32ValueToDB(client, "DefaultSkillLev", client.ClientData.DefaultSkillLev, true); client.ClientData.DefaultSkillUseNum = roleCustomData.DefaultSkillUseNum; Global.SaveRoleParamsInt32ValueToDB(client, "DefaultSkillUseNum", client.ClientData.DefaultSkillUseNum, true); if (client.ClientData.FuWenTabList != null && client.ClientData.FuWenTabList.Count > 0) { for (int i = 0; i < client.ClientData.FuWenTabList.Count; i++) { int skillID = 0; List <int> shenShiActiveList = new List <int>(); if (roleCustomData.ShenShiEuipSkill != null && i < roleCustomData.ShenShiEuipSkill.Count) { skillID = roleCustomData.ShenShiEuipSkill[i].SkillEquip; shenShiActiveList = roleCustomData.ShenShiEuipSkill[i].ShenShiActiveList; } client.ClientData.FuWenTabList[i].SkillEquip = skillID; client.ClientData.FuWenTabList[i].ShenShiActiveList = shenShiActiveList; Global.sendToDB <int, FuWenTabData>(20316, client.ClientData.FuWenTabList[i], 0); } } }
private void SaveRoleCustomData(GameClient client, RoleCustomData customData) { int oldIndex = -1; RoleCustomDataItem roleCustomDataOld = null; RoleCustomDataItem roleCustomData = null; if (customData != null && customData.customDataList != null && customData.customDataList.Count > 0) { oldIndex = customData.customDataList.FindIndex((RoleCustomDataItem x) => x.Occupation == client.ClientData.Occupation); if (oldIndex >= 0) { roleCustomDataOld = customData.customDataList[oldIndex]; } } roleCustomData = new RoleCustomDataItem { Occupation = client.ClientData.Occupation }; roleCustomData.Main_quick_keys = client.ClientData.MainQuickBarKeys; roleCustomData.RolePointList.Add(client.ClientData.PropStrength - Global.GetRoleParamsInt32FromDB(client, "PropStrengthChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropIntelligence - Global.GetRoleParamsInt32FromDB(client, "PropIntelligenceChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropDexterity - Global.GetRoleParamsInt32FromDB(client, "PropDexterityChangeless")); roleCustomData.RolePointList.Add(client.ClientData.PropConstitution - Global.GetRoleParamsInt32FromDB(client, "PropConstitutionChangeless")); for (int i = 0; i < roleCustomData.RolePointList.Count; i++) { if (roleCustomData.RolePointList[i] < 0) { roleCustomData.RolePointList[i] = 0; } } int sum = roleCustomData.RolePointList.Sum(); while (sum > client.ClientData.TotalPropPoint) { for (int i = 0; i < roleCustomData.RolePointList.Count; i++) { if (roleCustomData.RolePointList[i] > 0) { List <int> rolePointList; int index; (rolePointList = roleCustomData.RolePointList)[index = i] = rolePointList[index] - 1; sum--; } } } TalentData talentData = client.ClientData.MyTalentData; if (talentData != null && null != talentData.EffectList) { foreach (TalentEffectItem item in talentData.EffectList) { roleCustomData.EffectList.Add(new TalentEffectItem { ID = item.ID, Level = item.Level, TalentType = item.TalentType }); } } roleCustomData.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID); roleCustomData.DefaultSkillLev = client.ClientData.DefaultSkillLev; roleCustomData.DefaultSkillUseNum = client.ClientData.DefaultSkillUseNum; if (client.ClientData.FuWenTabList != null && client.ClientData.FuWenTabList.Count > 0) { List <SkillEquipData> skillList = new List <SkillEquipData>(); foreach (FuWenTabData item2 in client.ClientData.FuWenTabList) { skillList.Add(new SkillEquipData { SkillEquip = item2.SkillEquip, ShenShiActiveList = item2.ShenShiActiveList }); } roleCustomData.ShenShiEuipSkill = skillList; } bool changed = false; if (null == roleCustomDataOld) { customData.customDataList.Add(roleCustomData); } else { if (null == roleCustomDataOld.RolePointList) { changed = true; } else if (roleCustomDataOld.RolePointList.Count != roleCustomData.RolePointList.Count) { changed = true; } else { int i = 0; while (i < roleCustomDataOld.RolePointList.Count && i < roleCustomData.RolePointList.Count) { if (roleCustomDataOld.RolePointList[i] != roleCustomData.RolePointList[i]) { changed = true; break; } i++; } } if (null == roleCustomDataOld.EffectList) { changed = true; } else if (roleCustomDataOld.EffectList.Count != roleCustomData.EffectList.Count) { changed = true; } else { roleCustomDataOld.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID); for (int i = 0; i < roleCustomDataOld.EffectList.Count; i++) { TalentEffectItem x2 = roleCustomDataOld.EffectList[i]; TalentEffectItem y2 = roleCustomData.EffectList[i]; if (x2.ID != y2.ID || x2.Level != y2.Level) { changed = true; break; } } } if (roleCustomDataOld.Main_quick_keys != roleCustomData.Main_quick_keys) { changed = true; } if (roleCustomData.DefaultSkillLev != roleCustomDataOld.DefaultSkillLev || roleCustomData.DefaultSkillUseNum != roleCustomDataOld.DefaultSkillUseNum) { changed = true; } if (null != roleCustomData.ShenShiEuipSkill) { changed = true; } if (changed) { customData.customDataList[oldIndex] = roleCustomData; } } if (client.ClientData.IsMainOccupation) { customData.roleData4Selector = Global.RoleDataEx2RoleData4Selector(client.ClientData.GetRoleData()); } Global.sendToDB <int, RoleCustomData>(10233, customData, client.ServerId); }
private bool ChangeOccupation(GameClient client, int nID, byte[] bytes, string[] cmdParams) { int result = 0; int targetOccupation = Global.SafeConvertToInt32(cmdParams[1]); int occupation = client.ClientData.Occupation; GameManager.ClientMgr.StopClientStoryboard(client, -1); if (!this.IsGongNengOpened(client)) { result = -12; } else if (!client.InSafeRegion) { result = -33; } else if (occupation == targetOccupation) { result = -18; } else { lock (this.RuntimeData.Mutex) { if (!this.RuntimeData.CanChangeOccupationMapCodes.Contains(client.ClientData.MapCode)) { result = -34; goto IL_221; } if (!client.ClientData.OccupationList.Contains(targetOccupation)) { result = -20; goto IL_221; } } RoleCustomData customData = Global.sendToDB <RoleCustomData, int>(10230, client.ClientData.RoleID, client.ServerId); if (null == customData) { customData = new RoleCustomData { roleId = client.ClientData.RoleID }; } this.SaveRoleCustomData(client, customData); if (!this.StoreRoleOccGoodsList(client)) { result = -15; } if (result >= 0) { string[] args = Global.SendToDB <string>(10126, string.Format("{0}:{1}", client.ClientData.RoleID, targetOccupation), client.ServerId); if (args[1] != targetOccupation.ToString()) { result = -15; } else { EventLogManager.AddChangeOccupationEvent(client, targetOccupation); client.ClientData.Occupation = targetOccupation; client.ClientData.IsMainOccupation = (client.ClientData.OccupationList[0] == client.ClientData.Occupation); this.RestoreRoleCustomData(client, customData); this.RestoreRoleOccGoodsList(client); RebornManager.getInstance().InitPlayerRebornPorperty(client); client.sendCmd <int>(13999, client.ClientData.RoleID, false); } } } IL_221: if (result < 0) { client.sendCmd <int>(nID, result, false); } return(true); }