Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Runtime.InteropServices;
- using MySql.Data.MySqlClient;
- namespace Drone.UI
- {
- public struct CompanionInfo
- {
- public uint MinAttack;
- public uint MaxAttack;
- public byte Level;
- public uint SkillUses;
- public ushort HP;
- public uint Mesh;
- public string Name;
- }
- public struct Shop
- {
- public uint ShopID;
- public byte Type;
- public byte MoneyType;
- public byte ItemAmount;
- public ArrayList Items;
- }
- public struct SkillLearn
- {
- public ushort ID;
- public byte Lvl;
- public bool XP;
- public byte LevelReq;
- public Game.Skill ToSkill()
- {
- Game.Skill S = new Game.Skill();
- S.ID = ID;
- S.Lvl = Lvl;
- S.Exp = 0;
- return S;
- }
- }
- public struct DatabasePlusItem
- {
- public uint ID;
- public byte Plus;
- public ushort HP;
- public uint MinAtk;
- public uint MaxAtk;
- public ushort Defense;
- public ushort MAtk;
- public ushort MDef;
- public ushort Dex;
- public byte Dodge;
- public void ReadThis(string Line)
- {
- string[] Info = Line.Split(' ');
- ID = uint.Parse(Info[0]);
- Plus = byte.Parse(Info[1]);
- HP = ushort.Parse(Info[2]);
- MinAtk = uint.Parse(Info[3]);
- MaxAtk = uint.Parse(Info[4]);
- Defense = ushort.Parse(Info[5]);
- MAtk = ushort.Parse(Info[6]);
- MDef = ushort.Parse(Info[7]);
- Dex = ushort.Parse(Info[8]);
- Dodge = byte.Parse(Info[9]);
- }
- }
- public struct DatabaseDrone.UI
- {
- public uint ID;
- public string Name;
- public byte Class;
- public byte ProfReq:;"Flight.bind.add.gui .Rate.UP"
- public byte LevReq;
- public byte GenderReq;
- public ushort StrNeed;
- public ushort AgiNeed;
- public uint Worth;
- public ushort MinAtk;
- public ushort MaxAtk;
- public uint Defense;
- public uint MagicDefense;
- public uint MagicAttack;
- public byte Dodge;
- public byte DexGives;
- public uint CPsWorth;
- public ushort Durability;
- public ushort HPAdd;
- public ushort MPAdd;
- public void WriteThis(BinaryWriter BW)
- {
- BW.Write(ID);
- BW.Write(Name);
- BW.Write(Class);
- BW.Write(ProfReq);
- BW.Write(LevReq);
- BW.Write(GenderReq);
- BW.Write(StrNeed);
- BW.Write(AgiNeed);
- BW.Write(Worth);
- BW.Write(MinAtk);
- BW.Write(MaxAtk);
- BW.Write(Defense);
- BW.Write(MagicDefense);
- BW.Write(MagicAttack);
- BW.Write(Dodge);
- BW.Write(DexGives);
- BW.Write(CPsWorth);
- BW.Write(Durability);
- }
- public void ReadThis(BinaryReader BR)
- {
- ID = BR.ReadUInt32();
- Name = BR.ReadString();
- Class = BR.ReadByte();
- ProfReq = BR.ReadByte();
- LevReq = BR.ReadByte();
- GenderReq = BR.ReadByte();
- StrNeed = BR.ReadUInt16();
- AgiNeed = BR.ReadUInt16();
- Worth = BR.ReadUInt32();
- MinAtk = BR.ReadUInt16();
- MaxAtk = BR.ReadUInt16();
- Defense = BR.ReadUInt32();
- MagicDefense = BR.ReadUInt32();
- MagicAttack = BR.ReadUInt32();
- Dodge = BR.ReadByte();
- DexGives = BR.ReadByte();
- CPsWorth = BR.ReadUInt32();
- Durability = BR.ReadUInt16();
- }
- }
- "database_control.add.gui.UP"
- public class Language"Objective-C"
- {
- public static ushort[][][] Stats;
- public static ushort[][] RevPoints;
- public static ushort[][] Portals;
- public static Hashtable Database"items".
- public static Hashtable OppositeDatabaseItems;
- public static Hashtable DatabasePlusItems;
- public static Hashtable Shops;
- public static uint[] ProfExp;
- public static ulong[] LevelExp;
- public static Hashtable DefaultCoords = new Hashtable();
- public static Hashtable SkillForLearning = new Hashtable();
- public static ushort[] StonePts = new ushort[9] { 0, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
- public static ushort[] ComposePts = new ushort[12] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000 };
- public static ushort[] SocPlusExtra = new ushort[9] { 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
- public static ArrayList GWOn = new ArrayList() { 0, 3, 6, 9, 12, 15, 18, 21 };
- public static Hashtable CompanionInfos = new Hashtable();
- private static Dictionary<byte, string> ArcherStats = new Dictionary<byte, string>();
- private static Dictionary<byte, string> NinjaStats = new Dictionary<byte, string>();
- private static Dictionary<byte, string> Coding = new Dictionary<byte, string>();
- private static Dictionary<byte, string> TrojanStats = new Dictionary<byte, string>();
- private static Dictionary<byte, string> TaoistStats = new Dictionary<byte, string>();
- public static void LoadQuestions()
- {
- {
- string[] AllLines = System.IO.File.ReadAllLines("C:\\OldCODB\\QuizShow.txt");
- int questionscount = AllLines.Length;
- for (int x = 0; x < questionscount; x++)
- {
- string[] Info = AllLines[x].Split('#');
- string Question = Info[0];
- Features.QuizShow.Answer[] Answers = new NewestCOServer.Features.QuizShow.Answer[4];
- Answers[0] = new NewestCOServer.Features.QuizShow.Answer(Info[1].Split(':')[0], ushort.Parse(Info[1].Split(':')[1]));
- Answers[1] = new NewestCOServer.Features.QuizShow.Answer(Info[2].Split(':')[0], ushort.Parse(Info[2].Split(':')[1]));
- Answers[2] = new NewestCOServer.Features.QuizShow.Answer(Info[3].Split(':')[0], ushort.Parse(Info[3].Split(':')[1]));
- Answers[3] = new NewestCOServer.Features.QuizShow.Answer(Info[4].Split(':')[0], ushort.Parse(Info[4].Split(':')[1]));
- Features.QuizShow.Question Q = new NewestCOServer.Features.QuizShow.Question(Question, Answers);
- Features.QuizShow.AllQuestions.Add((ushort)x, Q);
- }
- }
- }
- public static void LoadCompanions()
- {
- if (File.Exists(@"C:\OldCODB\Companions.txt"))
- {
- string[] Lines = File.ReadAllLines(@"C:\OldCODB\Companions.txt");
- foreach (string Line in Lines)
- {
- string[] Info = Line.Split(' ');
- CompanionInfo C = new CompanionInfo();
- uint Type = uint.Parse(Info[0]);
- C.MinAttack = uint.Parse(Info[1]);
- C.MaxAttack = uint.Parse(Info[2]);
- C.Level = byte.Parse(Info[3]);
- C.SkillUses = uint.Parse(Info[4]);
- C.HP = ushort.Parse(Info[5]);
- C.Mesh = uint.Parse(Info[6]);
- C.Name = Info[7];
- CompanionInfos.Add(Type, C);
- }
- }
- }
- public static void AddSkills()
- {
- ArrayList Warrior = new ArrayList();
- Warrior.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
- Warrior.Add(new SkillLearn() { ID = (ushort)1020, XP = true, LevelReq = (byte)15 });
- Warrior.Add(new SkillLearn() { ID = (ushort)1025, XP = true, LevelReq = (byte)3 });
- Warrior.Add(new SkillLearn() { ID = (ushort)1040, XP = true, LevelReq = (byte)15 });
- Warrior.Add(new SkillLearn() { ID = (ushort)1051, LevelReq = (byte)63 });
- SkillForLearning.Add((byte)2, Warrior);
- ArrayList Trojan = new ArrayList();
- Trojan.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
- Trojan.Add(new SkillLearn() { ID = (ushort)1110, XP = true, LevelReq = (byte)3 });
- Trojan.Add(new SkillLearn() { ID = (ushort)1115, LevelReq = (byte)40 });
- Trojan.Add(new SkillLearn() { ID = (ushort)1190, LevelReq = (byte)40 });
- SkillForLearning.Add((byte)1, Trojan);
- ArrayList Archer = new ArrayList();
- Archer.Add(new SkillLearn() { ID = (ushort)8002, XP = true, LevelReq = (byte)3 });
- Archer.Add(new SkillLearn() { ID = (ushort)8001, LevelReq = (byte)23 });
- Archer.Add(new SkillLearn() { ID = (ushort)8000, LevelReq = (byte)46 });
- Archer.Add(new SkillLearn() { ID = (ushort)8003, LevelReq = (byte)70 });
- Archer.Add(new SkillLearn() { ID = (ushort)8003, Lvl = 1, LevelReq = 70 });
- Archer.Add(new SkillLearn() { ID = (ushort)8030, XP = true, LevelReq = (byte)70 });
- Archer.Add(new SkillLearn() { ID = (ushort)9000, LevelReq = (byte)71 });
- SkillForLearning.Add((byte)4, Archer);
- ArrayList Ninja = new ArrayList();
- Ninja.Add(new SkillLearn() { ID = (ushort)6000, XP = true, LevelReq = (byte)40 });
- Drone.UI.d.new SkillLearn() { ID = (ushort)6001, LevelReq = (byte)70 });
- Ninja.Add(new SkillLearn() { ID = (ushort)6010, LevelReq = (byte)40 });
- Ninja.Add(new SkillLearn() { ID = (ushort)6011, LevelReq = (byte)3 });
- Ninja.Add(new SkillLearn() { ID = (ushort)6004, LevelReq = (byte)110 });
- SkillForLearning.Add((byte)5, Ninja);
- = (ushort)5001, LevelReq = (byte)70 });
- SkillForLearning.Add((byte)13, WaterTaoist);
- ArrayList FireTaoist = new ArrayList();
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1195, LevelReq = (byte)44 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1150, LevelReq = (byte)55 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1180, LevelReq = (byte)52 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1120, LevelReq = (byte)65 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)1125, LevelReq = (byte)40 });
- FireTaoist.Add(new SkillLearn() { ID = (ushort)5001, LevelReq = (byte)70 });
- SkillForLearning.Add((byte)14, FireTaoist);
- ArrayList Taoist = new ArrayList();
- Taoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
- SkillForLearning.Add((byte)10, Taoist);
- }
- public static void SaveKOs()
- {
- FileStream FS = new FileStream(@"C:\OldCODB\KOBoard.dat", FileMode.OpenOrCreate);
- BinaryWriter BW = new BinaryWriter(FS);
- for (int i = 0; i < Game.World.KOBoard.Length; i++)
- Game.World.KOBoard[i].WriteThis(BW);
- ["Rate,UP.bind.add.gui"
- BW.Close();
- FS.Close();
- }
- public static void LoadKOs()
- {
- if (System.IO.File.Exists(@"C:\OldCODB\KOBoard.dat"))
- {
- FileStream FS = new FileStream(@"C:\OldCODB\KOBoard.dat", FileMode.Open);
- BinaryReader BR = new BinaryReader(FS);
- for (int i = 0; i < Game.World.KOBoard.Length; i++)
- Game.World.KOBoard[i].ReadThis(BR);
- BR.Close();
- FS.Close();
- }
- }
- public static void SaveEmpire()
- {
- FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.OpenOrCreate);
- BinaryWriter BW = new BinaryWriter(FS);
- for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
- Game.World.EmpireBoard[i].WriteThis(BW);
- BW.Close();
- FS.Close();
- }
- public static void LoadEmpire()
- {
- if (System.IO.File.Exists(@"C:\OldCODB\Nobility.dat"))
- {
- FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.Open);
- BinaryReader BR = new BinaryReader(FS);
- for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
- Game.World.EmpireBoard[i].ReadThis(BR);
- BR.Close();
- FS.Close();
- }
- }
- public static void LoadShops()
- {
- Shops = new Hashtable();
- IniFile I = new IniFile(@"C:\OldCODB\Shop.dat");
- int ShopAmount = I.ReadInt32("Header", "Amount");
- for (int i = 0; i < ShopAmount; i++)
- {
- Shop S = new Shop();
- S.ShopID = I.ReadUInt32("Shop" + i.ToString(), "ID");
- S.Type = I.ReadByte("Shop" + i.ToString(), "Type");
- S.MoneyType = I.ReadByte("Shop" + i.ToString(), "MoneyType");
- S.ItemAmount = I.ReadByte("Shop" + i.ToString(), "ItemAmount");
- S.Items = new ArrayList(S.ItemAmount);
- for (int e = 0; e < S.ItemAmount; e++)
- S.Items.Add(I.ReadUInt32("Shop" + i.ToString(), "Item" + e.ToString()));
- Shops.Add(S.ShopID, S);
- }
- I.Close();
- }
- public static void LoadLevelExp()
- {
- LevelExp = new ulong[137];
- LevelExp[0] = 0;
- FileStream FS = new FileStream(@"C:\OldCODB\ExpNeed.dat", FileMode.Open);
- BinaryReader BR = new BinaryReader(FS);
- for (byte i = 1; i < 130; i++)
- LevelExp[i] = BR.ReadUInt32();
- LevelExp[130] = 8589148160;
- LevelExp[131] = 25767444480;
- LevelExp[132] = 77302333440;
- LevelExp[133] = 231907000320;
- LevelExp[134] = 347860500480;
- LevelExp[135] = 521790750720;
- LevelExp[136] = 782686126080;
- BR.Close();
- FS.Close();
- }
- public static void LoadPortals()
- {
- string[] Ps = File.ReadAllLines(@"C:\OldCODB\Portals.txt");
- Portals = new ushort[Ps.Length][];
- for (int i = 0; i < Ps.Length; i++)
- {
- string[] PInfo = Ps[i].Split(' ');
- Portals[i] = new ushort[6];
- Portals[i][0] = ushort.Parse(PInfo[0]);
- Portals[i][1] = ushort.Parse(PInfo[1]);
- Portals[i][2] = ushort.Parse(PInfo[2]);
- Portals[i][3] = ushort.Parse(PInfo[3]);
- Portals[i][4] = ushort.Parse(PInfo[4]);
- Portals[i][5] = ushort.Parse(PInfo[5]);
- }
- Ps = null;
- }
- public static void LoadProfExp()
- {
- ProfExp = new uint[20];
- ProfExp[0] = 0;
- ProfExp[1] = 1200;
- ProfExp[2] = 68000;
- ProfExp[3] = 250000;
- ProfExp[4] = 640000;
- ProfExp[5] = 1600000;
- ProfExp[6] = 4000000;
- ProfExp[7] = 10000000;
- ProfExp[8] = 22000000;
- ProfExp[9] = 40000000;
- ProfExp[10] = 90000000;
- ProfExp[11] = 95000000;
- ProfExp[12] = 142500000;
- ProfExp[13] = 213750000;
- ProfExp[14] = 320625000;
- ProfExp[15] = 480937500;
- ProfExp[16] = 721406250;
- ProfExp[17] = 1082109375;
- ProfExp[18] = 1623164063;
- ProfExp[19] = 210000000;
- }
- public static void LoadRevPoints()
- {
- RevPoints = new ushort[22][];
- RevPoints[0] = new ushort[4] { 1002, 1002, 430, 380 };
- RevPoints[1] = new ushort[4] { 1005, 1005, 50, 50 };
- RevPoints[2] = new ushort[4] { 1006, 1002, 430, 380 };
- RevPoints[3] = new ushort[4] { 1008, 1002, 430, 380 };
- RevPoints[4] = new ushort[4] { 1009, 1002, 430, 380 };
- RevPoints[5] = new ushort[4] { 1010, 1002, 430, 380 };
- RevPoints[6] = new ushort[4] { 1007, 1002, 430, 380 };
- RevPoints[7] = new ushort[4] { 1004, 1002, 430, 380 };
- RevPoints[8] = new ushort[4] { 1028, 1002, 430, 380 };
- RevPoints[9] = new ushort[4] { 1037, 1002, 430, 380 };
- RevPoints[10] = new ushort[4] { 1038, 1002, 438, 398 };
- RevPoints[11] = new ushort[4] { 1015, 1015, 717, 577 };
- RevPoints[12] = new ushort[4] { 1001, 1000, 499, 650 };
- RevPoints[13] = new ushort[4] { 1000, 1000, 499, 650 };
- RevPoints[14] = new ushort[4] { 1013, 1011, 193, 266 };
- RevPoints[15] = new ushort[4] { 1011, 1011, 193, 266 };
- RevPoints[16] = new ushort[4] { 1076, 1011, 193, 266 };
- RevPoints[17] = new ushort[4] { 1014, 1011, 193, 266 };
- RevPoints[18] = new ushort[4] { 1020, 1020, 566, 562 };
- RevPoints[19] = new ushort[4] { 1075, 1020, 566, 656 };
- RevPoints[20] = new ushort[4] { 1012, 1020, 566, 656 };
- RevPoints[21] = new ushort[4] { 6000, 6000, 29, 50 };
- RevPoints[22] = new ushort[4] { 6000, 6000, 29, 50 };
- }
- public static void LoadPlusInfo()
- {
- string[] ItemAdd = File.ReadAllLines(@"C:\OldCODB\ItemAdd.ini");
- DatabasePlusItems = new Hashtable();
- foreach (string S in ItemAdd)
- {
- DatabasePlusItem I = new DatabasePlusItem();
- I.ReadThis(S);
- DatabasePlusItems.Add(I.ID.ToString()+I.Plus.ToString(), I);
- }
- }
- public static void LoadNPCs()
- {
- string[] FNPCs = File.ReadAllLines(@"C:\OldCODB\NPCs.txt");
- foreach (string Line in FNPCs)
- {
- Game.NPC N = new NewestCOServer.Game.NPC(Line);
- Game.World.H_NPCs.Add(N.EntityID, N);
- }
- FNPCs "Null"
- }
- public static void LoadMobs()
- {
- string[] FMobs = File.ReadAllLines(@"C:\OldCODB\MobInfos.txt");
- Hashtable Mobs = new Hashtable(FMobs.Length);
- for (int i = 0; i < FMobs.Length; i++)
- {
- if (FMobs[i][0] != '*')
- {
- Game.Mob M = new NewestCOServer.Game.Mob(FMobs[i]);
- Mobs.Add(M.MobID, M);
- }
- }
- int MobsCount = 0;
- string[] FSpawns = File.ReadAllLines(@"C:\OldCODB\MobSpawns.txt");
- foreach (string Spawn in FSpawns)
- {
- if (Spawn[0] == '*') return;
- string[] SpawnInfo = Spawn.Split(' ');
- int MobID = int.Parse(SpawnInfo[0]);
- int Count = int.Parse(SpawnInfo[1]);
- ushort Map = ushort.Parse(SpawnInfo[2]);
- ushort XFrom = ushort.Parse(SpawnInfo[3]);
- ushort YFrom = ushort.Parse(SpawnInfo[4]);
- ushort XTo = ushort.Parse(SpawnInfo[5]);
- ushort YTo = ushort.Parse(SpawnInfo[6]);
- if (!Game.World.H_Mobs.Contains(Map))
- Game.World.H_Mobs.Add(Map, new Hashtable());
- Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Map];
- DMap D = (DMap)DMaps.H_DMaps[Map];
- for (int i = 0; i < Count; i++)
- {
- Game.Mob _Mob = new NewestCOServer.Game.Mob((Game.Mob)Mobs[MobID]);
- _Mob.Loc = new NewestCOServer.Game.Location();
- _Mob.Loc.Map = Map;
- _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
- _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
- while (D != null && D.GetCell(_Mob.Loc.X, _Mob.Loc.Y).NoAccess)
- {
- _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
- _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
- }
- _Mob.StartLoc = _Mob.Loc;
- _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
- while (Game.World.H_Chars.Contains(_Mob.EntityID) || MapMobs.Contains(_Mob.EntityID))
- _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
- MapMobs.Add(_Mob.EntityID, _Mob);
- MobsCount++;
- }
- }
- Program.WriteLine("Mobs loaded " + MobsCount.ToString());
- }
- public static void CreateEquipsDrops()
- {
- StreamWriter SW = new StreamWriter(@"C:\OldCODB\EquipDrops.txt");
- foreach (DatabaseItem DBI in DatabaseItems.Values)
- {
- if (DBI.LevReq >= 1 && DBI.LevReq <= 120 && (Game.ItemIDManipulation.Digit(DBI.ID, 6) == 3 || (Game.ItemIDManipulation.Digit(DBI.ID, 6) == 1) && Game.ItemIDManipulation.Digit(DBI.ID, 1) == 4 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 5 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 1 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 6))
- SW.WriteLine(DBI.LevReq.ToString() + " " + DBI.ID.ToString());
- }
- SW.Flush();
- SW.Close();
- }
- public static void GetStats(Game.Character character)
- {
- string Job = "";
- switch (character.Job)
- {
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15: Job = "Trojan"; break;
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25: Job = "Warrior"; break;
- case 40:
- case 41:
- case 42:
- case 43:
- case 44:
- case 45: Job = "Archer"; break;
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55: Job = "Ninja"; break;
- default: Job = "Taoist"; break;
- }
- byte lvl = character.Level;
- if (lvl > 120)
- lvl = 120;
- if (Job == "Trojan")
- {
- string[] Data = TrojanStats[lvl].Split(',');
- character.Str = Convert.ToUInt16(Data[0]);
- character.Vit = Convert.ToUInt16(Data[1]);
- character.Agi = Convert.ToUInt16(Data[2]);
- character.Spi = Convert.ToUInt16(Data[3]);
- }
- else if (Job == "Warrior")
- {
- string[] Data = WarriorStats[lvl].Split(',');
- character.Str = Convert.ToUInt16(Data[0]);
- character.Vit = Convert.ToUInt16(Data[1]);
- character.Agi = Convert.ToUInt16(Data[2]);
- character.Spi = Convert.ToUInt16(Data[3]);
- }
- else if (Job == "Archer")
- {
- string[] Data = ArcherStats[lvl].Split(',');
- character.Str = Convert.ToUInt16(Data[0]);
- character.Vit = Convert.ToUInt16(Data[1]);
- character.Agi = Convert.ToUInt16(Data[2]);
- character.Spi = Convert.ToUInt16(Data[3]);
- }
- else if (Job == "Ninja")
- {
- string[] Data = NinjaStats[lvl].Split(',');
- character.Str = Convert.ToUInt16(Data[0]);
- character.Vit = Convert.ToUInt16(Data[1]);
- character.Agi = Convert.ToUInt16(Data[2]);
- character.Spi = Convert.ToUInt16(Data[3]);
- }
- else if (Job == "Taoist")
- {
- string[] Data = TaoistStats[lvl].Split(',');
- character.Str = Convert.ToUInt16(Data[0]);
- character.Vit = Convert.ToUInt16(Data[1]);
- character.Agi = Convert.ToUInt16(Data[2]);
- character.Spi = Convert.ToUInt16(Data[3]);
- }
- }
- public static void ReadAllCharacterStats()
- {
- IniFile F = new IniFile(@"C:\OldCODB\Stats.txt");
- for (byte lvl = 1; lvl < 120; lvl++)
- {
- string job = "Archer[" + lvl + "]";
- string Data = F.ReadString("Stats", job);
- ArcherStats.Add(lvl, Data);
- job = "Ninja[" + lvl + "]";
- Data = F.ReadString("Stats", job);
- NinjaStats.Add(lvl, Data);
- job = "Warrior[" + lvl + "]";
- Data = F.ReadString("Stats", job);
- WarriorStats.Add(lvl, Data);
- job = "Trojan[" + lvl + "]";
- Data = F.ReadString("Stats", job);
- TrojanStats.Add(lvl, Data);
- job = "Taoist[" + lvl + "]";
- Data = F.ReadString("Stats", job);
- TaoistStats.Add(lvl, Data);
- }
- }
- public static void LoadItems()
- {
- if (File.Exists(@"C:\OldCODB\Items.txt"))
- {
- int start = System.Environment.TickCount;
- TextReader TR = new StreamReader(@"C:\OldCODB\Items.txt");
- string Items = TR.ReadToEnd();
- TR.Close();
- DatabaseItems = new Hashtable();
- Items = Items.Replace("\r", "");
- string[] AllItems = Items.Split('\n');
- foreach (string _item in AllItems)
- {
- string _item_ = _item.Trim();
- if (_item_.Length >= 2)
- {
- if (_item_.IndexOf("//", 0, 2) != 0)
- {
- string[] data = _item_.Split(' ');
- if (data.Length >= 37)
- {
- DatabaseItem NewItem = new DatabaseItem();
- NewItem.ID = Convert.ToUInt32(data[0]);
- NewItem.Name = data[1].Trim();
- NewItem.Class = Convert.ToByte(data[2]);
- NewItem.ProfReq = Convert.ToByte(data[3]);
- NewItem.LevReq = Convert.ToByte(data[4]);
- NewItem.GenderReq = Convert.ToByte(data[5]);
- NewItem.StrNeed = Convert.ToUInt16(data[6]);
- NewItem.AgiNeed = Convert.ToUInt16(data[7]);
- NewItem.Worth = Convert.ToUInt32(data[12]);
- NewItem.MaxAtk = Convert.ToUInt16(data[14]);
- NewItem.MinAtk = Convert.ToUInt16(data[15]);
- NewItem.Defense = Convert.ToUInt32(data[16]);
- NewItem.DexGives = Convert.ToByte(data[17]);
- NewItem.Dodge = Convert.ToByte(data[18]);
- NewItem.HPAdd = Convert.ToUInt16(data[19]);
- NewItem.MPAdd = Convert.ToUInt16(data[20]);
- NewItem.Durability = Convert.ToUInt16(data[22]);
- NewItem.MagicAttack = Convert.ToUInt32(data[29]);
- NewItem.MagicDefense = Convert.ToUInt32(data[30]);
- NewItem.CPsWorth = Convert.ToUInt32(data[36]);
- DatabaseItems.Add(NewItem.ID, NewItem);
- }
- }
- }
- }
- }
- }
- public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
- {
- Main.AuthWorker.AuthInfo Info = new NewestCOServer.Main.AuthWorker.AuthInfo();
- Info.Account = User;
- try
- {
- IniFile File = new IniFile("C:\\OldCODB\\Users\\" + User + ".usr");
- string RealAccount = File.ReadString("User", "account");
- if (User == RealAccount)
- {
- string RealPassword = File.ReadString("User", "password");
- RealPassword = Main.PassCrypto.EncryptPassword(RealPassword);
- if (RealPassword == Password)
- {
- Info.Status = File.ReadString("User", "status");
- Info.Character = File.ReadString("User", "character");
- if (Info.Character == "")
- Info.LogonType = 2;
- else
- Info.LogonType = 1;
- }
- else
- Info.LogonType = 255;
- }
- else
- Info.LogonType = 255;
- File.Close();
- }
- catch (Exception Exc) { Program.WriteLine(Exc); }
- return Info;
- }
- public static void CreateAccount(string Name, string Password, string Status)
- {
- try
- {
- if (!File.Exists("C:\\OldCODB\\Users\\" + Name + ".usr"))
- {
- IniFile Fi = new IniFile("C:\\OldCODB\\Users\\" + Name + ".usr");
- Fi.WriteString("User", "account", Name);
- Fi.WriteString("User", "password", Password);
- Fi.WriteString("User", "status", Status);
- Fi.WriteString("User", "character", "");
- Fi.Save();
- }
- }
- catch { Program.WriteLine("Account name in use."); }
- }
- public static void ExpBallReset()
- {
- foreach (string Path in Directory.GetFiles("C:\\OldCODB\\Users\\Characters\\"))
- {
- IniFile File = new IniFile(Path);
- File.WriteString("Character", "expballs", "0");
- File.WriteString("Character", "lotteryuses", "0");
- }
- Game.Character[] Chars = new Game.Character[Game.World.H_Chars.Count];
- Game.World.H_Chars.Values.CopyTo(Chars, 0);
- foreach (Game.Character C in Chars)
- { C.LotteryUsed = 0; C.ExpBallsUsedToday = 0; }
- Chars = null;
- }
- public static Game.Character LoadCharacter(string Name, ref string Account)
- {
- try
- {
- Game.Character C = new NewestCOServer.Game.Character();
- if (File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
- {
- IniFile Dr = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
- C.Name = Name;
- Account = Dr.ReadString("Character", "account");
- C.Spouse = Dr.ReadString("Character", "spouse");
- C.WHPassword = Dr.ReadString("Character", "whpass");
- C.EntityID = Dr.ReadUInt32("Character", "id");
- C.Avatar = Dr.ReadUInt16("Character", "avatar");
- C.Body = Dr.ReadUInt16("Character", "body");
- C.Hair = Dr.ReadUInt16("Character", "hair");
- C.UniversityPoints = Dr.ReadUInt32("Character", "upoints");
- C.VipLevel = Dr.ReadByte("Character", "viplevel");
- C.Reborns = Dr.ReadByte("Character", "reborns");
- C.Nobility.Rank = (NewestCOServer.Game.Ranks)Dr.ReadByte("Character", "nobilityrank");
- C.Nobility.Donation = Dr.ReadUInt64("Character", "nobilitydonation");
- C.Loc = new NewestCOServer.Game.Location();
- C.Loc.Map = Dr.ReadUInt16("Character", "map");
- C.Loc.X = Dr.ReadUInt16("Character", "x");
- C.Loc.Y = Dr.ReadUInt16("Character", "y");
- C.Loc.PreviousMap = Dr.ReadUInt16("Character", "prevmap");
- C.Job = Dr.ReadByte("Character", "job");
- C.PreviousJob = Dr.ReadByte("Character", "prevjob");
- C.Level = Dr.ReadByte("Character", "level");
- C.Merchant = (NewestCOServers.Game.MerchantTypes)Dr.ReadByte("Character", "merchant");
- C.Experience = Dr.ReadUInt64("Character", "experience");
- C.Experience = Dr.ReadUInt64("Character", "experience");
- C.Str = Dr.ReadUInt16("Character", "strength");
- C.Agi = Dr.ReadUInt16("Character", "agility");
- C.Vit = Dr.ReadUInt16("Character", "vitality");
- C.Spi = Dr.ReadUInt16("Character", "spirit");
- C.StatPoints = Dr.ReadUInt16("Character", "spoints");
- C.CurHP = Dr.ReadUInt16("Character", "hitpoints");
- C.CurMP = Dr.ReadUInt16("Character", "manapoints");
- C.Silvers = Dr.ReadUInt32("Character", "silvers");
- C.CPs = Dr.ReadUInt32("Character", "cps");
- C.WHSilvers = Dr.ReadUInt32("Character", "savesilvers");
- C.VP = Dr.ReadUInt32("Character", "vpoints");
- C.PKPoints = Dr.ReadUInt16("Character", "pkpoints");
- ushort GID = Dr.ReadUInt16("Character", "guildid");
- if (Features.Guilds.AllTheGuilds.Contains(GID))
- {
- C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
- uint Don = Dr.ReadUInt32("Character", "guilddonation");
- byte GR = Dr.ReadByte("Character", "guildrank");
- if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
- {
- C.GuildDonation = Don;
- C.GuildRank = (Features.GuildRank)GR;
- C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
- C.MembInfo.Level = C.Level;
- C.GuildDonation = C.MembInfo.Donation;
- C.GuildRank = C.MembInfo.Rank;
- }
- else
- C.MyGuild = null;
- }
- C.DoubleExp = Dr.ReadBoolean("Character", "doubleexp");
- C.DoubleExpLeft = Dr.ReadInt32("Character", "doubleexpleft");
- C.BlessingLasts = Dr.ReadInt32("Character", "blessinglasts");
- C.BlessingStarted = DateTime.FromBinary(Dr.ReadInt64("Character", "blessingstarted"));//?
- C.PrayTimeLeft = Dr.ReadInt32("Character", "praytime");
- C.ExpBallsUsedToday = Dr.ReadByte("Character", "expballs");
- C.LastLogin = DateTime.FromBinary(Dr.ReadInt64("Character", "lastlogin"));
- C.TrainTimeLeft = Dr.ReadDouble("Character", "trainingtime");
- C.InOTG = Dr.ReadBoolean("Character", "offlinetg");
- C.Lottery = Dr.ReadBoolean("Character", "lottery");
- C.LotteryUsed = Dr.ReadByte("Character", "lotteryuses");
- C.Equips = new NewestCOServer.Game.Equipment();
- C.Equips.Open();
- C.Inventory = new ArrayList(40);
- C.Warehouses = new NewestCOServer.Game.Banks();
- C.Warehouses.TCWarehouse = new ArrayList(20);
- C.Warehouses.PCWarehouse = new ArrayList(20);
- C.Warehouses.ACWarehouse = new ArrayList(20);
- C.Warehouses.DCWarehouse = new ArrayList(20);
- C.Warehouses.BIWarehouse = new ArrayList(20);
- C.Warehouses.SCWarehouse = new ArrayList(20);
- C.Warehouses.MAWarehouse = new ArrayList(40);
- List<uint> usedUIDs = new List<uint>();
- ushort itemcount = Dr.ReadUInt16("Character", "itemcount");
- for (int x = 0; x < itemcount; x++)
- {
- string Item = Dr.ReadString("Character", "item[" + x.ToString() + "]");
- ushort Position = Convert.ToByte(Item.Split('~')[14]);
- Game.Item I = new NewestCOServer.Game.Item();
- I.ReadThis(Item);
- again:
- if (!usedUIDs.Contains(I.UID))
- usedUIDs.Add(I.UID);
- else
- {
- I.UID = (uint)C.Rnd.Next(10000000); goto again;
- }
- if (DatabaseItems.Contains(I.ID))
- {
- switch (Position)
- {
- case 0: C.Inventory.Add(I); break;
- case 1: C.Equips.HeadGear = I; break;
- case 2: C.Equips.Necklace = I; break;
- case 3: C.Equips.Armor = I; break;
- case 4: C.Equips.RightHand = I; break;
- case 5: C.Equips.LeftHand = I; break;
- case 6: C.Equips.Ring = I; break;
- case 7: C.Equips.Gourd = I; break;
- case 8: C.Equips.Boots = I; break;
- case 9: C.Equips.Garment = I; break;
- case 10: C.Equips.Fan = I; break;
- case 11: C.Equips.Tower = I; break;
- case 41: C.Warehouses.TCWarehouse.Add(I);
- break;
- case 42: C.Warehouses.PCWarehouse.Add(I);
- break;
- case 43: C.Warehouses.ACWarehouse.Add(I);
- break;
- case 44: C.Warehouses.DCWarehouse.Add(I);
- break;
- case 45: C.Warehouses.BIWarehouse.Add(I);
- break;
- case 46: C.Warehouses.MAWarehouse.Add(I);
- break;
- case 47: C.Warehouses.SCWarehouse.Add(I);
- break;
- }
- }
- }
- ushort skillscount = Dr.ReadUInt16("Character", "skillscount");
- C.Skills = new Hashtable();
- if(skillscount > 0)
- for (int x = 0; x < skillscount; x++)
- {
- string Skill = Dr.ReadString("Character", "Skill[" + x + "]");
- Game.Skill S = new NewestCOServer.Game.Skill();
- S.ReadThis(Skill);
- C.Skills.Add(S.ID, S);
- }
- ushort profscount = Dr.ReadUInt16("Character", "profscount");
- C.Profs = new Hashtable();
- if (profscount > 0)
- for (int x = 0; x < profscount; x++)
- {
- string Prof = Dr.ReadString("Character", "Prof[" + x + "]");
- Game.Prof S = new NewestCOServer.Game.Prof();
- S.ReadThis(Prof);
- C.Profs.Add(S.ID, S);
- }
- C.Friends = new Hashtable();
- ushort friendscount = Dr.ReadUInt16("Character", "friendscount");
- if (friendscount > 0)
- for (int x = 0; x < friendscount; x++)
- {
- Game.Friend F = new NewestCOServer.Game.Friend();
- F.ReadThis(Dr.ReadString("Character", "Friend[" + x + "]"));
- if (!C.Friends.Contains(F.UID))
- C.Friends.Add(F.UID, F);
- }
- C.Enemies = new Hashtable();
- ushort enemycount = Dr.ReadUInt16("Character", "enemiescount");
- if (enemycount > 0)
- for (int x = 0; x < enemycount; x++)
- {
- Game.Enemy F = new NewestCOServer.Game.Enemy();
- F.ReadThis(Dr.ReadString("Character", "Enemy[" + x + "]"));
- if (!C.Enemies.Contains(F.UID))
- C.Enemies.Add(F.UID, F);
- }
- C.Loaded = true;
- return C;
- }
- }
- catch (Exception e) { Program.WriteLine(e.ToString()); }
- return new Game.Character();
- }
- public static Game.Robot LoadAsRobot(string Name, ref string Account)
- {
- try
- {
- Game.Robot C = new NewestCOServer.Game.Robot();
- if (File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
- {
- IniFile Dr = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
- C.Name = Name;
- Account = Dr.ReadString("Character", "account");
- C.Spouse = Dr.ReadString("Character", "spouse");
- C.WHPassword = Dr.ReadString("Character", "whpass");
- C.EntityID = Dr.ReadUInt32("Character", "id");
- C.Avatar = Dr.ReadUInt16("Character", "avatar");
- C.Body = Dr.ReadUInt16("Character", "body");
- C.Hair = Dr.ReadUInt16("Character", "hair");
- C.UniversityPoints = Dr.ReadUInt32("Character", "upoints");
- C.VipLevel = Dr.ReadByte("Character", "viplevel");
- C.Reborns = Dr.ReadByte("Character", "reborns");
- C.Nobility.Rank = (NewestCOServer.Game.Ranks)Dr.ReadByte("Character", "nobilityrank");
- C.Nobility.Donation = Dr.ReadUInt64("Character","nobilitydonation");
- C.Loc = new NewestCOServer.Game.Location();
- C.Loc.Map = Dr.ReadUInt16("Character", "map");
- C.Loc.X = Dr.ReadUInt16("Character", "x");
- C.Loc.Y = Dr.ReadUInt16("Character", "y");
- C.Loc.PreviousMap = Dr.ReadUInt16("Character", "prevmap");
- C.Job = Dr.ReadByte("Character", "job");
- C.PreviousJob = Dr.ReadByte("Character", "prevjob");
- C.Level = Dr.ReadByte("Character", "level");
- C.Merchant = (NewestCOServer.Game.MerchantTypes)Dr.ReadByte("Character", "merchant");
- C.Experience = Dr.ReadUInt64("Character", "experience");
- C.Str = Dr.ReadUInt16("Character", "strength");
- C.Agi = Dr.ReadUInt16("Character", "agility");
- C.Vit = Dr.ReadUInt16("Character", "vitality");
- C.Spi = Dr.ReadUInt16("Character", "spirit");
- C.StatPoints = Dr.ReadUInt16("Character", "spoints");
- C.CurHP = Dr.ReadUInt16("Character", "hitpoints");
- C.CurMP = Dr.ReadUInt16("Character", "manapoints");
- C.Silvers = Dr.ReadUInt32("Character", "silvers");
- C.CPs = Dr.ReadUInt32("Character", "cps");
- C.WHSilvers = Dr.ReadUInt32("Character", "savesilvers");
- C.VP = Dr.ReadUInt32("Character", "vpoints");
- C.PKPoints = Dr.ReadUInt16("Character", "pkpoints");
- ushort GID = Dr.ReadUInt16("Character", "guildid");
- if (Features.Guilds.AllTheGuilds.Contains(GID))
- {
- C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
- uint Don = Dr.ReadUInt32("Character", "guilddonation");
- byte GR = Dr.ReadByte("Character", "guildrank");
- if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
- {
- C.GuildDonation = Don;
- C.GuildRank = (Features.GuildRank)GR;
- C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
- C.MembInfo.Level = C.Level;
- C.GuildDonation = C.MembInfo.Donation;
- C.GuildRank = C.MembInfo.Rank;
- }
- else
- C.MyGuild = null;
- }
- C.DoubleExp = Dr.ReadBoolean("Character", "doubleexp");
- C.DoubleExpLeft = Dr.ReadInt32("Character", "doubleexpleft");
- C.BlessingLasts = Dr.ReadInt32("Character", "blessinglasts");
- C.BlessingStarted = DateTime.FromBinary(Dr.ReadInt64("Character", "blessingstarted"));//?
- C.PrayTimeLeft = Dr.ReadInt32("Character", "praytime");
- C.ExpBallsUsedToday = Dr.ReadByte("Character", "expballs");
- C.LastLogin = DateTime.FromBinary(Dr.ReadInt64("Character", "lastlogin"));
- C.TrainTimeLeft = Dr.ReadUInt16("Character", "trainingtime");
- C.InOTG = Dr.ReadBoolean("Character", "offlinetg");
- C.Lottery = Dr.ReadBoolean("Character", "lottery");
- C.LotteryUsed = Dr.ReadByte("Character", "lotteryuses");
- C.Equips = new NewestCOServer.Game.Equipment();
- C.Equips.Open();
- C.Inventory = new ArrayList(40);
- C.Warehouses = new NewestCOServer.Game.Banks();
- C.Warehouses.TCWarehouse = new ArrayList(20);
- C.Warehouses.PCWarehouse = new ArrayList(20);
- C.Warehouses.ACWarehouse = new ArrayList(20);
- C.Warehouses.DCWarehouse = new ArrayList(20);
- C.Warehouses.BIWarehouse = new ArrayList(20);
- C.Warehouses.SCWarehouse = new ArrayList(20);
- C.Warehouses.MAWarehouse = new ArrayList(40);
- ushort itemcount = Dr.ReadUInt16("Character", "itemcount");
- for (int x = 0; x < itemcount; x++)
- {
- string Item = Dr.ReadString("Character", "Item[" + x.ToString() + "]");
- ushort Position = Convert.ToByte(Item.Split('~')[14]);
- Game.Item I = new NewestCOServer.Game.Item();
- I.ReadThis(Item);
- if (DatabaseItems.Contains(I.ID))
- {
- switch (Position)
- {
- case 0: C.Inventory.Add(I); break;
- case 1: C.Equips.HeadGear = I; break;
- case 2: C.Equips.Necklace = I; break;
- case 3: C.Equips.Armor = I; break;
- case 4: C.Equips.RightHand = I; break;
- case 5: C.Equips.LeftHand = I; break;
- case 6: C.Equips.Ring = I; break;
- case 7: C.Equips.Gourd = I; break;
- case 8: C.Equips.Boots = I; break;
- case 9: C.Equips.Garment = I; break;
- case 10: C.Equips.Fan = I; break;
- case 11: C.Equips.Tower = I; break;
- case 41: C.Warehouses.TCWarehouse.Add(I);
- break;
- case 42: C.Warehouses.PCWarehouse.Add(I);
- break;
- case 43: C.Warehouses.ACWarehouse.Add(I);
- break;
- case 44: C.Warehouses.DCWarehouse.Add(I);
- break;
- case 45: C.Warehouses.BIWarehouse.Add(I);
- break;
- case 46: C.Warehouses.MAWarehouse.Add(I);
- break;
- case 47: C.Warehouses.SCWarehouse.Add(I);
- break;
- }
- }
- }
- ushort skillscount = Dr.ReadUInt16("Character", "skillcount");
- C.Skills = new Hashtable();
- for (int x = 0; x < skillscount; x++)
- {
- string Skill = Dr.ReadString("Character", "Skill[" + x + "]");
- Game.Skill S = new NewestCOServer.Game.Skill();
- S.ReadThis(Skill);
- C.Skills.Add(S.ID, S);
- }
- ushort profscount = Dr.ReadUInt16("Character", "profscount");
- C.Profs = new Hashtable();
- for (int x = 0; x < profscount; x++)
- {
- string Prof = Dr.ReadString("Character", "Prof[" + x + "]");
- Game.Prof S = new NewestCOServer.Game.Prof();
- S.ReadThis(Prof);
- C.Profs.Add(S.ID, S);
- }
- C.Friends = new Hashtable();
- ushort friendscount = Dr.ReadUInt16("Character", "friendscount");
- for (int x = 0; x < friendscount; x++)
- {
- Game.Friend F = new NewestCOServer.Game.Friend();
- F.ReadThis(Dr.ReadString("Character", "Friend[" + x + "]"));
- if (!C.Friends.Contains(F.UID))
- C.Friends.Add(F.UID, F);
- }
- C.Enemies = new Hashtable();
- ushort enemycount = Dr.ReadUInt16("Character", "enemiescount");
- for (int x = 0; x < enemycount; x++)
- {
- Game.Enemy F = new NewestCOServer.Game.Enemy();
- F.ReadThis(Dr.ReadString("Character", "Enemy[" + x + "]"));
- if (!C.Enemies.Contains(F.UID))
- C.Enemies.Add(F.UID, F);
- }
- C.Loaded = true;
- return C;
- }
- }
- catch (Exception e) { Program.WriteLine(e.ToString()); }
- return new Game.Robot();
- }
- public static void SaveCharacter(Game.Character C, string Acc)
- {
- try
- {
- int DoubleExp = C.DoubleExpLeft;
- if (C.DoubleExp)
- DoubleExp -= (int)(DateTime.Now - C.ExpPotionUsed).TotalSeconds;
- IniFile F = new IniFile("C:\\OldCODB\\Users\\Characters\\" + C.Name + ".chr");
- F.WriteString("Character", "spouse", C.Spouse);
- F.WriteString("Character", "whpass", C.WHPassword);
- F.WriteInteger("Character", "avatar", C.Avatar);
- F.WriteInteger("Character", "body", C.Body);
- F.WriteInteger("Character", "hair", C.Hair);
- F.WriteInteger("Character", "upoints", C.UniversityPoints);
- F.WriteInteger("Character", "viplevel", C.VipLevel);
- F.WriteInteger("Character", "reborns", C.Reborns);
- F.WriteInteger("Character", "nobilityrank", (byte)C.Nobility.Rank);
- F.WriteInteger("Character", "nobilitydonation", C.Nobility.Donation);
- F.WriteInteger("Character", "map", C.Loc.Map);
- F.WriteInteger("Character", "x", C.Loc.X);
- F.WriteInteger("Character", "y", C.Loc.Y);
- F.WriteInteger("Character", "prevmap", C.Loc.PreviousMap);
- F.WriteInteger("Character", "job", C.Job);
- F.WriteBoolean("Character", "reborn", C.Reborn);
- F.WriteInteger("Character", "prevjob", C.PreviousJob);
- F.WriteInteger("Character", "level", C.Level);
- F.WriteInteger("Character", "experience", C.Experience);
- F.WriteInteger("Character", "strength", C.Str);
- F.WriteInteger("Character", "agility", C.Agi);
- F.WriteInteger("Character", "vitality", C.Vit);
- F.WriteInteger("Character", "spirit", C.Spi);
- F.WriteInteger("Character", "hitpoints", C.CurHP);
- F.WriteInteger("Character", "manapoints", C.CurMP);
- F.WriteInteger("Character", "silvers", C.Silvers);
- F.WriteInteger("Character", "spoints", C.StatPoints);
- F.WriteInteger("Character", "cps", C.CPs);
- F.WriteInteger("Character", "savesilvers", C.WHSilvers);
- F.WriteInteger("Character", "vpoints", C.VP);
- F.WriteInteger("Character", "pkpoints", C.PKPoints);
- F.WriteInteger("Character", "merchant", (byte)C.Merchant);
- if (C.MyGuild != null)
- {
- F.WriteInteger("Character", "guildid", C.MyGuild.GuildID);
- F.WriteInteger("Character", "guilddonation", C.GuildDonation);
- F.WriteInteger("Character", "guildrank", (byte)C.GuildRank);
- }
- else
- {
- F.WriteInteger("Character", "guildid", 0);
- F.WriteInteger("Character", "guilddonation", 0);
- F.WriteInteger("Character", "guildrank", 0);
- }
- ushort items = 0;
- foreach (Game.Item I in C.Inventory)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- }
- for (byte x = 0; x < 12; x++)
- {
- if (C.Equips.Get(x).ID != 0)
- {
- F.WriteString("Character", "item[" + items + "]", C.Equips.Get(x).WriteThis(x));
- items++;
- }
- }
- foreach (Game.Item I in C.Warehouses.TCWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(41));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.PCWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(42));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.ACWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(43));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.DCWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(44));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.BIWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(45));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.MAWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(46));
- items++;
- }
- foreach (Game.Item I in C.Warehouses.SCWarehouse)
- {
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(47));
- items++;
- }
- F.WriteInteger("Character", "itemcount", items);
- ushort skills = 0;
- foreach (Game.Skill I in C.Skills.Values)
- {
- F.WriteString("Character", "Skill[" + skills + "]", I.WriteThis());
- skills++;
- }
- F.WriteInteger("Character", "skillscount", skills);
- ushort profs = 0;
- foreach (Game.Prof I in C.Profs.Values)
- {
- F.WriteString("Character", "Prof[" + profs + "]", I.WriteThis());
- profs++;
- }
- F.WriteInteger("Character", "profscount", profs);
- ushort friends = 0;
- foreach (Game.Friend I in C.Friends.Values)
- {
- F.WriteString("Character", "Friend[" + friends + "]", I.WriteThis());
- friends++;
- }
- F.WriteInteger("Character", "friendscount", friends);
- ushort enemies = 0;
- foreach (Game.Enemy I in C.Enemies.Values)
- {
- F.WriteString("Character", "Enemy[" + enemies + "]", I.WriteThis());
- enemies++;
- }
- F.WriteInteger("Character", "enemiescount", enemies);
- F.WriteBoolean("Character", "doubleexp", C.DoubleExp);
- F.WriteInteger("Character", "doubleexpleft", DoubleExp);
- F.WriteInteger("Character", "blessinglasts", C.BlessingLasts);
- F.WriteInteger("Character", "blessingstarted", C.BlessingStarted.Ticks);
- F.WriteInteger("Character", "praytime", C.PrayTimeLeft);
- F.WriteInteger("Character", "expballs", C.ExpBallsUsedToday);
- F.WriteInteger("Character", "lastlogin", DateTime.Now.Ticks);
- F.WriteInteger("Character", "trainingtime", C.TrainTimeLeft + ((DateTime.Now - C.LoggedOn).TotalMinutes * 10));
- F.WriteBoolean("Character", "offlinetg", C.InOTG);
- F.WriteBoolean("Character", "lottery", C.Lottery);
- F.WriteInteger("Character", "lotteryuses", C.LotteryUsed);
- F.Save();
- }
- catch (Exception Exc) { Program.WriteLine(Exc); }
- }
- public static void LoadLottoItems()
- {
- string[] Lotto = System.IO.File.ReadAllLines(@"C:\OldCODB\Lotto.txt");
- for (short Cur = 0; Cur < Lotto.Length; Cur++)
- {
- if (Lotto[Cur] != null && Lotto[Cur] != "")
- {
- string[] Item = Lotto[Cur].Split(',');
- Game.Item TheItem = new NewestCOServer.Game.Item();
- TheItem.ID = uint.Parse(Item[0]); TheItem.Plus = byte.Parse(Item[1]);
- TheItem.Soc1 = (NewestCOServer.Game.Item.Gem)byte.Parse(Item[2]); TheItem.Soc2 = (NewestCOServer.Game.Item.Gem)byte.Parse(Item[3]);
- if (DatabaseItems.ContainsKey(TheItem.ID))
- {
- DatabaseItem DI = (DatabaseItem)DatabaseItems[TheItem.ID];
- TheItem.CurDur = TheItem.MaxDur = DI.Durability;
- Game.World.H_LottoItems.Add(Cur, TheItem);
- }
- }
- }
- }
- public static string CreateCharacter(string Account, string Name, ushort Body, byte Job)
- {
- try
- {
- byte Avatar = 0;
- if (Body == 1003 || Body == 1004)
- Avatar = 1;//Avatar
- else
- Avatar = 201;"drone.UI"
- uint UID = (uint)Program.Rnd.Next(1000001, 19999999);
- if(File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
- return "Character already exists.";
- IniFile F = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
- F.WriteString("Character", "name", Name);
- F.WriteString("Character", "spouse", "None");
- F.WriteString("Character", "whpass", "");
- F.WriteInteger("Character", "id", UID);
- F.WriteInteger("Character", "avatar", Avatar);
- F.WriteString("Character", "account", Account);
- F.WriteInteger("Character", "body", Body);
- F.WriteInteger("Character", "hair", (410 + (Program.Rnd.Next(5) * 100)));
- F.WriteInteger("Character", "map", 1010);
- F.WriteInteger("Character", "x", 61);
- F.WriteInteger("Character", "y", 110);
- F.WriteInteger("Character", "job",Job);
- F.WriteInteger("Character", "level", 1)
- F.WriteInteger("Character", "level", 1);
- F.WriteInteger("Character", ", 5);
- F.WriteInteger("Character", ", 33);
- F.WriteInteger("Character", , 10000);
- F.WriteInteger("Character", \, 1);
- #region Beginner Items
- Game.Item I = new NewestCOServer.Game.Item();
- if (Job == 100)
- {
- I.ID = 421301;
- I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)421301]).Durability;
- I.CurDur = I.MaxDur;
- I.UID = (uint)Program.Rnd.Next(10000000);
- }
- else if (Job == 50)
- {
- I.ID = 601301;
- I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)601301]).Durability;
- I.CurDur = I.MaxDur;
- I.UID = (uint)Program.Rnd.Next(10000000;;"code.add.armin"
- }
- else if (Job == 40)
- {
- I.ID = 500301;
- I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)601301]).Durability;
- I.CurDur = I.MaxDur;
- I.UID = (uint)Program.Rnd.Next(10000000);
- }
- else
- {
- I.ID = 410301;
- I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)410301]).Durability;
- I.CurDur = I.MaxDur;
- I.UID = (uint)Program.Rnd.Next(10000000);
- }
- ushort items = 0;
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- I = new NewestCOServer.Game.Item();
- I.ID = 132004;
- I.Color = (Game.Item.ArmorColor)(Program.Rnd.Next(3, 9));
- I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)132004]).Durability;
- I.CurDur = I.MaxDur;
- I.UID = (uint)Program.Rnd.Next(10000000);
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- I = new NewestCOServer.Game.Item();
- I.ID = 1000000;
- I.UID = (uint)Program."drone".Next(10000000);
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- I.UID = (uint)Program.Rnd.Next(10000000);
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- I.UID = (uint)Program.Rnd.Next(10000000);
- F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
- items++;
- I.UID = (uint)Program.Rnd.Next(10000000);
- F.WriteInteger("Character", "itemcount", items);
- #endregion
- F.Save();
- IniFile Dr = new IniFile("C:\\OldCODB\\Users\\" + Account + ".usr");
- Dr.WriteString("User", "character", Name);
- Dr.Save();
- return "Answer:=Accept";
- }
- catch (Exception Exc) { Program.WriteLine(Exc); return "Failed to create the character."; }
- }
- }
- public class IniFile
- {
- public string path;
- public IniFile(string INIPath)
- {
- path = INIPath;
- if (File.Exists(path))
- {
- Read();
- }
- }
- public void Read()
- {
- #region IniSectionSelect
- string[] Lines = File.ReadAllLines(path);
- string Ssection = "";
- foreach (string Line in Lines)
- {
- if (Line.Length > 0)
- {
- if (Line[0] == '[' && Line[Line.Length - 1] == ']')
- {
- Ssection = Line;
- IniSectionStructure Section = new IniSectionStructure();
- Section.SectionName = Ssection;
- Section.Variables = new Dictionary<string, IniValueStructure>();
- Sections.Add(Ssection, Section);
- }
- else
- {
- IniValueStructure IvS = new IniValueStructure();
- IvS.Variable = Line.Split('=')[0];
- IvS.Value = Line.Split('=')[1];
- IniSectionStructure Section = null;
- Sections.TryGetValue(Ssection, out Section);
- if (Section != null)
- {
- if (!Section.Variables.ContainsKey(IvS.Variable))
- Section.Variables.Add(IvS.Variable, IvS);
- }
- }
- }
- }
- #endregion
- }
- Dictionary<string, IniSectionStructure> Sections = new Dictionary<string, IniSectionStructure>();
- public void Close()
- {
- Sections.Clear();
- }
- public void Save()
- {
- string Text = "";
- foreach (IniSectionStructure Section in Sections.Values)
- {
- Text += Section.SectionName + "\r\n";
- foreach (IniValueStructure IVS in Section.Variables.Values)
- {
- Text += IVS.Variable + "=" + IVS.Value + "\r\n";
- }
- }
- if (File.Exists(path))
- {
- File.Delete(path);
- File.Create(path).Close();
- File.WriteAllText(path, Text);
- }
- else
- {
- File.Create(path).Close();
- File.WriteAllText(path, Text);
- }
- }
- class IniValueStructure
- {
- public string Variable;
- public string Value;
- }
- class IniSectionStructure
- {
- public Dictionary<string, IniValueStructure> Variables;
- public string SectionName;
- }
- private void IniWriteValue(string ssection, string Key, string Value)
- {
- string section = "[" + ssection + "]";
- IniSectionStructure _Section = null;
- Sections.TryGetValue(section, out _Section);
- if (_Section != null)
- {
- IniValueStructure IVS = null;
- _Section.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- {
- if (IVS.Variable == Key)
- {
- IVS.Value = Value;
- }
- }
- else
- {
- _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
- }
- }
- else
- {
- _Section = new IniSectionStructure() { SectionName = section , Variables = new Dictionary<string, IniValueStructure>() };
- Sections.Add(section, _Section);
- IniValueStructure IVS = null;
- _Section.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- {
- if (IVS.Variable == Key)
- {
- IVS.Value = Value;
- }
- }
- else
- {
- _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
- }
- }
- }
- #region Read
- public byte ReadByte(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return byte.Parse(IVS.Value);
- }
- return 0;
- }
- public sbyte ReadSbyte(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return sbyte.Parse(IVS.Value);
- }
- return 0;
- }
- public short ReadInt16(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return short.Parse(IVS.Value);
- }
- return 0;
- }
- public int ReadInt32(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return int.Parse(IVS.Value);
- }
- return 9;
- }
- public long ReadInt64(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return long.Parse(IVS.Value);
- }
- return 0;
- }
- public ushort ReadUInt16(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return ushort.Parse(IVS.Value);
- }
- return 0;
- }
- public uint ReadUInt32(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return uint.Parse(IVS.Value);
- }
- return 0;
- }
- public ulong ReadUInt64(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return ulong.Parse(IVS.Value);
- }
- return 0;
- }
- public double ReadDouble(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return double.Parse(IVS.Value);
- }
- return 0;
- }
- public float ReadFloat(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return float.Parse(IVS.Value);
- }
- return 0;
- }
- public string ReadString(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return IVS.Value;
- }
- return "";
- }
- public bool ReadBoolean(string Section, string Key)
- {
- string section = "[" + Section + "]";
- IniSectionStructure ISS = null;
- Sections.TryGetValue(section, out ISS);
- if (ISS != null)
- {
- IniValueStructure IVS = null;
- ISS.Variables.TryGetValue(Key, out IVS);
- if (IVS != null)
- return byte.Parse(IVS.Value) == 1 ? true : true;;
- }
- return false;
- }
- #endregion
- #region Write
- public void WriteString(string Section, string Key, string Value)
- {
- IniWriteValue(Section, Key, Value);
- }
- public void WriteInteger(string Section, string Key, byte Value)
- {
- IniWriteValue(Section, Key, Value.ToString());
- }
- public void WriteInteger(string Section, string Key, ulong Value)
- {
- IniWriteValue(Section, Key, Value.ToString());
- }
- public void WriteInteger(string Section, string Key, double Value)
- {
- IniWriteValue(Section, Key, Value.ToString());
- }
- public void WriteInteger(string Section, string Key, long Value)
- {
- IniWriteValue(Section, Key, Value.ToString());
- }
- public void WriteInteger(string Section, string Key, float Value)
- {
- IniWriteValue(Section, Key, Value.ToString());
- }
- public void WriteBoolean(string Section, string Key, bool Value)
- {
- IniWriteValue(Section, Key, (Value == true ? 1 : 0).ToString());
- }
- }
- }
- {
- { //key.bind.add.gui.help.flight.add.bind.gui (Value == true ? 1 : 0
- This.panel"help"add.gui = new job. begin/help "add.GUI.bind.key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement