Пример #1
0
        public WorldCharacter CreateCharacter(string name, byte slot, byte hair, byte color, byte face, Job job, bool ismale)
        {
            if (Characters.ContainsKey(slot) || slot > 5)
            {
                return(null);
            }
            //TODO: check if hair etc are actual beginner ones! (premium hack)

            BaseStatsEntry stats = DataProvider.Instance.JobBasestats[job];

            if (stats == null)
            {
                Log.WriteLine(LogLevel.Warn, "Houston, we have a problem! Jobstats not found for job {0}", job.ToString());
                return(null);
            }

            Character newchar = new Character();

            newchar.AccountID = this.AccountID;
            newchar.CharLevel = 1;
            newchar.Name      = name;
            newchar.Face      = face;
            newchar.Hair      = hair;
            newchar.HairColor = color;
            newchar.Job       = (byte)job;
            newchar.Male      = ismale;
            newchar.Slot      = slot;
            newchar.XPos      = 7636;
            newchar.YPos      = 4610;
            newchar.HP        = (short)stats.MaxHP;
            newchar.SP        = (short)stats.MaxSP;
            newchar.HPStones  = (short)stats.MaxHPStones;
            newchar.SPStones  = (short)stats.MaxSPStones;
            Program.Entity.AddToCharacters(newchar);
            int    charID   = newchar.ID;
            ushort begineqp = GetBeginnerEquip(job);

            if (begineqp > 0)
            {
                DatabaseEquip eqp = new DatabaseEquip();
                eqp.EquipID = begineqp;
                eqp.Slot    = (short)((job == Job.Archer) ? -10 : -12);
                newchar.Equips.Add(eqp);
            }
            Program.Entity.SaveChanges();
            WorldCharacter tadaa = new WorldCharacter(newchar, (job == Job.Archer) ? (byte)12 : (byte)10, begineqp);

            Characters.Add(slot, tadaa);
            return(tadaa);
        }
Пример #2
0
        public WorldCharacter CreateCharacter(string name, byte slot, byte hair, byte color, byte face, Job job, bool ismale)
        {
            if (Characters.ContainsKey(slot) || slot > 5)
            {
                return(null);
            }
            //TODO: check if hair etc are actual beginner ones! (premium hack)
            //NOTE: Check the SHN's for this -> Moved to database
            BaseStatsEntry stats = DataProvider.Instance.JobBasestats[job];

            if (stats == null)
            {
                //NOTE be serious.. please
                // Log.WriteLine(LogLevel.Warn, "Houston, we have a problem! Jobstats not found for job {0}", job.ToString());
                Log.WriteLine(LogLevel.Error, "Jobstats not found for job {0}", job.ToString());
                return(null);
            }
            Database.Storage.LookInfo     newLook = new Database.Storage.LookInfo();
            Database.Storage.PositionInfo newPos  = new Database.Storage.PositionInfo();
            Database.Storage.Character    newchar = new Database.Storage.Character();
            newchar.AccountID    = this.AccountID;
            newchar.CharLevel    = 1;
            newchar.Name         = name;
            newLook.Face         = face;
            newLook.Hair         = hair;
            newLook.HairColor    = color;
            newchar.Job          = (byte)job;
            newLook.Male         = ismale;
            newchar.Slot         = slot;
            newPos.XPos          = 7636;
            newPos.YPos          = 4610;
            newchar.HP           = (short)stats.MaxHP;
            newchar.SP           = (short)stats.MaxSP;
            newchar.HPStones     = (short)stats.MaxHPStones;
            newchar.SPStones     = (short)stats.MaxSPStones;
            newchar.LookInfo     = newLook;
            newchar.PositionInfo = newPos;
            int            charID = newchar.ID;
            DatabaseClient client = Program.DatabaseManager.GetClient();

            string query =
                "INSERT INTO `characters` " +
                "(`AccountID`,`Name`,`MasterJoin`,`Slot`,`Job`,`Male`,`Hair`,`HairColor`,`Face`," +
                " `QuickBar`, `QuickBarState`, `ShortCuts`, `GameSettings`, `ClientSettings`) " +
                "VALUES " +
                "('" + newchar.AccountID +
                "', '" + newchar.Name +
                "', '" + DateTime.Now.ToDBString() +
                "', " + newchar.Slot +
                ", " + newchar.Job +
                ", " + Convert.ToByte(newchar.LookInfo.Male) +
                ", " + newchar.LookInfo.Hair +
                ", " + newchar.LookInfo.HairColor +
                ", " + newchar.LookInfo.Face +
                ", " + "0" +
                ", " + "0" +
                ", " + "0" +
                ", " + "0" +
                ", " + "0" +
                ")";

            client.ExecuteQuery(query);

            WorldCharacter tadaa    = new WorldCharacter(newchar, this);
            ushort         begineqp = GetBeginnerEquip(job);

            if (begineqp > 0)
            {
                sbyte eqp_slot = (sbyte)((job == Job.Archer) ? -10 : -12); //, (job == Job.Archer) ? (byte)12 : (byte)10, begineqp)
                Equip eqp      = new Equip((uint)newchar.ID, begineqp, eqp_slot);
                tadaa.Inventory.AddToEquipped(eqp);
                client.ExecuteQuery("INSERT INTO equips (owner,slot,EquipID) VALUES ('" + tadaa.ID + "','" + eqp_slot + "','" + eqp.EquipID + "')");
            }
            Characters.Add(slot, tadaa);
            return(tadaa);
        }