Criando um Conquer
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Fixar inner power

Ir para baixo

Fixar inner power Empty Fixar inner power

Mensagem por FelipeXP Sáb Dez 17, 2016 10:41 pm

Procure por class InnerPowerTable
Código:
using TroZenA.Network.GamePackets;
using TroZenA.Game;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace TroZenA.Database
{
    public static class InnerPowerTable
    {
        public enum AtributeType : byte
        {
            MaxHP = 1,
            PAttack = 2,
            MAttack = 3,
            PDefense = 4,
            MDefense = 5,
            FinalPAttack = 6,
            FinalMAttack = 7,
            FinalPDamage = 8,
            FinalMDamage = 9,
            PStrike = 10,
            MStrike = 11,
            Immunity = 12,
            Break = 13,
            Conteraction = 14
        }
        public static uint Count = 0;
        public static Stage[] Stages;
        public class Stage
        {
            public ushort ID;
            public string Name = "";
            public byte NeiGongNum;
            public AtributeType[] SpecialAtributesType;
            public uint[] AtributesValues;
            public NeiGong[] NeiGongAtributes;
            public class NeiGong
            {
                public byte ID;
                public byte MaxLevel;
                public AtributeType[] AtributesType;
                public uint[] AtributesValues;
                public uint[] ProgressNeiGongValue;
                public uint ItemID;
                public uint ReqLev;
                public bool CheckAccount(uint reborn, uint level)
                {
                    byte r_reborn = (byte)(ReqLev / 1000);
                    byte r_level = (byte)(ReqLev % 1000);
                    return reborn >= r_reborn && level >= r_level;
                }
            }
        }
        public static bool GetDBInfo(uint ID, out Stage stage, out Stage.NeiGong gong)
        {
            foreach (var m_stage in Stages)
            {
                foreach (var m_gong in m_stage.NeiGongAtributes)
                {
                    if (m_gong.ID == ID)
                    {
                        stage = m_stage;
                        gong = m_gong;
                        return true;
                    }
                }
            }
            stage = null;
            gong = null;
            return false;
        }
        public static void LoadDBInformation()
        {
            IniFile Reader = new IniFile("database\\NeiGongInfo.ini");
            Count = Reader.ReadUInt32("NeiGong", "Num");
            Stages = new Stage[Count];
            for (int x = 1; x <= Count; x++)
            {
                Stage stage = new Stage();
                stage.ID = Reader.ReadUInt16(x.ToString(), "id");
                stage.Name = Reader.ReadString(x.ToString(), "Name");
                stage.NeiGongNum = Reader.ReadByte(x.ToString(), "NeiGongNum", 0);
                string aAttriType = Reader.ReadString(x.ToString(), "AttriType");
                string[] atr_t = aAttriType.Split('-');
                stage.SpecialAtributesType = new AtributeType[stage.NeiGongNum];
                for (int y = 0; y < atr_t.Length; y++)
                    stage.SpecialAtributesType[y] = (AtributeType)byte.Parse(atr_t[y]);
                string atributesvalue = Reader.ReadString(x.ToString(), "AttriValue");
                stage.AtributesValues = new uint[stage.NeiGongNum];
                string[] a_atrs = atributesvalue.Split('-');
                for (int y = 0; y < a_atrs.Length; y++)
                    stage.AtributesValues[y] = uint.Parse(a_atrs[y]);
                stage.NeiGongAtributes = new Stage.NeiGong[stage.NeiGongNum];
                for (int i = 1; i <= stage.NeiGongNum; i++)
                {
                    string key = x.ToString() + "-" + i.ToString();
                    Stage.NeiGong gong = new Stage.NeiGong();
                    gong.ID = Reader.ReadByte(key, "Type", 0);
                    gong.MaxLevel = Reader.ReadByte(key, "MaxLev", 0);
                    string g_atributetype = Reader.ReadString(key, "AttriType");
                    string[] gg_atributes = g_atributetype.Split('-');
                    gong.AtributesType = new AtributeType[gg_atributes.Length];
                    for (int y = 0; y < gg_atributes.Length; y++)
                        gong.AtributesType[y] = (AtributeType)byte.Parse(gg_atributes[y]);
                    string AttriValue = Reader.ReadString(key, "AttriValue");
                    string[] g_AttriValue = AttriValue.Split('-');
                    gong.AtributesValues = new uint[g_AttriValue.Length];
                    for (int y = 0; y < g_AttriValue.Length; y++)
                        gong.AtributesValues[y] = uint.Parse(g_AttriValue[y]);
                    string NeiGongValue = Reader.ReadString(key, "NeiGongValue");
                    string[] g_NeiGongValue = NeiGongValue.Split('-');
                    gong.ProgressNeiGongValue = new uint[g_NeiGongValue.Length];
                    for (int y = 0; y < g_NeiGongValue.Length; y++)
                        gong.ProgressNeiGongValue[y] = uint.Parse(g_NeiGongValue[y]);
                    gong.ReqLev = Reader.ReadUInt32(key, "ReqLev");
                    gong.ItemID = Reader.ReadUInt32(key, "ReqItemType");
                    stage.NeiGongAtributes[i - 1] = gong;
                }
                Stages[x - 1] = stage;
            }
        }
        public static void Save()
        {
            if (File.Exists(@"database\InnerPower.txt")) File.Delete(@"database\InnerPower.txt");
            using (var _wr = new StreamWriter(File.Create(@"database\InnerPower.txt")))
            {
                var dictionary = InnerPower.InnerPowerPolle.Values;
                _wr.WriteLine(dictionary.Count());
                foreach (var inner in dictionary)
                    _wr.WriteLine(inner.ToString());
            }
        }
        public static void Load()
        {
            if (!File.Exists(@"database\InnerPower.txt")) return;
            using (StreamReader r = new StreamReader(@"database\InnerPower.txt"))
            {
                {
                    int count = int.Parse(r.ReadLine());
                    for (uint x = 0; x < count; x++)
                    {
                        var line = r.ReadLine().Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                        var index = 0;
                        var item = new InnerPower(line[index++], uint.Parse(line[index++]));
                        item.Potency = int.Parse(line[index++]);
                        int Stages = int.Parse(line[index++]);
                        for (int i = 0; i < Stages; i++)
                        {
                            var Stage = item.Stages[i];
                            Stage.ID = ushort.Parse(line[index++]);
                            Stage.UnLocked = byte.Parse(line[index++]) == 1;
                            int count_neigongs = int.Parse(line[index++]);
                            for (int y = 0; y < count_neigongs; y++)
                            {
                                var neigon = Stage.NeiGongs[y];
                                neigon.ID = byte.Parse(line[index++]);
                                neigon.Score = byte.Parse(line[index++]);
                                neigon.Unlocked = byte.Parse(line[index++]) == 1;
                                neigon.level = byte.Parse(line[index++]);
                                neigon.Complete = byte.Parse(line[index++]) == 1;
                            }
                        }
                        InnerPower.InnerPowerPolle.TryAdd(item.UID, item);
                        InnerPower.InnerPowerRank.UpdateRank(item);
                    }
                }
            }
            Console.WriteLine("Inner Power players info loaded");
        }
        public static void New(Client.GameClient client)
        {
            if (client.Entity.InnerPower == null)
                return;
            using (var cmd = new MySqlCommand(MySqlCommandType.SELECT))
            {
                cmd.Select("Inner").Where("UID", client.Entity.UID);
                using (MySqlReader rdr = new MySqlReader(cmd))
                {
                    if (!rdr.Read())
                    {
                        using (var command = new MySqlCommand(MySqlCommandType.INSERT))
                        {
                            command.Insert("Inner").Insert("UID", client.Entity.UID).Insert("Name", client.Entity.InnerPower.Name);
                            command.Execute();
                        }
                    }
                }
            }
        }

    }
}
Procure por public static class InnerPowerRank
e encontrar public InnerPower(string _Name, uint _uid)
e substitua por
Código:
public InnerPower(string _Name, uint _uid)
        {
            Name = _Name;
            UID = _uid;

            for (int x = 0; x < Database.InnerPowerTable.Count; x++)
            {
                var DBStage = Database.InnerPowerTable.Stages[x];
                Stage stage = new Stage();
                stage.ID = DBStage.ID;

                stage.NeiGongs = new Stage.NeiGong[DBStage.NeiGongNum];
                for (int y = 0; y < DBStage.NeiGongNum; y++)
                {
                    stage.NeiGongs[y] = new Stage.NeiGong();
                    stage.NeiGongs[y].ID = DBStage.NeiGongAtributes[y].ID;
                }
                Stages[x] = stage;
            }
            InnerPowerPolle.TryAdd(_uid, this);
        }
        public void UpdateStatus()
        {
            if (Kernel.GamePool.ContainsKey(UID))
            {
                var _WodClient = Kernel.GamePool[UID];
                if (_WodClient != null && _WodClient.Entity != null && _WodClient.Entity.InnerPower != null)
                {
                    _WodClient.Entity.Defence -= (ushort)Defence;
                    _WodClient.Entity.CriticalStrike -= (int)CriticalStrike;
                    _WodClient.Entity.SkillCStrike -= (int)SkillCriticalStrike;
                    _WodClient.Entity.Immunity += (int)Immunity;
                    _WodClient.Entity.Breaktrough -= (ushort)Breakthrough;
                    _WodClient.Entity.Counteraction -= (ushort)Counteraction;
                    _WodClient.Entity.MaxHitpoints += MaxLife;
                    _WodClient.Entity.MinAttack -= AddAttack;
                    _WodClient.Entity.MaxAttack -= AddAttack;
                    _WodClient.Entity.MagicAttack -= AddMagicAttack;
                    _WodClient.Entity.MagicDefence -= (ushort)AddMagicDefense;
                    _WodClient.Entity.PhysicalDamageIncrease -= (ushort)FinalAttack;
                    _WodClient.Entity.PhysicalDamageDecrease -= (ushort)FinalDefense;
                    _WodClient.Entity.MagicDamageIncrease -= (ushort)FinalMagicAttack;
                    _WodClient.Entity.MagicDamageDecrease -= (ushort)FinalMagicDefense;
                }
            }
            Defence = 0;
            CriticalStrike = 0;
            SkillCriticalStrike = 0;
            Immunity = 0;
            Breakthrough = 0;
            Counteraction = 0;
            MaxLife = 0;
            AddAttack = 0;
            AddMagicAttack = 0;
            AddMagicDefense = 0;
            FinalAttack = 0;
            FinalDefense = 0;
            FinalMagicAttack = 0;
            FinalMagicDefense = 0;
            foreach (var stage in Stages)
            {
                if (!stage.UnLocked)
                    break;
                var DBStage = Database.InnerPowerTable.Stages[stage.ID - 1];
                for (int x = 0; x < stage.NeiGongs.Length; x++)
                {
                    var neigong = stage.NeiGongs[x];
                    if (!neigong.Unlocked || neigong.level == 0)
                        break;
                    var DBNeiGong = DBStage.NeiGongAtributes[x];
                    for (int i = 0; i < DBNeiGong.AtributesType.Length; i++)
                    {
                        var AtributType = DBNeiGong.AtributesType[i];
                        var AtributValue = DBNeiGong.AtributesValues[i];

                        AddAtributes(AtributType, (uint)((AtributValue / DBNeiGong.MaxLevel) * neigong.level));
                    }
                }
                if (stage.Complete)
                {
                    for (int y = 0; y < DBStage.SpecialAtributesType.Length; y++)
                    {
                        var SpecialAtributType = DBStage.SpecialAtributesType[y];
                        var SpecialAtributValue = DBStage.AtributesValues[y];
                        AddAtributes(SpecialAtributType, SpecialAtributValue);
                    }
                }
            }
            if (Kernel.GamePool.ContainsKey(UID))
            {
                var _WodClient = Kernel.GamePool[UID];
                if (_WodClient != null && _WodClient.Entity != null && _WodClient.Entity.InnerPower != null)
                {
                    _WodClient.Entity.Defence += (ushort)Defence;
                    _WodClient.Entity.CriticalStrike += (int)CriticalStrike;
                    _WodClient.Entity.SkillCStrike += (int)SkillCriticalStrike;
                    _WodClient.Entity.Immunity += (int)Immunity;
                    _WodClient.Entity.Breaktrough += (ushort)Breakthrough;
                    _WodClient.Entity.Counteraction += (ushort)Counteraction;
                    _WodClient.Entity.MaxHitpoints += MaxLife;
                    _WodClient.Entity.MinAttack += AddAttack;
                    _WodClient.Entity.MaxAttack += AddAttack;
                    _WodClient.Entity.MagicAttack += AddMagicAttack;
                    _WodClient.Entity.MagicDefence += (ushort)AddMagicDefense;
                    _WodClient.Entity.PhysicalDamageIncrease += (ushort)FinalAttack;
                    _WodClient.Entity.PhysicalDamageDecrease += (ushort)FinalDefense;
                    _WodClient.Entity.MagicDamageIncrease += (ushort)FinalMagicAttack;
                    _WodClient.Entity.MagicDamageDecrease += (ushort)FinalMagicDefense;
                }
            }
        }
