public static void ReadNpc() { try { string DirNPC = Directory.GetCurrentDirectory() + @"\npc"; // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(DirNPC); foreach (string fileName in fileEntries) { Byte[] data = File.ReadAllBytes(fileName); STRUCT_MOB pMob = (STRUCT_MOB)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), typeof(STRUCT_MOB)); STRUCT_MOB pNpc = (STRUCT_MOB)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), typeof(STRUCT_MOB)); if (pMob.Merchant == 0) { Editor.MOBs.Add(pMob); } if (pMob.Merchant != 0) { Editor.NPCs.Add(pNpc); } } } catch (Exception ex) { Console.WriteLine(ex); } }
public static byte GetClassType(STRUCT_MOB Mob) { int chck = Mob.LearnedSkill & 0x40000000; int Face = Mob.Equip.Items[0].Index % 10; if (Face <= 5)//Mortal { return(0); } else if (chck != 0) //Cele { return(2); } else { return(1); //Arch } }
public static void ReadNPCNovo(List <STRUCT_MOB> Localizados) { try { Editor.MOBs.Clear(); foreach (var item in Localizados) { string NPC = Directory.GetCurrentDirectory() + @"\npc\" + item.name; Byte[] data = File.ReadAllBytes(NPC); STRUCT_MOB pMob = (STRUCT_MOB)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), typeof(STRUCT_MOB)); Editor.MOBs.Add(pMob); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void SaveNPC(STRUCT_MOB NPC) { try { string DirNPC = Directory.GetCurrentDirectory() + @"\npc\"; byte[] arr = new byte[Marshal.SizeOf(NPC)]; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(NPC)); Marshal.StructureToPtr(NPC, ptr, false); Marshal.Copy(ptr, arr, 0, Marshal.SizeOf(NPC)); Marshal.FreeHGlobal(ptr); File.WriteAllBytes(DirNPC + NPC.name, arr); } catch (Exception ex) { Console.WriteLine(ex); } }
static public void Start(DBController gs) { foreach (string file in Directory.EnumerateFiles("./npc/")) { using (StreamReader sr = new StreamReader(file)) { try { STRUCT_MOB CurrentMob = Functions.ReadAccount <STRUCT_MOB>(file); string indented = JsonConvert.SerializeObject(CurrentMob, Formatting.Indented); int update = gs.MySQL.nQuery(string.Format("INSERT INTO `mobs_json` (`nome`, `conteudo`) VALUES ('{0}', '{1}') ON DUPLICATE KEY UPDATE `nome` = '{2}' ", CurrentMob.Name, indented, CurrentMob.Name)); if (update != 0) { W2Log.Write(string.Format("Sucess update drops: {0}", file)); } } catch (Exception e) { return; } } } }
public int LocalizarItens(int index) { int encontrados = 0; string DirNPC = Directory.GetCurrentDirectory() + @"\npc"; // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(DirNPC); foreach (string fileName in fileEntries) { Byte[] data1 = File.ReadAllBytes(fileName); STRUCT_MOB MobsLocalizados = (STRUCT_MOB)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(data1, 0), typeof(STRUCT_MOB)); for (int i = 0; i < 64; i++) { if (MobsLocalizados.Carry[i].sIndex == index) { encontrados++; MOBsLocalizados.Add(MobsLocalizados); } } } return(encontrados); }
// Botão de salvar as informações do NPC private void button2_Click(object sender, EventArgs e) { // Salvar informações do NPC if (lbNpc2.SelectedIndex > 0) { STRUCT_MOB npc = Editor.NPCs[lbNpc2.SelectedIndex]; npc.name = txtNomeNPC.Text.ToString(); npc.Clan = Convert.ToByte(txtRaceNPC.Text.ToString()); npc.Merchant = Convert.ToByte(txtMerchantNPC.Text.ToString()); npc.Class = Convert.ToByte(txtClassNPC.Text.ToString()); npc.Coin = Convert.ToInt32(txtMoneyNPC.Text.ToString()); npc.Exp = Convert.ToInt64(txtExpNPC.Text.ToString()); npc.SPX = Convert.ToInt16(txtPosXNPC.Text.ToString()); npc.SPY = Convert.ToInt16(txtPosYNPC.Text.ToString()); string texto = txtSkillNPC.Text; string[] split = texto.Split(' '); npc.SkillBar[0] = Convert.ToByte(split[0]); npc.SkillBar[1] = Convert.ToByte(split[1]); npc.SkillBar[2] = Convert.ToByte(split[2]); npc.SkillBar[3] = Convert.ToByte(split[3]); npc.LearnedSkill = Convert.ToUInt64(txtLearnNPC.Text.ToString()); npc.RegenHP = Convert.ToInt16(txtRegenHPNPC.Text.ToString()); npc.RegenMP = Convert.ToInt16(txtRegenMPNPC.Text.ToString()); string texto2 = txtResistNPC.Text; string[] split2 = texto2.Split(' '); npc.Resist[0] = Convert.ToByte(split2[0]); npc.Resist[1] = Convert.ToByte(split2[1]); npc.Resist[2] = Convert.ToByte(split2[2]); npc.Resist[3] = Convert.ToByte(split2[3]); npc.BaseScore.Speed = Convert.ToByte(txtVeloNPC.Text.ToString()); npc.ScoreBonus = Convert.ToInt16(txtBonusNPC.Text.ToString()); // Salvar Informações do Score do MOB npc.BaseScore.Level = Convert.ToInt32(txtLevelNPC.Text.ToString()); npc.BaseScore.Defesa = Convert.ToInt32(txtDefNPC.Text.ToString()); npc.BaseScore.Ataque = Convert.ToInt32(txtDanoNPC.Text.ToString()); npc.BaseScore.Str = Convert.ToInt16(txtStrNPC.Text.ToString()); npc.BaseScore.Int = Convert.ToInt16(txtIntNPC.Text.ToString()); npc.BaseScore.Dex = Convert.ToInt16(txtDexNPC.Text.ToString()); npc.BaseScore.Con = Convert.ToInt16(txtConNPC.Text.ToString()); npc.BaseScore.HP = Convert.ToInt32(txtHPNPC.Text.ToString()); npc.BaseScore.MaxHP = Convert.ToInt32(txtMaxHPNPC.Text.ToString()); npc.BaseScore.MP = Convert.ToInt32(txtMPNPC.Text.ToString()); npc.BaseScore.MaxMP = Convert.ToInt32(txtMaxMPNPC.Text.ToString()); npc.BaseScore.Special[0] = Convert.ToInt16(txtNearNPC.Text.ToString()); npc.BaseScore.Special[1] = Convert.ToInt16(txtMotion1NPC.Text.ToString()); npc.BaseScore.Special[2] = Convert.ToInt16(txtFarNPC.Text.ToString()); npc.BaseScore.Special[3] = Convert.ToInt16(txtMotion2NPC.Text.ToString()); // Salvar informações do Equipamento do MOB foreach (Control gp in gbEquipes.Controls) { if (gp is TextBox) { npc.Equip[gp.TabIndex].sIndex = Convert.ToInt16(gp.Text.Split(' ')[0]); npc.Equip[gp.TabIndex].sEffect[0].cEfeito = Convert.ToByte(gp.Text.Split(' ')[1]); npc.Equip[gp.TabIndex].sEffect[0].cValue = Convert.ToByte(gp.Text.Split(' ')[2]); npc.Equip[gp.TabIndex].sEffect[1].cEfeito = Convert.ToByte(gp.Text.Split(' ')[3]); npc.Equip[gp.TabIndex].sEffect[1].cValue = Convert.ToByte(gp.Text.Split(' ')[4]); npc.Equip[gp.TabIndex].sEffect[2].cEfeito = Convert.ToByte(gp.Text.Split(' ')[5]); npc.Equip[gp.TabIndex].sEffect[2].cValue = Convert.ToByte(gp.Text.Split(' ')[6]); } } // Salvar o Inventario do NPC foreach (Control textbox in InventarioNPC.Controls) { if (textbox is TextBox) { if (textbox.Enabled == true) { npc.Carry[textbox.TabIndex].sIndex = Convert.ToInt16(textbox.Text.Split(' ')[0]); npc.Carry[textbox.TabIndex].sEffect[0].cEfeito = Convert.ToByte(textbox.Text.Split(' ')[1]); npc.Carry[textbox.TabIndex].sEffect[0].cValue = Convert.ToByte(textbox.Text.Split(' ')[2]); npc.Carry[textbox.TabIndex].sEffect[1].cEfeito = Convert.ToByte(textbox.Text.Split(' ')[3]); npc.Carry[textbox.TabIndex].sEffect[1].cValue = Convert.ToByte(textbox.Text.Split(' ')[4]); npc.Carry[textbox.TabIndex].sEffect[2].cEfeito = Convert.ToByte(textbox.Text.Split(' ')[5]); npc.Carry[textbox.TabIndex].sEffect[2].cValue = Convert.ToByte(textbox.Text.Split(' ')[6]); } } } MessageBox.Show(string.Format("O npc {0} foi salvo com sucesso!", npc.name)); Editor.NPCs[lbNpc2.SelectedIndex] = npc; Editor.SaveNPC(npc); } else { MessageBox.Show("Selecione um npc para salvar!"); return; } }
//Process PutCapsule (Cria o Selo da Alma e Apaga o Char) public static DBResult Exec_MSG_DBPutInCapsule(DBController gs, pServer GameServer) { _MSG_SIGNALPARM sm = W2Marshal.GetStructure <_MSG_SIGNALPARM>(GameServer.RecvPacket.RawBuffer); ConfigServer.ReadConfigFile(gs.Config); int Slot = sm.parm; int Idx = gs.GetIndex(sm.Header.ClientId); if (Slot < 0 || Slot >= 4) { W2Log.Write($"err,putincapsule slot out of range - {gs.AccountList[Idx].Account.Info.AccountName}"); return(DBResult.NO_ERROR); } gs.Config.LastCapsule++; MItem Cap = MItem.Empty(); Cap.Index = 3443; Cap.Effects[0].Code = 59; Cap.Effects[0].Value = (byte)(gs.Config.LastCapsule / 256); Cap.Effects[1].Code = 59; Cap.Effects[1].Value = (byte)gs.Config.LastCapsule; Cap.Effects[2].Code = 59; Cap.Effects[2].Value = 0; short Face = gs.AccountList[Idx].Account.Mob[Slot].Equip.Items[0].Index; if ((Face % 10) >= 6 && (gs.AccountList[Idx].Account.Mob[Slot].LearnedSkill & 0x40000000) != 0) { Cap.Effects[3].Value = 1; } STRUCT_CAPSULE File = STRUCT_CAPSULE.Empty(); //Sava a capsule File.Mob = gs.AccountList[Idx].Account.Mob[Slot]; File.Extra = gs.AccountList[Idx].Account.MobExtra[Slot]; File.Extra.Arch.MortalSlot = -1; if (!Functions.WriteCapsule(gs.Config.LastCapsule, File)) { W2Log.Write($"fail putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]"); return(DBResult.NO_ERROR); } W2Log.Write($"putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]"); ConfigServer.saveConfig(gs.Config); //Apaga o char do q fez a capsule gs.AccountList[Idx].Account.Mob[Slot] = STRUCT_MOB.ClearProperty(); gs.AccountList[Idx].Account.MobExtra[Slot] = new STRUCT_MOBEXTRA(); gs.AccountList[Idx].Account.Skillbar[Slot] = STRUCT_SKILLBAR.Clear(); for (int i = 0; i < 32; i++) { gs.AccountList[Idx].Account.Affects[Slot].Affects[i] = STRUCT_AFFECT.Clear(); } bool ret = gs.SaveAccount(sm.Header.ClientId); if (ret == false) { W2Log.Write(string.Format("err,putchar in capsule fail - save account - {0}", Idx), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleSucess); MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFDeleteCharacter, sm.Header.ClientId); for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++) { unsafe { answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin; for (int x = 0; x < GameBasics.MAXL_EQUIP; x++) { if (x == 0) { int Faces = answer.SelChar.Equip[i].Items[x].Index; if (Faces == 22 || Faces == 23 || Faces == 24 || Faces == 25 || Faces == 32) { Faces = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7; } answer.SelChar.Equip[i].Items[x].Index = (short)Faces; answer.SelChar.Equip[i].Items[x].Effects[0].Code = 43; answer.SelChar.Equip[i].Items[x].Effects[0].Value = 0; answer.SelChar.Equip[i].Items[x].Effects[1].Code = 86; answer.SelChar.Equip[i].Items[x].Effects[1].Value = Functions.GetClassType(gs.AccountList[Idx].Account.Mob[i]); answer.SelChar.Equip[i].Items[x].Effects[2].Code = 28; answer.SelChar.Equip[i].Items[x].Effects[2].Value = (byte)gs.AccountList[Idx].Account.MobExtra[i].Citizen; } answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x]; } answer.SelChar.Exp[i] = (int)gs.AccountList[Idx].Account.Mob[i].Exp; answer.SelChar.Guild[i] = gs.AccountList[Idx].Account.Mob[i].Guild; answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name; answer.SelChar.Score[i] = gs.AccountList[Idx].Account.Mob[i].BaseScore; answer.SelChar.SPosX[i] = gs.AccountList[Idx].Account.Mob[i].SPX; answer.SelChar.SPosY[i] = gs.AccountList[Idx].Account.Mob[i].SPY; } } gs.Server.SendPacket(answer); Functions.CreateImportItem(gs.AccountList[Idx].Account.Info.AccountName, Cap, 0, true); W2Log.Write($"sucess putchar in capsule [{gs.AccountList[Idx].Account.Info.AccountName}]"); return(DBResult.NO_ERROR); }
//Process CreateChar Arch (SelChar) public static DBResult Exec_MSG_DBCreateArchCharacter(DBController gs, pServer GameServer) { MSG_DBCreateArchCharacter sm = W2Marshal.GetStructure <MSG_DBCreateArchCharacter>(GameServer.RecvPacket.RawBuffer); int cls = sm.MobClass; bool ret = false; int Idx = gs.GetIndex(sm.Header.ClientId); int Slot = 0; for (Slot = 0; Slot < 5; Slot++) { if (string.IsNullOrEmpty(gs.AccountList[Idx].Account.Mob[Slot].Name)) { break; } } if (Slot < 0 || Slot >= 4) { W2Log.Write(string.Format("err,arch newchar slot out of range - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } if (cls < 0 || cls >= 4) { W2Log.Write(string.Format("err,arch newchar class out of range - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } string[] BadNames = { "KING", "KINGDOM", "GRITAR", "RELO" }; for (int i = 0; i < BadNames.Length; i++) { if (!sm.PlayerName.Contains(BadNames[i])) { continue; } gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } STRUCT_MOB mob = gs.AccountList[Idx].Account.Mob[Slot]; if (!String.IsNullOrEmpty(mob.Name)) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); W2Log.Write(string.Format("err,arch newchar already charged - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); return(DBResult.NO_ERROR); } ret = gs.CreateChar(sm.PlayerName, gs.AccountList[Idx].Account.Info.AccountName); if (ret == false) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } gs.AccountList[Idx].Account.Mob[Slot] = STRUCT_MOB.ClearProperty(); gs.AccountList[Idx].Account.MobExtra[Slot] = new STRUCT_MOBEXTRA(); gs.AccountList[Idx].Account.Skillbar[Slot] = STRUCT_SKILLBAR.Clear(); gs.AccountList[Idx].Account.Mob[Slot] = gs.BaseMob[cls]; gs.AccountList[Idx].Account.MobExtra[Slot].ClassMaster = (short)ClassType.Arch; gs.AccountList[Idx].Account.MobExtra[Slot].Arch.MortalSlot = (sbyte)sm.MortalSlot; gs.AccountList[Idx].Account.Mob[Slot].Equip.Items[0].Index = (short)(sm.MortalFace + 5 + cls); gs.AccountList[Idx].Account.MobExtra[Slot].MortalFace = gs.AccountList[Idx].Account.Mob[Slot].Equip.Items[0].Index; gs.AccountList[Idx].Account.Mob[Slot].Name = sm.PlayerName; gs.AccountList[Idx].Account.Mob[Slot].CurrentScore = gs.AccountList[Idx].Account.Mob[Slot].BaseScore; ret = gs.SaveAccount(sm.Header.ClientId); if (ret == false) { W2Log.Write(string.Format("err,arch newchar fail - create file - {0}", sm.PlayerName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } W2Log.Write(string.Format("create arch character [{0}]", sm.PlayerName), ELogType.GAME_EVENT); MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFNewCharacter, sm.Header.ClientId); answer.Slot = Slot; for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++) { unsafe { answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin; for (int x = 0; x < GameBasics.MAXL_EQUIP; x++) { if (x == 0) { int Face = answer.SelChar.Equip[i].Items[x].Index; if (Face == 22 || Face == 23 || Face == 24 || Face == 25 || Face == 32) { Face = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7; } answer.SelChar.Equip[i].Items[x].Index = (short)Face; answer.SelChar.Equip[i].Items[x].Effects[0].Code = 43; answer.SelChar.Equip[i].Items[x].Effects[0].Value = 0; answer.SelChar.Equip[i].Items[x].Effects[1].Code = 86; answer.SelChar.Equip[i].Items[x].Effects[1].Value = Functions.GetClassType(gs.AccountList[Idx].Account.Mob[i]); answer.SelChar.Equip[i].Items[x].Effects[2].Code = 28; answer.SelChar.Equip[i].Items[x].Effects[2].Value = (byte)gs.AccountList[Idx].Account.MobExtra[i].Citizen; } answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x]; } answer.SelChar.Exp[i] = (int)gs.AccountList[Idx].Account.Mob[i].Exp; answer.SelChar.Guild[i] = gs.AccountList[Idx].Account.Mob[i].Guild; answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name; answer.SelChar.Score[i] = gs.AccountList[Idx].Account.Mob[i].BaseScore; answer.SelChar.SPosX[i] = gs.AccountList[Idx].Account.Mob[i].SPX; answer.SelChar.SPosY[i] = gs.AccountList[Idx].Account.Mob[i].SPY; } } gs.Server.SendPacket(answer); return(DBResult.NO_ERROR); }
//Process DeletChar (SelChar) public static DBResult Exec_MSG_DBCNFDeleteCharacter(DBController gs, pServer GameServer) { STMSG_DeleteCharacter sm = W2Marshal.GetStructure <STMSG_DeleteCharacter>(GameServer.RecvPacket.RawBuffer); int Slot = sm.Slot; bool ret = false; int Idx = gs.GetIndex(sm.Header.ClientId); if (Slot < 0 || Slot >= 4) { W2Log.Write(string.Format("err,deletchar slot out of range - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBDeleteCharacterFail); return(DBResult.NO_ERROR); } STRUCT_MOB mob = gs.AccountList[Idx].Account.Mob[Slot]; if (String.IsNullOrEmpty(mob.Name)) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBDeleteCharacterFail); W2Log.Write(string.Format("err,deletchar already charged - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); return(DBResult.NO_ERROR); } if (String.Compare(gs.AccountList[Idx].Account.Info.AccountPass, sm.Pass) != 0) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBDeleteCharacterFail); W2Log.Write(string.Format("err,deletchar incorret pass - {0}", gs.AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT); return(DBResult.NO_ERROR); } ret = false; try { File.Delete(Functions.getCorrectCharPath(sm.PlayerName)); ret = true; } catch (Exception e) { W2Log.Write(string.Format("err,deletchar - {0}/{1}", gs.AccountList[Idx].Account.Info.AccountName, sm.PlayerName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBDeleteCharacterFail); return(DBResult.NO_ERROR); } if (ret == false) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBDeleteCharacterFail); return(DBResult.NO_ERROR); } gs.AccountList[Idx].Account.Mob[Slot] = STRUCT_MOB.ClearProperty(); gs.AccountList[Idx].Account.MobExtra[Slot] = new STRUCT_MOBEXTRA(); gs.AccountList[Idx].Account.Skillbar[Slot] = STRUCT_SKILLBAR.Clear(); for (int i = 0; i < 32; i++) { gs.AccountList[Idx].Account.Affects[Slot].Affects[i] = STRUCT_AFFECT.Clear(); } ret = gs.SaveAccount(sm.Header.ClientId); if (ret == false) { W2Log.Write(string.Format("err,deletchar fail - save account - {0}", sm.PlayerName), ELogType.GAME_EVENT); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); return(DBResult.NO_ERROR); } W2Log.Write(string.Format("delete character [{0}]", sm.PlayerName), ELogType.GAME_EVENT); MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFDeleteCharacter, sm.Header.ClientId); answer.Slot = Slot; for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++) { unsafe { answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin; for (int x = 0; x < GameBasics.MAXL_EQUIP; x++) { if (x == 0) { int Face = answer.SelChar.Equip[i].Items[x].Index; if (Face == 22 || Face == 23 || Face == 24 || Face == 25 || Face == 32) { Face = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7; } answer.SelChar.Equip[i].Items[x].Index = (short)Face; } answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x]; } answer.SelChar.Exp[i] = (int)gs.AccountList[Idx].Account.Mob[i].Exp; answer.SelChar.Guild[i] = gs.AccountList[Idx].Account.Mob[i].Guild; answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name; answer.SelChar.Score[i] = gs.AccountList[Idx].Account.Mob[i].BaseScore; answer.SelChar.SPosX[i] = gs.AccountList[Idx].Account.Mob[i].SPX; answer.SelChar.SPosY[i] = gs.AccountList[Idx].Account.Mob[i].SPY; } } gs.Server.SendPacket(answer); return(DBResult.NO_ERROR); }
//Process OutCapsule (Apaga o Selo da Alma e Cria o Char) public static DBResult Exec_MSG_DBOutCapsule(DBController gs, pServer GameServer) { MSG_DBOutCapsule sm = W2Marshal.GetStructure <MSG_DBOutCapsule>(GameServer.RecvPacket.RawBuffer); int Slot = sm.Slot; int NovoSlot = -1; int Idx = gs.GetIndex(sm.Header.ClientId); if (Slot < 0 || Slot >= 4) { W2Log.Write($"err,outcapsule slot out of range: {gs.AccountList[Idx].Account.Info.AccountName}"); return(DBResult.NO_ERROR); } for (int i = 0; i < 4; i++) { if (String.IsNullOrEmpty(gs.AccountList[Idx].Account.Mob[i].Name)) { NovoSlot = i; break; } } if (NovoSlot < 0 || NovoSlot >= 4) { W2Log.Write($"err,newcharcapsule slot out of range: {NovoSlot} - {gs.AccountList[Idx].Account.Info.AccountName}"); gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleCharacterFail); return(DBResult.NO_ERROR);; } bool ret = gs.CreateChar(sm.Name, gs.AccountList[Idx].Account.Info.AccountName); if (ret == false) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBCNFCapsuleCharacterFail2); return(DBResult.NO_ERROR); } MItem item = gs.AccountList[Idx].GetItemPointer(sm.SourType, sm.SourPos); int index = item.Effects[0].Value * 256 + item.Effects[1].Value; STRUCT_CAPSULE file = new STRUCT_CAPSULE(); if (!Functions.ReadCapsule(index, out file)) { W2Log.Write($"Exec_MSG_DBOutCapsule error read capsule index: {index}"); return(DBResult.NO_ERROR); } STRUCT_MOB mob = gs.AccountList[Idx].Account.Mob[NovoSlot]; if (!String.IsNullOrEmpty(mob.Name)) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); W2Log.Write($"err,newchar already charged: { gs.AccountList[Idx].Account.Info.AccountName} / {mob.Name}"); return(DBResult.NO_ERROR); } gs.AccountList[Idx].Account.Mob[NovoSlot] = file.Mob; gs.AccountList[Idx].Account.MobExtra[NovoSlot] = file.Extra; for (int i = 0; i < 32; i++) { gs.AccountList[Idx].Account.Affects[NovoSlot].Affects[i] = STRUCT_AFFECT.Clear(); } ret = gs.SaveAccount(sm.Header.ClientId); if (ret == false) { gs.Server.SendSignal(sm.Header.ClientId, BaseDef._MSG_DBNewCharacterFail); W2Log.Write($"err,newchar fail - create file: {sm.Name}"); return(DBResult.NO_ERROR); } MSG_CNFNewCharacter answer = W2Marshal.CreatePacket <MSG_CNFNewCharacter>(BaseDef._MSG_DBCNFNewCharacter, sm.Header.ClientId); for (int i = 0; i < GameBasics.MAXL_ACC_MOB; i++) { unsafe { answer.SelChar.Coin[i] = gs.AccountList[Idx].Account.Mob[i].Coin; for (int x = 0; x < GameBasics.MAXL_EQUIP; x++) { if (x == 0) { int Face = answer.SelChar.Equip[i].Items[x].Index; if (Face == 22 || Face == 23 || Face == 24 || Face == 25 || Face == 32) { Face = gs.AccountList[Idx].Account.MobExtra[i].ClassMaster == 0 ? 21 : (ushort)gs.AccountList[Idx].Account.MobExtra[i].MortalFace + 7; } answer.SelChar.Equip[i].Items[x].Index = (short)Face; answer.SelChar.Equip[i].Items[x].Effects[0].Code = 43; answer.SelChar.Equip[i].Items[x].Effects[0].Value = 0; answer.SelChar.Equip[i].Items[x].Effects[1].Code = 86; answer.SelChar.Equip[i].Items[x].Effects[1].Value = Functions.GetClassType(gs.AccountList[Idx].Account.Mob[i]); answer.SelChar.Equip[i].Items[x].Effects[2].Code = 28; answer.SelChar.Equip[i].Items[x].Effects[2].Value = (byte)gs.AccountList[Idx].Account.MobExtra[i].Citizen; } answer.SelChar.Equip[i].Items[x] = gs.AccountList[Idx].Account.Mob[i].Equip.Items[x]; } answer.SelChar.Exp[i] = (int)gs.AccountList[Idx].Account.Mob[i].Exp; answer.SelChar.Guild[i] = gs.AccountList[Idx].Account.Mob[i].Guild; answer.SelChar.Name[i].Value = gs.AccountList[Idx].Account.Mob[i].Name; answer.SelChar.Score[i] = gs.AccountList[Idx].Account.Mob[i].BaseScore; answer.SelChar.SPosX[i] = gs.AccountList[Idx].Account.Mob[i].SPX; answer.SelChar.SPosY[i] = gs.AccountList[Idx].Account.Mob[i].SPY; } } gs.Server.SendPacket(answer); return(DBResult.NO_ERROR); }