CalculateMP() публичный статический Метод

public static CalculateMP ( int Index_ ) : void
Index_ int
Результат void
Пример #1
0
        public static void GetXP(int Index_, ulong exp, ulong sp)
        {
            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_EXP);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendLword(exp);
            writer.AppendLword(sp);
            writer.AppendByte(0);
            if (CheckIfNewLevel(Index_, exp))
            {
                writer.AppendWord(Player.Stats[Index_].Attributes);
                ServerSocket.Send(writer.getWorkspace(), Index_);

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ANIMATION_LEVEL_UP);
                writer.AppendDword(Player.General[Index_].UniqueID);
                ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                Formula.CalculateHP(Index_);
                Formula.CalculateMP(Index_);
                STRUpdate(Index_);
                INTUpdate(Index_);
            }
            else
            {
                ServerSocket.Send(writer.getWorkspace(), Index_);
            }

            CheckIfNewSp(Index_, sp);

            HPUpdate(Index_, false);
            MPUpdate(Index_, false);
            OnStatPacket(Index_);
            DatabaseCore.WriteQuery("UPDATE characters SET experience='{0}',level = '{1}',sp = '{2}',skillpointbar = '{3}' WHERE name='{4}'", Player.Stats[Index_].Experience, Player.Stats[Index_].Level, Player.Stats[Index_].Skillpoints, Player.Stats[Index_].SkillpointBar, Player.General[Index_].CharacterName);
        }
Пример #2
0
        public static void INTUpdate(int Index_)
        {
            Player.Stats[Index_].Attributes--;
            Player.Stats[Index_].Intelligence++;
            OnStatPacket(Index_);

            Formula.CalculateMP(Index_);
            MPUpdate(Index_, false);

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_INT_UPDATE);
            writer.AppendByte(0x01);
            ServerSocket.Send(writer.getWorkspace(), Index_);
        }
Пример #3
0
        public static void GetXP(int Index_, int ObjectIndex)
        {
            int xprate = 2, sprate = 2, goldrate = 2;

            Silkroad.Gold_ tmpGold = Silkroad.GetGoldDataByLevel(Monsters.General[ObjectIndex].Level);
            ulong          sp      = (ulong)random.Next(tmpGold.Skillpoints, tmpGold.Skillpoints + 25);
            ulong          exp     = Monsters.General[ObjectIndex].Exp;

            if (Player.Stats[Index_].Level < Monsters.General[ObjectIndex].Level)
            {
                exp = ((ulong)(Monsters.General[ObjectIndex].Level - Player.Stats[Index_].Level) * Monsters.General[ObjectIndex].Exp) * (ulong)xprate;
            }
            if (Player.Stats[Index_].Level > Monsters.General[ObjectIndex].Level)
            {
                exp = ((ulong)(Player.Stats[Index_].Level - Monsters.General[ObjectIndex].Level) / Monsters.General[ObjectIndex].Exp) * (ulong)xprate;
                if (exp == 0)
                {
                    exp = 1;
                }
            }
            if (Player.Stats[Index_].Level == Monsters.General[ObjectIndex].Level)
            {
                exp = (Monsters.General[ObjectIndex].Exp * (ulong)xprate);
            }

            sp *= (ulong)sprate;

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_EXP);
            writer.AppendDword(Monsters.General[ObjectIndex].UniqueID);
            writer.AppendLword(exp);
            writer.AppendLword(sp);
            writer.AppendByte(0);
            if (CheckIfNewLevel(Index_, exp))
            {
                writer.AppendWord(Player.Stats[Index_].Attributes);
                ServerSocket.Send(writer.getWorkspace(), Index_);

                writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ANIMATION_LEVEL_UP);
                writer.AppendDword(Player.General[Index_].UniqueID);

                ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_);

                Formula.CalculateHP(Index_);
                Formula.CalculateMP(Index_);
                STRUpdate(Index_);
                INTUpdate(Index_);
            }
            else
            {
                ServerSocket.Send(writer.getWorkspace(), Index_);
            }

            CheckIfNewSp(Index_, sp);

            HPUpdate(Index_, false);
            MPUpdate(Index_, false);
            OnStatPacket(Index_);

            DatabaseCore.WriteQuery("UPDATE characters SET experience='{0}',level = '{1}',sp = '{2}',skillpointbar = '{3}' WHERE name='{4}'", Player.Stats[Index_].Experience, Player.Stats[Index_].Level, Player.Stats[Index_].Skillpoints, Player.Stats[Index_].SkillpointBar, Player.General[Index_].CharacterName);
            uint goldamount = (uint)(tmpGold.Gold * goldrate);

            int ItemIndex = Item.ItemAmount;

            if (goldamount < 10000)
            {
                Item.General[ItemIndex].Pk2ID = 1;
            }
            else if (goldamount >= 10000 && goldamount <= 500000)
            {
                Item.General[ItemIndex].Pk2ID = 2;
            }
            else if (goldamount >= 500001)
            {
                Item.General[ItemIndex].Pk2ID = 3;
            }

            Item.General[ItemIndex].UniqueID   = (uint)random.Next(76000000, 79999999);
            Item.General[ItemIndex].Plus       = 0;
            Item.General[ItemIndex].Durability = 0;
            Item.General[ItemIndex].Pickable   = true;
            Item.General[ItemIndex].Quantity   = goldamount;
            Item.Position[ItemIndex].XSector   = Monsters.Position[ObjectIndex].XSector;
            Item.Position[ItemIndex].YSector   = Monsters.Position[ObjectIndex].YSector;
            byte randomplace = (byte)random.Next(1, 7);

            Item.Position[ItemIndex].X = Monsters.Position[ObjectIndex].X + randomplace;
            Item.Position[ItemIndex].Z = Monsters.Position[ObjectIndex].Z;
            Item.Position[ItemIndex].Y = Monsters.Position[ObjectIndex].Y + randomplace;
            Item.General[ItemIndex].DroppedByUniqueId = Monsters.General[ObjectIndex].UniqueID;
            Item.ItemAmount++;

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SPAWN);
            if (goldamount < 10000)
            {
                writer.AppendDword(1);
            }
            else if (goldamount >= 10000 && goldamount <= 500000)
            {
                writer.AppendDword(2);
            }
            else if (goldamount >= 500001)
            {
                writer.AppendDword(3);
            }
            writer.AppendDword(goldamount);
            writer.AppendDword(Item.General[ItemIndex].UniqueID);
            writer.AppendByte(Item.Position[ItemIndex].XSector);
            writer.AppendByte(Item.Position[ItemIndex].YSector);
            writer.AppendFloat(Item.Position[ItemIndex].X);
            writer.AppendFloat(Item.Position[ItemIndex].X);
            writer.AppendFloat(Item.Position[ItemIndex].Y);
            writer.AppendWord(0xDC72);
            writer.AppendByte(0);
            writer.AppendByte(0);
            writer.AppendByte(5);
            writer.AppendDword(0);
            byte[] tmpBuffer = writer.getWorkspace();

            for (int i = 0; i < Player.PlayersOnline; i++)
            {
                if (Player.General[i].CharacterID != 0)
                {
                    if (Formula.CalculateDistance(Item.Position[ItemIndex], Player.Position[i]) <= 800)
                    {
                        ServerSocket.Send(tmpBuffer, i);
                        Player.Objects[i].SpawnedItemsIndex.Add(ItemIndex);
                    }
                }
            }
        }