|
أفضل جواب - كتبه Tefa |
جرب ف Perfection.cs ضيف كود:
ف player.cs ضيف كود:
ف thread سرش كود:
بدل تلاته الي تحت بعض ب دي كود:
سيرش كود:
و حط مكنها كود:
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProtoBuf;
using System.IO;
using Rayzo.Database;
using Rayzo.Network;
using Rayzo.Game;
namespace Rayzo.Game
{
public unsafe class MsgRankMemberShow : Writer
{
public MsgRankMemberShow() { }
public MsgRankMemberShowProto Info;
[ProtoContract]
public class MsgRankMemberShowProto
{
[ProtoMember(1, IsRequired = true)]
public uint ActionId;
[ProtoMember(2, IsRequired = true)]
public MsgRankMemberShowProtoSer proto;
}
[ProtoContract]
public class MsgRankMemberShowProtoSer
{
[ProtoMember(1, IsRequired = true)]
public uint dwParam;
[ProtoMember(2, IsRequired = true)]
public uint Count;
[ProtoMember(3, IsRequired = true)]
public uint UID;
[ProtoMember(4, IsRequired = true)]
public string Name = "";
[ProtoMember(5, IsRequired = true)]
public string Guild = "";
[ProtoMember(6, IsRequired = true)]
public uint Mesh;
[ProtoMember(7, IsRequired = true)]
public uint HairStyle;
[ProtoMember(8, IsRequired = true)]
public uint Hat;
[ProtoMember(9, IsRequired = true)]
public uint Garment;
[ProtoMember(10, IsRequired = true)]
public uint LeftWep;
[ProtoMember(11, IsRequired = true)]
public uint LeftWepAcc;
[ProtoMember(12, IsRequired = true)]
public uint RightWep;
[ProtoMember(13, IsRequired = true)]
public uint RightWepAcc;
[ProtoMember(14, IsRequired = true)]
public uint MountArmor;
[ProtoMember(15, IsRequired = true)]
public uint Flag;
[ProtoMember(16, IsRequired = true)]
public uint Wing;
[ProtoMember(17, IsRequired = true)]
public uint WingLevel;
[ProtoMember(18, IsRequired = true)]
public uint Title;
[ProtoMember(19, IsRequired = true)]
public uint Flag2;
[ProtoMember(20, IsRequired = true)]
public uint Flag3;
[ProtoMember(21, IsRequired = true)]
public uint Flag4;
}
public void UpdateBestPlayer()
{
Stuff = new Dictionary<string, uint>();
BestPlayer = Rayzo.Network.GamePackets.MsgUserAbilityScore.RankingList.OrderByDescending(i => i.Prestige).ThenByDescending(i => i.Level).ThenBy(i => i.UID).FirstOrDefault();
if (BestPlayer == null) return;
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("EntityID", BestPlayer.UID).And("Position", 0, true))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
if (reader.ReadByte("Position") == 5) Stuff.Add(GetPositionName(5), reader.ReadUInt32("ID"));
if (reader.ReadByte("Position") == 9) if (!Stuff.ContainsKey(GetPositionName(9))) Stuff.Add(GetPositionName(9), reader.ReadUInt32("ID"));
if (reader.ReadByte("Position") == 4) Stuff.Add(GetPositionName(4), reader.ReadUInt32("ID"));
if (reader.ReadByte("Position") == 19)
{
Stuff.Add(GetPositionName(19), reader.ReadUInt32("ID"));
Stuff.Add(GetPositionName(255), reader.ReadByte("Plus"));
}
}
if (!Stuff.Keys.Contains("MountArmor"))
{
using (var cmd2 = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("EntityID", BestPlayer.UID).And("Position", 0, true))
using (var reader2 = new MySqlReader(cmd2))
{
while (reader2.Read())
{
}
}
}
}
}
public static string GetPositionName(byte Position)
{
if (Position == 1) return "Hat";
if (Position == 3) return "Armor";
if (Position == 5) return "LeftWep";
if (Position == 9) return "Garment";
if (Position == 16) return "LeftWepAcc";
if (Position == 17) return "MountArmor";
if (Position == 4) return "RightWep";
if (Position == 15) return "RightWepAcc";
if (Position == 19) return "Wing";
if (Position == 255) return "WingLevel";
return "Unknwon";
}
public static Dictionary<string, uint> Stuff = new Dictionary<string, uint>();
public static Entity BestPlayer;
public void Handle(Client.GameState client)
{
if (BestPlayer == null) return;
switch (Info.ActionId)
{
case 0:
{
var proto2 = new MsgRankMemberShowProto();
proto2.ActionId = 0;
proto2.proto = new MsgRankMemberShowProtoSer();
proto2.proto.dwParam = 1;
proto2.proto.Count = 1;
proto2.proto.UID = BestPlayer.UID;
proto2.proto.Mesh = BestPlayer.Mesh;
proto2.proto.Name = BestPlayer.Name;
if (BestPlayer.GuildID != 0)
proto2.proto.Guild = Kernel.Guilds[BestPlayer.GuildID].Name;
proto2.proto.Hat = Stuff.Where(i => i.Key == "Hat").FirstOrDefault().Value;
proto2.proto.LeftWep = Stuff.Where(i => i.Key == "LeftWep").FirstOrDefault().Value;
proto2.proto.LeftWepAcc = Stuff.Where(i => i.Key == "LeftWepAcc").FirstOrDefault().Value;
proto2.proto.MountArmor = Stuff.Where(i => i.Key == "MountArmor").FirstOrDefault().Value;
proto2.proto.Garment = Stuff.Where(i => i.Key == "Garment").FirstOrDefault().Value;
proto2.proto.RightWep = Stuff.Where(i => i.Key == "RightWep").FirstOrDefault().Value;
proto2.proto.RightWepAcc = Stuff.Where(i => i.Key == "RightWepAcc").FirstOrDefault().Value;
proto2.proto.WingLevel = Stuff.Where(i => i.Key == "WingLevel").FirstOrDefault().Value;
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("entities").Where("UID", BestPlayer.UID))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
proto2.proto.HairStyle = reader.ReadUInt32("HairStyle");
proto2.proto.Wing = reader.ReadUInt32("WingID");
proto2.proto.Title = reader.ReadUInt32("TitleID");
}
}
client.Send(Kernel.FinalizeProtoBuf(proto2, 3257));
break;
}
case 1:
{
if (Kernel.GamePool.ContainsKey(Info.proto == null ? 0 : Info.proto.dwParam))
{
PacketHandler.ObserveEquipment(new MsgActionProto() { ID = 117, UID = client.Entity.UID, dwParam = Info.proto == null ? 0 : Info.proto.dwParam }, client);
}
else
{
client.Send(Kernel.FinalizeProtoBuf(Info, 3257));
}
break;
}
}
}
public bool Read(byte[] packet)
{
var mypkt = new byte[packet.Length - 4];
Array.Copy(packet, 4, mypkt, 0, mypkt.Length);
try
{
using (var memoryStream = new MemoryStream(packet))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgRankMemberShowProto>(memoryStream, PrefixStyle.Fixed32);
}
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
return true;
}
}
}
private void ServerFunctions(int time)
#region Perfection
#region Perfection
if (DateTime.Now >= LastPerfectionSort.AddSeconds(50))
{
LastPerfectionSort = DateTime.Now;
new MsgUserAbilityScore().GetRankingList();
new MsgEquipRefineRank().UpdateRanking();
new MsgRankMemberShow().UpdateBestPlayer();
}
#endregion
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.ReadLine();
return;
}
{
new MsgUserAbilityScore().GetRankingList();
new MsgEquipRefineRank().UpdateRanking();
new MsgRankMemberShow().UpdateBestPlayer();
using ProtoBuf;
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Collections.Concurrent;
using System.Text;
using Rayzo;
using Rayzo.Database;
using System.Threading.Tasks;
namespace Rayzo.Network.GamePackets
{
public class MsgUserAbilityScore
{
public MsgUserAbilityScore() { }
public MsgUserAbilityScoreProto Info;
[ProtoContract]
public class MsgUserAbilityScoreProto
{
[ProtoMember(1, IsRequired = true)]
public uint ActionId;
[ProtoMember(2, IsRequired = true)]
public uint UID;
[ProtoMember(3, IsRequired = true)]
public uint Level;
[ProtoMember(4, IsRequired = true)]
public Scores[] Scores;
}
[ProtoContract]
public class Scores
{
[ProtoMember(1, IsRequired = true)]
public uint Type;
[ProtoMember(2, IsRequired = true)]
public uint Score;
}
public static List<Game.Entity> RankingList;
public void GetRankingList()
{
RankingList = new List<Game.Entity>();
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("entities"))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
if (reader.ReadUInt32("TotalPerfectionScore") < 20000) continue;
Game.Entity client = new Game.Entity(Game.EntityFlag.Entity, false);
client.Name = reader.ReadString("Name");
client.UID = reader.ReadUInt32("UID");
client.Level = reader.ReadByte("Level");
client.Class = reader.ReadByte("Class");
client.Body = reader.ReadUInt16("Body");
client.Face = reader.ReadUInt16("Face");
client.Prestige = reader.ReadUInt32("TotalPerfectionScore");
if (reader.ReadString("Wardrobe") != "")
{
if (reader.ReadString("Wardrobe").Contains("~"))
{
var wing = reader.ReadString("Wardrobe").Split('~')[0];
int type = Convert.ToInt32(wing.Split('-')[0]);
int id = Convert.ToInt32(wing.Split('-')[1]);
client.EquippedWing = StorageManager.Wing<int>(type, id);
var title = reader.ReadString("Wardrobe").Split('~')[1];
int type2 = Convert.ToInt32(title.Split('-')[0]);
int id2 = Convert.ToInt32(title.Split('-')[1]);
client.EquippedTitle = StorageManager.Title<int>(type2, id2);
}
}
RankingList.Add(Kernel.GamePool.ContainsKey(client.UID) ? Kernel.GamePool[client.UID].Entity : client);
}
}
}
public bool Read(byte[] packet)
{
try
{
var mypkt = new byte[packet.Length - 4];
Array.Copy(packet, 4, mypkt, 0, mypkt.Length);
using (var memoryStream = new MemoryStream(packet))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgUserAbilityScoreProto>(memoryStream, PrefixStyle.Fixed32);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return true;
}
public void SendScore(Client.GameState client, Client.GameState Observer)
{
var packet = new MsgUserAbilityScoreProto();
packet.ActionId = 0;
packet.UID = client.Entity.UID;
packet.Level = client.Entity.Level;
packet.Scores = new Scores[20];
for (int i = 0; i < packet.Scores.Length; i++)
{
byte Type = (byte)(i + 1);
packet.Scores[i] = new Scores();
packet.Scores[i].Type = Type;
packet.Scores[i].Score = GetScoreValue(client, Type);
}
var proto = Kernel.FinalizeProtoBuf(packet, 3253);
Observer.Send(proto);
}
public uint GetScoreValue(Client.GameState client, uint Type)
{
uint Score = 0;
if (Type == 1) Score = (uint)MsgUserAbilityScore.CalculatePerfectionJiangPoints(client);
if (Type == 2) Score = (uint)MsgUserAbilityScore.CalculatePerfectionChiPoints(client);
if (Type == 3) Score = (uint)(client.Entity.InnerPower != null ? client.Entity.InnerPower.TotalScore * 2 : 0);
if (Type == 4) Score = client.Equipment.GetFullEquipmentEnchantPoints;
if (Type == 5) Score = (uint)(client.Entity.Level < 140 ? client.Entity.Level * 20 : client.Entity.Level * 25);
if (Type == 6) Score = client.Equipment.GetFullEquipmentPerfecetionLevelPoints;
if (Type == 7) Score = (uint)((client.Entity.Vitality + client.Entity.Atributes + client.Entity.Spirit + client.Entity.Strength + client.Entity.Agility) * 5);
if (Type == 8) Score = (uint)(client.Entity.Reborn * 1000);
if (Type == 9) Score = client.Equipment.GetFullEquipmentEnumPoints;
if (Type == 10) Score = client.Equipment.GetFullEquipmentSocketPoints;
if (Type == 11) Score = client.Equipment.GetFullEquipmentGemPoints;
if (Type == 12) Score = client.Equipment.GetFullEquipmentRefinePoints;
if (Type == 13) Score = client.Equipment.GetFullEquipmentPlusPoints;
if (Type == 14) Score = client.Equipment.GetFullEquipmentSoulPoints;
if (Type == 15) Score = client.Equipment.GetFullEquipmentBlessPoints;
if (Type == 16) Score = CalculateSubClassPoints(client);
if (Type == 17) Score = Database.storageItem.PerfectionPoints(client, true);
if (Type == 18) Score = Database.storageItem.PerfectionPoints(client, false);
if (Type == 19) Score = (uint)((uint)client.Entity.NobilityRank * 1000);
if (Type == 20) Score = client.Equipment.GetFullEquipmentLevelPoints;
return Score;
}
public void Handle(Client.GameState client)
{
switch (Info.ActionId)
{
case 1://Observ
{
if (Kernel.GamePool.ContainsKey(Info.UID))
{
SendScore(client, client);
SendScore(Kernel.GamePool[Info.UID], client);
}
else
{
client.Send(Kernel.FinalizeProtoBuf(new MsgUserAbilityScoreProto()
{
ActionId = 1,
UID = 0
}, 3253));
}
break;
}
}
}
/* public static int CalculatePerfectionChiPoints(Client.GameState client)
{
int value = 0;
if (client == null || client.ChiData == null)
return 0;
for (int x = 0; x < client.ChiData.Powers.Count; x++)
{
value += client.ChiData.Powers[x].Points * 30;
if (x == 0 && client.ChiData.DragonRank < 50)
value += client.ChiData.Powers[x].Points * 10;
if (x == 1 && client.ChiData.PhoenixPoints < 50)
value += client.ChiData.Powers[x].Points * 10;
if (x == 2 && client.ChiData.TigerRank < 50)
value += client.ChiData.Powers[x].Points * 10;
if (x == 3 && client.ChiData.TurtleRank < 50)
value += client.ChiData.Powers[x].Points * 10;
}
}*/
public static int CalculatePerfectionChiPoints(Client.GameState client)
{
try
{
int Point = 0;
if (client == null || client.ChiData == null)
return 0;
var TotalPoints = client.ChiData.DragonPoints + client.ChiData.PhoenixPoints + client.ChiData.TigerPoints + client.ChiData.TurtlePoints;
for (int x = 0; x < client.ChiData.Powers.Count; x++)
{
byte Double = 25;
if (client.ChiData.Powers[x].Points >= 277)
Double = 30;
if (client.ChiData.Powers[x].Points >= 317)
Double = 35;
if (client.ChiData.Powers[x].Points >= 357)
Double = 40;
if (client.ChiData.Powers[x].Points >= 380)
Double = 45;
if (client.ChiData.Powers[x].Points >= 397)
Double = 50;
if (client.ChiData.Powers[x].Points == 400)
Double = 60;
for (int i = 0; i < 4; i++)
{
ushort Value = (ushort)(client.ChiData.Powers[x].Attributes[i].Value - (ushort)Game.Enums.ChiMinValues(client.ChiData.Powers[x].Attributes[i].Type));
int MaxValue = Game.Enums.ChiMaxValues(client.ChiData.Powers[x].Attributes[i].Type) - (ushort)Game.Enums.ChiMinValues(client.ChiData.Powers[x].Attributes[i].Type);
if (client.ChiData.Powers[x].Attributes[i].Type == 0)
continue;
Point += (int)(100 * Value / MaxValue) * Double;
//Point += Convert.ToUInt16(Points);
//Console.WriteLine(Point);
}
}
return Point;
}
catch (Exception e)
{
Console.WriteLine(e);
}
return 0;
}
public static int CalculatePerfectionJiangPoints(Client.GameState client)
{
int Points = 0;
if (client.Entity.MyJiang != null)
{
if (client.Entity.MyJiang.Inner_Strength == 0) return Points;
if (client.Entity.MyJiang.Inner_Strength <= 16200) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.3);
else if (client.Entity.MyJiang.Inner_Strength <= 40500) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.33);
else if (client.Entity.MyJiang.Inner_Strength <= 60750) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.36);
else if (client.Entity.MyJiang.Inner_Strength <= 72000) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.40);
else if (client.Entity.MyJiang.Inner_Strength <= 79200) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.45);
else if (client.Entity.MyJiang.Inner_Strength <= 80800) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.50);
else if (client.Entity.MyJiang.Inner_Strength <= 81000) Points = (int)(client.Entity.MyJiang.Inner_Strength * 0.60);
}
return Points;
}
public static uint CalculateSubClassPoints(Client.GameState client)
{
uint Points = 0;
if (client.Entity.SubClasses.Classes != null)
{
foreach (var sub in client.Entity.SubClasses.Classes.Values)
{
if (sub == null) continue;
Points += (uint)(sub.Level == 9 ? 1000 : sub.Level * 100);
}
}
return Points;
}
public static uint CalculatePerfectionItemPoints(ConquerItem item)
{
uint Points = 50;
if (item == null || !Database.ConquerItemInformation.BaseInformations.ContainsKey(item.ID)) return 50;
#region Plus
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.Plus == 1) Points += 200;
if (item.Plus == 2) Points += 600;
if (item.Plus == 3) Points += 1200;
if (item.Plus == 4) Points += 1800;
if (item.Plus == 5) Points += 2600;
if (item.Plus == 6) Points += 3500;
if (item.Plus == 7) Points += 4800;
if (item.Plus == 8) Points += 5800;
if (item.Plus == 9) Points += 6800;
if (item.Plus == 10) Points += 7800;
if (item.Plus == 11) Points += 8800;
if (item.Plus == 12) Points += 10000;
}
else
{
if (item.Plus == 1) Points += 400;
if (item.Plus == 2) Points += 1200;
if (item.Plus == 3) Points += 2400;
if (item.Plus == 4) Points += 3600;
if (item.Plus == 5) Points += 5200;
if (item.Plus == 6) Points += 7000;
if (item.Plus == 7) Points += 9600;
if (item.Plus == 8) Points += 11600;
if (item.Plus == 9) Points += 13600;
if (item.Plus == 10) Points += 15600;
if (item.Plus == 11) Points += 17600;
if (item.Plus == 12) Points += 20000;
}
#endregion
#region Quality
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.ID % 10 == 9) Points += 500;
if (item.ID % 10 == 8) Points += 300;
if (item.ID % 10 == 7) Points += 200;
if (item.ID % 10 == 6) Points += 100;
if (item.ID % 10 > 0 && item.ID % 10 < 6) Points += 50;
}
else
{
if (item.ID % 10 == 9) Points += 1000;
if (item.ID % 10 == 8) Points += 600;
if (item.ID % 10 == 7) Points += 400;
if (item.ID % 10 == 6) Points += 200;
if (item.ID % 10 > 0 && item.ID % 10 < 6) Points += 100;
}
#endregion
#region Soul
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.Purification.PurificationLevel == 1) Points += 100;
if (item.Purification.PurificationLevel == 2) Points += 300;
if (item.Purification.PurificationLevel == 3) Points += 500;
if (item.Purification.PurificationLevel == 4) Points += 800;
if (item.Purification.PurificationLevel == 5) Points += 1200;
if (item.Purification.PurificationLevel == 6) Points += 1600;
if (item.Purification.PurificationLevel == 7) Points += 2000;
}
else
{
if (item.Purification.PurificationLevel == 1) Points += 200;
if (item.Purification.PurificationLevel == 2) Points += 600;
if (item.Purification.PurificationLevel == 3) Points += 1000;
if (item.Purification.PurificationLevel == 4) Points += 1600;
if (item.Purification.PurificationLevel == 5) Points += 2400;
if (item.Purification.PurificationLevel == 6) Points += 3200;
if (item.Purification.PurificationLevel == 7) Points += 4000;
}
#endregion
#region Bless
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
Points += (uint)(item.Bless * 100);
}
else
{
Points += (uint)(item.Bless * 200);
}
#region Refine
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.ExtraEffect.EffectLevel == 1) Points += 100;
if (item.ExtraEffect.EffectLevel == 2) Points += 400;
if (item.ExtraEffect.EffectLevel == 3) Points += 800;
if (item.ExtraEffect.EffectLevel == 4) Points += 1200;
if (item.ExtraEffect.EffectLevel == 5) Points += 1600;
if (item.ExtraEffect.EffectLevel == 6) Points += 2000;
}
else
{
if (item.ExtraEffect.EffectLevel == 1) Points += 200;
if (item.ExtraEffect.EffectLevel == 2) Points += 800;
if (item.ExtraEffect.EffectLevel == 3) Points += 1600;
if (item.ExtraEffect.EffectLevel == 4) Points += 2400;
if (item.ExtraEffect.EffectLevel == 5) Points += 3200;
if (item.ExtraEffect.EffectLevel == 6) Points += 4000;
}
#endregion
#endregion
#region Level
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
var lvl = (uint)Database.ConquerItemInformation.BaseInformations[item.ID].Level;
if (lvl <= 120)
Points += lvl * 3;
else if (lvl <= 130)
Points += lvl * 5;
else if (lvl <= 140)
Points += lvl * 6;
}
else
{
var lvl = (uint)Database.ConquerItemInformation.BaseInformations[item.ID].Level;
if (lvl <= 120)
Points += lvl * 6;
else if (lvl <= 130)
Points += lvl * 10;
else if (lvl <= 140)
Points += lvl * 12;
}
#endregion
#region Gem
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.SocketOne != (Game.Enums.Gem)0)
{
if (item.SocketOne2 % 10 == 1) Points += 200;
if (item.SocketOne2 % 10 == 2) Points += 500;
if (item.SocketOne2 % 10 == 3) Points += 800;
}
if (item.SocketTwo != (Game.Enums.Gem)0)
{
if (item.SocketTwo2 % 10 == 1) Points += 200;
if (item.SocketTwo2 % 10 == 2) Points += 500;
if (item.SocketTwo2 % 10 == 3) Points += 800;
}
}
else
{
if (item.SocketOne != (Game.Enums.Gem)0)
{
if (item.SocketOne2 % 10 == 1) Points += 400;
if (item.SocketOne2 % 10 == 2) Points += 1000;
if (item.SocketOne2 % 10 == 3) Points += 1600;
}
if (item.SocketTwo != (Game.Enums.Gem)0)
{
if (item.SocketTwo2 % 10 == 1) Points += 400;
if (item.SocketTwo2 % 10 == 2) Points += 1000;
if (item.SocketTwo2 % 10 == 3) Points += 1600;
}
}
#endregion
#region Stars
if (item.Stars >= 1) Points += 180;
if (item.Stars >= 2) Points += 180;
if (item.Stars >= 3) Points += 180;
if (item.Stars >= 4) Points += 180;
if (item.Stars >= 5) Points += 180;
if (item.Stars >= 6) Points += 180;
if (item.Stars >= 7) Points += 180;
if (item.Stars >= 8) Points += 180;
if (item.Stars >= 9) Points += 180;
if (item.Stars >= 10) Points += 2380;
if (item.Stars >= 11) Points += 400;
if (item.Stars >= 12) Points += 400;
if (item.Stars >= 13) Points += 400;
if (item.Stars >= 14) Points += 400;
if (item.Stars >= 15) Points += 400;
if (item.Stars >= 16) Points += 400;
if (item.Stars >= 17) Points += 400;
if (item.Stars >= 18) Points += 400;
if (item.Stars >= 19) Points += 5150;
if (item.Stars >= 20) Points += 650;
if (item.Stars >= 21) Points += 650;
if (item.Stars >= 22) Points += 650;
if (item.Stars >= 23) Points += 650;
if (item.Stars >= 24) Points += 650;
if (item.Stars >= 25) Points += 650;
if (item.Stars >= 26) Points += 650;
if (item.Stars >= 27) Points += 650;
if (item.Stars >= 28) Points += 100;
if (item.Stars >= 29) Points += 100;
if (item.Stars >= 30) Points += 100;
if (item.Stars >= 31) Points += 100;
if (item.Stars >= 32) Points += 100;
if (item.Stars >= 33) Points += 100;
if (item.Stars >= 34) Points += 100;
if (item.Stars >= 35) Points += 100;
if (item.Stars >= 36) Points += 100;
if (item.Stars >= 37) Points += 100;
if (item.Stars >= 38) Points += 100;
if (item.Stars >= 39) Points += 100;
if (item.Stars >= 40) Points += 100;
if (item.Stars >= 41) Points += 100;
if (item.Stars >= 42) Points += 100;
if (item.Stars >= 43) Points += 100;
if (item.Stars >= 44) Points += 100;
if (item.Stars >= 45) Points += 100;
if (item.Stars >= 46) Points += 100;
if (item.Stars >= 47) Points += 100;
if (item.Stars >= 48) Points += 100;
if (item.Stars >= 49) Points += 100;
if (item.Stars >= 50) Points += 100;
if (item.Stars >= 51) Points += 100;
if (item.Stars >= 52) Points += 100;
if (item.Stars >= 53) Points += 100;
if (item.Stars >= 54) Points += 100;
if (Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.Stars >= 1) Points += 180;
if (item.Stars >= 2) Points += 180;
if (item.Stars >= 3) Points += 180;
if (item.Stars >= 4) Points += 180;
if (item.Stars >= 5) Points += 180;
if (item.Stars >= 6) Points += 180;
if (item.Stars >= 7) Points += 180;
if (item.Stars >= 8) Points += 180;
if (item.Stars >= 9) Points += 180;
if (item.Stars >= 10) Points += 2380;
if (item.Stars >= 11) Points += 400;
if (item.Stars >= 12) Points += 400;
if (item.Stars >= 13) Points += 400;
if (item.Stars >= 14) Points += 400;
if (item.Stars >= 15) Points += 400;
if (item.Stars >= 16) Points += 400;
if (item.Stars >= 17) Points += 400;
if (item.Stars >= 18) Points += 400;
if (item.Stars >= 19) Points += 5150;
if (item.Stars >= 20) Points += 650;
if (item.Stars >= 21) Points += 650;
if (item.Stars >= 22) Points += 650;
if (item.Stars >= 23) Points += 650;
if (item.Stars >= 24) Points += 650;
if (item.Stars >= 25) Points += 650;
if (item.Stars >= 26) Points += 650;
if (item.Stars >= 27) Points += 650;
if (item.Stars >= 28) Points += 100;
if (item.Stars >= 29) Points += 100;
if (item.Stars >= 30) Points += 100;
if (item.Stars >= 31) Points += 100;
if (item.Stars >= 32) Points += 100;
if (item.Stars >= 33) Points += 100;
if (item.Stars >= 34) Points += 100;
if (item.Stars >= 35) Points += 100;
if (item.Stars >= 36) Points += 100;
if (item.Stars >= 37) Points += 100;
if (item.Stars >= 38) Points += 100;
if (item.Stars >= 39) Points += 100;
if (item.Stars >= 40) Points += 100;
if (item.Stars >= 41) Points += 100;
if (item.Stars >= 42) Points += 100;
if (item.Stars >= 43) Points += 100;
if (item.Stars >= 44) Points += 100;
if (item.Stars >= 45) Points += 100;
if (item.Stars >= 46) Points += 100;
if (item.Stars >= 47) Points += 100;
if (item.Stars >= 48) Points += 100;
if (item.Stars >= 49) Points += 100;
if (item.Stars >= 50) Points += 100;
if (item.Stars >= 51) Points += 100;
if (item.Stars >= 52) Points += 100;
if (item.Stars >= 53) Points += 100;
if (item.Stars >= 54) Points += 100;
}
#endregion
#region Socket
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
if (item.SocketOne != (Game.Enums.Gem)0) Points += 1000;
if (item.SocketTwo != (Game.Enums.Gem)0) Points += 2500;
}
else
{
if (item.SocketOne != (Game.Enums.Gem)0) Points += 2000;
if (item.SocketTwo != (Game.Enums.Gem)0) Points += 5000;
}
#endregion
#region Enchant
if (!Network.PacketHandler.IsTwoHand(item.ID))
{
var enc = (uint)(item.Enchant);
if (enc != 0)
{
if (enc <= 200) Points += enc * 1;
if (enc <= 240) Points += (uint)(enc * 1.3);
if (enc <= 254) Points += (uint)(enc * 1.6);
if (enc <= 255) Points += enc * 2;
}
}
else
{
var enc = (uint)(item.Enchant);
if (enc != 0)
{
if (enc <= 200) Points += enc * 2;
if (enc <= 240) Points += (uint)(enc * 2.6);
if (enc <= 254) Points += (uint)(enc * 3.2);
if (enc <= 255) Points += enc * 4;
}
}
#endregion
return Points;
}
}
public class MsgItemRefineOpt
{
public MsgItemRefineOpt() { }
public MsgItemRefineOptProto Info;
public MsgItemRefineOptProto2 Info2;
[ProtoContract]
public class MsgItemRefineOptProto
{
[ProtoMember(1, IsRequired = true)]
public uint ActionId;
[ProtoMember(2, IsRequired = true)]
public uint ItemUID;
[ProtoMember(3, IsRequired = true)]
public string Signature;
[ProtoMember(4, IsRequired = true)]
public uint ItemPlusUID;
}
[ProtoContract]
public class MsgItemRefineOptProto2
{
[ProtoMember(1, IsRequired = true)]
public uint ItemUID;
[ProtoMember(2, IsRequired = true)]
public uint EntityUID;
[ProtoMember(3, IsRequired = true)]
public uint Stars;
[ProtoMember(4, IsRequired = true)]
public uint Progress;
[ProtoMember(5, IsRequired = true)]
public uint OwnerUID;
[ProtoMember(6, IsRequired = true)]
public string OwnerName;
}
public double GetPerfectionProgress(uint value)
{
return (value * 1.25);
}
public uint GetPerfectionProgress(ConquerItem item)
{
if (item.Stars == 0) return 30;
if (item.Stars == 1) return 60;
if (item.Stars == 2) return 100;
if (item.Stars == 3) return 200;
if (item.Stars == 4) return 350;
if (item.Stars == 5) return 600;
if (item.Stars == 6) return 1000;
if (item.Stars == 7) return 1500;
if (item.Stars == 8) return 2300;
if (item.Stars == 9) return 3500;
if (item.Stars == 10) return 5000;
if (item.Stars == 11) return 6500;
if (item.Stars == 12) return 8000;
if (item.Stars == 13) return 9500;
if (item.Stars == 14) return 11000;
return 12000;
}
public uint GetPlusStonePoints(uint value)
{
if (value == 3009000) return 10;
if (value == 3009001) return 100;
if (value == 3009002) return 1000;
if (value == 3009003) return 10000;
foreach (Rayzo.Client.GameState client in Kernel.GamePool.Values)
{
if (value == 730001 || value == 1)
return 10;
if (value == 730002 || value == 2)
return 40;
if (value == 730003 || value == 3)
return 120;
if (value == 730004 || value == 4)
return 360;
if (value == 730005 || value == 5)
return 1080;
if (value == 730006 || value == 6)
return 3240;
if (value == 730007 || value == 7)
return 9720;
if (value == 730008 || value == 8)
return 29160;
}
if (value == 9) return 87480;
if (value == 10) return 90180;
if (value == 11) return 95680;
if (value == 12) return 104680;
return 0;
}
public uint GetTransferCost(Network.GamePackets.ConquerItem item)
{
if (item.Stars == 2) return 30;
if (item.Stars == 3) return 70;
if (item.Stars == 4) return 150;
if (item.Stars == 5) return 300;
if (item.Stars == 6) return 500;
if (item.Stars == 7) return 800;
if (item.Stars == 8) return 1100;
if (item.Stars >= 9) return 1500;
return 10;
}
public void Handle(Client.GameState client, byte[] myPacket)
{
try
{
switch (Info.ActionId)
{
case 0://Temper
{
#region Minors
var packet2 = new byte[myPacket.Length - 4];
Array.Copy(myPacket, 4, packet2, 0, packet2.Length);
var variable = Kernel.Read7BitEncodedInt(packet2).SelectMany(System.BitConverter.GetBytes).ToArray();
var variable2 = new byte[variable.Length - 8];
Array.Copy(variable, 8, variable2, 0, variable.Length - 8);
var MinorsCount = (variable2.Length / 4);
uint[] Minors = new uint[MinorsCount];
byte x = 0;
for (int i = 0; i < MinorsCount; i++)
{
Minors[i] = BitConverter.ToUInt32(variable2, x);
x += 4;
}
#endregion
if (Minors != null)
{
ConquerItem Item;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item))
{
foreach (var minor in Minors)
{
ConquerItem ItemPlus;
if (client.Inventory.TryGetItem(minor, out ItemPlus))
{
if (ItemPlus.ID == 730001
|| ItemPlus.ID == 730002
|| ItemPlus.ID == 730003
|| ItemPlus.ID == 730004
|| ItemPlus.ID == 730005
|| ItemPlus.ID == 730006
|| ItemPlus.ID == 730007
|| ItemPlus.ID == 730008) { client.MessageBox("You can't temp the perfection with a Stone "); return; }
if (ItemPlus.ID == 300000) { client.MessageBox("You can't temp the perfection with a Steed "); return; }
Item.PerfectionProgress += GetPlusStonePoints(ItemPlus.ID == 300000 ? ItemPlus.Plus : ItemPlus.ID)/*Database.PerfectionTable.CostList[ItemPlus.ID].Progress*/;
client.Inventory.Remove(minor, Game.Enums.ItemUse.Remove, true);
}
}
while (Item.PerfectionProgress >= GetPerfectionProgress(Item)/*Database.PerfectionTable.UpgradeList.Where(i => i.Stars == (Item.Stars + 1)).FirstOrDefault().Progress*/)
{
Item.PerfectionProgress -= GetPerfectionProgress(Item)/*Database.PerfectionTable.UpgradeList.Where(i => i.Stars == (Item.Stars + 1)).FirstOrDefault().Progress*/;
Item.Stars++;
}
while (Item.Stars >= 54 && Item.PerfectionProgress > 0)
{
Item.Stars = 54;
Item.PerfectionProgress = 0;
}
Item.Owner = client.Entity.Name;
Item.OwnerUID = client.Entity.UID;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
client.LoadItemStats();
client.Send(proto);
Database.ConquerItemTable.UpdatePerfection(Item);
new MsgUserTotalRefineLev().Send(client);
}
}
break;
}
case 1://Transfer
{
ConquerItem Item;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item))
{
if (client.Entity.BoundCps >= 1000)
{
client.Entity.BoundCps -= 1000;
Item.Owner = client.Entity.Name;
Item.OwnerUID = client.Entity.UID;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
client.Send(proto);
Database.ConquerItemTable.UpdatePerfection(Item);
}
}
break;
}
case 2://Signature
{
ConquerItem Item;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item))
{
if (Item.Signature == String.Empty || Item.Signature == null)
{
Item.Signature = Info.Signature;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
Database.ConquerItemTable.UpdatePerfection(Item);
}
else
{
if (client.Entity.ConquerPoints >= 270)
{
client.Entity.ConquerPoints -= 270;
Item.Signature = Info.Signature;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
Database.ConquerItemTable.UpdatePerfection(Item);
}
else if (client.Entity.BoundCps >= 270)
{
client.Entity.BoundCps -= 270;
Item.Signature = Info.Signature;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
Database.ConquerItemTable.UpdatePerfection(Item);
}
}
}
break;
}
case 4://Exchange
{
ConquerItem Item;
ConquerItem Item2;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item2) || client.Inventory.TryGetItem(Info.ItemUID, out Item2))
{
if (client.Inventory.TryGetItem(Info.ItemPlusUID, out Item) || client.Equipment.TryGetItem(Info.ItemPlusUID, out Item))
{
if (PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.Inventory
|| PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.Bottle
|| PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.Garment
|| PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.SteedArmor
|| PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.RightAccessory
|| PacketHandler.GetPositionFromID(Item.ID) == PacketHandler.Positions.LeftAccessory)
break;
if (client.Entity.ConquerPoints >= 1000)
{
client.Entity.ConquerPoints -= 1000;
#region MostafaPro
//MostafaMohamed
//www.facebook.com/dayalamar
//01096308752
var item2Progress = Item2.PerfectionProgress;
var item1Progress = Item.PerfectionProgress;
var item2Stars = Item2.Stars;
var item1Stars = Item.Stars;
if (item1Stars == item2Stars)
{
if (item1Progress > item2Progress)
{
Item.PerfectionProgress = item2Progress;
Item.Stars = item2Stars;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
Item2.PerfectionProgress = item1Progress;
Item2.Stars = item1Stars;
Item2.Mode = Game.Enums.ItemMode.Update;
Item2.Send(client);
}
if (item2Progress > item1Progress)
{
Item2.PerfectionProgress = item1Progress;
Item2.Stars = item1Stars;
Item2.Mode = Game.Enums.ItemMode.Update;
Item2.Send(client);
Item.PerfectionProgress = item2Progress;
Item.Stars = item2Stars;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
}
}
else
if (item1Stars > item2Stars)
{
Item.PerfectionProgress = item2Progress;
Item.Stars = item2Stars;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
Item2.PerfectionProgress = item1Progress;
Item2.Stars = item1Stars;
Item2.Mode = Game.Enums.ItemMode.Update;
Item2.Send(client);
}
if (item2Stars > item1Stars)
{
Item2.PerfectionProgress = item1Progress;
Item2.Stars = item1Stars;
Item2.Mode = Game.Enums.ItemMode.Update;
Item2.Send(client);
Item.PerfectionProgress = item2Progress;
Item.Stars = item2Stars;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
}
#endregion
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
Database.ConquerItemTable.UpdatePerfection(Item);
Database.ConquerItemTable.UpdatePerfection(Item2);
}
}
}
break;
}
case 5://Quick
{
ConquerItem Item;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item))
{
if (Item.PerfectionProgress == 0 || Item.Stars >= 54) break;
double percent = (double)Item.PerfectionProgress / (double)GetPerfectionProgress(Item) * 0;
if (Kernel.Rate(percent))
{
Item.Stars++;
}
Item.PerfectionProgress = 0;
Item.Owner = client.Entity.Name;
Item.OwnerUID = client.Entity.UID;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
var proto = Kernel.FinalizeProtoBuf((new MsgItemRefineOptProto2()
{
ItemUID = Item.UID,
EntityUID = client.Entity.UID,
OwnerUID = Item.OwnerUID,
OwnerName = Item.Owner,
Progress = Item.PerfectionProgress,
Stars = Item.Stars
}), 3250);
Database.ConquerItemTable.UpdatePerfection(Item);
client.LoadItemStats();
}
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public byte GetStars(byte Stars)
{
if (Stars >= 0 && Stars <= 8) return 9;
if (Stars >= 9 && Stars <= 17) return 18;
if (Stars >= 18 && Stars <= 26) return 27;
if (Stars >= 27 && Stars <= 35) return 36;
if (Stars >= 36 && Stars <= 44) return 45;
if (Stars >= 45 && Stars <= 53) return 54;
return 0;
}
public byte[] GetBytes(string packetString)
{
if (packetString != "" && packetString != null && packetString != string.Empty && packetString != " ")
{
byte[] bytes = new byte[(packetString.Length / 3) + 1];
int t = 0;
for (int i = 0; i < packetString.Length; i += 3)
{
string cha = packetString.Substring(i, 2);
bytes[t] = byte.Parse(cha, System.Globalization.NumberStyles.HexNumber);
t++;
}
return bytes;
}
return null;
}
public bool Read(byte[] packet)
{
try
{
var mypkt = new byte[packet.Length - 4];
Array.Copy(packet, 4, mypkt, 0, mypkt.Length);
using (var memoryStream = new MemoryStream(packet))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgItemRefineOptProto>(memoryStream, PrefixStyle.Fixed32);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return true;
}
}
public class MsgItemRefineRecord
{
public MsgItemRefineRecord() { }
public MsgItemRefineRecordProto Info;
[ProtoContract]
public class MsgItemRefineRecordProto
{
[ProtoMember(1, IsRequired = true)]
public uint ActionId;
[ProtoMember(2, IsRequired = true)]
public uint MaxStars;
}
public void Handle(Client.GameState client)
{
switch (Info.ActionId)
{
case 0:
{
Send(client);
break;
}
}
}
public void Send(Client.GameState client)
{
client.Send(Kernel.FinalizeProtoBuf(new MsgItemRefineRecordProto()
{
ActionId = 0,
MaxStars = 54
}, 3255));
}
public bool Read(byte[] packet)
{
var mypkt = new byte[packet.Length - 4];
Array.Copy(packet, 4, mypkt, 0, mypkt.Length);
using (var memoryStream = new MemoryStream(packet))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgItemRefineRecordProto>(memoryStream, PrefixStyle.Fixed32);
}
return true;
}
}
public class MsgEquipRefineRank
{
public MsgEquipRefineRank() { }
public MsgEquipRefineRankProto Info;
[Flags]
public enum ActionID
{
MainRank = 0,
RankItems = 1,
UserItemRanking = 2,
MyRanks = 3,
View = 4,
}
[ProtoContract]
public class MsgEquipRefineRankProto
{
[ProtoMember(1, IsRequired = true)]
public ActionID Action;
[ProtoMember(2)]
public uint RegisteredCount;
[ProtoMember(3)]
public uint Page;
[ProtoMember(4, IsRequired = true)]
public uint Index;
[ProtoMember(5, IsRequired = true)]
public EquipProto[] items;
}
[ProtoContract]
public class EquipProto
{
[ProtoMember(1, IsRequired = true)]
public uint Rank;
[ProtoMember(2, IsRequired = true)]
public uint UnKnow2;
[ProtoMember(3, IsRequired = true)]
public uint Position;
[ProtoMember(4, IsRequired = true)]
public uint RankScore;
[ProtoMember(5, IsRequired = true)]
public uint UID;
[ProtoMember(6, IsRequired = true)]
public uint ItemID;
[ProtoMember(7, IsRequired = true)]
public uint PurificationID;
[ProtoMember(8, IsRequired = true)]
public uint Plus;
[ProtoMember(9, IsRequired = true)]
public uint Stars;
[ProtoMember(10, IsRequired = true)]
public string Name = "";
[ProtoMember(11, IsRequired = true)]
public uint PerfectionLevel;
}
public byte GetRealyPosition(byte FakePosition)
{
if (FakePosition == 5) return 19;
if (FakePosition == 7) return 18;
if (FakePosition == 9) return 12;
return FakePosition;
}
public static Dictionary<byte, ConquerItem> MainRank;
public void UpdateRanking()
{
AllItemsRanking = new List<ConquerItem>();
MainRank = new Dictionary<byte, ConquerItem>();
for (byte i = 0; i < 11; i++)
{
byte z = GetRealyPosition((byte)(i + 1));
List<ConquerItem> items = new List<ConquerItem>();
MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
command.Select("items").Where("Position", z).And("Stars", 0, true);
MySqlReader reader = new MySqlReader(command);
while (reader.Read())
{
ConquerItem item = new ConquerItem(true);
item.ID = reader.ReadUInt32("ID");
item.UID = reader.ReadUInt32("UID");
item.MaximDurability = reader.ReadUInt16("MaximDurability");
item.Durability = reader.ReadUInt16("Durability");
item.Position = reader.ReadUInt16("Position");
item.Signature = reader.ReadString("Signature");
item.SocketProgress = reader.ReadUInt32("SocketProgress");
item.PlusProgress = reader.ReadUInt32("PlusProgress");
item.Stars = reader.ReadByte("Stars");
item.PerfectionProgress = reader.ReadUInt32("PerfectionProgress");
item.Owner = reader.ReadString("Owner");
item.OwnerUID = reader.ReadUInt32("OwnerUID");
item.SocketOne = (Game.Enums.Gem)reader.ReadByte("SocketOne");
item.SocketTwo = (Game.Enums.Gem)reader.ReadByte("SocketTwo");
item.Effect = (Game.Enums.ItemEffect)reader.ReadByte("Effect");
item.Mode = Game.Enums.ItemMode.Default;
item.Plus = reader.ReadByte("Plus");
item.Bless = reader.ReadByte("Bless");
item.Bound = reader.ReadBoolean("Bound");
// item.TimeStamp = DateTime.FromBinary(reader.ReadInt64("TimeStamp"));
// item.Minutes = reader.ReadUInt64("MinutesLeft");
item.Enchant = reader.ReadByte("Enchant");
item.Lock = reader.ReadByte("Locked");
item.UnlockEnd = DateTime.FromBinary(reader.ReadInt64("UnlockEnd"));
item.Suspicious = reader.ReadBoolean("Suspicious");
item.SuspiciousStart = DateTime.FromBinary(reader.ReadInt64("SuspiciousStart"));
item.Color = (Game.Enums.Color)reader.ReadByte("Color");
item.Inscribed = reader.ReadByte("Inscribed") == 1;
item.StackSize = reader.ReadUInt16("StackSize");
item.Warehouse = reader.ReadByte("Warehouse");
item.RefineItem = reader.ReadUInt32("RefineryItem");
item.InWardrobe = reader.ReadBoolean("InWardrobe");
Int64 rTime = reader.ReadInt64("RefineryTime");
ItemAddingTable.GetAddingsForItem(item);
items.Add(item);
if (!AllItemsRanking.Contains(item))
AllItemsRanking.Add(item);
}
MainRank[z] = items.OrderByDescending(x => MsgUserAbilityScore.CalculatePerfectionItemPoints(x)).FirstOrDefault();
}
}
public static List<ConquerItem> AllItemsRanking;
public void Handle(Client.GameState client)
{
switch (Info.Action)
{
case ActionID.UserItemRanking:
{
var item = AllItemsRanking.Where(p => p.Position == GetRealyPosition((byte)Info.Index)).OrderByDescending(i => MsgUserAbilityScore.CalculatePerfectionItemPoints(i)).ToArray();
var min = Math.Min(item.Length, 50);
for (int i = 0; i < min; i++)
{
if (client.Equipment.IsWearingItemUID(item[i].UID))
{
var packet = new MsgEquipRefineRankProto();
packet.Page = Info.Page;
packet.RegisteredCount = Info.RegisteredCount;
packet.Action = Info.Action;
packet.Index = Info.Index;
packet.items = new EquipProto[1];
packet.items[0] = new EquipProto();
var itemm = item[i];
packet.items[0].Rank = (uint)(i + 1);
packet.items[0].RankScore = MsgUserAbilityScore.CalculatePerfectionItemPoints(itemm);
packet.items[0].ItemID = itemm.ID;
packet.items[0].Name = itemm.Owner.Replace("/0", "");
packet.items[0].Stars = itemm.Stars;
packet.items[0].Position = GetRealyPosition((byte)Info.Index);
packet.items[0].Plus = itemm.Plus;
packet.items[0].UID = itemm.UID;
packet.items[0].UnKnow2 = (uint)Kernel.Random.Next(800, 3000);
client.Send(Kernel.FinalizeProtoBuf(packet, 3256));
break;
}
}
break;
}
case ActionID.MyRanks:
{
var packet = new MsgEquipRefineRankProto();
packet.Action = ActionID.MyRanks;
packet.items = new EquipProto[11];
for (byte i = 0; i < packet.items.Length; i++)
{
byte z = GetRealyPosition((byte)(i + 1));
var itemmm = AllItemsRanking.Where(p => p.Position == z).OrderByDescending(m => MsgUserAbilityScore.CalculatePerfectionItemPoints(m)).ToArray();
for (int h = 0; h < itemmm.Length; h++)
{
if (client.Equipment.IsWearingItemUID(itemmm[h].UID))
{
packet.items[i] = new EquipProto();
packet.items[i].ItemID = itemmm[h].ID;
packet.items[i].Name = itemmm[h].Owner.Replace("/0", "");
packet.items[i].Stars = itemmm[h].Stars;
packet.items[i].Plus = itemmm[h].Plus;
packet.items[i].Position = (uint)(i + 1);
if (itemmm[h].Purification.Available)
packet.items[i].PurificationID = itemmm[h].Purification.PurificationItemID;
packet.items[i].Rank = (uint)(h + 1);
packet.items[i].RankScore = MsgUserAbilityScore.CalculatePerfectionItemPoints(itemmm[h]);
packet.items[i].UID = itemmm[h].UID;
packet.items[i].UnKnow2 = (uint)Kernel.Random.Next(800, 3000);
break;
}
}
}
var proto = Kernel.FinalizeProtoBuf(packet, 3256);
client.Send(proto);
break;
}
case ActionID.View://ViewItem
{
if (Database.ConquerItemTable.LoadItem(Info.Index) != null)
{
var item = Database.ConquerItemTable.LoadItem(Info.Index);
item.Mode = Game.Enums.ItemMode.Perfection;
item.Send(client);
}
else
{
client.Send(Kernel.FinalizeProtoBuf(Info, 3256));
}
break;
}
case ActionID.RankItems://AllRanking
{
var cnt = AllItemsRanking.Where(p => p.Position == GetRealyPosition((byte)Info.Index)).Count();
var packet = new MsgEquipRefineRankProto();
packet.Action = ActionID.RankItems;
packet.RegisteredCount = (uint)Math.Min(cnt, 50);
packet.Page = Info.Page;
packet.Index = Info.Index;
uint sss = (ushort)Math.Min(cnt - (packet.Page * 11), 11);
int rank = (int)packet.Page * 11;
packet.items = new EquipProto[sss];
for (int i = 0; i < sss; i++)
{
var iteeeem = AllItemsRanking.Where(p => p.Position == GetRealyPosition((byte)Info.Index)).OrderByDescending(x => MsgUserAbilityScore.CalculatePerfectionItemPoints(x)).ToArray()[i + rank];
packet.items[i] = new EquipProto();
packet.items[i].ItemID = iteeeem.ID;
packet.items[i].Name = iteeeem.Owner.Replace("/0", "");
packet.items[i].Stars = iteeeem.Stars;
packet.items[i].Plus = iteeeem.Plus;
packet.items[i].Position = GetRealyPosition((byte)Info.Index);
if (iteeeem.Purification.Available)
packet.items[i].PurificationID = iteeeem.Purification.PurificationItemID;
packet.items[i].Rank = (uint)(i + 1 + rank);
packet.items[i].RankScore = MsgUserAbilityScore.CalculatePerfectionItemPoints(iteeeem);
packet.items[i].UID = iteeeem.UID;
packet.items[i].UnKnow2 = (uint)Kernel.Random.Next(800, 3000);
}
var proto = Kernel.FinalizeProtoBuf(packet, 3256);
client.Send(proto);
break;
}
case ActionID.MainRank:
{
var packet = new MsgEquipRefineRankProto();
packet.Action = ActionID.MainRank;
packet.items = new EquipProto[11];
for (byte i = 0; i < packet.items.Length; i++)
{
byte z = GetRealyPosition((byte)(i + 1));
ConquerItem itemmm = MainRank[z];
if (itemmm == null) continue;
packet.items[i] = new EquipProto();
packet.items[i].ItemID = itemmm.ID;
packet.items[i].Name = itemmm.Owner.Replace("/0", "");
packet.items[i].Stars = itemmm.Stars;
packet.items[i].Plus = itemmm.Plus;
packet.items[i].Position = (uint)(i + 1);
if (itemmm.Purification.Available)
packet.items[i].PurificationID = itemmm.Purification.PurificationItemID;
packet.items[i].Rank = 1;
packet.items[i].RankScore = MsgUserAbilityScore.CalculatePerfectionItemPoints(itemmm);
packet.items[i].UID = itemmm.UID;
packet.items[i].UnKnow2 = (uint)Kernel.Random.Next(800, 3000);
}
var proto = Kernel.FinalizeProtoBuf(packet, 3256);
client.Send(proto);
break;
}
}
}
public bool Read(byte[] packet)
{
using (var memoryStream = new MemoryStream(packet))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgEquipRefineRankProto>(memoryStream, PrefixStyle.Fixed32);
}
return true;
}
}
public class MsgUserTotalRefineLev
{
public MsgUserTotalRefineLev() { }
public MsgUserTotalRefineLevProto Info;
[ProtoContract]
public class MsgUserTotalRefineLevProto
{
[ProtoMember(1, IsRequired = true)]
public uint ActionId;
[ProtoMember(2, IsRequired = true)]
public uint EntityUID;
[ProtoMember(3, IsRequired = true)]
public uint TotalPrefectionLevel;
}
public void SendPerfectionEffects(Client.GameState client)
{
if (client.Equipment.TotalStars >= 10) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 890; client.Entity.BaseMagicAttack += 890; }
if (client.Equipment.TotalStars >= 10) { client.Entity.BaseDefence += 1180; client.Entity.MagicDefence += 445; }
if (client.Equipment.TotalStars >= 20) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 20) { client.Entity.BaseDefence += 240; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 30) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 30) { client.Entity.BaseDefence += 180; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 40) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 40) { client.Entity.BaseDefence += 180; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 50) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 50) { client.Entity.BaseDefence += 240; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 60) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 60) { client.Entity.BaseDefence += 480; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 75) { client.Entity.BaseMaxAttack += 150; client.Entity.BaseMinAttack += 150; client.Entity.BaseMagicAttack += 150; }
if (client.Equipment.TotalStars >= 80) { client.Entity.BaseMaxAttack += 60; client.Entity.BaseMinAttack += 60; client.Entity.BaseMagicAttack += 60; }
if (client.Equipment.TotalStars >= 80) { client.Entity.BaseDefence += 420; client.Entity.MagicDefence += 105; }
if (client.Equipment.TotalStars >= 90) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 90) { client.Entity.BaseDefence += 180; client.Entity.MagicDefence += 135; }
if (client.Equipment.TotalStars >= 100) { client.Entity.BaseDefence += 180; client.Entity.MagicDefence += 45; }
if (client.Equipment.TotalStars >= 110) { client.Entity.BaseMaxAttack += 210; client.Entity.BaseMinAttack += 210; client.Entity.BaseMagicAttack += 210; }
if (client.Equipment.TotalStars >= 120) { client.Entity.BaseDefence += 600; client.Entity.MagicDefence += 150; }
if (client.Equipment.TotalStars >= 130) { client.Entity.BaseDefence += 180; client.Entity.MagicDefence += 60; }
if (client.Equipment.TotalStars >= 140) { client.Entity.BaseMaxAttack += 300; client.Entity.BaseMinAttack += 300; client.Entity.BaseMagicAttack += 300; }
if (client.Equipment.TotalStars >= 150) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 160) { client.Entity.BaseDefence += 780; client.Entity.MagicDefence += 210; }
if (client.Equipment.TotalStars >= 180) { client.Entity.BaseDefence += 420; client.Entity.MagicDefence += 110; }
if (client.Equipment.TotalStars >= 230) { client.Entity.BaseMaxAttack += 780; client.Entity.BaseMinAttack += 240; client.Entity.BaseMagicAttack += 240; }
if (client.Equipment.TotalStars >= 270) { client.Entity.BaseDefence += 305; client.Entity.MagicDefence += 135; }
if (client.Equipment.TotalStars >= 270) { client.Entity.BaseMaxAttack += 390; client.Entity.BaseMinAttack += 390; client.Entity.BaseMagicAttack += 390; }
if (client.Equipment.TotalStars >= 300) { client.Entity.BaseMaxAttack += 330; client.Entity.BaseMinAttack += 720; client.Entity.BaseMagicAttack += 720; }
if (client.Equipment.TotalStars >= 310) { client.Entity.BaseDefence += 305; client.Entity.MagicDefence += 135; }
if (client.Equipment.TotalStars >= 316) { client.Entity.BaseDefence += 305; client.Entity.MagicDefence += 135; }
if (client.Equipment.TotalStars >= 318) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 323) { client.Entity.BaseDefence += 305; client.Entity.MagicDefence += 135; }
if (client.Equipment.TotalStars >= 324) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 340) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 350) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 890; client.Entity.BaseMagicAttack += 890; }
if (client.Equipment.TotalStars >= 360) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 370) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 380) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 390) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
if (client.Equipment.TotalStars >= 400) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 415) { client.Entity.BaseMaxAttack += 150; client.Entity.BaseMinAttack += 150; client.Entity.BaseMagicAttack += 150; }
if (client.Equipment.TotalStars >= 420) { client.Entity.BaseMaxAttack += 60; client.Entity.BaseMinAttack += 60; client.Entity.BaseMagicAttack += 60; }
if (client.Equipment.TotalStars >= 430) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 450) { client.Entity.BaseMaxAttack += 210; client.Entity.BaseMinAttack += 210; client.Entity.BaseMagicAttack += 210; }
if (client.Equipment.TotalStars >= 480) { client.Entity.BaseMaxAttack += 300; client.Entity.BaseMinAttack += 300; client.Entity.BaseMagicAttack += 300; }
if (client.Equipment.TotalStars >= 490) { client.Entity.BaseMaxAttack += 90; client.Entity.BaseMinAttack += 90; client.Entity.BaseMagicAttack += 90; }
if (client.Equipment.TotalStars >= 570) { client.Entity.BaseMaxAttack += 780; client.Entity.BaseMinAttack += 240; client.Entity.BaseMagicAttack += 240; }
if (client.Equipment.TotalStars >= 610) { client.Entity.BaseMaxAttack += 390; client.Entity.BaseMinAttack += 390; client.Entity.BaseMagicAttack += 390; }
if (client.Equipment.TotalStars >= 640) { client.Entity.BaseMaxAttack += 330; client.Entity.BaseMinAttack += 720; client.Entity.BaseMagicAttack += 720; }
if (client.Equipment.TotalStars >= 648) { client.Entity.BaseMaxAttack += 120; client.Entity.BaseMinAttack += 120; client.Entity.BaseMagicAttack += 120; }
}
public void Send(Client.GameState client)
{
client.Send(Kernel.FinalizeProtoBuf(new MsgUserTotalRefineLevProto()
{
ActionId = 0,
EntityUID = client.Entity.UID,
TotalPrefectionLevel = client.Equipment.TotalStars
}, 3252));
}
}
public class MsgRefineEffect
{
public MsgRefineEffect() { }
public MsgRefineEffectProto Info;
[ProtoContract]
public class MsgRefineEffectProto
{
[ProtoMember(1, IsRequired = true)]
public uint AttackerUID;
[ProtoMember(2, IsRequired = true)]
public uint AttackedUID;
[ProtoMember(3, IsRequired = true)]
public uint Effect;
}
public enum RefineEffects
{
None,
ToxinEraserLevel,
StrikeLockLevel,
LuckyStrike,
CalmWind,
DrainingTouch,
BloodSpawn,
LightOfStamina,
ShiledBreak,
KillingFlash,
MirrorOfSin,
DivineGuard,
CoreStrike,
InvisbleArrow,
FreeSoul,
StraightLife,
AbsoluteLuck
}
public void Attacking(Game.Entity attacker, Interfaces.IMapObject attacked, ref uint damage, ref Attack attack, ref bool loadItemStats)
{
if (attacker == null || attacked == null) return;
if (attacker.Owner.Equipment.TotalStars == 0) return;
if (attacker.EntityFlag == Game.EntityFlag.Monster) return;
double chance = 0;
var effect = Game.Enums.PerfectionEffect.CalmWind;
byte level = 0;
var dics = Database.PerfectionTable.Effects.Values.Where(i => i.Stars == attacker.Owner.Equipment.TotalStars).FirstOrDefault();
if (dics == null) return;
var dic = dics.Effects;
var item = Kernel.RandFromGivingNums(dic.ToArray());
effect = (Game.Enums.PerfectionEffect)(item / 1000);
level = (byte)(item % 1000);
chance = Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().Chance / 100;
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (attacker.Owner.Equipment.IsWearingItemID(val.ItemID))
{
if (attacker.Owner.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum <= 16)
{
if (val.AttributeNum == (uint)effect)
{
chance += (byte)val.Value;
}
}
}
}
}
while (effect == Game.Enums.PerfectionEffect.Stricklock ||
effect == Game.Enums.PerfectionEffect.FreeSoul ||
effect == Game.Enums.PerfectionEffect.StraightLife ||
effect == Game.Enums.PerfectionEffect.ToxinEarser ||
effect == Game.Enums.PerfectionEffect.BloodSpawn ||
effect == Game.Enums.PerfectionEffect.MirrorofSin)
{
item = Kernel.RandFromGivingNums(dic.ToArray());
effect = (Game.Enums.PerfectionEffect)(item / 1000);
level = (byte)(item % 1000);
chance = Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().Chance / 100;
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (attacker.Owner.Equipment.IsWearingItemID(val.ItemID))
{
if (attacker.Owner.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum <= 16)
{
if (val.AttributeNum == (uint)effect)
{
chance += (byte)val.Value;
}
}
}
}
}
}
if (Kernel.Rate((byte)chance))
{
#region DoEffects
/* #region DrainingTouch
if (effect == Game.Enums.PerfectionEffect.DrainingTouch)
{
attacker.Hitpoints = attacker.MaxHitpoints;
attacker.Mana = attacker.MaxMana;
}
#endregion
#region LuckyStrike
// if (effect == Game.Enums.PerfectionEffect.LuckyStrike || effect == Game.Enums.PerfectionEffect.AbsoluteLuck) { damage *= 2; attack.Effect1 = Attack.AttackEffects1.LuckyStrike; }
#endregion
#region KillingFlash
if (effect == Game.Enums.PerfectionEffect.KillingFlash)
{
attacker.Owner.XPCount = 100;
}
#endregion
#region DivineGuard
if (effect == Game.Enums.PerfectionEffect.DivineGuard)
{
attacker.AddFlag3(Network.GamePackets.Update.Flags3.DivineGuard);
attacker.Defence = (ushort)(((attacker.Defence) * 300) / 100);
attacker.DivineGuardStamp = Time32.Now;
}
#endregion
#region InvisibleArrow
if (effect == Game.Enums.PerfectionEffect.InvisibleArrow)
{
damage += ((uint)(attacker.MagicAttack * 5) / 100);
}
#endregion
#region ShieldBreak
if (effect == Game.Enums.PerfectionEffect.ShieldBreak)
{
attacker.AddFlag3(Network.GamePackets.Update.Flags3.ShieldBreak);
attacker.ShieldBreakStamp = Time32.Now;
if (attacked.MapObjType == Game.MapObjectType.Entity)
{
(attacked as Game.Entity).Block -= (ushort)((((attacked as Game.Entity).Block) * 20) / 100);
if ((attacked as Game.Entity).Block < 0) (attacked as Game.Entity).Block = 0;
loadItemStats = true;
}
}
#endregion
#region CoreStrike
if (effect == Game.Enums.PerfectionEffect.CoreStrike)
{
damage += ((uint)(attacker.MagicDamageIncrease - 0) * 100);
}
#endregion
#region LightofStamina
if (effect == Game.Enums.PerfectionEffect.LightofStamina)
{
byte limit = 0;
if (attacker.HeavenBlessing > 0)
limit = 50;
attacker.Stamina = (byte)(100 + limit);
}
#endregion*/
#endregion
var proto = new MsgRefineEffectProto();
proto.AttackerUID = attacker.UID;
proto.AttackedUID = attacked != null ? attacked.UID : 0;
proto.Effect = (uint)effect;
var proto2 = Kernel.FinalizeProtoBuf(proto, 3254);
attacker.Owner.SendScreen(proto2, true);
}
}
public void beingAttacked(Interfaces.IMapObject attacker, Game.Entity attacked, ref uint damage)
{
if (attacker == null || attacked == null) return;
if (attacker.Owner.Equipment.TotalStars == 0) return;
if (attacked.EntityFlag == Game.EntityFlag.Monster) return;
double chance = 0;
var effect = Game.Enums.PerfectionEffect.CalmWind;
byte level = 0;
var dic0 = Database.PerfectionTable.Effects.Values.Where(i => i.Stars == attacked.Owner.Equipment.TotalStars).FirstOrDefault();
if (dic0 == null) return;
var dic = dic0.Effects;
var item = Kernel.RandFromGivingNums(dic.ToArray());
effect = (Game.Enums.PerfectionEffect)(item / 1000);
level = (byte)(item % 1000);
chance = Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().Chance / 100;
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (attacked.Owner.Equipment.IsWearingItemID(val.ItemID))
{
if (attacked.Owner.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum <= 16)
{
if (val.AttributeNum == (uint)effect)
{
chance += (byte)val.Value;
}
}
}
}
}
/////////////WhileAttackedNotAttackingEffects////////////
while (!(effect == Game.Enums.PerfectionEffect.Stricklock ||
effect == Game.Enums.PerfectionEffect.BloodSpawn ||
effect == Game.Enums.PerfectionEffect.MirrorofSin))
{
item = Kernel.RandFromGivingNums(dic.ToArray());
effect = (Game.Enums.PerfectionEffect)(item / 1000);
level = (byte)(item % 1000);
chance = Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().Chance / 100;
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (attacked.Owner.Equipment.IsWearingItemID(val.ItemID))
{
if (attacked.Owner.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum <= 16)
{
if (val.AttributeNum == (uint)effect)
{
chance += (byte)val.Value;
}
}
}
}
}
}
if (Kernel.Rate((byte)chance))
{
var proto = new MsgRefineEffectProto();
proto.AttackerUID = attacked.UID;
proto.AttackedUID = attacker.UID;
proto.Effect = (uint)effect;
var proto2 = Kernel.FinalizeProtoBuf(proto, 3254);
attacked.Owner.SendScreen(proto2, true);
}
}
public void GenerateChance(Game.Entity Entity, Game.Enums.PerfectionEffect effect, ref byte chance, bool dwParam = false)
{
if (Entity.Owner.Equipment.TotalStars == 0) { chance = 0; return; }
byte level = (byte)(Database.PerfectionTable.Effects.Values.Where(i => i.Stars == Entity.Owner.Equipment.TotalStars).FirstOrDefault().Effects.Where(i => i >= ((uint)(effect) * 1000) && i <= ((uint)(effect) * 1000 + 20)).FirstOrDefault() % 1000);
if (Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault() != null)
{
if (!dwParam)
chance = (byte)(Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().Chance / 100);
else chance = (byte)(Database.PerfectionTable.AttributeList.Values.Where(i => i.Type == effect && i.Level == level).FirstOrDefault().dwParam / 100);
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (Entity.Owner.Equipment.IsWearingItemID(val.ItemID))
{
if (Entity.Owner.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum <= 16)
{
if (val.AttributeNum == (uint)effect)
{
chance += (byte)val.Value;
}
}
}
}
}
}
}
public static byte GetChance(Client.GameState client, Game.Enums.PerfectionEffect effect)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 0) return 0;
byte Chance = 0;
if (effect == Game.Enums.PerfectionEffect.CalmWind)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 3) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 90) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 170) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 250) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 285) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.BloodSpawn)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 40) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 240) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 288) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.DivineGuard)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints <= 40) Chance += 5;
}
if (effect == Game.Enums.PerfectionEffect.CoreStrike)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 50) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 80) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 135) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 205) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 245) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.DrainingTouch)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 35) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 220) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 276) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 324) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 570) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 648) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.FreeSoul)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 25) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 95) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 130) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 195) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 279) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.InvisibleArrow)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 65) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 225) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 282) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.KillingFlash)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 25) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 55) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 95) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 165) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 294) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 324) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 470) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 560) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 648) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.LightofStamina)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 1) Chance += 5;
}
if (effect == Game.Enums.PerfectionEffect.LuckyStrike)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 15) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 115) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 215) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 314) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 320) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.MirrorofSin)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 60) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 190) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 291) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.ShieldBreak)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 155 && client.Equipment.GetFullEquipmentPerfecetionLevelPoints <= 254) Chance += 50 / 100;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 255 && client.Equipment.GetFullEquipmentPerfecetionLevelPoints <= 296) Chance += 70 / 100;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 297 && client.Equipment.GetFullEquipmentPerfecetionLevelPoints <= 311) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 312 && client.Equipment.GetFullEquipmentPerfecetionLevelPoints <= 321) Chance += 150 / 100;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 322 && client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 322) Chance += 2;
}
if (effect == Game.Enums.PerfectionEffect.StraightLife)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 30) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 125) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 210) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 265) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 303) Chance += 1;
}
if (effect == Game.Enums.PerfectionEffect.Stricklock)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 30) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 125) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 210) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 265) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 303) Chance += 1;
}
return Chance;
}
public void SendEffect(Game.Entity attacker, Game.Entity attacked, Game.Enums.PerfectionEffect effect)
{
if (attacker == null || attacked == null) return;
var proto = new MsgRefineEffectProto();
proto.AttackerUID = attacker.UID;
if (attacked.EntityFlag == Game.EntityFlag.Entity)
proto.AttackedUID = attacked.UID;
else if (attacked.EntityFlag == Game.EntityFlag.Monster && attacked != null && attacked.UID != 0)
{
proto.AttackedUID = attacked.UID;
}
proto.Effect = (uint)effect;
var proto2 = Kernel.FinalizeProtoBuf(proto, 3254);
attacker.Owner.SendScreen(proto2, true);
if (effect == Game.Enums.PerfectionEffect.DrainingTouch)
{
attacker.Hitpoints = attacker.MaxHitpoints;
}
/* if (effect == Game.Enums.PerfectionEffect.KillingFlash)
{
attacker.AddFlag((ulong)MsgUpdate.Flags.XPList);
attacker.Owner.XPListStamp = Time32.Now;
}*/
/* if (effect == Game.Enums.PerfectionEffect.DivineGuard)
{
attacker.AddFlag3((ulong)Network.GamePackets.Update.Flags3.DivineGuard);
attacker.Defence = (ushort)(((attacker.Defence) * 20) / 100);
attacker.DivineGuardStamp = Time32.Now;
}
if (effect == Game.Enums.PerfectionEffect.ShieldBreak)
{
attacker.AddFlag3((ulong)Network.GamePackets.Update.Flags3.ShieldBreak);
attacker.ShieldBreakStamp = Time32.Now;
attacker.Block += (ushort)(((attacker.Block) * 2) / 10);
}*/
if (effect == Game.Enums.PerfectionEffect.StraightLife)
{
attacker.BringToLife();
}
if (effect == Game.Enums.PerfectionEffect.LightofStamina && attacked.EntityFlag == Game.EntityFlag.Entity && attacker.Owner.Equipment.GetFullEquipmentPerfecetionLevelPoints > attacked.Owner.Equipment.GetFullEquipmentPerfecetionLevelPoints || effect == Game.Enums.PerfectionEffect.LightofStamina && attacked.EntityFlag == Game.EntityFlag.Monster) attacker.Stamina = 100;
}
public void GenerateEffectandChance(Client.GameState client, ref Game.Enums.PerfectionEffect effect, ref byte chance)
{
effect = (Game.Enums.PerfectionEffect)Kernel.Random.Next(3, 14);
chance = GetChance(client, effect);
while (chance == 10)
{
effect = (Game.Enums.PerfectionEffect)Kernel.Random.Next(3, 14);
chance = GetChance(client, effect);
}
}
public void HandleStraightLife(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.StraightLife);
}
public void HandleBloodSpawn(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.BloodSpawn);
}
public void HandleMirror(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.MirrorofSin);
}
public void HandleCalmWind(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.CalmWind);
}
public void HandleInvisibleArrow(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.InvisibleArrow);
}
public void HandleStrickeLock(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.Stricklock);
}
public void HandleLightofStamina(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.LightofStamina);
}
public void HandleCoreStrike(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.CoreStrike);
}
public void HandleKillingFlash(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.KillingFlash);
}
public void HandleFreeSoul(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.FreeSoul);
}
public void HandleDrainingTouch(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.DrainingTouch);
}
public void HandleLuckyStrike(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.LuckyStrike);
}
public void HandleDivineGuard(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.DivineGuard);
}
public void HandleShieldBreak(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.ShieldBreak);
}
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
اهو يا رايدر | taha | مشكلات السيرفيرات كونكر الشخصيه | 7 | 2020-02-18 06:36 AM |
طلب من رايزو او رايدر | محمودمحمدسالم | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2020-02-17 12:29 AM |
ممكن طلب يا رايدر او يارجاله | taha | مشكلات السيرفيرات كونكر الشخصيه | 7 | 2020-02-11 05:42 AM |
يا رايدر خش شوف انا مستني من الصبح | مجدى | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2020-01-24 08:30 PM |
معلش يا رايدر | nova | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2019-11-24 10:45 AM |