|
|
المشاركات 504 |
+التقييم 0.27 |
تاريخ التسجيل Jun 2019 |
الاقامة المنوفية |
نظام التشغيل windows Server 2012R2 |
رقم العضوية 325 |
\Source PlayConquer V2\Network\GamePackets\PrestigeRank.cs
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 PlayConquer;
using PlayConquer.Database;
using System.Threading.Tasks;
namespace PlayConquer.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 ConcurrentDictionary<uint, Game.Entity> RankingList;
public void GetRankingList()
{
RankingList = new ConcurrentDictionary<uint, 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.TotalPerfectionScore = 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(client.UID, 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.WardrobeTable.PerfectionPoints(client, true);
if (Type == 18) Score = Database.WardrobeTable.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)
{
if (client == null || client.ChiData == null || client.ChiData.Powers == null)
return 0;
int Point = 0;
for (int i = 0; i < 4; i++)
{
if (client.ChiData.Powers.Count < 1) break;
Point += ((client.ChiData.Powers[0].Attributes[i].Value / Game.Enums.ChiMaxValues(client.ChiData.Powers[0].Attributes[i].Type)) * 100) * 60;
}
for (int i = 0; i < 4; i++)
{
if (client.ChiData.Powers.Count < 2) break;
Point += ((client.ChiData.Powers[1].Attributes[i].Value / Game.Enums.ChiMaxValues(client.ChiData.Powers[1].Attributes[i].Type)) * 100) * 60;
}
for (int i = 0; i < 4; i++)
{
if (client.ChiData.Powers.Count < 3) break;
Point += ((client.ChiData.Powers[2].Attributes[i].Value / Game.Enums.ChiMaxValues(client.ChiData.Powers[2].Attributes[i].Type)) * 100) * 60;
}
for (int i = 0; i < 4; i++)
{
if (client.ChiData.Powers.Count < 4) break;
Point += ((client.ChiData.Powers[3].Attributes[i].Value / Game.Enums.ChiMaxValues(client.ChiData.Powers[3].Attributes[i].Type)) * 100) * 60;
}
return Point;
}
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;
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))
{
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.ConquerPoints >= 1000)
{
client.Entity.ConquerPoints -= 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 3://CPBoost
{
ConquerItem Item;
if (client.Equipment.TryGetItem(Info.ItemUID, out Item) && Item != null)
{
uint valuee;
valuee = Math.Min(414112, (uint)client.Entity.ConquerPoints);
if (client.Entity.ConquerPoints >= valuee)
{
client.Entity.ConquerPoints -= valuee;
Item.Owner = client.Entity.Name;
Item.OwnerUID = client.Entity.UID;
Item.PerfectionProgress += (uint)GetPerfectionProgress(valuee);
while (Item.PerfectionProgress >= GetPerfectionProgress(Item))
{
Item.PerfectionProgress -= GetPerfectionProgress(Item);
Item.Stars++;
}
while (Item.Stars >= 54 && Item.PerfectionProgress > 0)
{
Item.Stars = 54;
Item.PerfectionProgress = 0;
}
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 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 (client.Entity.ConquerPoints >= 0)
{
client.Entity.ConquerPoints -= 0;
Item.PerfectionProgress = Item2.PerfectionProgress;
Item.Stars = Item2.Stars;
Item.Mode = Game.Enums.ItemMode.Update;
Item.Send(client);
Item2.PerfectionProgress = 0;
Item2.Stars = 0;
Item2.Mode = Game.Enums.ItemMode.Update;
Item2.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 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 MsgRankMemberShow
{
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 UpdateBestEntity()
{
DateTime StartTime = DateTime.Now;
Items = new Dictionary<byte, uint>();
BestEntity = MsgUserAbilityScore.RankingList.OrderByDescending(i => i.Value.TotalPerfectionScore).ThenByDescending(i => i.Value.Level).ThenBy(i => i.Value.UID).FirstOrDefault().Value;
if (BestEntity == null) return;
byte[] Positions = new byte[10] { 1, 3, 4, 5, 9, 12, 15, 16, 17, 19 };
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("EntityID", BestEntity.UID))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
foreach (var pos in Positions)
{
if (reader.ReadByte("Position") == pos)
{
if (Items.ContainsKey(pos)) Items.Remove(pos);
Items.Add(pos, reader.ReadUInt32("ID"));
if (pos == 19) Items.Add(255, reader.ReadByte("Plus"));
break;
}
}
}
}
foreach (var pos in Positions)
{
if (!Items.ContainsKey(pos)) Items.Add(pos, 0);
}
if (!Items.ContainsKey(255)) Items.Add(255, 0);
}
public static Dictionary<byte, uint> Items = new Dictionary<byte, uint>();
public static Game.Entity BestEntity;
public void Handle(Client.GameState client)
{
if (BestEntity == 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 = BestEntity.UID;
#region If He Is Online
if (Kernel.GamePool.ContainsKey(BestEntity.UID))
{
var Entity = Kernel.GamePool[BestEntity.UID].Entity;
proto2.proto.HairStyle = Entity.HairStyle;
proto2.proto.Mesh = Entity.Mesh;
proto2.proto.Name = Entity.Name;
if (BestEntity.GuildID != 0)
proto2.proto.Guild = Kernel.Guilds[BestEntity.GuildID].Name;
if (Entity.Owner.Equipment != null)
{
var Equipment = Entity.Owner.Equipment;
proto2.proto.Hat = Equipment.TryGetItem((byte)ConquerItem.Head) != null ? Equipment.TryGetItem((byte)ConquerItem.Head).ID : 0;
proto2.proto.LeftWep = Equipment.TryGetItem((byte)ConquerItem.LeftWeapon) != null ? Equipment.TryGetItem((byte)ConquerItem.LeftWeapon).ID : 0;
proto2.proto.LeftWepAcc = Equipment.TryGetItem((byte)ConquerItem.LeftWeaponAccessory) != null ? Equipment.TryGetItem((byte)ConquerItem.LeftWeaponAccessory).ID : 0;
proto2.proto.MountArmor = Equipment.TryGetItem((byte)ConquerItem.SteedArmor) != null ? Equipment.TryGetItem((byte)ConquerItem.SteedArmor).ID : (Equipment.TryGetItem((byte)ConquerItem.Steed) != null ? Equipment.TryGetItem((byte)ConquerItem.Steed).ID : 0);
proto2.proto.Garment = Equipment.TryGetItem((byte)ConquerItem.Garment) != null ? Equipment.TryGetItem((byte)ConquerItem.Garment).ID : ((Equipment.TryGetItem((byte)ConquerItem.Armor) != null ? Equipment.TryGetItem((byte)ConquerItem.Armor).ID : 0));
proto2.proto.RightWep = Equipment.TryGetItem((byte)ConquerItem.RightWeapon) != null ? Equipment.TryGetItem((byte)ConquerItem.RightWeapon).ID : 0;
proto2.proto.RightWepAcc = Equipment.TryGetItem((byte)ConquerItem.RightWeaponAccessory) != null ? Equipment.TryGetItem((byte)ConquerItem.RightWeaponAccessory).ID : 0;
proto2.proto.Wing = Entity.EquippedWing == 0 ? (Equipment.TryGetItem((byte)ConquerItem.Wing) != null ? Equipment.TryGetItem((byte)ConquerItem.Wing).ID : 0) : (uint)Entity.EquippedWing;
proto2.proto.WingLevel = (byte)(Equipment.TryGetItem((byte)ConquerItem.Wing) != null ? Equipment.TryGetItem((byte)ConquerItem.Wing).Plus : 0);
}
proto2.proto.Title = (uint)Entity.EquippedTitle;
proto2.proto.Flag = (uint)Entity.StatusFlag;
proto2.proto.Flag2 = (uint)Entity.StatusFlag2;
proto2.proto.Flag3 = (uint)Entity.StatusFlag3;
//proto2.proto.Flag4 = (uint)Entity.StatusFlag4;
client.Send(Kernel.FinalizeProtoBuf(proto2, 3257));
break;
}
#endregion
proto2.proto.HairStyle = BestEntity.HairStyle;
proto2.proto.Mesh = BestEntity.Mesh;
proto2.proto.Name = BestEntity.Name;
if (BestEntity.GuildID != 0 && Kernel.Guilds.ContainsKey(BestEntity.GuildID))
proto2.proto.Guild = Kernel.Guilds[BestEntity.GuildID].Name;
proto2.proto.Hat = Items[(byte)ConquerItem.Head];
proto2.proto.LeftWep = Items[(byte)ConquerItem.LeftWeapon];
proto2.proto.LeftWepAcc = Items[(byte)ConquerItem.LeftWeaponAccessory];
proto2.proto.MountArmor = Items[(byte)ConquerItem.SteedArmor] == 0 ? Items[(byte)ConquerItem.Steed] : Items[(byte)ConquerItem.SteedArmor];
proto2.proto.Garment = Items[(byte)ConquerItem.Garment];
proto2.proto.RightWep = Items[(byte)ConquerItem.RightWeapon];
proto2.proto.RightWepAcc = Items[(byte)ConquerItem.RightWeaponAccessory];
proto2.proto.Wing = BestEntity.EquippedWing == 0 ? Items[(byte)ConquerItem.Wing] : (uint)BestEntity.EquippedWing;
proto2.proto.WingLevel = Items[255];
proto2.proto.Title = (uint)BestEntity.EquippedTitle;
client.Send(Kernel.FinalizeProtoBuf(proto2, 3257));
break;
}
case 1:
{
if (Kernel.GamePool.ContainsKey(Info.proto == null ? 0 : Info.proto.dwParam))
{
PacketHandler.ObserveEquipment(new Data(true) { 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;
}
}
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 * 10), 10);
int rank = (int)packet.Page * 10;
packet.items = new EquipProto[sss];
for (int i = rank; i < rank + sss; i++)
{
var iteeeem = AllItemsRanking.Where(p => p.Position == GetRealyPosition((byte)Info.Index)).OrderByDescending(x => MsgUserAbilityScore.CalculatePerfectionItemPoints(x)).ToArray()[i];
if (iteeeem == null) continue;
packet.items[i] = new EquipProto();
packet.items[i].ItemID = iteeeem.ID;
packet.items[i].Name = iteeeem.Owner.Replace("/0", "");
packet.items[i].PerfectionLevel = 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);
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.MaxAttack += 100; client.Entity.MinAttack += 100; client.Entity.MagicAttack += 100; }
if (client.Equipment.TotalStars >= 70) { client.Entity.Defence += 100; client.Entity.MagicDefence += 100; }
if (client.Equipment.TotalStars >= 75) { client.Entity.MaxAttack += 200; client.Entity.MinAttack += 200; client.Entity.MagicAttack += 300; }
if (client.Equipment.TotalStars >= 100) { client.Entity.Defence += 200; client.Entity.MagicDefence += 50; }
if (client.Equipment.TotalStars >= 140) { client.Entity.MaxAttack += 200; client.Entity.MinAttack += 200; client.Entity.MagicAttack += 400; }
if (client.Equipment.TotalStars >= 150) { client.Entity.MaxAttack += 300; client.Entity.MinAttack += 300; client.Entity.MagicAttack += 500; }
if (client.Equipment.TotalStars >= 160) { client.Entity.Defence += 300; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 180) { client.Entity.Defence += 400; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 235) { client.Entity.MaxAttack += 400; client.Entity.MinAttack += 400; client.Entity.MagicAttack += 500; }
if (client.Equipment.TotalStars >= 270) { client.Entity.Defence += 400; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 273) { client.Entity.MaxAttack += 400; client.Entity.MinAttack += 400; client.Entity.MagicAttack += 500; }
if (client.Equipment.TotalStars >= 306) { client.Entity.MaxAttack += 400; client.Entity.MinAttack += 400; client.Entity.MagicAttack += 500; }
if (client.Equipment.TotalStars >= 310) { client.Entity.Defence += 400; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 316) { client.Entity.Defence += 500; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 318) { client.Entity.MaxAttack += 500; client.Entity.MinAttack += 500; client.Entity.MagicAttack += 500; }
if (client.Equipment.TotalStars >= 323) { client.Entity.Defence += 500; client.Entity.MagicDefence += 125; }
if (client.Equipment.TotalStars >= 324) { client.Entity.MaxAttack += 500; client.Entity.MinAttack += 500; client.Entity.MagicAttack += 500; }
}
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 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.Effect = Attack.AttackEffects.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))
{
#region DoEffects
#region StrickLock
if (effect == Game.Enums.PerfectionEffect.Stricklock)
{
damage = 0;
}
#endregion
#region BloodSpawn
if (effect == Game.Enums.PerfectionEffect.BloodSpawn)
{
attacked.Hitpoints = attacked.MaxHitpoints;
attacked.Mana = attacked.MaxMana;
}
#endregion
#region KillingFlash
if (effect == Game.Enums.PerfectionEffect.MirrorofSin)
{
attacked.Owner.XPCount = 100;
}
#endregion
#endregion
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 byte GetChance(Client.GameState client, Game.Enums.PerfectionEffect effect)
{
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints == 0) return 0;
byte Chance = 10;
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 (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 >= 55) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 165) Chance += 1;
if (client.Equipment.GetFullEquipmentPerfecetionLevelPoints >= 294) 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)Network.GamePackets.Update.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 HandleStrickeLock(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.Stricklock);
}
public void HandleLuckyStrike(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.LuckyStrike);
}
public void HandleMirror(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.MirrorofSin);
}
public void HandleFreeSoul(Game.Entity client, ref byte chance)
{
chance = GetChance(client.Owner, Game.Enums.PerfectionEffect.FreeSoul);
}
}
}
Game\Features\Flowers
using System;
using System.Linq;
using System.Text;
using PlayConquer.Client;
using System.Collections.Generic;
using PlayConquer.Network.GamePackets;
using PlayConquer.Rangers.Inner;
namespace PlayConquer.Game.Features
{
public class Flowers
{
public enum Effect : byte
{
None = 0,
Rouse = 1,
Lilies = 2,
Orchids = 3,
Tulips = 4,
Kiss = 1,
love = 2,
Tins = 3,
Jade = 4,
}
public enum FlowersT : byte
{
Rouse = 0,
Lilies = 1,
Orchids = 2,
Tulips = 3,
Kiss = 4,
love = 5,
Tins = 6,
Jade = 7,
}
public Flowers()
{
}
public Flowers(uint _UID, string name)
{
UID = _UID;
Name = name;
aFlower = GetCountFlowers();
}
public uint UID;
public uint aFlower = 1;
public uint SendDay = 0;
public string Name = "";
public byte GetCountFlowers()
{
if (Client.GameState.GetClientFromID(UID) != null)
{
if (Client.GameState.GetClientFromID(UID).Entity.VIPLevel == 1)
return 2;
if (Client.GameState.GetClientFromID(UID).Entity.VIPLevel == 2)
return 3;
if (Client.GameState.GetClientFromID(UID).Entity.VIPLevel == 3)
return 5;
if (Client.GameState.GetClientFromID(UID).Entity.VIPLevel == 4)
return 10;
if (Client.GameState.GetClientFromID(UID).Entity.VIPLevel == 5)
return 15;
if (Kernel.GamePool[UID].Entity.VIPLevel == 6)
return 30;
return 1;
}
return 1;
}
public int SendScreenValue(FlowersT typ, int rak)
{
if (rak == 0 || rak > 100)
return 0;
return (int)(30000002 + (uint)(100 * (byte)typ) + GetRank(rak));
}
public ushort GetRank(int rank)
{
if (rank == 1)
return 0;
if (rank == 2)
return 10000;
if (rank == 3)
return 20000;
if (rank > 3)
return 30000;
return 0;
}
public int BoySendScreenValue(FlowersT typ, int rak)
{
int ret = 0;
if (rak == -1) return 0;
if (rak > 100) return 0;
ret = (int)(30000402 + (uint)(100 * (byte)typ));
return ret;
}
public int RankRoses = 0;
public int RankLilies = 0;//max 10 start with -1.
public int RankOrchids = 0;//max 10 start with -1.
public int RankTuilps = 0;//max 10 start with -1.
public uint RedRoses;//kiss
public uint RedRoses2day;
public uint Lilies;//love
public uint Lilies2day;
public uint Orchads;//wine
public uint Orchads2day;
public uint Tulips;//jade
public uint Tulips2day;
public override string ToString()
{
return UID + "#"
+ Name + "#"
+ RedRoses + "#"
+ RedRoses2day + "#"
+ Lilies + "#"
+ Lilies2day + "#"
+ Orchads + "#"
+ Orchads2day + "#"
+ Tulips + "#"
+ Tulips2day + "#"
+ SendDay + "#"
+ aFlower + "#"
+ 0 + "#"
+ 0 + "#"
+ 0 + "#"
+ 0 + "#"
+ 0 + "#";
}
public void Read(string aLine)
{
if (aLine == "" || aLine == null) return;
string[] line = aLine.Split('#');
UID = uint.Parse(line[0]);
Name = line[1];
RedRoses = uint.Parse(line[2]);
RedRoses2day = uint.Parse(line[3]);
Lilies = uint.Parse(line[4]);
Lilies2day = uint.Parse(line[5]);
Orchads = uint.Parse(line[6]);
Orchads2day = uint.Parse(line[7]);
Tulips = uint.Parse(line[8]);
Tulips2day = uint.Parse(line[9]);
SendDay = uint.Parse(line[10]);
aFlower = uint.Parse(line[11]);
Reset();
}
public void Reset()
{
if (SendDay != DateTime.Now.Day)
{
RedRoses2day = Lilies2day = Orchads2day = Tulips2day = 0;
aFlower = GetCountFlowers();
SendDay = (uint)DateTime.Now.Day;
}
Database.Flowers.SaveFlowers();
}
public static System.Collections.Concurrent.ConcurrentDictionary<uint, Flowers> Flowers_Poll = new System.Collections.Concurrent.ConcurrentDictionary<uint, Flowers>();
public static System.Collections.Concurrent.ConcurrentDictionary<uint, Flowers> BoyFlowers = new System.Collections.Concurrent.ConcurrentDictionary<uint, Flowers>();
public static Flowers[] KissTop100 = new Flowers[0];
public static Flowers[] LoveTop100 = new Flowers[0];
public static Flowers[] TineTop100 = new Flowers[0];
public static Flowers[] JadeTop100 = new Flowers[0];
public static Flowers[] RedRousesTop100 = new Flowers[0];
public static Flowers[] LiliesTop100 = new Flowers[0];
public static Flowers[] OrchidsTop100 = new Flowers[0];
public static Flowers[] TulipsTop100 = new Flowers[0];
public static object RouseLock = new object();
public static object LilisLock = new object();
public static object OrchidsLock = new object();
public static object TulipsLock = new object();
public static object KissLock = new object();
public static object LoveLock = new object();
public static object TineLock = new object();
public static object JadeLock = new object();
public static List<Flowers> RankKiss = new List<Flowers>();
public static List<Flowers> RankLove = new List<Flowers>();
public static List<Flowers> RankTine = new List<Flowers>();
public static List<Flowers> RankJade = new List<Flowers>();
public static List<Flowers> Rankrose = new List<Flowers>();
public static List<Flowers> Ranklili = new List<Flowers>();
public static List<Flowers> Rankorchid = new List<Flowers>();
public static List<Flowers> RankTulips = new List<Flowers>();
public static void CulculateRankJade(Flowers afflow)
{
lock (JadeLock)
{
try
{
if (!RankJade.Contains(afflow))
RankJade.Add(afflow);
var data = RankJade.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Tulips == 0) continue;
if (x < 100)
{
flow.RankTuilps = x;
backUpd.Add(flow);
}
else
flow.RankTuilps = 0;
x++;
}
lock (JadeTop100)
{
RankJade = new List<Flowers>(backUpd);
JadeTop100 = backUpd.ToArray();
}
}
catch (Exception) { }
}
}
public static void CulculateRankTine(Flowers afflow)
{
lock (TineLock)
{
try
{
if (!RankTine.Contains(afflow))
RankTine.Add(afflow);
var data = RankTine.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Orchads == 0) continue;
if (x < 100)
{
flow.RankOrchids = x;
backUpd.Add(flow);
}
else
flow.RankOrchids = 0;
x++;
}
lock (TineTop100)
{
RankTine = new List<Flowers>(backUpd);
TineTop100 = backUpd.ToArray();
}
}
catch (Exception) { }
}
}
public static void CulculateRankLove(Flowers afflow)
{
lock (LoveLock)
{
try
{
if (!RankLove.Contains(afflow))
RankLove.Add(afflow);
var data = RankLove.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Lilies == 0) continue;
if (x < 100)
{
flow.RankLilies = x;
backUpd.Add(flow);
}
else
flow.RankLilies = 0;
x++;
}
lock (LoveTop100)
{
RankLove = new List<Flowers>(backUpd);
LoveTop100 = backUpd.ToArray();
}
}
catch (Exception) { }
}
}
public static void CulculateRankKiss(Flowers afflow)
{
lock (KissLock)
{
try
{
if (!RankKiss.Contains(afflow))
RankKiss.Add(afflow);
var data = RankKiss.ToArray();
Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.RedRoses == 0) continue;
if (x < 100)
{
flow.RankRoses = x;
backUpd.Add(flow);
}
else
flow.RankRoses = 0;
x++;
}
lock (KissTop100)
{
RankKiss = new List<Flowers>(backUpd);
KissTop100 = backUpd.ToArray();
}
}
catch (Exception) { }
}
}
public static void CulculateRankRouse(Flowers afflow)
{
lock (RouseLock)
{
try
{
if (!Rankrose.Contains(afflow))
Rankrose.Add(afflow);
var data = Rankrose.ToArray();
Array.Sort(data, (c1, c2) => { return c2.RedRoses.CompareTo(c1.RedRoses); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.RedRoses == 0) continue;
if (x < 100)
{
flow.RankRoses = x;
backUpd.Add(flow);
}
else
{
flow.RankRoses = 0;
}
x++;
}
lock (RedRousesTop100)
{
Rankrose = new List<Flowers>(backUpd);
RedRousesTop100 = backUpd.ToArray();
}
}
catch (Exception) { }
}
}
public static void CulculateRankLilies(Flowers afflow)
{
lock (LilisLock)
{
if (!Ranklili.Contains(afflow))
Ranklili.Add(afflow);
var data = Ranklili.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Lilies.CompareTo(c1.Lilies); });
//IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
//var room = query.ToArray();
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Lilies == 0) continue;
if (x < 100)
{
flow.RankLilies = x;
backUpd.Add(flow);
}
else
{
flow.RankLilies = 0;
}
x++;
}
lock (LiliesTop100)
{
Ranklili = new List<Flowers>(backUpd);
LiliesTop100 = backUpd.ToArray();
}
}
}
public static void CulculateRankOrchids(Flowers afflow)
{
lock (OrchidsLock)
{
if (!Rankorchid.Contains(afflow))
Rankorchid.Add(afflow);
var data = Rankorchid.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Orchads.CompareTo(c1.Orchads); });
//IEnumerable<Flowers> query = data.OrderBy(redrous => redrous.Tulips);
//var room = query.ToArray();
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Orchads == 0) continue;
if (x < 100)
{
flow.RankOrchids = x;
backUpd.Add(flow);
}
else
{
flow.RankOrchids = 0;
}
x++;
}
lock (OrchidsTop100)
{
Rankorchid = new List<Flowers>(backUpd);
OrchidsTop100 = backUpd.ToArray();
}
}
}
public static void CulculateRankTulips(Flowers afflow)
{
lock (TulipsLock)
{
if (!RankTulips.Contains(afflow))
RankTulips.Add(afflow);
var data = RankTulips.ToArray();
Array.Sort(data, (c1, c2) => { return c2.Tulips.CompareTo(c1.Tulips); });
var room = data.ToArray();
List<Flowers> backUpd = new List<Flowers>();
int x = 1;
foreach (Flowers flow in room)
{
if (flow.Tulips == 0) continue;
if (x < 100)
{
flow.RankTuilps = x;
backUpd.Add(flow);
}
else
{
flow.RankTuilps = 0;
}
x++;
}
lock (TulipsTop100)
{
RankTulips = new List<Flowers>(backUpd);
TulipsTop100 = backUpd.ToArray();
}
}
}
public static void FlowersPacket(byte[] packet, GameState client)
{
GenericRanking ranking = new GenericRanking(true);
ranking.Deserialize(packet);
switch (packet[4])
{
#region Ranking
case GenericRanking.Ranking:
{
uint uid = BitConverter.ToUInt32(packet, 8);
ushort pagenumber = BitConverter.ToUInt16(packet, 14);
GenericRanking ranking1 = new GenericRanking(true, 10);
ranking1.Mode = 1;
ranking1.Page = pagenumber;
ranking1.RankingType = uid;
switch (uid)
{
#region Chi
case GenericRanking.DragonChi:
{
PlayConquer.Network.PacketHandler.ShowGenericRanking(ranking1, client);
break;
}
case GenericRanking.TigerChi:
{
PlayConquer.Network.PacketHandler.ShowGenericRanking(ranking1, client);
break;
}
case GenericRanking.PhoenixChi:
{
PlayConquer.Network.PacketHandler.ShowGenericRanking(ranking1, client);
break;
}
case GenericRanking.TurtleChi:
{
PlayConquer.Network.PacketHandler.ShowGenericRanking(ranking1, client);
break;
}
#endregion
#region InnerPower
case GenericRanking.InnerPower:
{
ushort page = ranking.Page;
InnerPower[] list = null;
Func<InnerPower, uint> select = null;
list = InnerPower.InnerPowerRank.GetRankingList();
select = (inner) => { return inner.TotalScore; };
byte count = (byte)Math.Min(list.Length - page * 10, 10);
var nRanking = new GenericRanking(true, count);
nRanking.Mode = GenericRanking.Ranking;
nRanking.RankingType = ranking.RankingType;
nRanking.Page = page;
nRanking.RegisteredCount = (ushort)Math.Min(list.Length * 100, 100);
int rank = (int)page * 10;
for (int i = rank; i < rank + count; i++)
{
var current = list[i];
nRanking.Append((uint)(i + 1), (uint)select(current), current.UID, current.Name);
}
client.Send(nRanking);
break;
}
#endregion
#region Perfection
case 80000001:
case 80000002:
case 80000003:
case 80000004:
case 80000005:
case 80000006:
case 80000007:
case 80000008:
case 80000009:
case 80000010:
{
byte realyclass = 0;
if (ranking.RankingType % 10 == 1) realyclass = 15;
if (ranking.RankingType % 10 == 2) realyclass = 25;
if (ranking.RankingType % 10 == 3) realyclass = 45;
if (ranking.RankingType % 10 == 4) realyclass = 55;
if (ranking.RankingType % 10 == 5) realyclass = 65;
if (ranking.RankingType % 10 == 6) realyclass = 75;
if (ranking.RankingType % 10 == 7) realyclass = 85;
if (ranking.RankingType % 10 == 8) realyclass = 135;
if (ranking.RankingType % 10 == 9) realyclass = 145;
if (ranking.RankingType % 100 == 10) realyclass = 165;
var array = MsgUserAbilityScore.RankingList.Where(i => i.Value.Class >= (realyclass - 5) && i.Value.Class <= realyclass).OrderByDescending(i => i.Value.TotalPerfectionScore).ThenByDescending(i => i.Value.Level).ThenBy(i => i.Value.UID).ToArray();
var nRanking = new GenericRanking(true, (byte)Math.Min(10, array.Length));
nRanking.RegisteredCount = (ushort)Math.Min(array.Length, 100);
nRanking.Mode = 1;
nRanking.RankingType = ranking.RankingType;
nRanking.Page = ranking.Page;
// nRanking.Count = (ushort)Math.Min(array.Length - (ranking.Page * 10), 10);
uint sss = (ushort)Math.Min(array.Length - (ranking.Page * 10), 10);
int rank = (int)nRanking.Page * 10;
for (int i = rank; i < rank + sss; i++)
{
var current = array[i]; if (current.Value == null) break;
nRanking.Append2((uint)(i + 1), current.Value.TotalPerfectionScore, current.Value.UID, current.Value.Name, current.Value.Level, current.Value.Class, current.Value.Mesh);
}
client.Send(nRanking);
break;
}
case 80000000:
{
var array = MsgUserAbilityScore.RankingList.OrderByDescending(i => i.Value.TotalPerfectionScore).ThenByDescending(i => i.Value.Level).ThenBy(i => i.Value.UID).ToArray();
var nRanking = new GenericRanking(true, (byte)Math.Min(10, array.Length));
nRanking.RegisteredCount = (ushort)Math.Min(array.Length, 100);
nRanking.Mode = 1;
nRanking.RankingType = ranking.RankingType;
nRanking.Page = ranking.Page;
// nRanking.Count = (ushort)Math.Min(array.Length - (ranking.Page * 10), 10);
uint sss = (ushort)Math.Min(array.Length - (ranking.Page * 10), 10);
int rank = (int)nRanking.Page * 10;
for (int i = rank; i < rank + sss; i++)
{
var current = array[i]; if (current.Value == null) break;
nRanking.Append2((uint)(i + 1), current.Value.TotalPerfectionScore, current.Value.UID, current.Value.Name, current.Value.Level, current.Value.Class, current.Value.Mesh);
}
client.Send(nRanking);
break;
}
#endregion
default: { Console.WriteLine("[1151-Ranking] UnKnown = " + uid); } break;
}
break;
}
#endregion
case 6://Prestige
{
var index = new byte[11] { 0, 15, 25, 45, 55, 65, 75, 85, 135, 145, 165 };
Entity[] Chars = new Entity[11];
for (int i = 0; i < Chars.Length; i++)
{
if (i == 0)
Chars[i] = MsgUserAbilityScore.RankingList.OrderByDescending(x => x.Value.TotalPerfectionScore).ThenByDescending(x => x.Value.Level).ThenBy(x => x.Value.UID).FirstOrDefault().Value;
else Chars[i] = MsgUserAbilityScore.RankingList.Where(x => x.Value.Class >= (index[i] - 5) && x.Value.Class <= index[i]).OrderByDescending(x => x.Value.TotalPerfectionScore).ThenByDescending(x => x.Value.Level).ThenBy(x => x.Value.UID).FirstOrDefault().Value;
}
byte count = 0;
foreach (var zz in Chars) if (zz != null) count++;
var nRanking = new GenericRanking(true, count);
nRanking.Mode = 6;
nRanking.Count = count;
for (byte z = 0; z < Chars.Length; z++)
{
var Entity = Chars[z];
if (Entity == null) continue;
nRanking.Append2((uint)(z + 1), Entity.TotalPerfectionScore, Entity.UID, Entity.Name, Entity.Level, Entity.Class, Entity.Mesh, true);
}
client.Send(nRanking);
break;
}
case GenericRanking.QueryCount:
{
if (ranking.RankingType == 70000000)
{
if (client.Entity.InnerPower != null)
{
GenericRanking genericRanking3 = new GenericRanking(true, 1);
genericRanking3.Mode = 2;
genericRanking3.RankingType = ranking.RankingType;
genericRanking3.Count = 1;
genericRanking3.Append((uint)client.Entity.InnerPower.Rank, client.Entity.InnerPower.TotalScore, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking3.ToArray());
}
return;
}
#region Perfection
if (ranking.RankingType == 80000000)
{
var array = MsgUserAbilityScore.RankingList.Values.OrderByDescending(i => i.TotalPerfectionScore).ThenByDescending(i => i.Level).ThenBy(i => i.UID).ToArray();
for (int i = 0; i < array.Length; i++)
{
if (array[i].UID == client.Entity.UID)
{
Network.GamePackets.GenericRanking PacketRank = new Network.GamePackets.GenericRanking(true);
PacketRank.Mode = Network.GamePackets.GenericRanking.QueryCount;
PacketRank.RankingType = ranking.RankingType;
PacketRank.Append2((uint)(i + 1), array[i].TotalPerfectionScore, array[i].UID, array[i].Name, array[i].Level, array[i].Class, array[i].Mesh);
client.Send(PacketRank.ToArray());
break;
}
}
break;
}
if (ranking.RankingType >= 80000000 && ranking.RankingType <= 80000010)
{
byte realyclass = 0;
if (ranking.RankingType % 10 == 1) realyclass = 15;
if (ranking.RankingType % 10 == 2) realyclass = 25;
if (ranking.RankingType % 10 == 3) realyclass = 45;
if (ranking.RankingType % 10 == 4) realyclass = 55;
if (ranking.RankingType % 10 == 5) realyclass = 65;
if (ranking.RankingType % 10 == 6) realyclass = 75;
if (ranking.RankingType % 10 == 7) realyclass = 85;
if (ranking.RankingType % 10 == 8) realyclass = 135;
if (ranking.RankingType % 10 == 9) realyclass = 145;
if (ranking.RankingType % 100 == 10) realyclass = 165;
var array = MsgUserAbilityScore.RankingList.Values.Where(i => i.Class >= (realyclass - 5) && i.Class <= realyclass).OrderByDescending(i => i.TotalPerfectionScore).ThenByDescending(i => i.Level).ThenBy(i => i.UID).ToArray();
for (int i = 0; i < array.Length; i++)
{
if (array[i].UID == client.Entity.UID)
{
Network.GamePackets.GenericRanking PacketRank = new Network.GamePackets.GenericRanking(true);
PacketRank.Mode = Network.GamePackets.GenericRanking.QueryCount;
PacketRank.RankingType = ranking.RankingType;
PacketRank.Append2((uint)(i + 1), array[i].TotalPerfectionScore, array[i].UID, array[i].Name, array[i].Level, array[i].Class, array[i].Mesh);
client.Send(PacketRank.ToArray());
break;
}
}
break;
}
#endregion
if (Flowers.IsGirl((uint)client.Entity.Body))
{
if (client.Entity.MyFlowers != null)
{
int num61 = -1;
uint num62 = Flowers.CreateMyRank(client, out num61);
packet[4] = 5;
client.Send(packet);
client.Entity.FlowerRank = (uint)client.Entity.MyFlowers.SendScreenValue((Game.Features.Flowers.FlowersT)num62, num61);
GenericRanking genericRanking2 = new GenericRanking(true);
genericRanking2.Mode = 2u;
genericRanking2.RankingType = client.Entity.FlowerRank;
genericRanking2.Count = 1u;
int rank = num61;
if (client.Entity.MyFlowers.RankRoses < 100 && client.Entity.MyFlowers.RankRoses > 0)
{
genericRanking2.RankingType = GenericRanking.RoseFairy;
genericRanking2.Append((uint)client.Entity.MyFlowers.RankRoses, client.Entity.MyFlowers.RedRoses, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking2.ToArray());
}
if (client.Entity.MyFlowers.RankLilies < 100 && client.Entity.MyFlowers.RankLilies > 0)
{
genericRanking2.Reset();
genericRanking2.RankingType = GenericRanking.LilyFairy;
genericRanking2.Append((uint)client.Entity.MyFlowers.RankLilies, client.Entity.MyFlowers.Lilies, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking2.ToArray());
}
if (client.Entity.MyFlowers.RankOrchids < 100 && client.Entity.MyFlowers.RankOrchids > 0)
{
genericRanking2.Reset();
genericRanking2.RankingType = GenericRanking.OrchidFairy;
genericRanking2.Append((uint)client.Entity.MyFlowers.RankOrchids, client.Entity.MyFlowers.Orchads, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking2.ToArray());
}
if (client.Entity.MyFlowers.RankTuilps < 100 && client.Entity.MyFlowers.RankTuilps > 0)
{
genericRanking2.Reset();
genericRanking2.RankingType = GenericRanking.TulipFairy;
genericRanking2.Append((uint)client.Entity.MyFlowers.RankTuilps, client.Entity.MyFlowers.Tulips, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking2.ToArray());
}
packet[4] = 5;
client.Send(packet);
break;
}
break;
}
else
{
if (client.Entity.MyFlowers != null)
{
GenericRanking genericRanking3 = new GenericRanking(true);
genericRanking3.Mode = 2u;
genericRanking3.RankingType = 30000402u;
genericRanking3.Count = 1u;
if (client.Entity.MyFlowers.RankRoses < 100 && client.Entity.MyFlowers.RankRoses > 0)
{
genericRanking3.Append((uint)client.Entity.MyFlowers.RankRoses, client.Entity.MyFlowers.RedRoses, client.Entity.UID, client.Entity.Name);
client.Send(genericRanking3.ToArray());
}
if (client.Entity.MyFlowers.RankLilies < 100 && client.Entity.MyFlowers.RankLilies > 0)
{
genericRanking3.Reset();
genericRanking3.Append((uint)client.Entity.MyFlowers.RankLilies, client.Entity.MyFlowers.Lilies, client.Entity.UID, client.Entity.Name);
genericRanking3.RankingType = 30000502u;
client.Send(genericRanking3.ToArray());
}
if (client.Entity.MyFlowers.RankOrchids < 100 && client.Entity.MyFlowers.RankOrchids > 0)
{
genericRanking3.Reset();
genericRanking3.Append((uint)client.Entity.MyFlowers.RankOrchids, client.Entity.MyFlowers.Orchads, client.Entity.UID, client.Entity.Name);
genericRanking3.RankingType = 30000602u;
client.Send(genericRanking3.ToArray());
}
if (client.Entity.MyFlowers.RankTuilps < 100 && client.Entity.MyFlowers.RankTuilps > 0)
{
genericRanking3.Reset();
genericRanking3.Append((uint)client.Entity.MyFlowers.RankTuilps, client.Entity.MyFlowers.Tulips, client.Entity.UID, client.Entity.Name);
genericRanking3.RankingType = 30000702u;
client.Send(genericRanking3.ToArray());
}
packet[4] = 5;
client.Send(packet);
break;
}
}
break;
}
}
}
public static void SendFlower(Client.GameState client, byte[] packet)
{
byte typ1 = packet[4];
uint Target = BitConverter.ToUInt32(packet, 8);
uint ITEM_UID = BitConverter.ToUInt32(packet, 12);
if (IsBoy(client.Entity.Body) && typ1 == 0)//boy send
{
switch (ITEM_UID)
{
case 0://send my flower
{
if (client.Entity.MyFlowers.aFlower == 0) break;
Client.GameState target_client;
if (Kernel.GamePool.TryGetValue(Target, out target_client))
{
if (!IsGirl(target_client.Entity.Body)) return;
// client.Activenes.SendSinglePacket(client, Activeness.Types.FlowerTask, 1);
client.Entity.MyFlowers.aFlower -= 1;
client.Entity.MyFlowers.SendDay = (uint)DateTime.Now.Day;
target_client.Entity.MyFlowers.RedRoses2day += 1;
target_client.Entity.MyFlowers.RedRoses += 1;
SendFlower flow = new SendFlower();
flow.Typing = 0;
flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
flow.Amount = 1;
flow.SenderName = client.Entity.Name;
flow.ReceiverName = target_client.Entity.Name;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
client.SendScreen(flow.ToArray(), true);
Database.Flowers.SaveFlowers();
}
break;
}
default:
{
Network.GamePackets.ConquerItem Item = null;
if (client.Inventory.TryGetItem(ITEM_UID, out Item))
{
Client.GameState target_client;
if (Kernel.GamePool.TryGetValue(Target, out target_client))
{
if (!IsGirl(target_client.Entity.Body)) return;
uint Amount = Item.ID % 1000;
SendFlower flow = new SendFlower();
flow.Typing = typ1;
flow.Amount = Amount;
flow.SenderName = client.Entity.Name;
flow.ReceiverName = target_client.Entity.Name;
if (target_client.Entity.MyFlowers == null) target_client.Entity.MyFlowers = new Game.Features.Flowers(target_client.Entity.UID, target_client.Entity.Name);//abdalhsamy
switch (GetFlowerTyp(Item.ID))
{
case (byte)Game.Features.Flowers.FlowersT.Rouse:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Rouse;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Rouse;
target_client.Entity.MyFlowers.RedRoses2day += Amount;
target_client.Entity.MyFlowers.RedRoses += Amount;
if (Game.Features.Flowers.RedRousesTop100.Length > 98)
{
if (Game.Features.Flowers.RedRousesTop100[98].RedRoses <= target_client.Entity.MyFlowers.RedRoses)
{
Game.Features.Flowers.CulculateRankRouse(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankRouse(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Lilies:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Lilies;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Lilies;
target_client.Entity.MyFlowers.Lilies2day += Amount;
target_client.Entity.MyFlowers.Lilies += Amount;
if (Game.Features.Flowers.LiliesTop100.Length > 98)
{
if (Game.Features.Flowers.LiliesTop100[98].Lilies <= target_client.Entity.MyFlowers.Lilies)
{
Game.Features.Flowers.CulculateRankLilies(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankLilies(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Orchids:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Orchids;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Orchids;
target_client.Entity.MyFlowers.Orchads2day += Amount;
target_client.Entity.MyFlowers.Orchads += Amount;
if (Game.Features.Flowers.OrchidsTop100.Length > 98)
{
if (Game.Features.Flowers.OrchidsTop100[98].Orchads <= target_client.Entity.MyFlowers.Orchads)
{
Game.Features.Flowers.CulculateRankOrchids(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankOrchids(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Tulips:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Tulips;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Tulips;
target_client.Entity.MyFlowers.Tulips2day += Amount;
target_client.Entity.MyFlowers.Tulips += Amount;
if (Game.Features.Flowers.TulipsTop100.Length > 98)
{
if (Game.Features.Flowers.TulipsTop100[98].Tulips <= target_client.Entity.MyFlowers.Tulips)
{
Game.Features.Flowers.CulculateRankTulips(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankTulips(target_client.Entity.MyFlowers);
break;
}
}
client.Inventory.Remove(Item, Enums.ItemUse.Remove);
client.SendScreen(flow.ToArray(), true);
Database.Flowers.SaveFlowers();
}
}
break;
}
}
}
else if (IsGirl(client.Entity.Body) && typ1 == 1)//girl send
{
switch (ITEM_UID)
{
case 0://curent flower
{
if (client.Entity.MyFlowers.aFlower == 0)
return;
Client.GameState target_client;
if (Kernel.GamePool.TryGetValue(Target, out target_client))
{
if (!IsBoy(target_client.Entity.Body)) return;
client.Entity.MyFlowers.aFlower -= 1;
client.Entity.MyFlowers.SendDay = (uint)DateTime.Now.Day;
target_client.Entity.MyFlowers.RedRoses += 1;
target_client.Entity.MyFlowers.RedRoses2day += 1;
SendFlower flow = new SendFlower();
flow.Typing = 1;
flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
flow.Amount = 1;
flow.SenderName = client.Entity.Name;
flow.ReceiverName = target_client.Entity.Name;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
client.SendScreen(flow.ToArray(), true);
Database.Flowers.SaveFlowers();
}
break;
}
default:
{
ConquerItem Item = null;
if (client.Inventory.TryGetItem(ITEM_UID, out Item))
{
Client.GameState target_client = null;
if (Kernel.GamePool.TryGetValue(Target, out target_client))
{
if (!IsBoy(target_client.Entity.Body)) return;
uint Amount = Item.ID % 1000;
SendFlower flow = new SendFlower();
flow.Typing = 1;
flow.Amount = Amount;
flow.SenderName = client.Entity.Name;
flow.ReceiverName = target_client.Entity.Name;
switch (GetFlowerTyp(Item.ID))
{
case (byte)Game.Features.Flowers.FlowersT.Rouse:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Kiss;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Kiss;
target_client.Entity.MyFlowers.RedRoses2day += Amount;
target_client.Entity.MyFlowers.RedRoses += Amount;
if (Game.Features.Flowers.KissTop100.Length > 98)
{
if (Game.Features.Flowers.KissTop100[98].RedRoses <= target_client.Entity.MyFlowers.RedRoses)
{
Game.Features.Flowers.CulculateRankKiss(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankKiss(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Lilies:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.love;
flow.FType = (byte)Game.Features.Flowers.FlowersT.love;
target_client.Entity.MyFlowers.Lilies2day += Amount;
target_client.Entity.MyFlowers.Lilies += Amount;
if (Game.Features.Flowers.LoveTop100.Length > 98)
{
if (Game.Features.Flowers.LoveTop100[98].Lilies <= target_client.Entity.MyFlowers.Lilies)
{
Game.Features.Flowers.CulculateRankLove(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankLove(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Orchids:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Tins;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Tins;
target_client.Entity.MyFlowers.Orchads2day += Amount;
target_client.Entity.MyFlowers.Orchads += Amount;
if (Game.Features.Flowers.TineTop100.Length > 98)
{
if (Game.Features.Flowers.TineTop100[98].Orchads <= target_client.Entity.MyFlowers.Orchads)
{
Game.Features.Flowers.CulculateRankTine(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankTine(target_client.Entity.MyFlowers);
break;
}
case (byte)Game.Features.Flowers.FlowersT.Tulips:
{
flow.Effect = (byte)Game.Features.Flowers.Effect.Jade;
flow.FType = (byte)Game.Features.Flowers.FlowersT.Jade;
target_client.Entity.MyFlowers.Tulips2day += Amount;
target_client.Entity.MyFlowers.Tulips += Amount;
if (Game.Features.Flowers.JadeTop100.Length > 98)
{
if (Game.Features.Flowers.JadeTop100[98].Tulips <= target_client.Entity.MyFlowers.Tulips)
{
Game.Features.Flowers.CulculateRankJade(target_client.Entity.MyFlowers);
}
}
else Game.Features.Flowers.CulculateRankJade(target_client.Entity.MyFlowers);
break;
}
}
client.Inventory.Remove(Item, Enums.ItemUse.Remove);
client.SendScreen(flow.ToArray(), true);
Database.Flowers.SaveFlowers();
}
}
break;
}
}
}
}
public static uint CreateMyRank(Client.GameState client, out int rank)
{
List<ClientRank> FRanks = new List<ClientRank>()
{
new ClientRank(){Rank = (uint)client.Entity.MyFlowers.RankLilies, Amount = client.Entity.MyFlowers.Lilies}
, new ClientRank(){Rank = (uint)client.Entity.MyFlowers.RankOrchids, Amount = client.Entity.MyFlowers.Orchads}
, new ClientRank(){Rank = (uint)client.Entity.MyFlowers.RankRoses, Amount = client.Entity.MyFlowers.RedRoses}
, new ClientRank(){Rank = (uint)client.Entity.MyFlowers.RankTuilps, Amount = client.Entity.MyFlowers.Tulips}
};
var array = FRanks.Where((f1) => f1.Rank != 0).ToArray();
Array.Sort(array, (f1, f2) =>
{
int n_rank = f1.Rank.CompareTo(f2.Rank);
if (f2.Rank == f1.Rank)
return f2.Amount.CompareTo(f1.Amount);
return n_rank;
});
if (array != null && array.Length > 0)
{
ClientRank BestRank = array[0];
if (BestRank.Rank != 0)
{
rank = (int)BestRank.Rank;
if (client.Entity.MyFlowers.RankLilies == BestRank.Rank && client.Entity.MyFlowers.Lilies == BestRank.Amount)
return (byte)Game.Features.Flowers.FlowersT.Lilies;
if (client.Entity.MyFlowers.RankOrchids == BestRank.Rank && client.Entity.MyFlowers.Orchads == BestRank.Amount)
return (byte)Game.Features.Flowers.FlowersT.Orchids;
if (client.Entity.MyFlowers.RankRoses == BestRank.Rank && client.Entity.MyFlowers.RedRoses == BestRank.Amount)
return (byte)Game.Features.Flowers.FlowersT.Rouse;
if (client.Entity.MyFlowers.RankTuilps == BestRank.Rank && client.Entity.MyFlowers.Tulips == BestRank.Amount)
return (byte)Game.Features.Flowers.FlowersT.Tulips;
}
}
rank = 0;
return 0;
}
public static uint GetFlowerTyp(uint ID)
{
if (ID >= 751001 && ID <= 751999 || ID >= 755001 && ID <= 755999)
return (uint)Game.Features.Flowers.FlowersT.Rouse;
if (ID >= 752001 && ID <= 752999 || ID >= 756001 && ID <= 756999)
return (uint)Game.Features.Flowers.FlowersT.Lilies;
if (ID >= 753001 && ID <= 753999 || ID >= 757001 && ID <= 757999)
return (uint)Game.Features.Flowers.FlowersT.Orchids;
if (ID >= 754001 && ID <= 754999 || ID >= 758001 && ID <= 758999)
return (uint)Game.Features.Flowers.FlowersT.Tulips;
return 0;
}
public static bool IsBoy(uint mesh)
{
return mesh == 1003 || mesh == 1004;
}
public static bool IsGirl(uint mesh)
{
return mesh == 2001 || mesh == 2002;
}
public class ClientRank
{
public uint Rank;
public uint Amount;
}
}
}
\Game\ConquerStructures\Society
using System;
using System.Collections.Generic;
using PlayConquer.Network.GamePackets;
using PlayConquer.Network;
using System.IO;
using System.Text;
using System.Linq;
using PlayConquer.Game.Features;
namespace PlayConquer.Game.ConquerStructures.Society
{
public enum ArsenalType
{
Headgear,
Armor,
Weapon,
Ring,
Boots,
Necklace,
Fan,
Tower
}
public enum GuildRank
{
Agent = 590,
Aide = 0x25a,
ArsenalAgent = 0x254,
ArsFollower = 0x1f0,
ASupervisor = 0x358,
CPAgent = 0x255,
CPFollower = 0x1f1,
CPSupervisor = 0x359,
DeputyLeader = 990,
DeputySteward = 650,
DLeaderAide = 0x263,
DLeaderSpouse = 620,
Follower = 490,
GSupervisor = 0x356,
GuideAgent = 0x252,
GuideFollower = 0x1ee,
GuildLeader = 0x3e8,
HDeputyLeader = 980,
HonoraryManager = 880,
HonorarySteward = 680,
HonorarySuperv = 840,
LeaderSpouse = 920,
LilyAgent = 0x24f,
LilyFollower = 0x1eb,
LilySupervisor = 0x353,
LSpouseAide = 610,
Manager = 890,
ManagerAide = 510,
ManagerSpouse = 520,
Member = 200,
None = 0,
OrchidAgent = 0x256,
OrchidFollower = 0x1f2,
OSupervisor = 0x35a,
PKAgent = 0x251,
PKFollower = 0x1ed,
PKSupervisor = 0x355,
RoseAgent = 0x250,
RoseFollower = 0x1ec,
RoseSupervisor = 0x354,
SeniorMember = 210,
SilverAgent = 0x253,
SilverFollower = 0x1ef,
SSupervisor = 0x357,
Steward = 690,
StewardSpouse = 420,
Supervisor = 850,
SupervisorAide = 0x1ff,
SupervSpouse = 0x209,
TSupervisor = 0x35b,
TulipAgent = 0x257,
TulipFollower = 0x1f3
}
public class Guild : Writer
{
public void SendGuildLevel()
{
foreach (var Arsenal in Arsenals)
{
TotalDonation += Arsenal.Donation;
}
if (TotalDonation < 5000000)
{
GuildLevel = 1;
}
else if ((TotalDonation >= 5000000) && (TotalDonation < 10000000))
{
GuildLevel = 2;
}
else if ((TotalDonation >= 10000000) && (TotalDonation < 15000000))
{
GuildLevel = 3;
}
else if ((TotalDonation >= 15000000) && (TotalDonation < 20000000))
{
GuildLevel = 4;//Py*keka
}
else if ((TotalDonation >= 20000000) && (TotalDonation < 25000000))
{
GuildLevel = 5;
}
else if ((TotalDonation >= 30000000) && (TotalDonation < 35000000))
{
GuildLevel = 6;
}
else if ((TotalDonation >= 35000000) && (TotalDonation < 40000000))
{
GuildLevel = 7;
}
else if ((TotalDonation >= 40000000) && (TotalDonation < 50000000))
{
GuildLevel = 8;
}
else if (TotalDonation >= 50000000)
{
GuildLevel = 9;
}
}*
public class Advertise
{
public static System.Collections.Concurrent.ConcurrentDictionary<uint, Guild> AGuilds = new System.Collections.Concurrent.ConcurrentDictionary<uint, Guild>();
public static Guild[] AdvertiseRanks = new Guild[0];
public static void Add(Guild obj)
{
if (!AGuilds.ContainsKey(obj.ID))
AGuilds.TryAdd(obj.ID, obj);
CalculateRanks();
}
public static void CalculateRanks()
{
lock (AdvertiseRanks)
{
Guild[] array = AGuilds.Values.ToArray();
array = (from guil in array orderby guil.AdvertiseRecruit.Donations descending select guil).ToArray();
List<Guild> listarray = new List<Guild>();
for (ushort x = 0; x < array.Length; x++)
{
listarray.Add(array[x]);
if (x == 40) break;
}
AdvertiseRanks = listarray.ToArray();
}
}
public static void FixedRank()
{
AGuilds.Clear();
foreach (var guil in AdvertiseRanks)
{
AGuilds.TryAdd(guil.ID, guil);
}
}
}
public class Recruitment
{
public Recruitment()
{
NotAllowFlag = 0;
}
public enum Mode
{
Requirements, Recruit
}
public class Flags
{
public const int
NoneBlock = 0,
Trojan = 1,
Warrior = 2,
Taoist = 4,
Archas = 8,
Ninja = 16,
Monk = 32,
Pirate = 64;
}
public bool AutoJoin = true;
public string Buletin = "Nothing";
public int NotAllowFlag;
public byte Level = 0;
public byte Reborn = 0;
public byte Grade = 0;
public ulong Donations = 0;
public bool ContainFlag(int val)
{
return (NotAllowFlag & val) == val;
}
public void AddFlag(int val)
{
if (!ContainFlag(val))
NotAllowFlag |= val;
}
public void Remove(int val)
{
if (ContainFlag(val))
NotAllowFlag &= ~val;
}
public void SetFlag(int m_flag, Mode mod)
{
switch (mod)
{
case Mode.Requirements:
{
if (m_flag == 0) NotAllowFlag = Flags.NoneBlock;
if (m_flag >= 127)
AddFlag(Flags.Trojan | Flags.Warrior | Flags.Taoist | Flags.Archas | Flags.Ninja | Flags.Monk | Flags.Pirate);
int n_flag = 127 - m_flag;
AddFlag(n_flag);
break;
}
case Mode.Recruit:
{
if (m_flag == 0) NotAllowFlag = Flags.NoneBlock;
AddFlag(m_flag);
break;
}
}
}
public bool Compare(Game.Entity Entity, Mode mod)
{
if (Entity.Level < Level)
return false;
if (Entity.Reborn < Reborn && Reborn != 0)
return false;
if (Database.DataHolder.IsArcher(Entity.Class) && ContainFlag(Flags.Archas))
return false;
if (Database.DataHolder.IsTaoist(Entity.Class) && ContainFlag(Flags.Taoist))
return false;
if (Database.DataHolder.IsWarrior(Entity.Class) && ContainFlag(Flags.Warrior))
return false;
if (Database.DataHolder.IsTrojan(Entity.Class) && ContainFlag(Flags.Trojan))
return false;
if (Database.DataHolder.IsPirate(Entity.Class) && ContainFlag(Flags.Pirate))
return false;
if (Database.DataHolder.IsMonk(Entity.Class) && ContainFlag(Flags.Monk))
return false;
if (Database.DataHolder.IsNinja(Entity.Class) && ContainFlag(Flags.Ninja))
return false;
//if (Database.DataHolder.IsWinwalker(Entity.Class) && ContainFlag(Flags.IsWinwalker))
// return false;
//if (Database.DataHolder.IsDragonWarrior(Entity.Class) && ContainFlag(Flags.IsDragonWarrior))
// return false;
if (mod == Mode.Recruit)
{
if (Grade == 0) return true;
}
return true;
}
public override string ToString()
{
StringBuilder build = new StringBuilder();
build.Append(NotAllowFlag + "^" + Level + "^" + Reborn + "^" + Grade + "^" + Donations + "^"
+ (byte)(AutoJoin ? 1 : 0) + "^" + Buletin + "^0" + "^0");
return build.ToString();
}
public bool WasLoad = false;
public void Load(string line)
{
if (line == null)
return;
if (line == "") return;
if (!line.Contains('^')) return;
string[] data = line.Split('^');
NotAllowFlag = int.Parse(data[0]);
Level = byte.Parse(data[1]);
Reborn = byte.Parse(data[2]);
Grade = byte.Parse(data[3]);
Donations = ulong.Parse(data[4]);
AutoJoin = byte.Parse(data[5]) == 1;
Buletin = data[6];
WasLoad = true;
}
public void Save()
{
}
}
public Member[] RankSilversDonations = new Member[0];
public Member[] RankArsenalDonations = new Member[0];
public Member[] RankCPDonations = new Member[0];
public Member[] RankPkDonations = new Member[0];
public Member[] RankLiliesDonations = new Member[0];
public Member[] RankOrchidsDonations = new Member[0];
public Member[] RankRosseDonations = new Member[0];
public Member[] RankTulipsDonations = new Member[0];
public Member[] RankGuideDonations = new Member[0];
public Member[] RankTotalDonations = new Member[0];
public ushort[] RanksCounts = new ushort[(ushort)Enums.GuildMemberRank.GuildLeader + 1];
public class ClassRequirements
{
public const uint
Trojan = 1,
Warrior = 2,
Taoist = 4,
Archer = 8,
Ninja = 16,
Monk = 32,
Pirate = 64;
}
public Arsenal[] Arsenals;
public List<uint> BlackList = new List<uint>();
public bool ArsenalBPChanged = true;
public int UnlockedArsenals
{
get
{
int unlocked = 0;
for (int i = 0; i < 8; i++)
if (Arsenals[i].Unlocked)
unlocked++;
return unlocked;
}
}
public uint GetCurrentArsenalCost()
{
int val = UnlockedArsenals;
if (val >= 0 && val <= 1)
return 5000000;
else if (val >= 2 && val <= 4)
return 10000000;
else if (val >= 5 && val <= 6)
return 15000000;
else
return 20000000;
}
int arsenal_bp;
public override int GetHashCode()
{
return (int)ID;
}
public int ArsenalTotalBattlepower
{
get { return arsenal_bp; }
set
{
arsenal_bp = value;
foreach (var member in Members.Values)
{
if (member.IsOnline)
{
member.Client.Entity.GuildBattlePower = GetSharedBattlepower(member.Rank);
}
}
}
}
public int GetMaxSharedBattlepower(bool force = false)
{
if (ArsenalBPChanged || force)
{
int a_bp = 0;
var arsenals = Arsenals.OrderByDescending(p => p.TotalSharedBattlePower);
int a = 0;
foreach (var arsenal in arsenals)
{
if (a == 5) break;
a_bp += (int)(arsenal.TotalSharedBattlePower);
a++;
}
ArsenalTotalBattlepower = a_bp;
ArsenalBPChanged = false;
byte lev = 1;
foreach (var getlev in arsenals)
if (getlev.TotalSharedBattlePower >= 2)
lev++;
Level = lev;
}
return arsenal_bp;
}
public uint GetMemberPotency(Enums.GuildMemberRank RankMember)
{
uint GetArsenalPotency = (uint)arsenal_bp;
return GetArsenalPotency;
//if (RankMember == Enums.GuildMemberRank.GuildLeader || RankMember == Enums.GuildMemberRank.LeaderSpouse || RankMember == Enums.GuildMemberRank.DeputyLeader )
// return GetArsenalPotency;
//if (RankMember == Enums.GuildMemberRank.HDeputyLeader)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 90 / 100));
//if (RankMember == Enums.GuildMemberRank.Manager || RankMember == Enums.GuildMemberRank.HonoraryManager
// || RankMember == Enums.GuildMemberRank.Supervisor)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 80 / 100));
//if ((ushort)RankMember <= 859 && (ushort)RankMember >= 850 || RankMember == Enums.GuildMemberRank.ASupervisor || RankMember == Enums.GuildMemberRank.HonorarySuperv)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 70 / 100));
//if (RankMember == Enums.GuildMemberRank.Steward || RankMember == Enums.GuildMemberRank.DLeaderSpouse
// || RankMember == Enums.GuildMemberRank.DLeaderAide)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 50 / 100));
//if (RankMember == Enums.GuildMemberRank.DeputySteward)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 40 / 100));
//if (RankMember == Enums.GuildMemberRank.Agent || (ushort)RankMember <= 599 && (ushort)RankMember >= 590
// || RankMember == Enums.GuildMemberRank.SSupervisor || RankMember == Enums.GuildMemberRank.ManagerSpouse
// || RankMember == Enums.GuildMemberRank.SupervisorAide || RankMember == Enums.GuildMemberRank.ManagerAide)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 30 / 100));
//if (RankMember == Enums.GuildMemberRank.StewardSpouse || RankMember == Enums.GuildMemberRank.SeniorMember)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 15 / 100));
//if (RankMember == Enums.GuildMemberRank.Member)
// return (uint)Math.Ceiling((double)(GetArsenalPotency * 10 / 100));
//return (uint)Math.Ceiling((double)(GetArsenalPotency * 20 / 100));//Fallower
}
public uint GetSharedBattlepower(int rank)
{
return GetMemberPotency((Enums.GuildMemberRank)rank);//(uint)(arsenal_bp * SharedBattlepowerPercentage[rank / 100]);
}
public uint GetSharedBattlepower(Enums.GuildMemberRank rank)
{
return GetSharedBattlepower((int)rank);
}
public void SaveArsenal()
{
Database.GuildArsenalTable.Save(this);
}
public static Counter GuildCounter;
public int GuildLevel;
public uint TotalDonation;*
public static void GuildProfile(byte[] Packet, Client.GameState client)
{
GuildProfilePacket p = new GuildProfilePacket();
p.Deserialize(Packet);
p.Silver = 0;
p.Pk = client.Entity.PKPoints;
p.Cps = 0;
p.Guide = 0;
p.Arsenal = 0;
p.Rose = 0;
p.Lily = 0;
p.Orchid = 0;
p.Tulip = 0;
p.HistorySilvers = 0;
p.HistoryCps = 0;
p.HistoryGuide = 0;
p.HistoryPk = 0;
client.Send(Packet);
}
public class Member //: Interfaces.IKnownPerson
{
public Member(uint GuildID)
{
this.GuildID = GuildID;
}
public uint ExploitsRank = 0;
public uint Exploits = 0;
public uint ID
{
get;
set;
}
public string Name
{
get;
set;
}
public string Spouse;
public bool IsOnline
{
get
{
return Kernel.GamePool.ContainsKey(ID);
}
}
public Client.GameState Client
{
get
{
if (!IsOnline) return null;
return Kernel.GamePool[ID];
}
}
public ulong SilverDonation
{
get;
set;
}
public ulong ConquerPointDonation
{
get;
set;
}
public ulong LastLogin = 0;
public uint GuildID
{
get;
set;
}
public Guild Guild
{
get
{
return Kernel.Guilds[GuildID];
}
}
public Enums.GuildMemberRank Rank
{
get;
set;
}
public byte Level
{
get;
set;
}
public NobilityRank NobilityRank
{
get;
set;
}
public byte Gender
{
get;
set;
}
public uint Mesh = 0;
public byte Class;
public uint VirtutePointes;
public uint Lilies;
public uint Rouses;
public uint Orchids;
public uint Tulips;
public uint ArsenalDonation;
public uint PkDonation;
public uint TotalDonation { get { return (uint)(Lilies + Orchids + Tulips + Rouses + ConquerPointDonation + VirtutePointes + (uint)SilverDonation + ArsenalDonation + PkDonation); } }
public uint CTFSilverReward = 0;
public uint CTFCpsReward = 0;
public uint WarScore;
}
private byte[] Buffer;
public uint GuildScoreWar;
public uint WarScore;
public uint sWarScore;
public bool PoleKeeper
{
get
{
return GuildWar.Pole.Name == Name;
}
}
public bool PoleKeeper2
{
get
{
return EliteGuildWar.Poles.Name == Name;
}
}
public Guild(string leadername)
{
Buffer = new byte[92 + 8];
LeaderName = leadername;
Writer.WriteUInt16(92, 0, Buffer);
Writer.WriteUInt16(1106, 2, Buffer);
Buffer[48] = 0x2;
LevelRequirement = 1;
Members = new SafeDictionary<uint, Member>(1000);
Ally = new SafeDictionary<uint, Guild>(1000);
Enemy = new SafeDictionary<uint, Guild>(1000);
Arsenals = new Arsenal[8];
for (byte i = 0; i < 8; i++)
{
Arsenals[i] = new Arsenal(this)
{
Position = (byte)(i + 1)
};
}
AdvertiseRecruit = new Recruitment();
}
public uint CTFdonationCPs = 0;
public uint CTFdonationSilver = 0;
public uint CTFdonationCPsold = 0;
public uint CTFdonationSilverold = 0;
public void CalculateCTFRANK(bool create_Entitys_reward = false)
{
var rank_ctf = Members.Values.Where(p => p.Exploits != 0).OrderByDescending(p => p.Exploits).ToArray();
for (ushort x = 0; x < rank_ctf.Length; x++)
{
var a_mem = rank_ctf[x];
var mem = Members[a_mem.ID];
mem.ExploitsRank = (uint)(x + 1);
if (create_Entitys_reward)
{
uint[] RewardCTF = CalculateRewardCTF(mem.ExploitsRank);
mem.CTFSilverReward = RewardCTF[0];
mem.CTFCpsReward = RewardCTF[1];
}
}
}
private uint[] CalculateRewardCTF(uint Rank)
{
uint[] rew = new uint[2];
rew[0] = (CTFdonationSilverold / (Rank + 1));
rew[1] = (CTFdonationCPsold / (Rank + 1));
return rew;
}
public Recruitment AdvertiseRecruit;
public void CreateMembersRank()
{
lock (this)
{
//remove all ranks
foreach (Member memb in Members.Values)
{
if ((ushort)memb.Rank < 920)
{
if (RanksCounts[(ushort)memb.Rank] > 0)
RanksCounts[(ushort)memb.Rank]--;
memb.Rank = Enums.GuildMemberRank.Member;
RanksCounts[(ushort)memb.Rank]++;
}
}
Member[] Poll = null;
//calculate manager`s
const byte MaxMannager = 5;//0,1,2,3,4
const byte MaxHonorManager = 2;//5,6,
const byte MaxSupervisor = 2;//7,8,
const byte MaxSteward = 4;//9,10,11,12
const byte MaxArsFollower = 2;//13,14
byte amount = 0;//8
Poll = (from memb in Members.Values orderby memb.ArsenalDonation descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.Manager)
continue;
if (amount < MaxMannager)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.Manager;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxMannager + MaxHonorManager)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.HonoraryManager;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxHonorManager + MaxMannager + MaxSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.Supervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxHonorManager + MaxMannager + MaxSupervisor + MaxSteward)
{
if (membru.Rank > Enums.GuildMemberRank.Steward)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.Steward;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxHonorManager + MaxMannager + MaxSupervisor + MaxSteward + MaxArsFollower)
{
if (membru.Rank > Enums.GuildMemberRank.ArsFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.ArsFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankArsenalDonations = Poll.ToArray();
//calculate rank cps
const byte MaxCPSupervisor = 3;//0,1,2
const byte MaxCpAgent = 2;//3,4
const byte MaxCpFollower = 2;//5,6
amount = 0;//3
Poll = (from memb in Members.Values orderby memb.ConquerPointDonation descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.CPSupervisor)
continue;
if (amount < MaxCPSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.CPSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxCPSupervisor + MaxCpAgent)
{
if (membru.Rank > Enums.GuildMemberRank.CPAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.CPAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxCPSupervisor + MaxCpAgent + MaxCpFollower)
{
if (membru.Rank > Enums.GuildMemberRank.CPFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.CPFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankCPDonations = Poll.ToArray();
//calculate pk ranks
const byte MaxPkSupervisor = 3;//0,1,2
const byte MaxPkAgent = 2;//3,4,
const byte MaxPkFollower = 2;//5,6
amount = 0;//3
Poll = (from memb in Members.Values orderby memb.PkDonation descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.PKSupervisor)
continue;
if (amount < MaxPkSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.PKSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxPkSupervisor + MaxPkAgent)
{
if (membru.Rank > Enums.GuildMemberRank.PKAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.PKAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxPkSupervisor + MaxPkAgent + MaxPkFollower)
{
if (membru.Rank > Enums.GuildMemberRank.PKFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.PKFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankPkDonations = Poll.ToArray();
//calculate RoseSupervisor
const byte MaxRoseSupervisor = 3;//0,1,2
const byte MaxRoseAgent = 2;//3,4
const byte MaxRoseFollower = 2;//5,6
amount = 0;//3
Poll = (from memb in Members.Values orderby memb.Rouses descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.RoseSupervisor)
continue;
if (amount < MaxRoseSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.RoseSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxRoseSupervisor + MaxRoseAgent)
{
if (membru.Rank > Enums.GuildMemberRank.RoseAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.RoseAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxRoseSupervisor + MaxRoseAgent + MaxRoseFollower)
{
if (membru.Rank > Enums.GuildMemberRank.RoseFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.RoseFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankRosseDonations = Poll.ToArray();
//calculate LilySupervisor
const byte MaxLilySupervisor = 3;
const byte MaxLilyAgent = 2;
const byte MaxLilyFollower = 2;
amount = 0;//3
Poll = (from memb in Members.Values orderby memb.Lilies descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.LilySupervisor)
continue;
if (amount < MaxLilySupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.LilySupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxLilySupervisor + MaxLilyAgent)
{
if (membru.Rank > Enums.GuildMemberRank.LilyAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.LilyAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxLilySupervisor + MaxLilyAgent + MaxLilyFollower)
{
if (membru.Rank > Enums.GuildMemberRank.LilyFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.LilyFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankLiliesDonations = Poll.ToArray();
//calculate TulipAgent
const byte MaxTSupervisor = 3;
const byte MaxTulipAgent = 2;
const byte MaxTulupFollower = 2;
amount = 0;//3
Poll = (from memb in Members.Values orderby memb.Tulips descending select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.TSupervisor)
continue;
if (amount < MaxTSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.TSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxTSupervisor + MaxTulipAgent)
{
if (membru.Rank > Enums.GuildMemberRank.TulipAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.TulipAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxTSupervisor + MaxTulipAgent + MaxTulupFollower)
{
if (membru.Rank > Enums.GuildMemberRank.TulipFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.TulipFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankTulipsDonations = Poll.ToArray();
// calculate OrchidAgent
const byte MaxOSupervisor = 3;
const byte MaxOrchidAgent = 2;
const byte MaxOrchidFollower = 2;
amount = 0;//3
Poll = (from memb in Members.Values
orderby memb.Tulips descending
select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.OSupervisor)
continue;
if (amount < MaxOSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.OSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxOSupervisor + MaxOrchidAgent)
{
if (membru.Rank > Enums.GuildMemberRank.OrchidAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.OrchidAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < MaxOSupervisor + MaxOrchidFollower + MaxOrchidAgent)
{
if (membru.Rank > Enums.GuildMemberRank.OrchidFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.OrchidFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankOrchidsDonations = Poll.ToArray();
Poll = (from memb in Members.Values
orderby memb.TotalDonation descending
select memb).ToArray();
const byte HDeputyLeader = 2;//0,1
const byte MaxHonorarySteward = 2;//2,3
amount = 0;//20
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.HDeputyLeader)
continue;
if (amount < HDeputyLeader)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.HDeputyLeader;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < HDeputyLeader + MaxHonorarySteward)
{
if (membru.Rank > Enums.GuildMemberRank.HonorarySteward)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.HonorarySteward;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankTotalDonations = Poll.ToArray();
const byte SSupervisor = 5;//0,1,2,3
const byte MaxSilverAgent = 2;//4,5
const byte MaxSilverFollowr = 2;//6,7
amount = 0;//20
Poll = (from memb in Members.Values
orderby memb.SilverDonation descending
select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.SSupervisor)
continue;
if (amount < SSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.SSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < SSupervisor + MaxSilverAgent)
{
if (membru.Rank > Enums.GuildMemberRank.SilverAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.SilverAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < SSupervisor + MaxSilverAgent + MaxSilverFollowr)
{
if (membru.Rank > Enums.GuildMemberRank.SilverFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.SilverFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankSilversDonations = Poll.ToArray();
const byte GSupervisor = 3;//0,1,2
const byte MaxGAgent = 2;//3,4
const byte MaxGFollower = 2;//5,6
amount = 0;//20
Poll = (from memb in Members.Values
orderby memb.VirtutePointes descending
select memb).ToArray();
for (byte x = 0; x < Poll.Length; x++)
{
Member membru = Poll[x];
if (membru.Rank > Enums.GuildMemberRank.GSupervisor)
continue;
if (amount < GSupervisor)
{
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.GSupervisor;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < GSupervisor + MaxGAgent)
{
if (membru.Rank > Enums.GuildMemberRank.GuideAgent)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.GuideAgent;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else if (amount < GSupervisor + MaxGAgent + MaxGFollower)
{
if (membru.Rank > Enums.GuildMemberRank.GuideFollower)
continue;
if (RanksCounts[(ushort)membru.Rank] > 0)
RanksCounts[(ushort)membru.Rank]--;
membru.Rank = Enums.GuildMemberRank.GuideFollower;
RanksCounts[(ushort)membru.Rank]++;
amount++;
}
else
break;
}
RankGuideDonations = Poll.ToArray();
}
}
public uint ID
{
get { return BitConverter.ToUInt32(Buffer, 4); }
set { Writer.WriteUInt32(value, 4, Buffer); }
}
public ulong SilverFund
{
get { return BitConverter.ToUInt64(Buffer, 12); }
set { Writer.WriteUInt64(value, 12, Buffer); }
}
public uint ConquerPointFund
{
get { return BitConverter.ToUInt32(Buffer, 20); }
set { Writer.WriteUInt32(value, 20, Buffer); }
}
public uint MemberCount
{
get { return BitConverter.ToUInt32(Buffer, 24); }
set { Writer.WriteUInt32(value, 24, Buffer); }
}
public uint LevelRequirement
{
get { return BitConverter.ToUInt32(Buffer, 48); }
set { Writer.WriteUInt32(value, 48, Buffer); }
}
public bool GetMember(string name, out Member
getmem)
{
foreach (Member mem in Members.Values)
{
if (mem.Name == name)
{
getmem = mem;
return true;
}
}
getmem = null; return false;
}
public uint RebornRequirement
{
get { return BitConverter.ToUInt32(Buffer, 52); }
set { Writer.WriteUInt32(value, 52, Buffer); }
}
public uint ClassRequirement
{
get { return BitConverter.ToUInt32(Buffer, 56); }
set { Writer.WriteUInt32(value, 56, Buffer); }
}
public bool AllowTrojans
{
get
{
return ((ClassRequirement & ClassRequirements.Trojan) != ClassRequirements.Trojan);
}
set
{
ClassRequirement ^= ClassRequirements.Trojan;
}
}
public bool AllowWarriors
{
get
{
return ((ClassRequirement & ClassRequirements.Warrior) != ClassRequirements.Warrior);
}
set
{
ClassRequirement ^= ClassRequirements.Warrior;
}
}
public bool AllowTaoists
{
get
{
return ((ClassRequirement & ClassRequirements.Taoist) != ClassRequirements.Taoist);
}
set
{
ClassRequirement ^= ClassRequirements.Taoist;
}
}
public bool AllowArchers
{
get
{
return ((ClassRequirement & ClassRequirements.Archer) != ClassRequirements.Archer);
}
set
{
ClassRequirement ^= ClassRequirements.Archer;
}
}
public bool AllowNinjas
{
get
{
return ((ClassRequirement & ClassRequirements.Ninja) != ClassRequirements.Ninja);
}
set
{
ClassRequirement ^= ClassRequirements.Ninja;
}
}
public bool AllowMonks
{
get
{
return ((ClassRequirement & ClassRequirements.Monk) != ClassRequirements.Monk);
}
set
{
ClassRequirement ^= ClassRequirements.Monk;
}
}
public bool AllowPirates
{
get
{
return ((ClassRequirement & ClassRequirements.Pirate) != ClassRequirements.Pirate);
}
set
{
ClassRequirement ^= ClassRequirements.Pirate;
}
}
public byte Level
{
get { return Buffer[60]; }
set { Buffer[60] = value; }
/*
get
{
if (Losts == 0)
return Buffer[60];
else
return 0;
}
set
{
Buffer[60] = 0;
if (Losts == 0)
Buffer[60] = (byte)(Math.Min(Wins, 100));
}*/
}
public string Name;
public SafeDictionary<uint, Member> Members = new SafeDictionary<uint, Member>();
public SafeDictionary<uint, Guild> Ally = new SafeDictionary<uint, Guild>();
public SafeDictionary<uint, Guild> Enemy = new SafeDictionary<uint, Guild>();
public uint Wins;
public uint Losts;
public uint cp_donaion = 0;
public ulong money_donation = 0;
public uint honor_donation = 0;
public uint pkp_donation = 0;
public uint rose_donation = 0;
public uint tuil_donation = 0;
public uint orchid_donation = 0;
public uint lilies_donation = 0;
public string Bulletin;
public Member Leader;
private string leaderName;
public uint EWarScore;
public uint PTScore;
public uint DCScore;
public uint DPScore;
public uint PIScore;
public uint PPScore;
public uint APScore;
public uint CTFPoints;
public uint CTFReward = 0;
public uint CTFFlagScore;
public string LeaderName
{
get
{
return leaderName;
}
set
{
leaderName = value;
Writer.WriteString(value, 32, Buffer);
}
}
public static Boolean CheckNameExist(String Name)
{
foreach (Guild guilds in Kernel.Guilds.Values)
{
if (guilds.Name == Name)
return true;
}
return false;
}
public bool Create(string name)
{
if (name.Length < 16)
{
Name = name;
SilverFund = 500000;
Members.Add(Leader.ID, Leader);
try
{
Database.GuildTable.Create(this);
}
catch { return false; }
Kernel.Guilds.Add(ID, this);
Message message = null;
message = new Message("Congratulations, " + leaderName + " has created guild " + name + " Succesfully!", System.Drawing.Color.White, Message.World);
foreach (Client.GameState client in Program.Values)
{
client.Send(message);
}
CreateTime();
return true;
}
return false;
}
public uint GuildEnrole = 0;
public uint BuletinEnrole = 0;
public uint UnionID;
public void CreateBuletinTime(uint Time = 0)
{
if (Time == 0)
{
var timers = DateTime.Now;
Time = GetTime((uint)timers.Year, (uint)timers.Month, (uint)timers.Day);
Database.GuildTable.SaveEnroles(this);
}
BuletinEnrole = Time;
}
public void CreateTime(uint Time = 0)
{
if (Time == 0)
{
var timers = DateTime.Now;
Time = GetTime((uint)timers.Year, (uint)timers.Month, (uint)timers.Day);
Database.GuildTable.SaveEnroles(this);
}
GuildEnrole = Time;
Writer.WriteUInt32(Time, 67, Buffer);
}
public uint GetTime(uint year, uint month, uint day)
{
uint Timer = year * 10000 + month * 100 + day;
return Timer;
}
public void AddMember(Client.GameState client)
{
if (client.AsMember == null && client.Guild == null)
{
client.AsMember = new Member(ID)
{
ID = client.Entity.UID,
Level = client.Entity.Level,
Name = client.Entity.Name,
Rank = PlayConquer.Game.Enums.GuildMemberRank.Member,
Mesh = client.Entity.Mesh
};
if (Nobility.Board.ContainsKey(client.Entity.UID))
{
client.AsMember.Gender = Nobility.Board[client.Entity.UID].Gender;
client.AsMember.NobilityRank = Nobility.Board[client.Entity.UID].Rank;
}
MemberCount++;
client.Guild = this;
client.Entity.GuildID = (ushort)client.Guild.ID;
client.Entity.GuildRank = (ushort)client.AsMember.Rank;
client.Entity.GuildBattlePower = GetSharedBattlepower(client.AsMember.Rank);
for (int i = 0; i < client.ArsenalDonations.Length; i++)
client.ArsenalDonations[i] = 0;
Database.EntityTable.UpdateGuildID(client);
Database.EntityTable.UpdateGuildRank(client);
Members.Add(client.Entity.UID, client.AsMember);
SendGuild(client);
client.Screen.FullWipe();
client.Screen.Reload(null);
SendGuildMessage(new Message(client.AsMember.Name + " has joined our guild.", System.Drawing.Color.Black, Message.Guild));
Network.GamePackets.GuildMinDonations mindonation = new GuildMinDonations(31);
mindonation.AprendGuild(this);
client.Send(mindonation.ToArray());
}
}
public void SendMembers(Client.GameState client, ushort page)
{
MemoryStream strm = new MemoryStream();
BinaryWriter wtr = new BinaryWriter(strm);
wtr.Write((ushort)0);
wtr.Write((ushort)2102);
wtr.Write((uint)0);
wtr.Write((uint)page);
int left = (int)MemberCount - page;
if (left > 12)
left = 12;
if (left < 0)
left = 0;
wtr.Write((uint)left);
int count = 0;
int maxmem = page + 12;
int minmem = page;
List<Member> online = new List<Member>(250);
List<Member> offline = new List<Member>(250);
foreach (Member member in Members.Values)
{
if (member.IsOnline)
online.Add(member);
else
offline.Add(member);
}
var unite = online.Union<Member>(offline);
foreach (Member member in unite)
{
if (count >= minmem && count < maxmem)
{
wtr.Write((uint)0);
for (int i = 0; i < 16; i++)
{
if (i < member.Name.Length)
{
wtr.Write((byte)member.Name[i]);
}
else
wtr.Write((byte)0);
}
wtr.Write((uint)(member.IsOnline ? 1 : 0));
wtr.Write((uint)member.NobilityRank);
if (member.Gender == 3) wtr.Write((uint)(member.Gender - 2));
else wtr.Write((uint)(member.Gender + 1));
wtr.Write((uint)member.Level);
wtr.Write((uint)member.Rank);
wtr.Write((uint)0);
wtr.Write((uint)member.TotalDonation);
wtr.Write((uint)0);
if (member.IsOnline)
wtr.Write((uint)Client.GameState.GetClientFromID(member.ID).Entity.TotalPerfectionScore);
else
{
if (MsgUserAbilityScore.RankingList.Values.Where(i => i.UID == member.ID).Count() != 0)
{
wtr.Write((uint)MsgUserAbilityScore.RankingList.Values.Where(i => i.UID == member.ID).FirstOrDefault().TotalPerfectionScore);
}
else
{
wtr.Write((uint)0);
}
}
wtr.Write((uint)member.Class);
wtr.Write((uint)(PacketHandler.UnixTimestamp - member.LastLogin));
wtr.Write((uint)0);
}
count++;
}
int packetlength = (int)strm.Length;
strm.Position = 0;
wtr.Write((ushort)packetlength);
strm.Position = strm.Length;
wtr.Write(ASCIIEncoding.ASCII.GetBytes("TQServer"));
strm.Position = 0;
byte[] buf = new byte[strm.Length];
strm.Read(buf, 0, buf.Length);
wtr.Close();
strm.Close();
client.Send(buf);
}
public void SendGuildMessage(Interfaces.IPacket message)
{
foreach (Member member in Members.Values)
{
if (member.IsOnline)
{
member.Client.Send(message);
}
}
}
public Member GetMemberByName(string membername)
{
foreach (Member member in Members.Values)
{
if (member.Name == membername)
{
return member;
}
}
return null;
}
public void ExpelMember(string membername, bool ownquit)
{
Member member = GetMemberByName(membername);
if (member != null)
{
if (member.IsOnline)
PacketHandler.UninscribeAllItems(member.Client);
else
foreach (var arsenal in Arsenals)
arsenal.RemoveInscribedItemsBy(member.ID);
if (ownquit)
SendGuildMessage(new Message(member.Name + " has quit our guild.", System.Drawing.Color.Black, Message.Guild));
else
SendGuildMessage(new Message(member.Name + " have been expelled from our guild.", System.Drawing.Color.Black, Message.Guild));
uint uid = member.ID;
if (member.Rank == Enums.GuildMemberRank.DeputyLeader)
RanksCounts[(ushort)Game.Enums.GuildMemberRank.DeputyLeader]--;
if (member.IsOnline)
{
GuildCommand command = new GuildCommand(true);
command.Type = GuildCommand.Disband;
command.dwParam = ID;
member.Client.Send(command);
member.Client.AsMember = null;
member.Client.Guild = null;
member.Client.Entity.GuildID = (ushort)0;
member.Client.Entity.GuildRank = (ushort)0;
member.Client.Screen.FullWipe();
member.Client.Screen.Reload(null);
member.Client.Entity.GuildBattlePower = 0;
}
else
{
member.GuildID = 0;
Database.EntityTable.UpdateData(member.ID, "GuildID", 0);
}
MemberCount--;
Members.Remove(uid);
}
}
public void Disband()
{
var members = Members.Values.ToArray();
foreach (Member member in members)
{
uint uid = member.ID;
if (member.IsOnline)
{
PacketHandler.UninscribeAllItems(member.Client);
member.Client.Entity.GuildBattlePower = 0;
GuildCommand command = new GuildCommand(true);
command.Type = GuildCommand.Disband;
command.dwParam = ID;
member.Client.Entity.GuildID = 0;
member.Client.Entity.GuildRank = 0;
member.Client.Send(command);
member.Client.Screen.FullWipe();
member.Client.Screen.Reload(null);
member.Client.AsMember = null;
member.Client.Guild = null;
Message message = null;
message = new Message("guild " + Name + " has been Disbanded!", System.Drawing.Color.White, Message.World);
foreach (Client.GameState client in Program.Values)
{
client.Send(message);
}
}
else
{
foreach (var arsenal in Arsenals)
arsenal.RemoveInscribedItemsBy(member.ID);
member.GuildID = 0;
Database.EntityTable.UpdateData(member.ID, "GuildID", 0);
}
MemberCount--;
Members.Remove(uid);
}
var ally_ = Ally.Values.ToArray();
foreach (Guild ally in ally_)
{
RemoveAlly(ally.Name);
ally.RemoveAlly(Name);
}
Database.GuildTable.Disband(this);
Kernel.GamePool.Remove(ID);
}
public void AddAlly(string name)
{
foreach (Guild guild in Kernel.Guilds.Values)
{
if (guild.Name == name)
{
/*if (Enemy.ContainsKey(guild.ID))
RemoveEnemy(guild.Name);
if (!Ally.ContainsKey(guild.ID))
{
Database.GuildTable.AddAlly(this, guild.ID);
Ally.Add(guild.ID, guild);
_String stringPacket = new _String(true);
stringPacket.UID = guild.ID;
stringPacket.Type = _String.GuildAllies;
stringPacket.Texts.Add(guild.Name + " " + guild.LeaderName + " " + guild.Level + " " + guild.MemberCount);
SendGuildMessage(stringPacket);
}
return;*/
if (this.Enemy.ContainsKey(guild.ID))
{
this.RemoveEnemy(guild.Name);
}
this.Ally.Add(guild.ID, guild);
_String message = new _String(true)
{
UID = guild.ID,
Type = 0x15
};
message.Texts.Add(string.Concat(new object[] { guild.Name, " ", guild.LeaderName, " 0 ", guild.MemberCount }));
this.SendGuildMessage(message);
this.SendGuildMessage(message);
Database.GuildTable.AddAlly(this, guild.ID);
return;
}
}
}
public void RemoveAlly(string name)
{
foreach (Guild guild in Ally.Values)
{
if (guild.Name == name)
{
GuildCommand cmd = new GuildCommand(true);
cmd.Type = GuildCommand.Neutral1;
cmd.dwParam = guild.ID;
SendGuildMessage(cmd);
Database.GuildTable.RemoveAlly(this, guild.ID);
Ally.Remove(guild.ID);
return;
}
}
}
public void AddEnemy(string name)
{
foreach (Guild guild in Kernel.Guilds.Values)
{
if (guild.Name == name)
{
if (Ally.ContainsKey(guild.ID))
{
RemoveAlly(guild.Name);
guild.RemoveAlly(Name);
}
Enemy.Add(guild.ID, guild);
_String stringPacket = new _String(true);
stringPacket.UID = guild.ID;
stringPacket.Type = _String.GuildEnemies;
stringPacket.Texts.Add(guild.Name + " " + guild.LeaderName + " " + guild.Level + " " + guild.MemberCount);
SendGuildMessage(stringPacket);
SendGuildMessage(stringPacket);
Database.GuildTable.AddEnemy(this, guild.ID);
return;
}
}
}
public void RemoveEnemy(string name)
{
foreach (Guild guild in Enemy.Values)
{
if (guild.Name == name)
{
GuildCommand cmd = new GuildCommand(true);
cmd.Type = GuildCommand.Neutral2;
cmd.dwParam = guild.ID;
SendGuildMessage(cmd);
SendGuildMessage(cmd);
Database.GuildTable.RemoveEnemy(this, guild.ID);
Enemy.Remove(guild.ID);
return;
}
}
}
public void SendName(Client.GameState client)
{
_String stringPacket = new _String(true);
stringPacket.UID = ID;
stringPacket.Type = _String.GuildName;
stringPacket.Texts.Add(Name + " " + LeaderName + " 0 " + MemberCount);
client.Send(stringPacket);
}
public void SendGuild(Client.GameState client)
{
if (Members.ContainsKey(client.Entity.UID))
{
if (Bulletin == null)
Bulletin = "This*is*a*new*guild!";
client.Send(new Message(Bulletin, System.Drawing.Color.White, Message.GuildAnnouncement));
Writer.WriteUInt32(uint.Parse(DateTime.Now.ToString("yyyymmdd")), 67, Buffer);
Writer.WriteUInt32((uint)client.AsMember.SilverDonation, 8, Buffer);
Writer.WriteUInt32((ushort)client.AsMember.Rank, 28, Buffer);
SendGuildLevel();
Writer.WriteInt32(GuildLevel, 60, Buffer);
client.Send(Buffer);
}
}*
public void SendAllyAndEnemy(Client.GameState client)
{
foreach (Guild guild in Enemy.Values)
{
_String stringPacket = new _String(true);
stringPacket.UID = guild.ID;
stringPacket.Type = _String.GuildEnemies;
stringPacket.Texts.Add(guild.Name + " " + guild.LeaderName + " 0 " + guild.MemberCount);
client.Send(stringPacket);
client.Send(stringPacket);
}
foreach (Guild guild in Ally.Values)
{
_String stringPacket = new _String(true);
stringPacket.UID = guild.ID;
stringPacket.Type = _String.GuildAllies;
stringPacket.Texts.Add(guild.Name + " " + guild.LeaderName + " 0 " + guild.MemberCount);
client.Send(stringPacket);
client.Send(stringPacket);
}
}
public static bool ValidName(string Name)
{
if (Name.Length < 4 && Name.Length > 15) return false;
else if (Name.IndexOfAny(new char[20] { ' ', '#', '%', '^', '&', '*', '(', ')', ';', ':', '\'', '\"', '/', '\\', ',', '.', '{', '}', '[', ']' }) > 0) return false;
else return true;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace PlayConquer.Database
{
public class PerfectionTable
{
public class PerfectionPower
{
public class PeStats
{
public int Level;
public int PAttack;
public int PDefense;
public int MAttack;
public int MDefense;
public int ToxinEraserLevel;
public int StrikeLockLevel;
public int LuckyStrike;
public int CalmWind;
public int DrainingTouch;
public int BloodSpawn;
public int LightOfStamina;
public int ShiledBreak;
public int KillingFlash;
public int MirrorOfSin;
public int DivineGuard;
public int CoreStrike;
public int InvisableArrow;
public int FreeSoul;
public int StraightLife;
public int AbsoluteLuck;
}
public static Dictionary<int, PeStats> Stats = new Dictionary<int, PeStats>();
}
#region ItemRefineAttribute
public static Dictionary<ushort, ItemRefineAttribute> AttributeList = new Dictionary<ushort, ItemRefineAttribute>();
public class ItemRefineAttribute
{
public ushort ID;
public Game.Enums.PerfectionEffect Type;
public byte Level;
public uint dwParam;
public uint dwParam2;
public ushort Chance;
}
public static void LoadItemRefineAttribute()
{
if (File.Exists(Constants.DataHolderPath + "item_refine_attr.txt"))
{
string[] Lines = File.ReadAllLines((Constants.DataHolderPath + "item_refine_attr.txt"));
foreach (var line in Lines)
{
var spilitline = line.Split(new string[] { "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
ItemRefineAttribute iru = new ItemRefineAttribute();
iru.ID = Convert.ToUInt16(spilitline[0]);
iru.Type = (Game.Enums.PerfectionEffect)Convert.ToByte(spilitline[1]);
iru.Level = Convert.ToByte(spilitline[2]);
iru.dwParam = Convert.ToUInt16(spilitline[3]);
iru.dwParam2 = Convert.ToUInt16(spilitline[4]);
iru.Chance = Convert.ToUInt16(spilitline[5]);
AttributeList.Add(iru.ID, iru);
}
}
}
#endregion ItemRefineAttribute
#region ItemRefineEffectEX
public static Dictionary<uint, EffectEX> EffectsEX = new Dictionary<uint, EffectEX>();
public class EffectEX
{
public uint ID;
public uint ItemID;
public uint StarReq;
public uint AttributeNum;
public uint Value;
}
public static void LoadItemRefineEffectEX()
{
if (File.Exists(Constants.DataHolderPath + "item_refine_effect_ex.txt"))
{
string[] Lines = File.ReadAllLines((Constants.DataHolderPath + "item_refine_effect_ex.txt"));
foreach (var line in Lines)
{
var spilitline = line.Split(new string[] { "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
EffectEX iru = new EffectEX();
iru.ID = Convert.ToUInt16(spilitline[0]);
iru.ItemID = Convert.ToUInt32(spilitline[1]);
iru.StarReq = Convert.ToUInt32(spilitline[2]);
iru.AttributeNum = Convert.ToUInt32(spilitline[3]);
iru.Value = Convert.ToUInt32(spilitline[4]);
EffectsEX.Add(iru.ID, iru);
}
}
}
public static void GetStats(Client.GameState client)
{
foreach (var val in Database.PerfectionTable.EffectsEX.Values)
{
if (client.Equipment.IsWearingItemID(val.ItemID))
{
if (client.Equipment.TotalStars >= val.StarReq)
{
if (val.AttributeNum == 18)
{
client.Entity.BaseMinAttack += val.Value;
client.Entity.BaseMaxAttack += val.Value;
}
if (val.AttributeNum == 19)
{
client.Entity.BaseDefence += (ushort)val.Value;
}
if (val.AttributeNum == 22)
{
client.Entity.ItemHP += val.Value;
}
}
}
}
}
#endregion ItemRefineEffectEX
#region ItemRefineEffect
public static Dictionary<ushort, Effect> Effects = new Dictionary<ushort, Effect>();
public class Effect
{
public ushort Stars;
public uint PAttack;
public uint MAttack;
public uint PDefense;
public uint MDefense;
public List<uint> Effects;
}
public static void LoadItemRefineEffect()
{
if (File.Exists(Constants.DataHolderPath + "item_refine_effect.txt"))
{
string[] Lines = File.ReadAllLines((Constants.DataHolderPath + "item_refine_effect.txt"));
foreach (var line in Lines)
{
var spilitline = line.Split(new string[] { "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
Effect iru = new Effect();
iru.Stars = Convert.ToUInt16(spilitline[0]);
iru.PAttack = Convert.ToUInt32(spilitline[1]);
iru.MAttack = Convert.ToUInt32(spilitline[2]);
iru.PDefense = Convert.ToUInt32(spilitline[3]);
iru.MDefense = Convert.ToUInt32(spilitline[4]);
iru.Effects = new List<uint>();
for (int x = 5; x < spilitline.Length; x++)
{
uint effect = uint.Parse(spilitline[x]);
if (effect != 0)
iru.Effects.Add(effect);
}
Effects.Add(iru.Stars, iru);
}
}
}
#endregion ItemRefineEffect
}
}
FloorItemTable.Load();
new MsgUserAbilityScore().GetRankingList();
new MsgEquipRefineRank().UpdateRanking();
new MsgRankMemberShow().UpdateBestEntity();
private void ServerFunctions(int time)
DateTime LastPerfectionSort = DateTime.Now;
if (DateTime.Now >= LastPerfectionSort.AddHours(1))
Program.Save();
LastPerfectionSort = DateTime.Now;
new MsgUserAbilityScore().GetRankingList();
new MsgEquipRefineRank().UpdateRanking();
new MsgRankMemberShow().UpdateBestEntity();
#region DailySignIn
#region MsgPrestigeRanking
case 3257:
{
var pkt = new MsgRankMemberShow();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
if (pkt.Read(myPacket))
pkt.Handle(client);
break;
}
#endregion
#region Skill Soul
#region MsgEquipRefineRank
case 3256:
{
var pkt = new MsgEquipRefineRank();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
if (pkt.Read(myPacket))
pkt.Handle(client);
break;
}
#endregion
#region MsgItemRefineRecord
case 3255:
{
var pkt = new MsgItemRefineRecord();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
if (pkt.Read(myPacket))
pkt.Handle(client);
/* var packet2 = new byte[myPacket.Length - 4];
Array.Copy(myPacket, 4, packet2, 0, packet2.Length);
var variable = Kernel.Read7BitEncodedInt(packet2).SelectMany(BitConverter.GetBytes).ToArray();
Console.WriteLine(PacketHandler.DumpPacket(variable));*/
break;
}
#endregion
#region MsgItemRefineOpt
case 3251:
{
var pkt = new MsgItemRefineOpt();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
if (pkt.Read(myPacket))
pkt.Handle(client, myPacket);
break;
}
#endregion
#region MsgUserAbilityScore
case 3253:
{
var pkt = new MsgUserAbilityScore();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
if (pkt.Read(myPacket))
pkt.Handle(client);
break;
}
#endregion
https://code.vpscairo.com/showthread.php?p=363
|
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
اضافة الميلاد كامل بالشخصية الجديده | محمد ياسر | تطوير سيرفرات كونكر | 16 | 2024-08-23 10:17 AM |
اضافة ابيك القرصان كامل | محمد ياسر | تطوير سيرفرات كونكر | 28 | 2023-09-10 08:59 PM |
عايز اضافت البرتو كامل | ElSaher | الطلبات المدفوعه | 2 | 2020-03-06 12:19 AM |
اضافة المونك كامل | محمد ياسر | تطوير سيرفرات كونكر | 7 | 2020-02-15 10:59 PM |
انبسي كامل للاسطفا بي البرفكشن بناءآ علي طلب الناس مسج | ahmedfathy | تطوير سيرفرات كونكر | 5 | 2019-08-10 02:02 PM |