|
المشاركات 186 |
+التقييم 0.10 |
تاريخ التسجيل Sep 2019 |
الاقامة Egypt |
نظام التشغيل Windows 7 Ultimate |
رقم العضوية 1525 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project_Terror_v2.Game.MsgServer;
namespace Project_Terror_v2.Role.Instance
{
public class Nobility
{
public class NobilityRanking
{
public ulong KnightDonation = 30000000, BaronDonation = 100000000, EarlDonation = 200000000;
public ulong DukeDonation;
public ulong PrinceDonation;
public ulong KingDonation;
private Dictionary<uint, Nobility> ClientPoll;
public NobilityRanking()
{
ClientPoll = new Dictionary<uint, Nobility>();
}
public bool TryGetValue(uint UID, out Nobility user)
{
return ClientPoll.TryGetValue(UID, out user);
}
public Nobility[] GetArray()
{
return ClientPoll.Values.ToArray();
}
public void UpdateRank(Nobility user)
{
if (ClientPoll.Count < 50)
CreateRank(user);
else
{
var array = ClientPoll.Values.ToArray();
if (array[49].Donation < user.Donation)
CreateRank(user);
else if (ClientPoll.ContainsKey(user.UID))
CreateRank(user);
}
}
internal void CreateRank(Nobility user)
{
lock (ClientPoll)
{
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
if (!ClientPoll.ContainsKey(user.UID))
ClientPoll.Add(user.UID, user);
var Array = ClientPoll.Values.Where(p => p.Donation > 200000000).ToArray();
var Order = Array.OrderByDescending(p => p.Donation).ToArray();
ClientPoll.Clear();
for (int x = 0; x < Order.Length; x++)
{
var nobilityclient = Order[x];
int OldPosition = nobilityclient.Position;
var OldRank = nobilityclient.Rank;
if (x < 50)
{
nobilityclient.Position = x;
ClientPoll.Add(nobilityclient.UID, nobilityclient);
if (x == 2)
KingDonation = nobilityclient.Donation;
else if (x == 14)
PrinceDonation = nobilityclient.Donation;
else if (x == 49)
DukeDonation = nobilityclient.Donation;
}
else
nobilityclient.Position = -1;
if (OldPosition != nobilityclient.Position)
{
UpdateClientIcon(stream,nobilityclient);
if (nobilityclient.Rank > OldRank)
{
if (Program.SendGlobalPackets != null)
{
#if Arabic
Program.SendGlobalPackets.Enqueue(new Game.MsgServer.MsgMessage(nobilityclient.Name + " has been promoted to " + nobilityclient.Rank.ToString() + ".", "ALL", Game.MsgServer.MsgMessage.MsgColor.red, Game.MsgServer.MsgMessage.ChatMode.Center).GetArray(stream));
#else
Program.SendGlobalPackets.Enqueue(new Game.MsgServer.MsgMessage(nobilityclient.Name + " has been promoted to " + nobilityclient.Rank.ToString() + ".", "ALL", Game.MsgServer.MsgMessage.MsgColor.red, Game.MsgServer.MsgMessage.ChatMode.Center).GetArray(stream));
#endif
}
//Program.SendGlobalPackets.Enqueue(new Game.MsgServer.MsgMessage("Congratulation! " + nobilityclient.Name + " donated to " + nobilityclient.Rank.ToString() + " in Nobility Rank.", "ALL", Game.MsgServer.MsgMessage.MsgColor.red, Game.MsgServer.MsgMessage.ChatMode.Center).GetArray(stream));
}
}
}
}
}
}
internal unsafe void UpdateClientIcon(ServerSockets.Packet stream, Nobility user)
{
Client.GameClient client;
if (Database.Server.GamePoll.TryGetValue(user.UID, out client))
{
client.Player.NobilityRank = user.Rank;
client.Send(stream.NobilityIconCreate(user));
}
}
}
public enum NobilityRank : byte
{
Serf = 0,
Knight = 1,
Baron = 3,
Earl = 5,
Duke = 7,
Prince = 9,
King = 12
}
public uint UID;
public string Name;
public int Position = -1;
public ulong Donation;
public uint Mesh;
public byte Gender;
public NobilityRank Rank
{
get
{
#if Encore
if (Position >= 0 && Position < 3)
return NobilityRank.King;
else if (Position >= 3 && Position < 15)
return NobilityRank.Prince;
#else
if (Position >= 0 && Position < 6)
return NobilityRank.King;
else if (Position >= 6 && Position < 20)
return NobilityRank.Prince;
#endif
else if (Position >= 20 && Position < 50)
return NobilityRank.Duke;
if (Donation >= 200000000)
return NobilityRank.Earl;
else if (Donation >= 100000000)
return NobilityRank.Baron;
else if (Donation >= 30000000)
return NobilityRank.Knight;
return NobilityRank.Serf;
}
}
public Nobility(uint _uid, string _name, ulong _donation, uint _mesh, byte _gender)
{
UID = _uid;
Name = _name;
Donation = _donation;
Mesh = _mesh;
Gender = _gender;
}
public Nobility(Client.GameClient user)
{
UID = user.Player.UID;
Name = user.Player.Name;
Mesh = user.Player.Mesh;
Gender = user.Player.GetGender;
}
}
}
static void ComposePlus(Compose compose, Client.GameState client)
static void ComposePlus(Compose compose, Client.GameState client)
{
ConquerItem Item = null;
ConquerItem[] Minors = null;
if (client.Inventory.TryGetItem(compose[0], out Item) || (client.Equipment.TryGetItem(compose[0]) != null) || (compose.Mode == Compose.QuickCompose))
{
if (Item == null && client.Inventory.TryGetItem(compose[0], out Item) == false && (client.Equipment.TryGetItem(compose[0]) != null))
Item = client.Equipment.TryGetItem(compose[0]);
if (compose.Mode == Compose.DragonBallUpgrade || compose.Mode == Compose.MeteorUpgrade)
{
Minors = new ConquerItem[compose.Countx];
for (int i = 0; i < compose.Countx; i++)
{
if (!client.Inventory.TryGetItem(compose[i + 2], out Minors[i]))
return;
else
if (Minors[i].UID == Item.UID)
return;
}
}
else
{
Minors = new ConquerItem[compose.Count - 1];
for (int i = 0; i < compose.Count - 1; i++)
{
if (!client.Inventory.TryGetItem(compose[i + 1], out Minors[i]))
return;
else
if (Minors[i].UID == Item.UID)
return;
}
}
ushort pos = ItemPosition(Item.ID);
if (pos == ConquerItem.Bottle || pos == ConquerItem.Garment || pos == ConquerItem.LeftWeaponAccessory || pos == ConquerItem.RightWeaponAccessory || pos == ConquerItem.SteedArmor) //mohsen.. i'm remove crop
return;
if (compose.Mode == Compose.ChanceUpgrade || compose.Mode == Compose.QuickCompose)
{
if (Item.Plus < 8 && Item.PlusProgress != 0)
{
double percent = (double)Item.PlusProgress / (double)Database.DataHolder.ComposePlusPoints(Item.Plus);
if (Kernel.Rate(percent))
{
Item.PlusProgress = 0;
Item.Plus++;
}
else
Item.PlusProgress = 0;
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
Database.ConquerItemTable.UpdatePlus(Item);
Database.ConquerItemTable.UpdatePlusProgress(Item);
if (Item.Plus >= 8)
Kernel.SendWorldMessage(new Message("Congratulations, " + client.Entity.Name + " has upgraded His " + Database.ConquerItemInformation.BaseInformations[Item.ID].Name + " to + " + Item.Plus + " and " + Item.PlusProgress + " in Progress!", System.Drawing.Color.Red, Network.GamePackets.Message.TopLeft), Program.Values);
}
return;
}
if (compose.Mode == Compose.MeteorUpgrade || compose.Mode == Compose.DragonBallUpgrade)
{
Database.ConquerItemInformation info = new MrHassan.Database.ConquerItemInformation(Item.ID, Item.Plus);
Minors = new ConquerItem[compose.Count - 2];
for (int i = 0; i < compose.Count - 2; i++)
{
if (!client.Inventory.TryGetItem(compose[i + 2], out Minors[i]))
return;
else
if (Minors[i].UID == Item.UID)
return;
}
switch (compose.Mode)
{
case Compose.DragonBallUpgrade:
{
if (Item.ID % 10 == (byte)Game.Enums.ItemQuality.Super)
break;
if (Item.Durability < Item.MaximDurability)
break;
// byte chance = (byte)(70 - ((infos.BaseInformation.Level - (infos.BaseInformation.Level > 100 ? 30 : 0)) / (10 - Item.ID % 10)));
byte cost = DragonBallUpgradeCost(Item, info);
double chance = (((double)compose.Countx / (double)cost) * 100);
if (MyMath.Success(chance))
{
switch ((Game.Enums.ItemQuality)(Item.ID % 10))
{
case Game.Enums.ItemQuality.Normal:
case Game.Enums.ItemQuality.NormalV1:
case Game.Enums.ItemQuality.NormalV2:
case Game.Enums.ItemQuality.NormalV3: Item.ID = (Item.ID - (Item.ID % 10)) + (byte)Game.Enums.ItemQuality.Refined; break;
default: Item.ID++; break;
}
Database.ConquerItemTable.UpdateItemID(Item, client);
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
client.Send(new ItemUsage(true)
{
UID = client.Entity.UID,
dwParam = 1,
ID = ItemUsage.DragonBallUpgrade
});
}
else
{
Item.Durability = (ushort)(Item.Durability / 2);
Database.ConquerItemTable.UpdateDurabilityItem(Item);
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
}
foreach (var item in Minors)
client.Inventory.Remove(item, MrHassan.Game.Enums.ItemUse.Remove);
if (compose.Countx > cost)
{
var diff = compose.Countx - cost;
client.Inventory.Add((uint)(Minors[0].ID == 720028 ? 1088000 : 1088001), 0, (byte)diff);
}
break;
}
case Compose.MeteorUpgrade:
{
if (info.BaseInformation.Level == ItemMaxLevel(ItemPosition(info.BaseInformation.ID)))
break;
if (Item.Durability < Item.MaximDurability)
{
client.MessageBox("Ro7 sal7ha ya Dog ..", null, null);
break;
}
byte cost = MeteorUpgradeCost(Item.ID);
if (ItemPosition(Item.ID) == (ushort)ConquerItem.Armor || ItemPosition(Item.ID) == (ushort)ConquerItem.Head || IsShield(Item.ID))
{
if (info.BaseInformation.Level >= 110)
cost = 1;
}
else
{
if (info.BaseInformation.Level >= 115)
cost = 1;
}
double chance = (((double)compose.Countx / (double)cost) * 100);
uint newid = info.CalculateUplevel();
if (newid != 0 && newid != Item.ID)
{
if (MyMath.Success(chance))
{
Item.ID = newid;
info = new MrHassan.Database.ConquerItemInformation(Item.ID, Item.Plus);
Item.Durability = Item.MaximDurability = info.BaseInformation.Durability;
Database.ConquerItemTable.UpdateItemID(Item, client);
Database.ConquerItemTable.UpdateDurabilityItem(Item);
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
client.Send(new ItemUsage(true)
{
UID = client.Entity.UID,
dwParam = 1,
ID = ItemUsage.MeteorUpgrade
});
}
else
{
Item.Durability = (ushort)(Item.Durability / 2);
Database.ConquerItemTable.UpdateDurabilityItem(Item);
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
}
}
foreach (var item in Minors)
client.Inventory.Remove(item, MrHassan.Game.Enums.ItemUse.Remove);
if (compose.Countx > cost)
{
var diff = compose.Countx - cost;
client.Inventory.Add((uint)(Minors[0].ID == 720028 ? 1088000 : 1088001), 0, (byte)diff);
}
break;
}
}
}
foreach (var item in Minors)
{
var ItemPlus = item;
Database.ConquerItemInformation infos = new MrHassan.Database.ConquerItemInformation(Item.ID, Item.Plus);
switch (compose.Mode)
{
case Compose.CurrentSteed:
case Compose.Plus:
{
if (Item.Plus == 8 && Item.GetItemType() == ConquerItem.ItemTypes.WingID || Item.Plus == 8 && pos == ConquerItem.Wing || Item.Plus == 8 && pos == ConquerItem.Steed)//Mr.MrHassan
{
Item.PlusProgress += Database.DataHolder.StonePlusPoints(ItemPlus.Plus);
Item.PlusProgress -= Database.DataHolder.ComposePlusPoints(Item.Plus);//Mr.MrHassan
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
Database.ConquerItemTable.UpdatePlusProgress(Item);
client.Inventory.Remove(ItemPlus, MrHassan.Game.Enums.ItemUse.Remove);
}
if (Item.Plus < 8 && Item.GetItemType() != ConquerItem.ItemTypes.GarmentID_1 && Item.GetItemType() != ConquerItem.ItemTypes.GarmentID_2 && Item.GetItemType() != ConquerItem.ItemTypes.BottleID && Item.GetItemType() != ConquerItem.ItemTypes.RightAccessory1 && Item.GetItemType() != ConquerItem.ItemTypes.RightAccessory2 && Item.GetItemType() != ConquerItem.ItemTypes.RightAccessory3 && Item.GetItemType() != ConquerItem.ItemTypes.LeftAccessory)
{
Item.PlusProgress += Database.DataHolder.StonePlusPoints(ItemPlus.Plus);
while (Item.PlusProgress >= Database.DataHolder.ComposePlusPoints(Item.Plus) && Item.Plus != 8)
{
Item.PlusProgress -= Database.DataHolder.ComposePlusPoints(Item.Plus);
Item.Plus++;
if (Item.Plus == 8)
Item.PlusProgress = 0;
}
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
Database.ConquerItemTable.UpdatePlus(Item);
Database.ConquerItemTable.UpdatePlusProgress(Item);
client.Inventory.Remove(ItemPlus, MrHassan.Game.Enums.ItemUse.Remove);
if (Item.Plus >= 8)
Kernel.SendWorldMessage(new Message("Congratulations, " + client.Entity.Name + " has upgraded His " + Database.ConquerItemInformation.BaseInformations[Item.ID].Name + " to + " + Item.Plus + " and " + Item.PlusProgress + " in Progress!", System.Drawing.Color.Red, Network.GamePackets.Message.TopLeft), Program.Values);
}
break;
}
case Compose.NewSteed:
{
if (Item.Plus < 8)
{
Item.PlusProgress += Database.DataHolder.StonePlusPoints(ItemPlus.Plus);
while (Item.PlusProgress >= Database.DataHolder.ComposePlusPoints(Item.Plus) && Item.Plus != 8)
{
Item.PlusProgress -= Database.DataHolder.ComposePlusPoints(Item.Plus);
Item.Plus++;
if (Item.Plus == 8)
Item.PlusProgress = 0;
}
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
Database.ConquerItemTable.UpdatePlus(Item);
client.Inventory.Remove(ItemPlus, MrHassan.Game.Enums.ItemUse.Remove);
}
int color1 = (int)Item.SocketProgress;
int color2 = (int)ItemPlus.SocketProgress;
int G1 = color1 & 0xFF;
int G2 = color2 & 0xFF;
int B1 = (color1 >> 8) & 0xFF;
int B2 = (color2 >> 8) & 0xFF;
int R1 = (color1 >> 16) & 0xFF;
int R2 = (color2 >> 16) & 0xFF;
Item.NextGreen = (byte)((int)Math.Floor(0.9 * G1) + (int)Math.Floor(0.1 * G2) + 1);
Item.NextBlue = (byte)((int)Math.Floor(0.9 * B1) + (int)Math.Floor(0.1 * B2) + 1);
Item.NextRed = (byte)((int)Math.Floor(0.9 * R1) + (int)Math.Floor(0.1 * R2) + 1);
Item.SocketProgress = (uint)(Item.NextGreen | (Item.NextBlue << 8) | (Item.NextRed << 16));
Item.Mode = MrHassan.Game.Enums.ItemMode.Update;
Item.Send(client);
Database.ConquerItemTable.UpdatePlusProgress(Item);
Database.ConquerItemTable.UpdateSocketProgress(Item);
// Database.ConquerItemTable.UpdateNextSteedColor(Item);
client.Inventory.Remove(ItemPlus, MrHassan.Game.Enums.ItemUse.Remove);
break;
}
}
}
}
}
--------------------------------------------------------------------------------
من دا
Serf = 0,
Knight = 1,
Baron = 3,
Earl = 5,
Duke = 7,
Prince = 9,
King = 12
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
التعديل علي ملفات c3 | محمد ياسر | تطوير سيرفرات كونكر | 88 | 2024-11-15 03:45 PM |
شرح التعديل علي الاتاك | Mero | تطوير سيرفرات كونكر | 2 | 2022-04-08 02:18 AM |
التعديل ع portals | midoazoz | مشكلات السيرفيرات كونكر الشخصيه | 5 | 2019-12-06 03:08 AM |
طلب التعديل علي الاستريك | ElSaher | مشكلات السيرفيرات كونكر الشخصيه | 4 | 2019-08-27 03:03 PM |
التعديل على البرفكشن | Users | تطوير سيرفرات كونكر | 4 | 2019-07-14 01:04 PM |