em class Program
coloque em static bool OnclosingEvent:
Código:
static bool OnclosingEvent(int Type)
        {
            foreach (Client.GameClient client in GamePool)
            {
                Database.StatueTable.Save();
                Database.Flowers.SaveFlowers();
                Database.JiangHu.SaveJiangHu();
                AuctionBase.Save();
                Database.MailboxTable.Save(client);
                Database.DailyQuestTable.Save(client);
                Database.ActivenessTable.Save(client);
                Database.SkillTable.SaveSpells(client);
                Database.EntityTable.SaveEntity(client);
                Database.SkillTable.SaveProficiencies(client);
                Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, client.CP);
                InnerPowerTable.Save();
                Database.TeamArenaTable.SaveArenaStatistics(client.TeamArenaStatistic);
            }
            return true;
        }
na mesma program.cs adicione
Código:
public static void Save()
        {
            try
            {
                using (var conn = Database.DataHolder.MySqlConnection)
                {
                    conn.Open();
                    foreach (Client.GameClient client in Kernel.GamePool.Values)
                    {
                        client.Quests.Save();
                        client.Account.Save(client);
                        Database.JiangHu.SaveJiangHu();
                        Database.EntityTable.SaveEntity(client, conn);
                        Database.DailyQuestTable.Save(client);
                        Database.SkillTable.SaveProficiencies(client, conn);
                        Database.ActivenessTable.Save(client);
                        Database.ChiTable.Save(client);
                        Database.SkillTable.SaveSpells(client, conn);
                        Database.MailboxTable.Save(client);
                        Database.StatueTable.Save();
                        Database.InnerPowerTable.Save();
                        Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, client.CP, conn);
                        Database.TeamArenaTable.SaveArenaStatistics(client.TeamArenaStatistic, conn);
                        Database.KingdomMissionTable.Save(client, conn);
                    }
                }
                AuctionBase.Save();
                Database.EntityVariableTable.Save(0, Vars);
                new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration").Set("ServerKingdom", Kernel.ServerKingdom).Where("Server", Constants.ServerName).Execute();
                new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("UnionID", TroZenA.Network.GamePackets.Union.Union.UnionCounter.Now).Execute();
                using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
                {
                    cmd.Select("configuration");
                    using (MySqlReader r = new MySqlReader(cmd))
                    {
                        if (r.Read())
                        {
                            new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ServerKingdom", Kernel.ServerKingdom).Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now).Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now).Set("UnionID", Union.UnionCounter.Now).Execute();
                            if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) MsgSignIn.Reset();
                        }
                    }
                }
                using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration"))
                    cmd.Set("LastDailySignReset", DateTime.Now.Month).Execute();
                Console.WriteLine("Save is Done");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        } 
Para ver links você precisa está logado
Adicione em database na source : Download

FelipeXP
Membro
Membro

Mensagens : 320
Data de inscrição : 28/05/2014

https://www.youtube.com/channel/UCOmLJd3M1OSrMmlcR7UGlhw

Ir para o topo Ir para baixo

Ir para o topo


 
Permissões neste sub-fórum
Não podes responder a tópicos