Tefa
2019-07-29, 11:50 PM
بسم الله و الصلاة و السلام علي اشرف خلق الله سيدنا محمد عليه افضل الصلاة و السلام
اول حاجه لو كنت من الناس الي بتتعصب بسرعه ف اقفل الصفحه دي فورا
عفواً لايمكن عرض الروابط في الإرشيف g
اما لو كنت من الناس الصبوره الكويسه فكمل قراءه
عفواً لايمكن عرض الروابط في الإرشيف
تحذير هام
ينوه منتدي اكواد انه غير مسئول عن اي اضرار نفسيه او عصبيه او اي جلطه قد تحدث لمن يحاول اضافة البروتو
و الله الموفق و المستعان
متنساش الصبر مفتاح الفرج و امشي خطوه خطوه
المتطلبات
عفواً لايمكن عرض الروابط في الإرشيف
1- سورس عادي الي هتضيف فيه البروتو و خد منه نسخه عشان لما تبوظه ترجعه تاني
1- سورس بروتو و هتلاقي منه كتير ع النت و المنتدي
1- كوب شاي او عصير
هنجيب سورس البروتو بتاعنا و هندخل علي المسار ده
Network\GamePackets\Proto
هناخد كل الي جواه كوبي
و بعدها نروح للسورس بتاعنا الي عايزين نضيف فيه البروتو هندخل علي نفس المسار و هنعمل فولدر جديد اسمه Proto
عفواً لايمكن عرض الروابط في الإرشيف
بعد ما نعمله هنضيف جواه كل الملفات الي خدناها كوبي
و ندخل علي بروجيكت نضيفهم بردوا
عفواً لايمكن عرض الروابط في الإرشيف
و متنساش تغير اسم البروجيكت
كده اول حته خلصت
بعد كده ابحث عن
ProtoContract
كلك يمين عليها و دوس Find All References
شوف بقا كل الي انته لسه منقلتوش و انقله للسورس بتاعك و متنساش تغير اسم بروجيكت
بعد كده ادخل علي كلاس Entity.cs
و ابحث عن PlayerProto
هيبقي بالشكل ده كده public byte[] PlayerProto(Entity Entity, byte WindowsView = 0)
اقفله من السالب و خده كوبي في السورس بتاعك
هتلاقي حاجات جوه
PlayerProto
جيبالك ايرورات اقف عليها في سورس بروتو و دوس كلك يمين و دوس Find All References
و ظبطها لحد ما تخلصهم كده انته عملت باكت بروتو 10014
طب انا كده خلصت عايز ادخل
افتح
Forward.cs
بدل الي فيه ب
using System;
using System.Text;
using New_Thor_S_B_Mohamed_Hossam.Interfaces;
using New_Thor_S_B_Mohamed_Hossam.Client;
namespace New_Thor_S_B_Mohamed_Hossam.Network.AuthPackets
{
public class Forward : IPacket
{
private byte[] Buffer;
public Forward()
{
this.Buffer = new byte[48];
Writer.WriteUInt16((ushort)40, 0, this.Buffer);
Writer.WriteUInt16((ushort)1637, 2, this.Buffer);
}
public uint Identifier
{
get
{
return BitConverter.ToUInt32(this.Buffer, 4);
}
set
{
Writer.WriteUInt32(value, 4, this.Buffer);
}
}
public Forward.ForwardType Type
{
get
{
return (Forward.ForwardType)BitConverter.ToUInt32(this.Bu ffer, 12);
}
set
{
Writer.WriteUInt32((uint)value, 12, this.Buffer);
}
}
public ushort Port
{
get
{
return BitConverter.ToUInt16(this.Buffer, 16);
}
set
{
Writer.WriteUInt16(value, 16, this.Buffer);
}
}
public string IP
{
get
{
return Encoding.Default.GetString(this.Buffer, 24, 16);
}
set
{
Writer.WriteString(value, 24, this.Buffer);
}
}
public byte[] ToArray()
{
return this.Buffer;
}
public void Deserialize(byte[] buffer)
{
}
public void Send(GameState client)
{
client.Send(this.Buffer);
}
public enum ForwardType : byte
{
InvalidInfo = 1,
Ready = 2,
Banned = 25,
WrongAccount = 57,
}
}
}
Class Program
static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3)
{
var player = arg3.Connector as Client.AuthClient;
player.Cryptographer.Decrypt(buffer, length);
player.Queue.Enqueue(buffer, length);
while (player.Queue.CanDequeue())
{
byte[] packet = player.Queue.Dequeue();
ushort len = BitConverter.ToUInt16(packet, 0);
ushort id = BitConverter.ToUInt16(packet, 2);
if (len == 312)
{
player.Info = new Authentication();
player.Info.Deserialize(packet);
player.Account = new AccountTable(player.Info.Username);
string passdone = "";
msvcrt.msvcrt.srand(player.PasswordSeed);
Forward Fw = new Forward();
if (!player.Account.exists)
{
Fw.Type = Forward.ForwardType.InvalidInfo;
player.Send(Fw);
}
if (player.Account.Password == player.Info.Password && player.Account.exists)
{
Fw.Type = Forward.ForwardType.Ready;
}
else
{
Fw.Type = Forward.ForwardType.InvalidInfo;
}
if (IPBan.IsBanned(arg3.IP))
{
Fw.Type = Forward.ForwardType.Banned;
player.Send(Fw);
return;
}
if (Fw.Type == Network.AuthPackets.Forward.ForwardType.Ready)
{
/* if (player.Info.Server != Constants.ServerName)
{
Console.WriteLine("User==>[" + player.Info.Username + "] Change Name Server To [" + player.Info.Server + "] UID=[" + player.Account.EntityID + "]", ConsoleColor.Blue);
// return;
} */
Client.GameState aClient;
if (Kernel.GamePool.TryGetValue(Fw.Identifier, out aClient))
{
Fw.Type = Forward.ForwardType.InvalidInfo;
aClient.Disconnect();
player.Send(Fw);
return;
}
Fw.Identifier = player.Account.GenerateKey();
Kernel.AwaitingPool[Fw.Identifier] = player.Account;
Fw.IP = GameIP;
Fw.Port = GamePort;
}
player.Send(Fw);
}
}
}
void GameServer_OnClientReceive
static void GameServer_OnClientReceive(byte[] buffer, int length, ClientWrapper obj)
{
if (obj.Connector == null)
{
obj.Disconnect();
return;
}
Client.GameState Client = obj.Connector as Client.GameState;
if (Client.Exchange)
{
Client.Exchange = false;
Client.Action = 1;
var crypto = new GameCryptography(Program.Encoding.GetBytes(Constan ts.GameCryptographyKey));
byte[] otherData = new byte[length];
Array.Copy(buffer, otherData, length);
crypto.Decrypt(otherData, length);
bool extra = false;
int pos = 0;
if (BitConverter.ToInt32(otherData, length - 140) == 128)//no extra packet
{
pos = length - 140;
Client.Cryptography.Decrypt(buffer, length);
}
else if (BitConverter.ToInt32(otherData, length - 180) == 128)//extra packet + 4 3d
{
pos = length - 180;
extra = true;
Client.Cryptography.Decrypt(buffer, length - 40);
}
int len = BitConverter.ToInt32(buffer, pos); pos += 4;
if (len != 128)
{
Client.Disconnect();
return;
}
byte[] pubKey = new byte[128];
for (int x = 0; x < len; x++, pos++) pubKey[x] = buffer[pos];
string PubKey = Program.Encoding.GetString(pubKey);
Client.Cryptography = Client.DHKeyExchange.HandleClientKeyPacket(PubKey, Client.Cryptography);
if (extra)
{
byte[] data = new byte[40];
Buffer.BlockCopy(buffer, length - 40, data, 0, 40);
processData(data, 40, Client);
}
}
else
{
processData(buffer, length, Client);
}
}
class Authentication
using System;
using System.IO;
using System.Text;
using New_Thor_S_B_Mohamed_Hossam.Network.Cryptography;
namespace New_Thor_S_B_Mohamed_Hossam.Network.AuthPackets
{
public class Authentication : Interfaces.IPacket
{
public string Username, Password, Server;
public Authentication() { }
public void Deserialize(byte[] buffer)
{
Username = Program.Encoding.GetString(buffer, 8, 32).Replace("\0", "");
Password = Program.Encoding.GetString(buffer, 100, 32).Replace("\0", "");
Server = Program.Encoding.GetString(buffer, 136, 16).Replace("\0", "");
}
public byte[] ToArray() { throw new NotImplementedException(); }
public void Send(Client.GameState client) { }
}
}
class Constants
GameCryptographyKey = "C238xs65pjy7HU9Q",
CLASS PacketHandler
#region Data (10010)
case 10010:
{
if (client.Action != 2)
return;
var pkt = new MsgAction_TATA();
pkt.Handle(client, packet);
break;
}
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ProtoBuf;
using New_Thor_S_B_Mohamed_Hossam.Network;
using New_Thor_S_B_Mohamed_Hossam.Network.GamePackets;
using New_Thor_S_B_Mohamed_Hossam.Game.Features;
using New_Thor_S_B_Mohamed_Hossam.Game.MsgServer;
using New_Thor_S_B_Mohamed_Hossam.Interfaces;
using New_Thor_S_B_Mohamed_Hossam.Game;
using System.Drawing;
using New_Thor_S_B_Mohamed_Hossam.Client;
namespace New_Thor_S_B_Mohamed_Hossam
{
class MsgAction_TATA
{
public class CustomCommands
{
public const ushort
ExitQuestion = 1,
Minimize = 2,
ShowReviveButton = 1053,
FlowerPointer = 1067,
Enchant = 1091,
LoginScreen = 1153,
SelectRecipiet = 30,
JoinGuild = 34,
MakeFriend = 38,
ChatWhisper = 40,
CloseClient = 43,
HotKey = 53,
Furniture = 54,
TQForum = 79,
PathFind = 97,
LockItem = 102,
ShowRevive = 1053,
HideRevive = 1054,
StatueMaker = 1066,
GambleOpen = 1077,
GambleClose = 1078,
Compose = 1086,
Craft1 = 1088,
Craft2 = 1089,
Warehouse = 1090,
ShoppingMallShow = 1100,
ShoppingMallHide = 1101,
NoOfflineTraining = 1117,
CenterClient = 1155,
ClaimCP = 1197,
ClaimAmount = 1198,
Advertise = 3274,
MerchantApply = 1201,
MerchantDone = 1202,
RedeemEquipment = 1233,
ClaimPrize = 1234,
RepairAll = 1239,
FlowerIcon = 1244,
SendFlower = 1246,
ReciveFlower = 1248,
WarehouseVIP = 1272,
UseExpBall = 1288,
HackProtection = 1298,
HideGUI = 1307,
Inscribe = 3059,
BuyPrayStone = 3069,
HonorStore = 3104,
Opponent = 3107,
CountDownQualifier = 3109,
QualifierStart = 3111,
ItemsReturnedShow = 3117,
ItemsReturnedWindow = 3118,
ItemsReturnedHide = 3119,
QuestFinished = 3147,
QuestPoint = 3148,
QuestPointSparkle = 3164,
StudyPointsUp = 3192,
PKTeamName = 3209,
CTFFlag = 3211,
Updates = 3218,
IncreaseLineage = 3227,
HorseRacingStore = 3245,
GuildPKTourny = 3249,
QuitPK = 3251,
Spectators = 3252,
CardPlayOpen = 3270,
CardPlayClost = 3271,
ArtifactPurification = 3344,
SafeguardConvoyShow = 3389,
SafeguardConvoyHide = 3390,
RefineryStabilization = 3392,
ArtifactStabilization = 3398,
SmallChat = 3406,
NormalChat = 3407,
Reincarnation = 3439,
CTFEnd = 3549,
CTFScores = 3359;
}
public class WindowCommands
{
public const ushort
Compose = 1,
Craft = 2,
Warehouse = 4,
DetainRedeem = 336,
DetainClaim = 337,
VIPWarehouse = 341,
Breeding = 368,
PurificationWindow = 455,
StabilizationWindow = 459,
TalismanUpgrade = 347,
GemComposing = 422,
OpenSockets = 425,
Blessing = 426,
TortoiseGemComposing = 438,
RefineryStabilization = 448,
HorseRacingStore = 464,
JiangHuSetName = 617,
Reincarnation = 485;
}
public const ushort
DragonBallDropped = 165,
JumpOutEffect = 134,
ObserveKnownPerson = 54,
SetLocation = 74,
Hotkeys = 75,
ConfirmFriends = 76,
ConfirmProficiencies = 77,
ConfirmSpells = 78,
ChangeDirection = 79,
ChangeAction = 81,
UsePortal = 85,
Teleport = 86,
Leveled = 92,
XPListEnd = 93,
Revive = 94,
DeleteCharacter = 95,
ChangePKMode = 96,
ConfirmGuild = 97,
SwingPickaxe = 99,
TeamMemberPos = 101,
UnknownEntity = 102,
TeamSearchForMember = 106,
RemoveSpell = 109,
NewCoordonates = 108,
OwnBooth = 111,
GetSurroundings = 114,
OpenCustom = 116,
ObserveEquipment = 117,
EndTransformation = 118,
EndFly = 120,
ViewEnemyInfo = 123,
OpenWindow = 126,
JiangHu0 = 126,
CompleteLogin = 251,
RemoveEntity = 135,
AddEntity = 134,
Jump = 137,
Die = 145,
EndTeleport = 146,
ViewFriendInfo = 148,
ChangeFace = 151,
ViewPartnerInfo = 152,
Confiscator = 153,
OpenShop = 0xA0,
FlashStep = 156,
CountDown = 159,
Away = 161,
AutoPatcher = 162,
HideGui = 158,
AppearanceType = 178,
SpawnEffect = 134,
LevelUpSpell = 252,
RemoveTrap = 434,
LevelUpProficiency = 253,
ObserveEquipment2 = 310,
BeginSteedRace = 401,
FinishSteedRace = 402,
DetainWindowRequest = 153;
public void MsgAction(Client.GameState client, MsgActionProto action, bool SendScreen = false)
{
MsgActionProto Action = new MsgActionProto();
Action = action;
if (SendScreen == true)
{
if (client.Entity.EntityFlag == EntityFlag.Entity)
{
client.SendScreen(SendPacket(Action));
}
else if (client.Entity.EntityFlag == EntityFlag.Monster)
{
client.Entity.MonsterInfo.SendScreen(SendPacket(Ac tion));
}
}
else
{
if (client.Entity.EntityFlag == EntityFlag.Entity)
{
client.Send(SendPacket(Action));
}
}
}
public MsgActionProto Info;
public void Handle(Client.GameState client, byte[] packet)
{
Info = new MsgActionProto();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
using (var memoryStream = new MemoryStream(myPacket))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgActionProto>(memoryStream, PrefixStyle.Fixed32);
}
switch (Info.ID)
{
case SetLocation:
if (client._setlocation)
{
if (client.Entity.MyJiang != null)
{
JiangHu.AttributesToArray(client);
if (client.Entity.MyJiang.SecondsEnd != 0)
{
client.Entity.MyJiang.SendOnline(client, true);
client.Entity.MyJiang.OnShutDown = true;
client.Entity.MyJiang.StartJiang = Time32.Now;
client.LoadItemStats();
}
else
{
client.Entity.MyJiang.SendToArray(client, false);
}
}
else if (client.Entity.Reborn == 2)
{
TalentStatus tal = new TalentStatus(client.Entity.UID);
tal.Mode = "0";
tal.Type = 0;
client.Send(tal);
}
SendFlower sendFlower = new SendFlower();
sendFlower.Typing = (Flowers.IsBoy((uint)client.Entity.Body) ? 3u : 2u);
// sendFlower.Apprend(client.Entity.MyFlowers);
client.Send(sendFlower.ToArray());
client.Send(client.Entity.MyAchievement.ToArray()) ;
// ElitePKTournament.GiveClientReward(client);
if (client.Guild != null)
{
client.Guild.SendGuild(client);
GuildMinDonations guildMinDonations = new GuildMinDonations(31);
guildMinDonations.AprendGuild(client.Guild);
client.Send(guildMinDonations.ToArray());
}
Clan clan = client.Entity.GetClan;
if (clan != null)
{
clan.Build(client, Clan.Types.Info);
client.Send(clan);
client.Entity.ClanName = clan.Name;
client.Send(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
client.Send(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));
}
foreach (Game.ConquerStructures.Society.Guild guild in Kernel.Guilds.Values)
{
guild.SendName(client);
guild.SendName(client);
}
if (client.Entity.EnlightmentTime > 0)
{
Enlight enlight = new Enlight(true);
enlight.Enlighted = client.Entity.UID;
enlight.Enlighter = 0;
if (client.Entity.EnlightmentTime > 80)
client.Entity.EnlightmentTime = 100;
else if (client.Entity.EnlightmentTime > 60)
client.Entity.EnlightmentTime = 80;
else if (client.Entity.EnlightmentTime > 40)
client.Entity.EnlightmentTime = 60;
else if (client.Entity.EnlightmentTime > 20)
client.Entity.EnlightmentTime = 40;
else if (client.Entity.EnlightmentTime > 0)
client.Entity.EnlightmentTime = 20;
for (int count = 0; count < client.Entity.EnlightmentTime; count += 20)
{
client.Send(enlight);
}
}
if (client.Entity.Hitpoints != 0)
{
if (client.Map.ID == 1036 || client.Map.ID == 1039)
{
if (client.Entity.PreviousMapID == 0)
client.Entity.SetLocation(1002, 410, 354);
else
{
switch (client.Entity.PreviousMapID)
{
default:
{
client.Entity.SetLocation(1002, 410, 354);
break;
}
case 1000:
{
client.Entity.SetLocation(1000, 500, 650);
break;
}
case 1020:
{
client.Entity.SetLocation(1020, 565, 562);
break;
}
case 1011:
{
client.Entity.SetLocation(1011, 188, 264);
break;
}
case 1015:
{
client.Entity.SetLocation(1015, 717, 571);
break;
}
}
}
}
}
else
{
if (client.Entity.MapID == 1038 && New_Thor_S_B_Mohamed_Hossam.Game.GuildWar.IsWar)
{
client.Entity.SetLocation(6001, 31, 74);
}
else
{
ushort[] Point = Database.DataHolder.FindReviveSpot(client.Map.ID);
client.Entity.SetLocation(Point[0], Point[1], Point[2]);
}
}
Info.dwParam = client.Map.BaseID;
Info.wParam1 = client.Entity.X;
Info.wParam2 = client.Entity.Y;
client.Send(SendPacket(Info));
client.Screen.Reload(null);//Done
client.Screen.FullWipe();
client.SendScreenSpawn(client.Entity, true);
client.Screen.Reload(null);
}
break;
case 256:
{
if (client.SashSlots < 200)
{
if (client.Entity.ConquerPoints >= 90)
{
client.Entity.ConquerPoints -= 90;
client.SashSlots += 1;
}
else
{
client.Entity.SendSysMesage("make sure you Have 90 CPs");
}
}
else
{
client.Entity.SendSysMesage("you already opened max number of slots");
}
break;
}
case 255:
{
//PrintPacket(packet);
Info.UID = client.Entity.UID;
Info.ID = 257;
client.Send(SendPacket(Info));
break;
}
case DetainWindowRequest:
{
if (!client.JustOpenedDetain)
{
if (client.DeatinedItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)WindowCommands.DetainRedeem;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
client.Send(MsgAction_TATA.SendPacket(Action));
}
if (client.ClaimableItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)WindowCommands.DetainClaim;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
client.Send(MsgAction_TATA.SendPacket(Action));
}
}
client.JustOpenedDetain = !client.JustOpenedDetain;
break;
}
case 408:
{
if (!client.JustOpenedDetain)
{
if (client.ClaimableItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)MsgAction_TATA.WindowCommands.DetainClaim;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
Action.wParam1 = client.Entity.X;
Action.wParam2 = client.Entity.Y;
client.Send(MsgAction_TATA.SendPacket(Action));
}
}
client.JustOpenedDetain = !client.JustOpenedDetain;
break;
}
case 132:
{
Console.WriteLine("Dis? " + client.Entity.Name);
client.Disconnect();
break;
}
case AppearanceType:
{
if (client.Entity.Tournament_Signed)
return;
Info.UID = client.Entity.UID;
client.Entity.Appearance = (Game.AppearanceType)Info.dwParam;
client.Appearance = (uint)client.Entity.Appearance;
client.SendScreen(SendPacket(Info), true);
break;
}
case CompleteLogin:
{
MsgSignIn.Show(client);
PacketHandler.LoginMessages(client);
client.Send(packet);
break;
}
case LevelUpSpell:
{
if (client.Trade.InTrade)
return;
MsgSpell Spell;
if (client.MySpells.ClientSpells.TryGetValue((ushort) Info.dwParam, out Spell))
{
Dictionary<ushort, Database.MagicType.Magic> DbSpells;
if (Kernel.Magic.TryGetValue(Spell.ID, out DbSpells))
{
if (Spell.Level < DbSpells.Count - 1)
{
decimal cpCost = DbSpells[Spell.Level].CpsCost;
cpCost = ((cpCost / 2) - (cpCost / 2 / 10)) / 10;
int max = Math.Max((int)Spell.Experience, 1);
int percentage = (int)Math.Ceiling((decimal)(100 - (int)(max / Math.Max((DbSpells[Spell.Level].Experience / 100), 1))));
cpCost = Math.Ceiling((decimal)(cpCost * percentage / 100));
if (client.Entity.ConquerPoints >= cpCost)
{
client.Entity.ConquerPoints -= (ulong)cpCost;
client.MySpells.Add(packet, Spell.ID, (ushort)(Spell.Level + 1), Spell.SoulLevel, Spell.PreviousLevel, 0);
}
}
}
}
break;
}
case LevelUpProficiency:
{
ushort proficiencyID = (ushort)Info.dwParam;
IProf proficiency = null;
if (client.Proficiencies.TryGetValue(proficiencyID, out proficiency))
{
if (proficiency.Level != 20)
{
if (client.Trade.InTrade) return;
uint cpCost = 0;
#region Costs
switch (proficiency.Level)
{
case 1: cpCost = 28; break;
case 2: cpCost = 28; break;
case 3: cpCost = 28; break;
case 4: cpCost = 28; break;
case 5: cpCost = 28; break;
case 6: cpCost = 55; break;
case 7: cpCost = 81; break;
case 8: cpCost = 135; break;
case 9: cpCost = 162; break;
case 10: cpCost = 270; break;
case 11: cpCost = 324; break;
case 12: cpCost = 324; break;
case 13: cpCost = 324; break;
case 14: cpCost = 324; break;
case 15: cpCost = 375; break;
case 16: cpCost = 548; break;
case 17: cpCost = 799; break;
case 18: cpCost = 1154; break;
case 19: cpCost = 1420; break;
}
#endregion
uint needExperience = Database.DataHolder.ProficiencyLevelExperience(pro ficiency.Level);
int max = Math.Max((int)proficiency.Experience, 1);
int percentage = 100 - (int)(max / (needExperience / 100));
cpCost = (uint)(cpCost * percentage / 100);
if (client.Entity.ConquerPoints >= cpCost)
{
client.Entity.ConquerPoints -= cpCost;
proficiency.Level++;
if (proficiency.Level == proficiency.PreviousLevel / 2)
{
proficiency.Level = proficiency.PreviousLevel;
Database.DataHolder.ProficiencyLevelExperience((by te)(proficiency.Level + 1));
}
proficiency.Experience = 0;
proficiency.Send(client);
}
}
}
break;
}
case SwingPickaxe:
client.Mining = true;
break;
case Revive:
{
if (client.Entity.ContainFlag(MsgUpdate.Flags.SoulSha ckle))
return;
if (client.InTeamQualifier())
return;
client.Entity.OnDeath = null;
bool ReviveHere = Info.dwParam == 1;
bool Rev = Info.dwParam == 0;
if (client.Entity.StraightLife && !ReviveHere && !Rev)
{
client.Entity.BringToLife();
client.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y, false);
var spell = Database.SpellTable.GetSpell(1095, 4);
client.Entity.AddFlag(MsgUpdate.Flags.Stigma, (int)spell.Duration, true);
var spell1 = Database.SpellTable.GetSpell(1090, 4);
client.Entity.AddFlag(MsgUpdate.Flags.MagicShield, (int)spell1.Duration, true);
client.Entity.StraightLife = false;
}
else
{
if (Time32.Now >= client.Entity.DeathStamp.AddSeconds(18))
{
//
client.Entity.Action = New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.None;
client.ReviveStamp = Time32.Now;
client.Attackable = false;
client.Entity.TransformationID = 0;
client.Entity.RemoveFlag(MsgUpdate.Flags.Dead);
client.Entity.RemoveFlag(MsgUpdate.Flags.Ghost);
client.Entity.Hitpoints = client.Entity.MaxHitpoints;
if (client.Entity.MapID == 1507 || client.Entity.MapID == 1508 || client.Entity.MapID == 1509)
{
client.Entity.Teleport(1002, 410, 354);
return;
}
if (client.Entity.MapID == 1518)
{
client.Entity.Teleport(1002, 410, 354);
return;
}
if (ReviveHere && (client.Entity.HeavenBlessing > 0))
{
if (client.Entity.MapID == 10137)
{
client.Entity.Teleport(client.Map.BaseID, client.Entity.X, client.Entity.Y, false);
return;
}
}
if (client.Entity.MapID == 700)
{
client.Entity.Teleport(700, 51, 51);
}
if (client.Entity.MapID == 3868)
{
client.Entity.Teleport(3868, 227, 240);
}
if (client.Entity.MapID == 1038 && DateTime.Now.DayOfWeek == DayOfWeek.Friday)
{
client.Entity.Teleport(6001, 31, 74);
}
else if (client.Entity.MapID == 10380 && DateTime.Now.Day >= 27 && DateTime.Now.Day <= 29)
{
client.Entity.Teleport(1002, 410, 354);
}
else if (client.Entity.MapID == 1509)
{
client.Entity.Teleport(1509, 103, 43);
}
else if (client.Entity.MapID == 11024)
{
client.Entity.Teleport(11024, 303, 147);
}
else if (client.Entity.MapID == 11032)
{
client.Entity.Teleport(11032, 226, 227);
}
else if (client.Entity.MapID == 2014)
{
client.Entity.Teleport(2014, 150, 162);
}
else if (client.Entity.MapID == 10137)
{
client.Entity.Teleport(10137, 96, 411);
}
else if (client.Entity.MapID == GuildScoreWar.Map.ID)
{
client.Entity.Teleport(GuildScoreWar.Map.ID, 226, 229);
}
else if (client.Entity.MapID == 2071 || client.Entity.MapID == 11022)
{
client.Entity.Teleport(client.Entity.MapID, 43, 129);
}
else if (client.Entity.MapID == 1730)
{
client.Entity.Teleport(1731, 59, 69);
}
else if (client.Entity.MapID == 1731)
{
client.Entity.Teleport(1732, 59, 69);
}
else if (client.Entity.MapID == 1732)
{
client.Entity.Teleport(1733, 59, 69);
}
else if (client.Entity.MapID == 1733)
{
client.Entity.Teleport(1734, 59, 69);
}
else if (client.Entity.MapID == 1734)
{
client.Entity.Teleport(1735, 59, 69);
}
else if (client.Entity.MapID == 1735)
{
}
else if (client.Entity.MapID == 2071)
{
client.Entity.Teleport(2071, 44, 130);
}
else if (client.Entity.MapID == 11017)
{
client.Entity.Teleport(11017, 302, 147);
}
else if (client.Entity.MapID == 1510)
{
client.Entity.Teleport(1510, 103, 44);
}
else if (client.Entity.MapID == 3693)
{
client.Entity.Teleport(1002, 410, 354);
}
else if (client.Entity.MapID == 7777)
{
client.Entity.Teleport(7777, 150, 164);
}
else if (client.Entity.MapID == 8883)
{
if (client.Entity.TeamDeathMatch_BlackTeam == true)
{
client.Entity.Teleport(8883, 042, 051);
}
if (client.Entity.TeamDeathMatch_BlueTeam == true)
{
client.Entity.Teleport(8883, 060, 042);
}
if (client.Entity.TeamDeathMatch_WhiteTeam == true)
{
client.Entity.Teleport(8883, 066, 064);
if (client.Entity.TeamDeathMatch_RedTeam == true)
{
client.Entity.Teleport(8883, 039, 036);
}
}
}
else
{
if (ReviveHere && (client.Entity.HeavenBlessing > 0 || client.Entity.PKMode == Enums.PKMode.Jiang || client.Entity.JiangActive == true))
{
if (client.Entity.MapID == 1762)
{
client.Entity.Teleport(1762, 290, 72);
}
else
client.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y, false);
}
else
{
ushort[] Point = Database.DataHolder.FindReviveSpot(client.Map.ID);
client.Entity.Teleport(Point[0], Point[1], Point[2], false);
}
}
}
}
break;
}
case UsePortal:
{
client.Entity.Action = New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.None;
client.ReviveStamp = Time32.Now;
client.Attackable = false;
ushort portal_X = (ushort)(Info.dwParam & 0xFFFF);
ushort portal_Y = (ushort)(Info.dwParam >> 16);
string portal_ID = portal_X.ToString() + ":" + portal_Y.ToString() + ":" + client.Map.ID.ToString();
if (client.Account.State == Database.AccountTable.AccountState.ProjectManager)
client.Send(new Message("Portal ID: " + portal_ID, System.Drawing.Color.Red, Network.GamePackets.Message.TopLeft));
foreach (Game.Portal portal in client.Map.Portals)
{
int P = Kernel.GetDistance(portal.CurrentX, portal.CurrentY, client.Entity.X, client.Entity.Y);
if (P <= 20)
{
client.Entity.Teleport(portal.DestinationMapID, portal.DestinationX, portal.DestinationY);
return;
}
}
client.Entity.Teleport(1002, 410, 354);
break;
}
case ChangePKMode:
{
if (client.Entity.TeamWatchingMatch != null || client.Entity.SkillWatchingMatch != null || client.WatchingElitePKMatch != null || client.WatchingGroup != null || client.TeamWatchingGroup != null)
{
client.Send("You can not change your pk mode while you are watching.");
return;
}
if (client.Team != null && (client.Team.TeamMatch != null || client.Team.SkillMatch != null))
return;
if (client.InTeamQualifier()) return;
if (client.Entity.PKMode == Game.Enums.PKMode.Jiang)
{
if ((Game.Enums.PKMode)(byte)Info.dwParam != Game.Enums.PKMode.Jiang)
{
if (client.Entity.MyJiang != null && client.Entity.JiangActive)
{
client.Entity.MyJiang.StartJiang = Time32.Now;
client.Entity.MyJiang.SecondsEnd = 60;
client.Entity.MyJiang.OnShutDown = true;
}
}
}
client.Entity.AttackPacket = null;
client.Entity.PKMode = (Game.Enums.PKMode)(byte)Info.dwParam;
Info.dwParam2 = Info.dwParam;
client.Send(SendPacket(Info));
if (client.Entity.PKMode == Enums.PKMode.PK)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Free PK mode. You can attack monster and all Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Capture)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Capture PK mode. You can only attack monsters, black-name and blue-name Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Peace)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Peace mode. You can only attack monsters.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Team)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Team PK mode. You can attack monster and all Entitys except your teammates.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Revenge)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Revenge PK mode. You can attack monster and all Your Enemy List Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Guild)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Guild PK mode. You can attack monster and all Your Guild's Enemies", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Jiang)
{
client.Entity.MyJiang.SendOnline(client, true);
}
break;
}
case ChangeAction:
{
if (client.ProgressBar != null)
client.ProgressBar.End(client);
client.Entity.Action = (ushort)Info.dwParam;
if (client.Entity.ContainFlag(MsgUpdate.Flags.CastPra y))
{
foreach (var Client in client.Prayers)
{
Info.UID = Client.Entity.UID;
Info.dwParam = (uint)client.Entity.Action;
Info.wParam1 = Client.Entity.X;
Info.wParam2 = Client.Entity.Y;
Client.Entity.Action = client.Entity.Action;
if (Time32.Now >= Client.CoolStamp.AddMilliseconds(1500))
{
if (Client.Equipment.IsAllSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(Client.Entity.Class * 0x10000 + 0x1000000));
else if (Client.Equipment.IsArmorSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(Client.Entity.Class * 0x10000));
Client.SendScreen(SendPacket(Info), true);
Client.CoolStamp = Time32.Now;
}
else
Client.SendScreen(SendPacket(Info), false);
}
}
Info.UID = client.Entity.UID;
Info.dwParam = (uint)client.Entity.Action;
if (client.Entity.Action == New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.Cool)
{
if (Time32.Now >= client.CoolStamp.AddMilliseconds(1500))
{
if (client.Equipment.IsAllSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(client.Entity.Class * 0x10000 + 0x1000000));
else if (client.Equipment.IsArmorSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(client.Entity.Class * 0x10000));
client.SendScreen(SendPacket(Info), true);
client.CoolStamp = Time32.Now;
}
else
client.SendScreen(SendPacket(Info), false);
}
else
client.SendScreen(SendPacket(Info), false);
break;
}
case ChangeDirection:
{
client.Entity.Facing = (Game.Enums.ConquerAngle)Info.Facing;
client.SendScreen(SendPacket(Info), false);
break;
}
case Hotkeys:
client.Send(packet);
break;
case ConfirmSpells:
if (client.MySpells.ClientSpells != null)
{
client.MySpells.SendAll(packet);
}
client.Send(packet);
break;
case ConfirmProficiencies:
if (client.Proficiencies != null)
foreach (Interfaces.IProf proficiency in client.Proficiencies.Values)
proficiency.Send(client);
client.Send(packet);
break;
case ConfirmGuild:
client.Send(packet);
break;
case ConfirmFriends:
#region Friends/Enemy/TradePartners/Apprentices
Message msg2 = new Message("Your friend, " + client.Entity.Name + ", has logged on.", System.Drawing.Color.Red, Message.TopLeft);
foreach (Game.ConquerStructures.Society.Friend friend in client.Friends.Values)
{
if (friend.IsOnline)
{
var pckt = new KnownPersons(true)
{
UID = client.Entity.UID,
Type = KnownPersons.RemovePerson,
Name = client.Entity.Name,
NobilityRank = client.Entity.NobilityRank,
IsBoy = Game.Features.Flowers.IsBoy(client.Entity.Body),
Online = true
};
friend.Client.Send(pckt);
pckt.Type = KnownPersons.AddFriend;
friend.Client.Send(pckt);
friend.Client.Send(msg2);
}
client.Send(new KnownPersons(true)
{
UID = friend.ID,
Type = KnownPersons.AddFriend,
Name = friend.Name,
NobilityRank = friend.NobilityRank,
IsBoy = friend.IsBoy,
Online = friend.IsOnline
});
if (friend.Message != "")
{
client.Send(new Message(friend.Message, client.Entity.Name, friend.Name, System.Drawing.Color.Red, Message.Whisper));
Database.KnownPersons.UpdateMessageOnFriend(friend .ID, client.Entity.UID, "");
}
}
foreach (Game.ConquerStructures.Society.Enemy enemy in client.Enemy.Values)
{
client.Send(new KnownPersons(true)
{
UID = enemy.ID,
Type = KnownPersons.AddEnemy,
Name = enemy.Name,
NobilityRank = enemy.NobilityRank,
// IsBoy = enemy.IsBoy,
Online = enemy.IsOnline
});
}
Message msg3 = new Message("Your partner, " + client.Entity.Name + ", has logged in.", System.Drawing.Color.Red, Message.TopLeft);
foreach (Game.ConquerStructures.Society.TradePartner partner in client.Partners.Values)
{
if (partner.IsOnline)
{
var packet3 = new TradePartner(true)
{
UID = client.Entity.UID,
Type = TradePartner.BreakPartnership,
Name = client.Entity.Name,
HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Tic ks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
Online = true
};
partner.Client.Send(packet3);
packet3.Type = TradePartner.AddPartner;
partner.Client.Send(packet3);
partner.Client.Send(msg3);
}
var packet4 = new TradePartner(true)
{
UID = partner.ID,
Type = TradePartner.AddPartner,
Name = partner.Name,
HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Tic ks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
Online = partner.IsOnline
};
client.Send(packet4);
}
foreach (Game.ConquerStructures.Society.Apprentice appr in client.Apprentices.Values)
{
if (appr.IsOnline)
{
ApprenticeInformation AppInfo = new ApprenticeInformation();
AppInfo.Apprentice_ID = appr.ID;
AppInfo.Apprentice_Level = appr.Client.Entity.Level;
AppInfo.Apprentice_Class = appr.Client.Entity.Class;
AppInfo.Apprentice_PkPoints = appr.Client.Entity.PKPoints;
AppInfo.Apprentice_Experience = appr.Actual_Experience;
AppInfo.Apprentice_Composing = appr.Actual_Plus;
AppInfo.Apprentice_Blessing = appr.Actual_HeavenBlessing;
AppInfo.Apprentice_Name = appr.Name;
AppInfo.Apprentice_Online = true;
AppInfo.Apprentice_Spouse_Name = appr.Client.Entity.Spouse;
AppInfo.Enrole_date = appr.EnroleDate;
AppInfo.Mentor_ID = client.Entity.UID;
AppInfo.Mentor_Mesh = client.Entity.Mesh;
AppInfo.Mentor_Name = client.Entity.Name;
AppInfo.Type = 2;
client.Send(AppInfo);
MentorInformation Information = new MentorInformation(true);
Information.Mentor_Type = 1;
Information.Mentor_ID = client.Entity.UID;
Information.Apprentice_ID = appr.ID;
Information.Enrole_Date = appr.EnroleDate;
Information.Mentor_Level = client.Entity.Level;
Information.Mentor_Class = client.Entity.Class;
Information.Mentor_PkPoints = client.Entity.PKPoints;
Information.Mentor_Mesh = client.Entity.Mesh;
Information.Mentor_Online = true;
Information.Shared_Battle_Power = appr.Client.Entity.BattlePowerFrom(client.Entity);
Information.String_Count = 3;
Information.Mentor_Name = client.Entity.Name;
Information.Apprentice_Name = appr.Name;
Information.Mentor_Spouse_Name = client.Entity.Spouse;
appr.Client.ReviewMentor();
appr.Client.Send(Information);
}
else
{
ApprenticeInformation AppInfo = new ApprenticeInformation();
AppInfo.Apprentice_ID = appr.ID;
AppInfo.Apprentice_Name = appr.Name;
AppInfo.Apprentice_Online = false;
AppInfo.Enrole_date = appr.EnroleDate;
AppInfo.Mentor_ID = client.Entity.UID;
AppInfo.Mentor_Mesh = client.Entity.Mesh;
AppInfo.Mentor_Name = client.Entity.Name;
AppInfo.Type = 2;
client.Send(AppInfo);
}
}
#endregion
client.Send(packet);
break;
case EndTeleport:
break;
case GetSurroundings:
{
if (client.Booth != null)
{
client.Entity.TransformationID = 0;
client.Booth.Remove();
client.Booth = null;
}
client.Screen.FullWipe();
client.Screen.Reload(null);
Game.Weather.CurrentWeatherBase.Send(client);
client.Send(packet);
break;
}
case Jump:
{
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
client.Entity.RemoveBuffersMovements(stream);
}
client.OnAutoAttack = false;
client.Entity.SetAway(false);
client.LastMove = Time32.Now;
if (client.Entity.Dead || client.Entity.ContainFlag((MsgUpdate.Flags.Dead)) || client.Entity.ContainFlag(MsgUpdate.Flags.Ghost))
{
return;
}
client.Entity.KillCount2 = 0;
client.Entity.SpiritFocus = false;
ushort oldX = client.Entity.X;
ushort oldY = client.Entity.Y;
if (client.Entity.OnCheckGuard)
{
client.Entity.OnCheckGuard = false;
client.MessageBox("Unable~to~check!", null, null, 0);
DialyQuestsEffect.CheckCancelGuard(client);
client.Entity.CheckGuardSec = 0;
}
if (client.Team == null)
{
if (client.Entity.SpookMap != null && client.Entity.MapID == client.Entity.SpookMap.ID && Kernel.GetDistance(client.Entity.X, client.Entity.Y, 36, 24) < 25)
{
((INpc)new NpcSpawn
{
UID = 8798,
Mesh = 7610,
Type = Enums.NpcType.Talker,
X = 36,
Y = 24,
MapID = client.Entity.MapID
}).SendSpawn(client);
((INpc)new NpcSpawn
{
UID = 8308,
Mesh = 2507,
Type = Enums.NpcType.Talker,
X = 25,
Y = 30,
MapID = client.Entity.MapID
}).SendSpawn(client);
}
}
else
{
if (client.Team.SpookMap != null && client.Entity.MapID == client.Team.SpookMap.ID && Kernel.GetDistance(client.Entity.X, client.Entity.Y, 36, 24) < 25)
{
((INpc)new NpcSpawn
{
UID = 8798,
Mesh = 7610,
Type = Enums.NpcType.Talker,
X = 36,
Y = 24,
MapID = client.Entity.MapID
}).SendSpawn(client);
((INpc)new NpcSpawn
{
UID = 8308,
Mesh = 2507,
Type = Enums.NpcType.Talker,
X = 25,
Y = 30,
MapID = client.Entity.MapID
}).SendSpawn(client);
}
}
if (client.Entity.MapID == 3846 && Kernel.SpawnNemesis2)
{
foreach (INpc Npc in client.Map.Npcs.Values)
{
if (Npc.MapID == 3846 && (Npc.UID == 3080) && Kernel.GetDistance(client.Entity.X, client.Entity.Y, Npc.X, Npc.Y) < 17)
{
Npc.SendSpawn(client);
}
}
}
if (client.Entity.MapID == 1927 && Kernel.SpawnBanshee2)
{
foreach (INpc Npc in client.Map.Npcs.Values)
{
if (Npc.MapID == 1927 && (Npc.UID == 2999) && Kernel.GetDistance(client.Entity.X, client.Entity.Y, Npc.X, Npc.Y) < 17)
{
Npc.SendSpawn(client);
}
}
}
client.Entity.Action = Enums.ConquerAction.None;
client.Mining = false;
if (client.Entity.ContainFlag(MsgUpdate.Flags.CastPra y))
{
client.Entity.RemoveFlag(MsgUpdate.Flags.CastPray) ;
foreach (var Client in client.Prayers)
{
if (Client.Entity.ContainFlag(MsgUpdate.Flags.Praying ))
{
Client.Entity.RemoveFlag(MsgUpdate.Flags.Praying);
}
}
client.Prayers.Clear();
}
if (client.Entity.ContainFlag(MsgUpdate.Flags.Praying ))
{
client.Entity.RemoveFlag(MsgUpdate.Flags.Praying);
client.PrayLead = null;
}
Time32 Now = Time32.Now;
client.Attackable = true;
if (client.Entity.AttackPacket != null)
{
client.Entity.AttackPacket = null;
}
if (client.Entity.Dead)
{
if (Now > client.Entity.DeathStamp.AddSeconds(4))
{
Console.WriteLine("Disconnected Jump");
client.Disconnect();
return;
}
}
ushort new_X = (ushort)Info.NewX;
ushort new_Y = (ushort)Info.NewY;
if (client.lastJumpDistance == 0) goto Jump;
if (client.Entity.ContainFlag(MsgUpdate.Flags.Ride))
{
int distance = Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
ushort take = (ushort)(1.5F * (distance / 2));
if (client.Entity.Vigor >= take)
{
client.Entity.Vigor -= take;
ServerTime time = new ServerTime();
time.Type = (uint)2;
time.Year = (uint)client.Entity.Vigor;
client.Send(Kernel.FinalizeProtoBuf(time, Game.GamePackets.ServerInfo));
}
}
client.LastJumpTime = (int)Kernel.maxJumpTime(client.lastJumpDistance);
int a1 = Now.GetHashCode() - client.lastJumpTime.GetHashCode();
int a2 = Info.TimeStamp.GetHashCode() - client.lastClientJumpTime.GetHashCode();
bool DOO = false;
if (a2 - a1 > 1000) DOO = true;
if (Now < client.lastJumpTime.AddMilliseconds(client.LastJum pTime))
{
bool doDisconnect = false;
if (client.Entity.Transformed)
if (client.Entity.TransformationID != 207 && client.Entity.TransformationID != 267)
doDisconnect = true;
if (client.Entity.Transformed && doDisconnect)
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
if (client.Entity.Transformed && !doDisconnect)
{
goto Jump;
}
if (!client.Entity.OnCyclone() && !client.Entity.ContainFlag(MsgUpdate.Flags.Ride) && !DOO)
{
//Speedhack detected
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//client.Send(new Message("You have been shifted back . speed hack detected or just lag.", Message.Tip));
//return;
}
else if (client.Entity.ContainFlag(MsgUpdate.Flags.Ride))
{
int time = (int)Kernel.maxJumpTime(client.lastJumpDistance);
int speedprc = Database.DataHolder.SteedSpeed(client.Equipment.Tr yGetItem(ConquerItem.Steed).Plus);
if (speedprc != 0)
{
if (Now < client.lastJumpTime.AddMilliseconds(time - (time * speedprc / 100)))
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
}
else
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
}
}
Jump:
client.lastJumpDistance = Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
client.lastClientJumpTime = Time32.Now;
client.lastJumpTime = Now;
Game.Map Map = client.Map;
if (Map != null)
{
if (Map.Floor[new_X, new_Y, Game.MapObjectType.Entity, null])
{
if (Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
{
client.Entity.Action = Game.Enums.ConquerAction.Jump;
client.Entity.Facing = Kernel.GetAngle((ushort)Info.wParam1, (ushort)Info.wParam2, (ushort)new_X, (ushort)new_Y);
client.Entity.PX = client.Entity.X;
client.Entity.PY = client.Entity.Y;
client.Entity.X = new_X;
client.Entity.Y = new_Y;
if (client.Entity.MapID == MsgCaptureTheFlag.MapID)
PacketHandler.CheckForFlag(client);
foreach (Interfaces.IMapObject obj in client.Screen.Objects)
{
if (obj == null) continue;
if (obj.UID != client.Entity.UID)
{
if (obj.MapObjType == Game.MapObjectType.Entity)
{
GameState client2 = obj.Owner as GameState;
client2.Send(SendPacket(Info));
}
}
}
client.Send(SendPacket(Info));
client.Screen.Reload(SendPacket(Info));
//if (client.Entity.InteractionInProgress && client.Entity.InteractionSet)
//{
// if (client.Entity.Body == 1005 || client.Entity.Body == 1006)
// {
// if (Kernel.GamePool.ContainsKey(client.Entity.Interac tionWith))
// {
// Client.GameState ch = Kernel.GamePool[client.Entity.InteractionWith];
// New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Da ta general = new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Da ta(true);
// general.UID = ch.Entity.UID;
// general.wParam1 = new_X;
// general.wParam2 = new_Y;
// general.ID = 0x9c;
// ch.Send(general.ToArray());
// ch.Entity.Action = Game.Enums.ConquerAction.Jump;
// ch.Entity.X = new_X;
// ch.Entity.Y = new_Y;
// ch.Entity.Facing = Kernel.GetAngle(ch.Entity.X, ch.Entity.Y, new_X, new_Y);
// ch.SendScreen(generalData, true);
// ch.Screen.Reload(general);
// client.SendScreen(generalData, true);
// client.Screen.Reload(general);
// }
// }
//}
}
else
{
client.Disconnect();
}
}
else
{
if (client.Entity.Mode == Game.Enums.Mode.None)
{
client.Entity.Teleport(client.Map.ID, client.Entity.X, client.Entity.Y);
}
}
}
else
{
if (Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
{
client.Entity.Action = Game.Enums.ConquerAction.Jump;
client.Entity.Facing = Kernel.GetAngle((ushort)Info.wParam1, (ushort)Info.wParam2, (ushort)new_X, (ushort)new_Y);
client.Entity.X = new_X;
client.Entity.Y = new_Y;
foreach (Interfaces.IMapObject obj in client.Screen.Objects)
{
if (obj == null) continue;
if (obj.UID != client.Entity.UID)
{
if (obj.MapObjType == Game.MapObjectType.Entity)
{
GameState client2 = obj.Owner as GameState;
client2.Send(SendPacket(Info));
}
}
}
client.Send(SendPacket(Info));
client.Screen.Reload(SendPacket(Info));
}
else
{
client.Disconnect();
}
}
if (client.Map.BaseID == 1038 && (New_Thor_S_B_Mohamed_Hossam.Game.GuildWar.IsWar || New_Thor_S_B_Mohamed_Hossam.Game.SuperGuildWar.IsW ar))
{
New_Thor_S_B_Mohamed_Hossam.Game.Calculations.IsBr eaking(client, oldX, oldY);
}
if (!client.Entity.HasMagicDefender)
{
if (client.Team != null)
{
var owners = client.Team.Teammates.Where(x => x.Entity.MagicDefenderOwner);
if (owners != null)
{
foreach (var owner in owners)
{
if (Kernel.GetDistance(client.Entity.X, client.Entity.Y, owner.Entity.X, owner.Entity.Y) <= 4)
{
client.Entity.HasMagicDefender = true;
client.Entity.MagicDefenderStamp = Time32.Now;
client.Entity.MagicDefenderSecs = (byte)(owner.Entity.MagicDefenderStamp.AddSeconds( owner.Entity.MagicDefenderSecs) - owner.Entity.MagicDefenderStamp).AllSeconds();
client.Entity.AddFlag(Game.MsgServer.MsgUpdate.Fla gs.MagicDefender, 60, true);
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
Game.MsgServer.MsgUpdate upgrade = new Game.MsgServer.MsgUpdate(stream, client.Entity.UID, 1);
//upgrade.UID = client.Entity.UID;
upgrade.Append(stream, Game.MsgServer.MsgUpdate.DataType.AzureShield, 128, client.Entity.MagicDefenderSecs, 0, 0);
client.Send(stream);
//client.Send(upgrade.ToArray());
}
break;
}
}
}
}
}
else
{
client.Entity.RemoveMagicDefender();
}
Database.EntityTable.UpdateCored(client);
client.Entity.SpellStamp = Time32.Now.AddSeconds(-1);
break;
}
case UnknownEntity:
{
#region UnknownEntity
Client.GameState pClient = null;
if (Kernel.GamePool.TryGetValue(Info.dwParam, out pClient))
{
if (Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance && client.Map.ID == pClient.Map.ID)
{
if (pClient.Guild != null)
pClient.Guild.SendName(client);
if (client.Guild != null)
client.Guild.SendName(pClient);
if (pClient.Entity.UID != client.Entity.UID)
{
if (pClient.Map.ID == client.Map.ID)
{
if (pClient.Map.BaseID == 700 && pClient.Map.ID != 700)
{
if (client.InQualifier())
{
if (pClient.InQualifier())
{
client.Entity.SendSpawn(pClient);
pClient.Entity.SendSpawn(client);
if (pClient.Guild != null)
client.Entity.SendSpawn(pClient, false);
if (client.Guild != null)
pClient.Entity.SendSpawn(client, false);
}
else
{
client.Entity.SendSpawn(pClient);
if (pClient.Guild != null)
client.Entity.SendSpawn(pClient, false);
client.Screen.Add(pClient.Entity);
}
}
else
{
if (pClient.InQualifier())
{
pClient.Entity.SendSpawn(client);
if (client.Guild != null)
pClient.Entity.SendSpawn(client, false);
pClient.Screen.Add(client.Entity);
}
else
{
client.Entity.SendSpawn(pClient, false);
pClient.Entity.SendSpawn(client, false);
}
}
}
else
{
client.Entity.SendSpawn(pClient, false);
pClient.Entity.SendSpawn(client, false);
}
}
}
}
}
else
{
Game.Entity monster = null;
if (client.Map.Entities.TryGetValue(Info.dwParam, out monster))
{
if (Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance)
{
monster.SendSpawn(client, false);
}
}
//if (client.Map.Companions.TryGetValue(gdwParam, out monster))
//{
// if (Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance)
// {
// monster.SendSpawn(client, false);
// }
//}
}
#endregion
break;
}
case ChangeFace:
{
if (client.Entity.Money >= 500)
{
uint newface = Info.dwParam;
if (client.Entity.Body > 2000)
{
newface = newface < 200 ? newface + 200 : newface;
client.Entity.Face = (ushort)newface;
}
else
{
newface = newface > 200 ? newface - 200 : newface;
client.Entity.Face = (ushort)newface;
}
}
break;
}
case ObserveEquipment:
case ObserveEquipment2:
case ObserveKnownPerson:
{
if (!client.Entity.InSkillMatch())
{
double power = 1.5;
client.Entity.EquipmentColor = (uint)power;
// client.Entity.BattlePower /= 2;
if (PacketHandler.NulledClient(client))
return;
GameState Observer, Observee;
if (Kernel.GamePool.TryGetValue(Info.UID, out Observer) && Kernel.GamePool.TryGetValue(Info.dwParam, out Observee))
{
if (Info.ID != 117)
{
Observee.Entity.Class = Observee.Entity.Class;
Observer.Send(Observee.Entity.PlayerProto(Observee .Entity, 1));
WindowsStats WS = new WindowsStats(Observee);
WS.Send(Observer);
}
for (byte Position = 1; (int)Position <= 29; ++Position)
{
ConquerItem i = Observee.Equipment.TryGetItem(Position);
if (i != null && i.IsWorn)
{
BoothItem boothItem = new BoothItem();
boothItem.CostType = (ushort)BoothItem.CostTypes.ViewEquip;
boothItem.Identifier = Observee.Entity.UID;
boothItem.Position = (PacketHandler.Positions)((uint)Position);
boothItem.ParseItem(i);
Observer.Send((IPacket)boothItem);
i.SendExtras(client);
}
}
foreach (var it in Observee.Entity.RuneItem.Values.Where(x => x.Position == 101 || x.Position == 102 || x.Position == 103 || x.Position == 104 || x.Position == 105))
{
BoothItem boothItem = new BoothItem();
boothItem.CostType = (ushort)(BoothItem.CostTypes)7;
boothItem.Identifier = Observee.Entity.UID;
boothItem.Position = (New_Thor_S_B_Mohamed_Hossam.Network.PacketHandler .Positions)it.Position;
boothItem.ParseItem(it);
Observer.Send((IPacket)boothItem);
}
_String packet2 = new _String(true);
packet2.Type = 16;
packet2.UID = client.Entity.UID;
packet2.TextsCount = 1;
packet2.Texts = new List<string>() { Observee.Entity.Spouse };
Observer.Send(packet2);
if (Info.ID == 117)
{
packet2.Type = 10;
Observer.Send(packet);
}
Observer.Send(SendPacket(Info));
Observee.Entity.Class = Observee.Entity.Class;
Observee.Send(new Message(Observer.Entity.Name + " is checking your equipment.", Color.Red, Message.Whisper));
}
}
break;
}
case ViewEnemyInfo:
{
if (client.Enemy.ContainsKey(Info.dwParam))
{
if (client.Enemy[Info.dwParam].IsOnline)
{
KnownPersonInfo info = new KnownPersonInfo(true);
info.Fill(client.Enemy[Info.dwParam], true, false);
if (client.Enemy[Info.dwParam].Client.Guild != null)
client.Enemy[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case ViewFriendInfo:
{
if (client.Friends.ContainsKey(Info.dwParam))
{
if (client.Friends[Info.dwParam].IsOnline)
{
KnownPersonInfo info = new KnownPersonInfo(true);
info.Fill(client.Friends[Info.dwParam], false, false);
if (client.Friends[Info.dwParam].Client.Guild != null)
client.Friends[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case ViewPartnerInfo:
{
if (client.Partners.ContainsKey(Info.dwParam))
{
if (client.Partners[Info.dwParam].IsOnline)
{
TradePartnerInfo info = new TradePartnerInfo(true);
info.Fill(client.Partners[Info.dwParam]);
if (client.Partners[Info.dwParam].Client.Guild != null)
client.Partners[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case EndFly:
client.Entity.RemoveFlag(MsgUpdate.Flags.Fly);
client.Entity.RemoveFlag(MsgUpdate.Flags.Infinity) ;
break;
case EndTransformation:
client.Entity.Untransform();
break;
case XPListEnd:
case Die:
break;
case OwnBooth:
{
client.Booth = new Game.ConquerStructures.Booth(client);
client.Send(new MapStatus() { BaseID = client.Map.BaseID, ID = client.Map.ID, Status = Database.MapsTable.MapInformations[1036].Status });
break;
}
case Away:
{
// client.Entity.SetAway(packet[8] == 1);
// client.SendScreen(gData, true);
if (client.Entity.Away == 0)
{
client.Entity.Away = 1;
}
else
{
client.Entity.Away = 0;
}
client.SendScreenSpawn(client.Entity, false);
break;
}
case DeleteCharacter:
{
if ((client.WarehousePW == 0 || client.WarehousePW == 0 && Info.dwParam == 0) || (client.WarehousePW == Info.dwParam))
{
Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.SE LECT).Select("entities").Where("UID", client.Entity.UID);//debug and test!
Database.MySqlReader reader = new Database.MySqlReader(cmd);
if (!reader.Read())//wait
{
Database.MySqlCommand cmd2 = new Database.MySqlCommand(Database.MySqlCommandType.DE LETE);
cmd2.Delete("entities", "Name", client.Entity.Name).Where("UID", client.Entity.UID).Execute();
}
client.Account.EntityID = 0;
client.Account.Save();
client.Disconnect();
}
break;
}
case TeamSearchForMember:
{
if (client.Team != null)
{
Client.GameState Client = null;
if (!client.Team.IsTeammate(Info.UID))
return;
if (Kernel.GamePool.TryGetValue(Info.UID, out Client))
{
Info.wParam1 = Client.Entity.X;
Info.wParam2 = Client.Entity.Y;
client.Send(SendPacket(Info));
}
}
break;
}
default:
client.Send(packet);
break;
}
}
public static byte[] SendPacket(MsgActionProto obj)
{
using (var memoryStream = new System.IO.MemoryStream())
{
Serializer.SerializeWithLengthPrefix(memoryStream, obj, PrefixStyle.Fixed32);
var pkt = new byte[8 + memoryStream.Length];
memoryStream.ToArray().CopyTo(pkt, 0);
Writer.Write((ushort)memoryStream.Length, 0, pkt);
Writer.Write((ushort)10010, 2, pkt);
return pkt;
}
}
}
}
AuthClient.cs
using System;
using Real_Conquer.Network;
using System.Net.Sockets;
using Real_Conquer.Network.Sockets;
using Real_Conquer.Network.Cryptography;
namespace Real_Conquer.Client
{
public class AuthClient
{
private ClientWrapper _socket;
public Network.AuthPackets.Authentication Info;
public Database.AccountTable Account;
public Network.Cryptography.AuthCryptography Cryptographer;
public int PasswordSeed;
public ConcurrentPacketQueue Queue;
public static uint nextID = 0;
public AuthClient(ClientWrapper socket)
{
Queue = new ConcurrentPacketQueue(0);
_socket = socket;
}
public void Send(byte[] buffer)
{
byte[] _buffer = new byte[buffer.Length];
Buffer.BlockCopy(buffer, 0, _buffer, 0, buffer.Length);
Cryptographer.Encrypt(_buffer);
_socket.Send(_buffer);
}
public void Send(Interfaces.IPacket buffer)
{
Send(buffer.ToArray());
}
// public static uint nextID = 0;
}
}
LoaderEncryption.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Real_Conquer.Network.Cryptography
{
public class LoaderEncryption
{
private static byte[] Key = { 12, 12, 215, 10, 20, 11, 60, 193, 11, 96, 53, 157, 71, 37, 150, 225, 86, 224, 178, 184, 230, 147, 79, 194, 160, 0, 99, 239, 218, 134, 179, 13, 247, 155, 237, 245, 165, 245, 128, 144 };
public static void Encrypt(byte[] arr)
{
int length = Key.Length;
for (int i = 0; i < arr.Length; i++)
{
arr[i] ^= Key[i % length];
arr[i] ^= Key[(i + 1) % length];
}
}
public static void Decrypt(byte[] arr, int size)
{
int length = Key.Length;
for (int i = 0; i < size; i++)
{
arr[i] ^= Key[(i + 1) % length];
arr[i] ^= Key[i % length];
}
}
}
}
عفواً لايمكن عرض الروابط في الإرشيف
اول حاجه لو كنت من الناس الي بتتعصب بسرعه ف اقفل الصفحه دي فورا
عفواً لايمكن عرض الروابط في الإرشيف g
اما لو كنت من الناس الصبوره الكويسه فكمل قراءه
عفواً لايمكن عرض الروابط في الإرشيف
تحذير هام
ينوه منتدي اكواد انه غير مسئول عن اي اضرار نفسيه او عصبيه او اي جلطه قد تحدث لمن يحاول اضافة البروتو
و الله الموفق و المستعان
متنساش الصبر مفتاح الفرج و امشي خطوه خطوه
المتطلبات
عفواً لايمكن عرض الروابط في الإرشيف
1- سورس عادي الي هتضيف فيه البروتو و خد منه نسخه عشان لما تبوظه ترجعه تاني
1- سورس بروتو و هتلاقي منه كتير ع النت و المنتدي
1- كوب شاي او عصير
هنجيب سورس البروتو بتاعنا و هندخل علي المسار ده
Network\GamePackets\Proto
هناخد كل الي جواه كوبي
و بعدها نروح للسورس بتاعنا الي عايزين نضيف فيه البروتو هندخل علي نفس المسار و هنعمل فولدر جديد اسمه Proto
عفواً لايمكن عرض الروابط في الإرشيف
بعد ما نعمله هنضيف جواه كل الملفات الي خدناها كوبي
و ندخل علي بروجيكت نضيفهم بردوا
عفواً لايمكن عرض الروابط في الإرشيف
و متنساش تغير اسم البروجيكت
كده اول حته خلصت
بعد كده ابحث عن
ProtoContract
كلك يمين عليها و دوس Find All References
شوف بقا كل الي انته لسه منقلتوش و انقله للسورس بتاعك و متنساش تغير اسم بروجيكت
بعد كده ادخل علي كلاس Entity.cs
و ابحث عن PlayerProto
هيبقي بالشكل ده كده public byte[] PlayerProto(Entity Entity, byte WindowsView = 0)
اقفله من السالب و خده كوبي في السورس بتاعك
هتلاقي حاجات جوه
PlayerProto
جيبالك ايرورات اقف عليها في سورس بروتو و دوس كلك يمين و دوس Find All References
و ظبطها لحد ما تخلصهم كده انته عملت باكت بروتو 10014
طب انا كده خلصت عايز ادخل
افتح
Forward.cs
بدل الي فيه ب
using System;
using System.Text;
using New_Thor_S_B_Mohamed_Hossam.Interfaces;
using New_Thor_S_B_Mohamed_Hossam.Client;
namespace New_Thor_S_B_Mohamed_Hossam.Network.AuthPackets
{
public class Forward : IPacket
{
private byte[] Buffer;
public Forward()
{
this.Buffer = new byte[48];
Writer.WriteUInt16((ushort)40, 0, this.Buffer);
Writer.WriteUInt16((ushort)1637, 2, this.Buffer);
}
public uint Identifier
{
get
{
return BitConverter.ToUInt32(this.Buffer, 4);
}
set
{
Writer.WriteUInt32(value, 4, this.Buffer);
}
}
public Forward.ForwardType Type
{
get
{
return (Forward.ForwardType)BitConverter.ToUInt32(this.Bu ffer, 12);
}
set
{
Writer.WriteUInt32((uint)value, 12, this.Buffer);
}
}
public ushort Port
{
get
{
return BitConverter.ToUInt16(this.Buffer, 16);
}
set
{
Writer.WriteUInt16(value, 16, this.Buffer);
}
}
public string IP
{
get
{
return Encoding.Default.GetString(this.Buffer, 24, 16);
}
set
{
Writer.WriteString(value, 24, this.Buffer);
}
}
public byte[] ToArray()
{
return this.Buffer;
}
public void Deserialize(byte[] buffer)
{
}
public void Send(GameState client)
{
client.Send(this.Buffer);
}
public enum ForwardType : byte
{
InvalidInfo = 1,
Ready = 2,
Banned = 25,
WrongAccount = 57,
}
}
}
Class Program
static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3)
{
var player = arg3.Connector as Client.AuthClient;
player.Cryptographer.Decrypt(buffer, length);
player.Queue.Enqueue(buffer, length);
while (player.Queue.CanDequeue())
{
byte[] packet = player.Queue.Dequeue();
ushort len = BitConverter.ToUInt16(packet, 0);
ushort id = BitConverter.ToUInt16(packet, 2);
if (len == 312)
{
player.Info = new Authentication();
player.Info.Deserialize(packet);
player.Account = new AccountTable(player.Info.Username);
string passdone = "";
msvcrt.msvcrt.srand(player.PasswordSeed);
Forward Fw = new Forward();
if (!player.Account.exists)
{
Fw.Type = Forward.ForwardType.InvalidInfo;
player.Send(Fw);
}
if (player.Account.Password == player.Info.Password && player.Account.exists)
{
Fw.Type = Forward.ForwardType.Ready;
}
else
{
Fw.Type = Forward.ForwardType.InvalidInfo;
}
if (IPBan.IsBanned(arg3.IP))
{
Fw.Type = Forward.ForwardType.Banned;
player.Send(Fw);
return;
}
if (Fw.Type == Network.AuthPackets.Forward.ForwardType.Ready)
{
/* if (player.Info.Server != Constants.ServerName)
{
Console.WriteLine("User==>[" + player.Info.Username + "] Change Name Server To [" + player.Info.Server + "] UID=[" + player.Account.EntityID + "]", ConsoleColor.Blue);
// return;
} */
Client.GameState aClient;
if (Kernel.GamePool.TryGetValue(Fw.Identifier, out aClient))
{
Fw.Type = Forward.ForwardType.InvalidInfo;
aClient.Disconnect();
player.Send(Fw);
return;
}
Fw.Identifier = player.Account.GenerateKey();
Kernel.AwaitingPool[Fw.Identifier] = player.Account;
Fw.IP = GameIP;
Fw.Port = GamePort;
}
player.Send(Fw);
}
}
}
void GameServer_OnClientReceive
static void GameServer_OnClientReceive(byte[] buffer, int length, ClientWrapper obj)
{
if (obj.Connector == null)
{
obj.Disconnect();
return;
}
Client.GameState Client = obj.Connector as Client.GameState;
if (Client.Exchange)
{
Client.Exchange = false;
Client.Action = 1;
var crypto = new GameCryptography(Program.Encoding.GetBytes(Constan ts.GameCryptographyKey));
byte[] otherData = new byte[length];
Array.Copy(buffer, otherData, length);
crypto.Decrypt(otherData, length);
bool extra = false;
int pos = 0;
if (BitConverter.ToInt32(otherData, length - 140) == 128)//no extra packet
{
pos = length - 140;
Client.Cryptography.Decrypt(buffer, length);
}
else if (BitConverter.ToInt32(otherData, length - 180) == 128)//extra packet + 4 3d
{
pos = length - 180;
extra = true;
Client.Cryptography.Decrypt(buffer, length - 40);
}
int len = BitConverter.ToInt32(buffer, pos); pos += 4;
if (len != 128)
{
Client.Disconnect();
return;
}
byte[] pubKey = new byte[128];
for (int x = 0; x < len; x++, pos++) pubKey[x] = buffer[pos];
string PubKey = Program.Encoding.GetString(pubKey);
Client.Cryptography = Client.DHKeyExchange.HandleClientKeyPacket(PubKey, Client.Cryptography);
if (extra)
{
byte[] data = new byte[40];
Buffer.BlockCopy(buffer, length - 40, data, 0, 40);
processData(data, 40, Client);
}
}
else
{
processData(buffer, length, Client);
}
}
class Authentication
using System;
using System.IO;
using System.Text;
using New_Thor_S_B_Mohamed_Hossam.Network.Cryptography;
namespace New_Thor_S_B_Mohamed_Hossam.Network.AuthPackets
{
public class Authentication : Interfaces.IPacket
{
public string Username, Password, Server;
public Authentication() { }
public void Deserialize(byte[] buffer)
{
Username = Program.Encoding.GetString(buffer, 8, 32).Replace("\0", "");
Password = Program.Encoding.GetString(buffer, 100, 32).Replace("\0", "");
Server = Program.Encoding.GetString(buffer, 136, 16).Replace("\0", "");
}
public byte[] ToArray() { throw new NotImplementedException(); }
public void Send(Client.GameState client) { }
}
}
class Constants
GameCryptographyKey = "C238xs65pjy7HU9Q",
CLASS PacketHandler
#region Data (10010)
case 10010:
{
if (client.Action != 2)
return;
var pkt = new MsgAction_TATA();
pkt.Handle(client, packet);
break;
}
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ProtoBuf;
using New_Thor_S_B_Mohamed_Hossam.Network;
using New_Thor_S_B_Mohamed_Hossam.Network.GamePackets;
using New_Thor_S_B_Mohamed_Hossam.Game.Features;
using New_Thor_S_B_Mohamed_Hossam.Game.MsgServer;
using New_Thor_S_B_Mohamed_Hossam.Interfaces;
using New_Thor_S_B_Mohamed_Hossam.Game;
using System.Drawing;
using New_Thor_S_B_Mohamed_Hossam.Client;
namespace New_Thor_S_B_Mohamed_Hossam
{
class MsgAction_TATA
{
public class CustomCommands
{
public const ushort
ExitQuestion = 1,
Minimize = 2,
ShowReviveButton = 1053,
FlowerPointer = 1067,
Enchant = 1091,
LoginScreen = 1153,
SelectRecipiet = 30,
JoinGuild = 34,
MakeFriend = 38,
ChatWhisper = 40,
CloseClient = 43,
HotKey = 53,
Furniture = 54,
TQForum = 79,
PathFind = 97,
LockItem = 102,
ShowRevive = 1053,
HideRevive = 1054,
StatueMaker = 1066,
GambleOpen = 1077,
GambleClose = 1078,
Compose = 1086,
Craft1 = 1088,
Craft2 = 1089,
Warehouse = 1090,
ShoppingMallShow = 1100,
ShoppingMallHide = 1101,
NoOfflineTraining = 1117,
CenterClient = 1155,
ClaimCP = 1197,
ClaimAmount = 1198,
Advertise = 3274,
MerchantApply = 1201,
MerchantDone = 1202,
RedeemEquipment = 1233,
ClaimPrize = 1234,
RepairAll = 1239,
FlowerIcon = 1244,
SendFlower = 1246,
ReciveFlower = 1248,
WarehouseVIP = 1272,
UseExpBall = 1288,
HackProtection = 1298,
HideGUI = 1307,
Inscribe = 3059,
BuyPrayStone = 3069,
HonorStore = 3104,
Opponent = 3107,
CountDownQualifier = 3109,
QualifierStart = 3111,
ItemsReturnedShow = 3117,
ItemsReturnedWindow = 3118,
ItemsReturnedHide = 3119,
QuestFinished = 3147,
QuestPoint = 3148,
QuestPointSparkle = 3164,
StudyPointsUp = 3192,
PKTeamName = 3209,
CTFFlag = 3211,
Updates = 3218,
IncreaseLineage = 3227,
HorseRacingStore = 3245,
GuildPKTourny = 3249,
QuitPK = 3251,
Spectators = 3252,
CardPlayOpen = 3270,
CardPlayClost = 3271,
ArtifactPurification = 3344,
SafeguardConvoyShow = 3389,
SafeguardConvoyHide = 3390,
RefineryStabilization = 3392,
ArtifactStabilization = 3398,
SmallChat = 3406,
NormalChat = 3407,
Reincarnation = 3439,
CTFEnd = 3549,
CTFScores = 3359;
}
public class WindowCommands
{
public const ushort
Compose = 1,
Craft = 2,
Warehouse = 4,
DetainRedeem = 336,
DetainClaim = 337,
VIPWarehouse = 341,
Breeding = 368,
PurificationWindow = 455,
StabilizationWindow = 459,
TalismanUpgrade = 347,
GemComposing = 422,
OpenSockets = 425,
Blessing = 426,
TortoiseGemComposing = 438,
RefineryStabilization = 448,
HorseRacingStore = 464,
JiangHuSetName = 617,
Reincarnation = 485;
}
public const ushort
DragonBallDropped = 165,
JumpOutEffect = 134,
ObserveKnownPerson = 54,
SetLocation = 74,
Hotkeys = 75,
ConfirmFriends = 76,
ConfirmProficiencies = 77,
ConfirmSpells = 78,
ChangeDirection = 79,
ChangeAction = 81,
UsePortal = 85,
Teleport = 86,
Leveled = 92,
XPListEnd = 93,
Revive = 94,
DeleteCharacter = 95,
ChangePKMode = 96,
ConfirmGuild = 97,
SwingPickaxe = 99,
TeamMemberPos = 101,
UnknownEntity = 102,
TeamSearchForMember = 106,
RemoveSpell = 109,
NewCoordonates = 108,
OwnBooth = 111,
GetSurroundings = 114,
OpenCustom = 116,
ObserveEquipment = 117,
EndTransformation = 118,
EndFly = 120,
ViewEnemyInfo = 123,
OpenWindow = 126,
JiangHu0 = 126,
CompleteLogin = 251,
RemoveEntity = 135,
AddEntity = 134,
Jump = 137,
Die = 145,
EndTeleport = 146,
ViewFriendInfo = 148,
ChangeFace = 151,
ViewPartnerInfo = 152,
Confiscator = 153,
OpenShop = 0xA0,
FlashStep = 156,
CountDown = 159,
Away = 161,
AutoPatcher = 162,
HideGui = 158,
AppearanceType = 178,
SpawnEffect = 134,
LevelUpSpell = 252,
RemoveTrap = 434,
LevelUpProficiency = 253,
ObserveEquipment2 = 310,
BeginSteedRace = 401,
FinishSteedRace = 402,
DetainWindowRequest = 153;
public void MsgAction(Client.GameState client, MsgActionProto action, bool SendScreen = false)
{
MsgActionProto Action = new MsgActionProto();
Action = action;
if (SendScreen == true)
{
if (client.Entity.EntityFlag == EntityFlag.Entity)
{
client.SendScreen(SendPacket(Action));
}
else if (client.Entity.EntityFlag == EntityFlag.Monster)
{
client.Entity.MonsterInfo.SendScreen(SendPacket(Ac tion));
}
}
else
{
if (client.Entity.EntityFlag == EntityFlag.Entity)
{
client.Send(SendPacket(Action));
}
}
}
public MsgActionProto Info;
public void Handle(Client.GameState client, byte[] packet)
{
Info = new MsgActionProto();
var myPacket = new byte[packet.Length - 8];
for (int i = 0; i < myPacket.Length; i++)
{
myPacket[i] = packet[i];
}
using (var memoryStream = new MemoryStream(myPacket))
{
Info = Serializer.DeserializeWithLengthPrefix<MsgActionProto>(memoryStream, PrefixStyle.Fixed32);
}
switch (Info.ID)
{
case SetLocation:
if (client._setlocation)
{
if (client.Entity.MyJiang != null)
{
JiangHu.AttributesToArray(client);
if (client.Entity.MyJiang.SecondsEnd != 0)
{
client.Entity.MyJiang.SendOnline(client, true);
client.Entity.MyJiang.OnShutDown = true;
client.Entity.MyJiang.StartJiang = Time32.Now;
client.LoadItemStats();
}
else
{
client.Entity.MyJiang.SendToArray(client, false);
}
}
else if (client.Entity.Reborn == 2)
{
TalentStatus tal = new TalentStatus(client.Entity.UID);
tal.Mode = "0";
tal.Type = 0;
client.Send(tal);
}
SendFlower sendFlower = new SendFlower();
sendFlower.Typing = (Flowers.IsBoy((uint)client.Entity.Body) ? 3u : 2u);
// sendFlower.Apprend(client.Entity.MyFlowers);
client.Send(sendFlower.ToArray());
client.Send(client.Entity.MyAchievement.ToArray()) ;
// ElitePKTournament.GiveClientReward(client);
if (client.Guild != null)
{
client.Guild.SendGuild(client);
GuildMinDonations guildMinDonations = new GuildMinDonations(31);
guildMinDonations.AprendGuild(client.Guild);
client.Send(guildMinDonations.ToArray());
}
Clan clan = client.Entity.GetClan;
if (clan != null)
{
clan.Build(client, Clan.Types.Info);
client.Send(clan);
client.Entity.ClanName = clan.Name;
client.Send(new ClanRelations(clan, ClanRelations.RelationTypes.Allies));
client.Send(new ClanRelations(clan, ClanRelations.RelationTypes.Enemies));
}
foreach (Game.ConquerStructures.Society.Guild guild in Kernel.Guilds.Values)
{
guild.SendName(client);
guild.SendName(client);
}
if (client.Entity.EnlightmentTime > 0)
{
Enlight enlight = new Enlight(true);
enlight.Enlighted = client.Entity.UID;
enlight.Enlighter = 0;
if (client.Entity.EnlightmentTime > 80)
client.Entity.EnlightmentTime = 100;
else if (client.Entity.EnlightmentTime > 60)
client.Entity.EnlightmentTime = 80;
else if (client.Entity.EnlightmentTime > 40)
client.Entity.EnlightmentTime = 60;
else if (client.Entity.EnlightmentTime > 20)
client.Entity.EnlightmentTime = 40;
else if (client.Entity.EnlightmentTime > 0)
client.Entity.EnlightmentTime = 20;
for (int count = 0; count < client.Entity.EnlightmentTime; count += 20)
{
client.Send(enlight);
}
}
if (client.Entity.Hitpoints != 0)
{
if (client.Map.ID == 1036 || client.Map.ID == 1039)
{
if (client.Entity.PreviousMapID == 0)
client.Entity.SetLocation(1002, 410, 354);
else
{
switch (client.Entity.PreviousMapID)
{
default:
{
client.Entity.SetLocation(1002, 410, 354);
break;
}
case 1000:
{
client.Entity.SetLocation(1000, 500, 650);
break;
}
case 1020:
{
client.Entity.SetLocation(1020, 565, 562);
break;
}
case 1011:
{
client.Entity.SetLocation(1011, 188, 264);
break;
}
case 1015:
{
client.Entity.SetLocation(1015, 717, 571);
break;
}
}
}
}
}
else
{
if (client.Entity.MapID == 1038 && New_Thor_S_B_Mohamed_Hossam.Game.GuildWar.IsWar)
{
client.Entity.SetLocation(6001, 31, 74);
}
else
{
ushort[] Point = Database.DataHolder.FindReviveSpot(client.Map.ID);
client.Entity.SetLocation(Point[0], Point[1], Point[2]);
}
}
Info.dwParam = client.Map.BaseID;
Info.wParam1 = client.Entity.X;
Info.wParam2 = client.Entity.Y;
client.Send(SendPacket(Info));
client.Screen.Reload(null);//Done
client.Screen.FullWipe();
client.SendScreenSpawn(client.Entity, true);
client.Screen.Reload(null);
}
break;
case 256:
{
if (client.SashSlots < 200)
{
if (client.Entity.ConquerPoints >= 90)
{
client.Entity.ConquerPoints -= 90;
client.SashSlots += 1;
}
else
{
client.Entity.SendSysMesage("make sure you Have 90 CPs");
}
}
else
{
client.Entity.SendSysMesage("you already opened max number of slots");
}
break;
}
case 255:
{
//PrintPacket(packet);
Info.UID = client.Entity.UID;
Info.ID = 257;
client.Send(SendPacket(Info));
break;
}
case DetainWindowRequest:
{
if (!client.JustOpenedDetain)
{
if (client.DeatinedItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)WindowCommands.DetainRedeem;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
client.Send(MsgAction_TATA.SendPacket(Action));
}
if (client.ClaimableItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)WindowCommands.DetainClaim;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
client.Send(MsgAction_TATA.SendPacket(Action));
}
}
client.JustOpenedDetain = !client.JustOpenedDetain;
break;
}
case 408:
{
if (!client.JustOpenedDetain)
{
if (client.ClaimableItem.Count != 0)
{
MsgActionProto Action = new MsgActionProto();
Action.ID = MsgAction_TATA.OpenWindow;
Action.UID = client.Entity.UID;
Action.dwParam = (uint)MsgAction_TATA.WindowCommands.DetainClaim;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
Action.wParam1 = client.Entity.X;
Action.wParam2 = client.Entity.Y;
client.Send(MsgAction_TATA.SendPacket(Action));
}
}
client.JustOpenedDetain = !client.JustOpenedDetain;
break;
}
case 132:
{
Console.WriteLine("Dis? " + client.Entity.Name);
client.Disconnect();
break;
}
case AppearanceType:
{
if (client.Entity.Tournament_Signed)
return;
Info.UID = client.Entity.UID;
client.Entity.Appearance = (Game.AppearanceType)Info.dwParam;
client.Appearance = (uint)client.Entity.Appearance;
client.SendScreen(SendPacket(Info), true);
break;
}
case CompleteLogin:
{
MsgSignIn.Show(client);
PacketHandler.LoginMessages(client);
client.Send(packet);
break;
}
case LevelUpSpell:
{
if (client.Trade.InTrade)
return;
MsgSpell Spell;
if (client.MySpells.ClientSpells.TryGetValue((ushort) Info.dwParam, out Spell))
{
Dictionary<ushort, Database.MagicType.Magic> DbSpells;
if (Kernel.Magic.TryGetValue(Spell.ID, out DbSpells))
{
if (Spell.Level < DbSpells.Count - 1)
{
decimal cpCost = DbSpells[Spell.Level].CpsCost;
cpCost = ((cpCost / 2) - (cpCost / 2 / 10)) / 10;
int max = Math.Max((int)Spell.Experience, 1);
int percentage = (int)Math.Ceiling((decimal)(100 - (int)(max / Math.Max((DbSpells[Spell.Level].Experience / 100), 1))));
cpCost = Math.Ceiling((decimal)(cpCost * percentage / 100));
if (client.Entity.ConquerPoints >= cpCost)
{
client.Entity.ConquerPoints -= (ulong)cpCost;
client.MySpells.Add(packet, Spell.ID, (ushort)(Spell.Level + 1), Spell.SoulLevel, Spell.PreviousLevel, 0);
}
}
}
}
break;
}
case LevelUpProficiency:
{
ushort proficiencyID = (ushort)Info.dwParam;
IProf proficiency = null;
if (client.Proficiencies.TryGetValue(proficiencyID, out proficiency))
{
if (proficiency.Level != 20)
{
if (client.Trade.InTrade) return;
uint cpCost = 0;
#region Costs
switch (proficiency.Level)
{
case 1: cpCost = 28; break;
case 2: cpCost = 28; break;
case 3: cpCost = 28; break;
case 4: cpCost = 28; break;
case 5: cpCost = 28; break;
case 6: cpCost = 55; break;
case 7: cpCost = 81; break;
case 8: cpCost = 135; break;
case 9: cpCost = 162; break;
case 10: cpCost = 270; break;
case 11: cpCost = 324; break;
case 12: cpCost = 324; break;
case 13: cpCost = 324; break;
case 14: cpCost = 324; break;
case 15: cpCost = 375; break;
case 16: cpCost = 548; break;
case 17: cpCost = 799; break;
case 18: cpCost = 1154; break;
case 19: cpCost = 1420; break;
}
#endregion
uint needExperience = Database.DataHolder.ProficiencyLevelExperience(pro ficiency.Level);
int max = Math.Max((int)proficiency.Experience, 1);
int percentage = 100 - (int)(max / (needExperience / 100));
cpCost = (uint)(cpCost * percentage / 100);
if (client.Entity.ConquerPoints >= cpCost)
{
client.Entity.ConquerPoints -= cpCost;
proficiency.Level++;
if (proficiency.Level == proficiency.PreviousLevel / 2)
{
proficiency.Level = proficiency.PreviousLevel;
Database.DataHolder.ProficiencyLevelExperience((by te)(proficiency.Level + 1));
}
proficiency.Experience = 0;
proficiency.Send(client);
}
}
}
break;
}
case SwingPickaxe:
client.Mining = true;
break;
case Revive:
{
if (client.Entity.ContainFlag(MsgUpdate.Flags.SoulSha ckle))
return;
if (client.InTeamQualifier())
return;
client.Entity.OnDeath = null;
bool ReviveHere = Info.dwParam == 1;
bool Rev = Info.dwParam == 0;
if (client.Entity.StraightLife && !ReviveHere && !Rev)
{
client.Entity.BringToLife();
client.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y, false);
var spell = Database.SpellTable.GetSpell(1095, 4);
client.Entity.AddFlag(MsgUpdate.Flags.Stigma, (int)spell.Duration, true);
var spell1 = Database.SpellTable.GetSpell(1090, 4);
client.Entity.AddFlag(MsgUpdate.Flags.MagicShield, (int)spell1.Duration, true);
client.Entity.StraightLife = false;
}
else
{
if (Time32.Now >= client.Entity.DeathStamp.AddSeconds(18))
{
//
client.Entity.Action = New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.None;
client.ReviveStamp = Time32.Now;
client.Attackable = false;
client.Entity.TransformationID = 0;
client.Entity.RemoveFlag(MsgUpdate.Flags.Dead);
client.Entity.RemoveFlag(MsgUpdate.Flags.Ghost);
client.Entity.Hitpoints = client.Entity.MaxHitpoints;
if (client.Entity.MapID == 1507 || client.Entity.MapID == 1508 || client.Entity.MapID == 1509)
{
client.Entity.Teleport(1002, 410, 354);
return;
}
if (client.Entity.MapID == 1518)
{
client.Entity.Teleport(1002, 410, 354);
return;
}
if (ReviveHere && (client.Entity.HeavenBlessing > 0))
{
if (client.Entity.MapID == 10137)
{
client.Entity.Teleport(client.Map.BaseID, client.Entity.X, client.Entity.Y, false);
return;
}
}
if (client.Entity.MapID == 700)
{
client.Entity.Teleport(700, 51, 51);
}
if (client.Entity.MapID == 3868)
{
client.Entity.Teleport(3868, 227, 240);
}
if (client.Entity.MapID == 1038 && DateTime.Now.DayOfWeek == DayOfWeek.Friday)
{
client.Entity.Teleport(6001, 31, 74);
}
else if (client.Entity.MapID == 10380 && DateTime.Now.Day >= 27 && DateTime.Now.Day <= 29)
{
client.Entity.Teleport(1002, 410, 354);
}
else if (client.Entity.MapID == 1509)
{
client.Entity.Teleport(1509, 103, 43);
}
else if (client.Entity.MapID == 11024)
{
client.Entity.Teleport(11024, 303, 147);
}
else if (client.Entity.MapID == 11032)
{
client.Entity.Teleport(11032, 226, 227);
}
else if (client.Entity.MapID == 2014)
{
client.Entity.Teleport(2014, 150, 162);
}
else if (client.Entity.MapID == 10137)
{
client.Entity.Teleport(10137, 96, 411);
}
else if (client.Entity.MapID == GuildScoreWar.Map.ID)
{
client.Entity.Teleport(GuildScoreWar.Map.ID, 226, 229);
}
else if (client.Entity.MapID == 2071 || client.Entity.MapID == 11022)
{
client.Entity.Teleport(client.Entity.MapID, 43, 129);
}
else if (client.Entity.MapID == 1730)
{
client.Entity.Teleport(1731, 59, 69);
}
else if (client.Entity.MapID == 1731)
{
client.Entity.Teleport(1732, 59, 69);
}
else if (client.Entity.MapID == 1732)
{
client.Entity.Teleport(1733, 59, 69);
}
else if (client.Entity.MapID == 1733)
{
client.Entity.Teleport(1734, 59, 69);
}
else if (client.Entity.MapID == 1734)
{
client.Entity.Teleport(1735, 59, 69);
}
else if (client.Entity.MapID == 1735)
{
}
else if (client.Entity.MapID == 2071)
{
client.Entity.Teleport(2071, 44, 130);
}
else if (client.Entity.MapID == 11017)
{
client.Entity.Teleport(11017, 302, 147);
}
else if (client.Entity.MapID == 1510)
{
client.Entity.Teleport(1510, 103, 44);
}
else if (client.Entity.MapID == 3693)
{
client.Entity.Teleport(1002, 410, 354);
}
else if (client.Entity.MapID == 7777)
{
client.Entity.Teleport(7777, 150, 164);
}
else if (client.Entity.MapID == 8883)
{
if (client.Entity.TeamDeathMatch_BlackTeam == true)
{
client.Entity.Teleport(8883, 042, 051);
}
if (client.Entity.TeamDeathMatch_BlueTeam == true)
{
client.Entity.Teleport(8883, 060, 042);
}
if (client.Entity.TeamDeathMatch_WhiteTeam == true)
{
client.Entity.Teleport(8883, 066, 064);
if (client.Entity.TeamDeathMatch_RedTeam == true)
{
client.Entity.Teleport(8883, 039, 036);
}
}
}
else
{
if (ReviveHere && (client.Entity.HeavenBlessing > 0 || client.Entity.PKMode == Enums.PKMode.Jiang || client.Entity.JiangActive == true))
{
if (client.Entity.MapID == 1762)
{
client.Entity.Teleport(1762, 290, 72);
}
else
client.Entity.Teleport(client.Entity.MapID, client.Entity.X, client.Entity.Y, false);
}
else
{
ushort[] Point = Database.DataHolder.FindReviveSpot(client.Map.ID);
client.Entity.Teleport(Point[0], Point[1], Point[2], false);
}
}
}
}
break;
}
case UsePortal:
{
client.Entity.Action = New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.None;
client.ReviveStamp = Time32.Now;
client.Attackable = false;
ushort portal_X = (ushort)(Info.dwParam & 0xFFFF);
ushort portal_Y = (ushort)(Info.dwParam >> 16);
string portal_ID = portal_X.ToString() + ":" + portal_Y.ToString() + ":" + client.Map.ID.ToString();
if (client.Account.State == Database.AccountTable.AccountState.ProjectManager)
client.Send(new Message("Portal ID: " + portal_ID, System.Drawing.Color.Red, Network.GamePackets.Message.TopLeft));
foreach (Game.Portal portal in client.Map.Portals)
{
int P = Kernel.GetDistance(portal.CurrentX, portal.CurrentY, client.Entity.X, client.Entity.Y);
if (P <= 20)
{
client.Entity.Teleport(portal.DestinationMapID, portal.DestinationX, portal.DestinationY);
return;
}
}
client.Entity.Teleport(1002, 410, 354);
break;
}
case ChangePKMode:
{
if (client.Entity.TeamWatchingMatch != null || client.Entity.SkillWatchingMatch != null || client.WatchingElitePKMatch != null || client.WatchingGroup != null || client.TeamWatchingGroup != null)
{
client.Send("You can not change your pk mode while you are watching.");
return;
}
if (client.Team != null && (client.Team.TeamMatch != null || client.Team.SkillMatch != null))
return;
if (client.InTeamQualifier()) return;
if (client.Entity.PKMode == Game.Enums.PKMode.Jiang)
{
if ((Game.Enums.PKMode)(byte)Info.dwParam != Game.Enums.PKMode.Jiang)
{
if (client.Entity.MyJiang != null && client.Entity.JiangActive)
{
client.Entity.MyJiang.StartJiang = Time32.Now;
client.Entity.MyJiang.SecondsEnd = 60;
client.Entity.MyJiang.OnShutDown = true;
}
}
}
client.Entity.AttackPacket = null;
client.Entity.PKMode = (Game.Enums.PKMode)(byte)Info.dwParam;
Info.dwParam2 = Info.dwParam;
client.Send(SendPacket(Info));
if (client.Entity.PKMode == Enums.PKMode.PK)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Free PK mode. You can attack monster and all Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Capture)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Capture PK mode. You can only attack monsters, black-name and blue-name Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Peace)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Peace mode. You can only attack monsters.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Team)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Team PK mode. You can attack monster and all Entitys except your teammates.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Revenge)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Revenge PK mode. You can attack monster and all Your Enemy List Entitys.", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Enums.PKMode.Guild)
{
client.Send(new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Me ssage("Guild PK mode. You can attack monster and all Your Guild's Enemies", System.Drawing.Color.Red, 0x7d0));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Jiang)
{
client.Entity.MyJiang.SendOnline(client, true);
}
break;
}
case ChangeAction:
{
if (client.ProgressBar != null)
client.ProgressBar.End(client);
client.Entity.Action = (ushort)Info.dwParam;
if (client.Entity.ContainFlag(MsgUpdate.Flags.CastPra y))
{
foreach (var Client in client.Prayers)
{
Info.UID = Client.Entity.UID;
Info.dwParam = (uint)client.Entity.Action;
Info.wParam1 = Client.Entity.X;
Info.wParam2 = Client.Entity.Y;
Client.Entity.Action = client.Entity.Action;
if (Time32.Now >= Client.CoolStamp.AddMilliseconds(1500))
{
if (Client.Equipment.IsAllSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(Client.Entity.Class * 0x10000 + 0x1000000));
else if (Client.Equipment.IsArmorSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(Client.Entity.Class * 0x10000));
Client.SendScreen(SendPacket(Info), true);
Client.CoolStamp = Time32.Now;
}
else
Client.SendScreen(SendPacket(Info), false);
}
}
Info.UID = client.Entity.UID;
Info.dwParam = (uint)client.Entity.Action;
if (client.Entity.Action == New_Thor_S_B_Mohamed_Hossam.Game.Enums.ConquerActi on.Cool)
{
if (Time32.Now >= client.CoolStamp.AddMilliseconds(1500))
{
if (client.Equipment.IsAllSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(client.Entity.Class * 0x10000 + 0x1000000));
else if (client.Equipment.IsArmorSuper())
Info.dwParam = (uint)(Info.dwParam | (uint)(client.Entity.Class * 0x10000));
client.SendScreen(SendPacket(Info), true);
client.CoolStamp = Time32.Now;
}
else
client.SendScreen(SendPacket(Info), false);
}
else
client.SendScreen(SendPacket(Info), false);
break;
}
case ChangeDirection:
{
client.Entity.Facing = (Game.Enums.ConquerAngle)Info.Facing;
client.SendScreen(SendPacket(Info), false);
break;
}
case Hotkeys:
client.Send(packet);
break;
case ConfirmSpells:
if (client.MySpells.ClientSpells != null)
{
client.MySpells.SendAll(packet);
}
client.Send(packet);
break;
case ConfirmProficiencies:
if (client.Proficiencies != null)
foreach (Interfaces.IProf proficiency in client.Proficiencies.Values)
proficiency.Send(client);
client.Send(packet);
break;
case ConfirmGuild:
client.Send(packet);
break;
case ConfirmFriends:
#region Friends/Enemy/TradePartners/Apprentices
Message msg2 = new Message("Your friend, " + client.Entity.Name + ", has logged on.", System.Drawing.Color.Red, Message.TopLeft);
foreach (Game.ConquerStructures.Society.Friend friend in client.Friends.Values)
{
if (friend.IsOnline)
{
var pckt = new KnownPersons(true)
{
UID = client.Entity.UID,
Type = KnownPersons.RemovePerson,
Name = client.Entity.Name,
NobilityRank = client.Entity.NobilityRank,
IsBoy = Game.Features.Flowers.IsBoy(client.Entity.Body),
Online = true
};
friend.Client.Send(pckt);
pckt.Type = KnownPersons.AddFriend;
friend.Client.Send(pckt);
friend.Client.Send(msg2);
}
client.Send(new KnownPersons(true)
{
UID = friend.ID,
Type = KnownPersons.AddFriend,
Name = friend.Name,
NobilityRank = friend.NobilityRank,
IsBoy = friend.IsBoy,
Online = friend.IsOnline
});
if (friend.Message != "")
{
client.Send(new Message(friend.Message, client.Entity.Name, friend.Name, System.Drawing.Color.Red, Message.Whisper));
Database.KnownPersons.UpdateMessageOnFriend(friend .ID, client.Entity.UID, "");
}
}
foreach (Game.ConquerStructures.Society.Enemy enemy in client.Enemy.Values)
{
client.Send(new KnownPersons(true)
{
UID = enemy.ID,
Type = KnownPersons.AddEnemy,
Name = enemy.Name,
NobilityRank = enemy.NobilityRank,
// IsBoy = enemy.IsBoy,
Online = enemy.IsOnline
});
}
Message msg3 = new Message("Your partner, " + client.Entity.Name + ", has logged in.", System.Drawing.Color.Red, Message.TopLeft);
foreach (Game.ConquerStructures.Society.TradePartner partner in client.Partners.Values)
{
if (partner.IsOnline)
{
var packet3 = new TradePartner(true)
{
UID = client.Entity.UID,
Type = TradePartner.BreakPartnership,
Name = client.Entity.Name,
HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Tic ks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
Online = true
};
partner.Client.Send(packet3);
packet3.Type = TradePartner.AddPartner;
partner.Client.Send(packet3);
partner.Client.Send(msg3);
}
var packet4 = new TradePartner(true)
{
UID = partner.ID,
Type = TradePartner.AddPartner,
Name = partner.Name,
HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Tic ks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
Online = partner.IsOnline
};
client.Send(packet4);
}
foreach (Game.ConquerStructures.Society.Apprentice appr in client.Apprentices.Values)
{
if (appr.IsOnline)
{
ApprenticeInformation AppInfo = new ApprenticeInformation();
AppInfo.Apprentice_ID = appr.ID;
AppInfo.Apprentice_Level = appr.Client.Entity.Level;
AppInfo.Apprentice_Class = appr.Client.Entity.Class;
AppInfo.Apprentice_PkPoints = appr.Client.Entity.PKPoints;
AppInfo.Apprentice_Experience = appr.Actual_Experience;
AppInfo.Apprentice_Composing = appr.Actual_Plus;
AppInfo.Apprentice_Blessing = appr.Actual_HeavenBlessing;
AppInfo.Apprentice_Name = appr.Name;
AppInfo.Apprentice_Online = true;
AppInfo.Apprentice_Spouse_Name = appr.Client.Entity.Spouse;
AppInfo.Enrole_date = appr.EnroleDate;
AppInfo.Mentor_ID = client.Entity.UID;
AppInfo.Mentor_Mesh = client.Entity.Mesh;
AppInfo.Mentor_Name = client.Entity.Name;
AppInfo.Type = 2;
client.Send(AppInfo);
MentorInformation Information = new MentorInformation(true);
Information.Mentor_Type = 1;
Information.Mentor_ID = client.Entity.UID;
Information.Apprentice_ID = appr.ID;
Information.Enrole_Date = appr.EnroleDate;
Information.Mentor_Level = client.Entity.Level;
Information.Mentor_Class = client.Entity.Class;
Information.Mentor_PkPoints = client.Entity.PKPoints;
Information.Mentor_Mesh = client.Entity.Mesh;
Information.Mentor_Online = true;
Information.Shared_Battle_Power = appr.Client.Entity.BattlePowerFrom(client.Entity);
Information.String_Count = 3;
Information.Mentor_Name = client.Entity.Name;
Information.Apprentice_Name = appr.Name;
Information.Mentor_Spouse_Name = client.Entity.Spouse;
appr.Client.ReviewMentor();
appr.Client.Send(Information);
}
else
{
ApprenticeInformation AppInfo = new ApprenticeInformation();
AppInfo.Apprentice_ID = appr.ID;
AppInfo.Apprentice_Name = appr.Name;
AppInfo.Apprentice_Online = false;
AppInfo.Enrole_date = appr.EnroleDate;
AppInfo.Mentor_ID = client.Entity.UID;
AppInfo.Mentor_Mesh = client.Entity.Mesh;
AppInfo.Mentor_Name = client.Entity.Name;
AppInfo.Type = 2;
client.Send(AppInfo);
}
}
#endregion
client.Send(packet);
break;
case EndTeleport:
break;
case GetSurroundings:
{
if (client.Booth != null)
{
client.Entity.TransformationID = 0;
client.Booth.Remove();
client.Booth = null;
}
client.Screen.FullWipe();
client.Screen.Reload(null);
Game.Weather.CurrentWeatherBase.Send(client);
client.Send(packet);
break;
}
case Jump:
{
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
client.Entity.RemoveBuffersMovements(stream);
}
client.OnAutoAttack = false;
client.Entity.SetAway(false);
client.LastMove = Time32.Now;
if (client.Entity.Dead || client.Entity.ContainFlag((MsgUpdate.Flags.Dead)) || client.Entity.ContainFlag(MsgUpdate.Flags.Ghost))
{
return;
}
client.Entity.KillCount2 = 0;
client.Entity.SpiritFocus = false;
ushort oldX = client.Entity.X;
ushort oldY = client.Entity.Y;
if (client.Entity.OnCheckGuard)
{
client.Entity.OnCheckGuard = false;
client.MessageBox("Unable~to~check!", null, null, 0);
DialyQuestsEffect.CheckCancelGuard(client);
client.Entity.CheckGuardSec = 0;
}
if (client.Team == null)
{
if (client.Entity.SpookMap != null && client.Entity.MapID == client.Entity.SpookMap.ID && Kernel.GetDistance(client.Entity.X, client.Entity.Y, 36, 24) < 25)
{
((INpc)new NpcSpawn
{
UID = 8798,
Mesh = 7610,
Type = Enums.NpcType.Talker,
X = 36,
Y = 24,
MapID = client.Entity.MapID
}).SendSpawn(client);
((INpc)new NpcSpawn
{
UID = 8308,
Mesh = 2507,
Type = Enums.NpcType.Talker,
X = 25,
Y = 30,
MapID = client.Entity.MapID
}).SendSpawn(client);
}
}
else
{
if (client.Team.SpookMap != null && client.Entity.MapID == client.Team.SpookMap.ID && Kernel.GetDistance(client.Entity.X, client.Entity.Y, 36, 24) < 25)
{
((INpc)new NpcSpawn
{
UID = 8798,
Mesh = 7610,
Type = Enums.NpcType.Talker,
X = 36,
Y = 24,
MapID = client.Entity.MapID
}).SendSpawn(client);
((INpc)new NpcSpawn
{
UID = 8308,
Mesh = 2507,
Type = Enums.NpcType.Talker,
X = 25,
Y = 30,
MapID = client.Entity.MapID
}).SendSpawn(client);
}
}
if (client.Entity.MapID == 3846 && Kernel.SpawnNemesis2)
{
foreach (INpc Npc in client.Map.Npcs.Values)
{
if (Npc.MapID == 3846 && (Npc.UID == 3080) && Kernel.GetDistance(client.Entity.X, client.Entity.Y, Npc.X, Npc.Y) < 17)
{
Npc.SendSpawn(client);
}
}
}
if (client.Entity.MapID == 1927 && Kernel.SpawnBanshee2)
{
foreach (INpc Npc in client.Map.Npcs.Values)
{
if (Npc.MapID == 1927 && (Npc.UID == 2999) && Kernel.GetDistance(client.Entity.X, client.Entity.Y, Npc.X, Npc.Y) < 17)
{
Npc.SendSpawn(client);
}
}
}
client.Entity.Action = Enums.ConquerAction.None;
client.Mining = false;
if (client.Entity.ContainFlag(MsgUpdate.Flags.CastPra y))
{
client.Entity.RemoveFlag(MsgUpdate.Flags.CastPray) ;
foreach (var Client in client.Prayers)
{
if (Client.Entity.ContainFlag(MsgUpdate.Flags.Praying ))
{
Client.Entity.RemoveFlag(MsgUpdate.Flags.Praying);
}
}
client.Prayers.Clear();
}
if (client.Entity.ContainFlag(MsgUpdate.Flags.Praying ))
{
client.Entity.RemoveFlag(MsgUpdate.Flags.Praying);
client.PrayLead = null;
}
Time32 Now = Time32.Now;
client.Attackable = true;
if (client.Entity.AttackPacket != null)
{
client.Entity.AttackPacket = null;
}
if (client.Entity.Dead)
{
if (Now > client.Entity.DeathStamp.AddSeconds(4))
{
Console.WriteLine("Disconnected Jump");
client.Disconnect();
return;
}
}
ushort new_X = (ushort)Info.NewX;
ushort new_Y = (ushort)Info.NewY;
if (client.lastJumpDistance == 0) goto Jump;
if (client.Entity.ContainFlag(MsgUpdate.Flags.Ride))
{
int distance = Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
ushort take = (ushort)(1.5F * (distance / 2));
if (client.Entity.Vigor >= take)
{
client.Entity.Vigor -= take;
ServerTime time = new ServerTime();
time.Type = (uint)2;
time.Year = (uint)client.Entity.Vigor;
client.Send(Kernel.FinalizeProtoBuf(time, Game.GamePackets.ServerInfo));
}
}
client.LastJumpTime = (int)Kernel.maxJumpTime(client.lastJumpDistance);
int a1 = Now.GetHashCode() - client.lastJumpTime.GetHashCode();
int a2 = Info.TimeStamp.GetHashCode() - client.lastClientJumpTime.GetHashCode();
bool DOO = false;
if (a2 - a1 > 1000) DOO = true;
if (Now < client.lastJumpTime.AddMilliseconds(client.LastJum pTime))
{
bool doDisconnect = false;
if (client.Entity.Transformed)
if (client.Entity.TransformationID != 207 && client.Entity.TransformationID != 267)
doDisconnect = true;
if (client.Entity.Transformed && doDisconnect)
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
if (client.Entity.Transformed && !doDisconnect)
{
goto Jump;
}
if (!client.Entity.OnCyclone() && !client.Entity.ContainFlag(MsgUpdate.Flags.Ride) && !DOO)
{
//Speedhack detected
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//client.Send(new Message("You have been shifted back . speed hack detected or just lag.", Message.Tip));
//return;
}
else if (client.Entity.ContainFlag(MsgUpdate.Flags.Ride))
{
int time = (int)Kernel.maxJumpTime(client.lastJumpDistance);
int speedprc = Database.DataHolder.SteedSpeed(client.Equipment.Tr yGetItem(ConquerItem.Steed).Plus);
if (speedprc != 0)
{
if (Now < client.lastJumpTime.AddMilliseconds(time - (time * speedprc / 100)))
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
}
else
{
//client.Entity.Shift(client.Entity.X, client.Entity.Y);
//return;
}
}
}
Jump:
client.lastJumpDistance = Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y);
client.lastClientJumpTime = Time32.Now;
client.lastJumpTime = Now;
Game.Map Map = client.Map;
if (Map != null)
{
if (Map.Floor[new_X, new_Y, Game.MapObjectType.Entity, null])
{
if (Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
{
client.Entity.Action = Game.Enums.ConquerAction.Jump;
client.Entity.Facing = Kernel.GetAngle((ushort)Info.wParam1, (ushort)Info.wParam2, (ushort)new_X, (ushort)new_Y);
client.Entity.PX = client.Entity.X;
client.Entity.PY = client.Entity.Y;
client.Entity.X = new_X;
client.Entity.Y = new_Y;
if (client.Entity.MapID == MsgCaptureTheFlag.MapID)
PacketHandler.CheckForFlag(client);
foreach (Interfaces.IMapObject obj in client.Screen.Objects)
{
if (obj == null) continue;
if (obj.UID != client.Entity.UID)
{
if (obj.MapObjType == Game.MapObjectType.Entity)
{
GameState client2 = obj.Owner as GameState;
client2.Send(SendPacket(Info));
}
}
}
client.Send(SendPacket(Info));
client.Screen.Reload(SendPacket(Info));
//if (client.Entity.InteractionInProgress && client.Entity.InteractionSet)
//{
// if (client.Entity.Body == 1005 || client.Entity.Body == 1006)
// {
// if (Kernel.GamePool.ContainsKey(client.Entity.Interac tionWith))
// {
// Client.GameState ch = Kernel.GamePool[client.Entity.InteractionWith];
// New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Da ta general = new New_Thor_S_B_Mohamed_Hossam.Network.GamePackets.Da ta(true);
// general.UID = ch.Entity.UID;
// general.wParam1 = new_X;
// general.wParam2 = new_Y;
// general.ID = 0x9c;
// ch.Send(general.ToArray());
// ch.Entity.Action = Game.Enums.ConquerAction.Jump;
// ch.Entity.X = new_X;
// ch.Entity.Y = new_Y;
// ch.Entity.Facing = Kernel.GetAngle(ch.Entity.X, ch.Entity.Y, new_X, new_Y);
// ch.SendScreen(generalData, true);
// ch.Screen.Reload(general);
// client.SendScreen(generalData, true);
// client.Screen.Reload(general);
// }
// }
//}
}
else
{
client.Disconnect();
}
}
else
{
if (client.Entity.Mode == Game.Enums.Mode.None)
{
client.Entity.Teleport(client.Map.ID, client.Entity.X, client.Entity.Y);
}
}
}
else
{
if (Kernel.GetDistance(new_X, new_Y, client.Entity.X, client.Entity.Y) <= 20)
{
client.Entity.Action = Game.Enums.ConquerAction.Jump;
client.Entity.Facing = Kernel.GetAngle((ushort)Info.wParam1, (ushort)Info.wParam2, (ushort)new_X, (ushort)new_Y);
client.Entity.X = new_X;
client.Entity.Y = new_Y;
foreach (Interfaces.IMapObject obj in client.Screen.Objects)
{
if (obj == null) continue;
if (obj.UID != client.Entity.UID)
{
if (obj.MapObjType == Game.MapObjectType.Entity)
{
GameState client2 = obj.Owner as GameState;
client2.Send(SendPacket(Info));
}
}
}
client.Send(SendPacket(Info));
client.Screen.Reload(SendPacket(Info));
}
else
{
client.Disconnect();
}
}
if (client.Map.BaseID == 1038 && (New_Thor_S_B_Mohamed_Hossam.Game.GuildWar.IsWar || New_Thor_S_B_Mohamed_Hossam.Game.SuperGuildWar.IsW ar))
{
New_Thor_S_B_Mohamed_Hossam.Game.Calculations.IsBr eaking(client, oldX, oldY);
}
if (!client.Entity.HasMagicDefender)
{
if (client.Team != null)
{
var owners = client.Team.Teammates.Where(x => x.Entity.MagicDefenderOwner);
if (owners != null)
{
foreach (var owner in owners)
{
if (Kernel.GetDistance(client.Entity.X, client.Entity.Y, owner.Entity.X, owner.Entity.Y) <= 4)
{
client.Entity.HasMagicDefender = true;
client.Entity.MagicDefenderStamp = Time32.Now;
client.Entity.MagicDefenderSecs = (byte)(owner.Entity.MagicDefenderStamp.AddSeconds( owner.Entity.MagicDefenderSecs) - owner.Entity.MagicDefenderStamp).AllSeconds();
client.Entity.AddFlag(Game.MsgServer.MsgUpdate.Fla gs.MagicDefender, 60, true);
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
Game.MsgServer.MsgUpdate upgrade = new Game.MsgServer.MsgUpdate(stream, client.Entity.UID, 1);
//upgrade.UID = client.Entity.UID;
upgrade.Append(stream, Game.MsgServer.MsgUpdate.DataType.AzureShield, 128, client.Entity.MagicDefenderSecs, 0, 0);
client.Send(stream);
//client.Send(upgrade.ToArray());
}
break;
}
}
}
}
}
else
{
client.Entity.RemoveMagicDefender();
}
Database.EntityTable.UpdateCored(client);
client.Entity.SpellStamp = Time32.Now.AddSeconds(-1);
break;
}
case UnknownEntity:
{
#region UnknownEntity
Client.GameState pClient = null;
if (Kernel.GamePool.TryGetValue(Info.dwParam, out pClient))
{
if (Kernel.GetDistance(pClient.Entity.X, pClient.Entity.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance && client.Map.ID == pClient.Map.ID)
{
if (pClient.Guild != null)
pClient.Guild.SendName(client);
if (client.Guild != null)
client.Guild.SendName(pClient);
if (pClient.Entity.UID != client.Entity.UID)
{
if (pClient.Map.ID == client.Map.ID)
{
if (pClient.Map.BaseID == 700 && pClient.Map.ID != 700)
{
if (client.InQualifier())
{
if (pClient.InQualifier())
{
client.Entity.SendSpawn(pClient);
pClient.Entity.SendSpawn(client);
if (pClient.Guild != null)
client.Entity.SendSpawn(pClient, false);
if (client.Guild != null)
pClient.Entity.SendSpawn(client, false);
}
else
{
client.Entity.SendSpawn(pClient);
if (pClient.Guild != null)
client.Entity.SendSpawn(pClient, false);
client.Screen.Add(pClient.Entity);
}
}
else
{
if (pClient.InQualifier())
{
pClient.Entity.SendSpawn(client);
if (client.Guild != null)
pClient.Entity.SendSpawn(client, false);
pClient.Screen.Add(client.Entity);
}
else
{
client.Entity.SendSpawn(pClient, false);
pClient.Entity.SendSpawn(client, false);
}
}
}
else
{
client.Entity.SendSpawn(pClient, false);
pClient.Entity.SendSpawn(client, false);
}
}
}
}
}
else
{
Game.Entity monster = null;
if (client.Map.Entities.TryGetValue(Info.dwParam, out monster))
{
if (Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance)
{
monster.SendSpawn(client, false);
}
}
//if (client.Map.Companions.TryGetValue(gdwParam, out monster))
//{
// if (Kernel.GetDistance(monster.X, monster.Y, client.Entity.X, client.Entity.Y) <= Constants.pScreenDistance)
// {
// monster.SendSpawn(client, false);
// }
//}
}
#endregion
break;
}
case ChangeFace:
{
if (client.Entity.Money >= 500)
{
uint newface = Info.dwParam;
if (client.Entity.Body > 2000)
{
newface = newface < 200 ? newface + 200 : newface;
client.Entity.Face = (ushort)newface;
}
else
{
newface = newface > 200 ? newface - 200 : newface;
client.Entity.Face = (ushort)newface;
}
}
break;
}
case ObserveEquipment:
case ObserveEquipment2:
case ObserveKnownPerson:
{
if (!client.Entity.InSkillMatch())
{
double power = 1.5;
client.Entity.EquipmentColor = (uint)power;
// client.Entity.BattlePower /= 2;
if (PacketHandler.NulledClient(client))
return;
GameState Observer, Observee;
if (Kernel.GamePool.TryGetValue(Info.UID, out Observer) && Kernel.GamePool.TryGetValue(Info.dwParam, out Observee))
{
if (Info.ID != 117)
{
Observee.Entity.Class = Observee.Entity.Class;
Observer.Send(Observee.Entity.PlayerProto(Observee .Entity, 1));
WindowsStats WS = new WindowsStats(Observee);
WS.Send(Observer);
}
for (byte Position = 1; (int)Position <= 29; ++Position)
{
ConquerItem i = Observee.Equipment.TryGetItem(Position);
if (i != null && i.IsWorn)
{
BoothItem boothItem = new BoothItem();
boothItem.CostType = (ushort)BoothItem.CostTypes.ViewEquip;
boothItem.Identifier = Observee.Entity.UID;
boothItem.Position = (PacketHandler.Positions)((uint)Position);
boothItem.ParseItem(i);
Observer.Send((IPacket)boothItem);
i.SendExtras(client);
}
}
foreach (var it in Observee.Entity.RuneItem.Values.Where(x => x.Position == 101 || x.Position == 102 || x.Position == 103 || x.Position == 104 || x.Position == 105))
{
BoothItem boothItem = new BoothItem();
boothItem.CostType = (ushort)(BoothItem.CostTypes)7;
boothItem.Identifier = Observee.Entity.UID;
boothItem.Position = (New_Thor_S_B_Mohamed_Hossam.Network.PacketHandler .Positions)it.Position;
boothItem.ParseItem(it);
Observer.Send((IPacket)boothItem);
}
_String packet2 = new _String(true);
packet2.Type = 16;
packet2.UID = client.Entity.UID;
packet2.TextsCount = 1;
packet2.Texts = new List<string>() { Observee.Entity.Spouse };
Observer.Send(packet2);
if (Info.ID == 117)
{
packet2.Type = 10;
Observer.Send(packet);
}
Observer.Send(SendPacket(Info));
Observee.Entity.Class = Observee.Entity.Class;
Observee.Send(new Message(Observer.Entity.Name + " is checking your equipment.", Color.Red, Message.Whisper));
}
}
break;
}
case ViewEnemyInfo:
{
if (client.Enemy.ContainsKey(Info.dwParam))
{
if (client.Enemy[Info.dwParam].IsOnline)
{
KnownPersonInfo info = new KnownPersonInfo(true);
info.Fill(client.Enemy[Info.dwParam], true, false);
if (client.Enemy[Info.dwParam].Client.Guild != null)
client.Enemy[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case ViewFriendInfo:
{
if (client.Friends.ContainsKey(Info.dwParam))
{
if (client.Friends[Info.dwParam].IsOnline)
{
KnownPersonInfo info = new KnownPersonInfo(true);
info.Fill(client.Friends[Info.dwParam], false, false);
if (client.Friends[Info.dwParam].Client.Guild != null)
client.Friends[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case ViewPartnerInfo:
{
if (client.Partners.ContainsKey(Info.dwParam))
{
if (client.Partners[Info.dwParam].IsOnline)
{
TradePartnerInfo info = new TradePartnerInfo(true);
info.Fill(client.Partners[Info.dwParam]);
if (client.Partners[Info.dwParam].Client.Guild != null)
client.Partners[Info.dwParam].Client.Guild.SendName(client);
client.Send(info);
}
}
break;
}
case EndFly:
client.Entity.RemoveFlag(MsgUpdate.Flags.Fly);
client.Entity.RemoveFlag(MsgUpdate.Flags.Infinity) ;
break;
case EndTransformation:
client.Entity.Untransform();
break;
case XPListEnd:
case Die:
break;
case OwnBooth:
{
client.Booth = new Game.ConquerStructures.Booth(client);
client.Send(new MapStatus() { BaseID = client.Map.BaseID, ID = client.Map.ID, Status = Database.MapsTable.MapInformations[1036].Status });
break;
}
case Away:
{
// client.Entity.SetAway(packet[8] == 1);
// client.SendScreen(gData, true);
if (client.Entity.Away == 0)
{
client.Entity.Away = 1;
}
else
{
client.Entity.Away = 0;
}
client.SendScreenSpawn(client.Entity, false);
break;
}
case DeleteCharacter:
{
if ((client.WarehousePW == 0 || client.WarehousePW == 0 && Info.dwParam == 0) || (client.WarehousePW == Info.dwParam))
{
Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.SE LECT).Select("entities").Where("UID", client.Entity.UID);//debug and test!
Database.MySqlReader reader = new Database.MySqlReader(cmd);
if (!reader.Read())//wait
{
Database.MySqlCommand cmd2 = new Database.MySqlCommand(Database.MySqlCommandType.DE LETE);
cmd2.Delete("entities", "Name", client.Entity.Name).Where("UID", client.Entity.UID).Execute();
}
client.Account.EntityID = 0;
client.Account.Save();
client.Disconnect();
}
break;
}
case TeamSearchForMember:
{
if (client.Team != null)
{
Client.GameState Client = null;
if (!client.Team.IsTeammate(Info.UID))
return;
if (Kernel.GamePool.TryGetValue(Info.UID, out Client))
{
Info.wParam1 = Client.Entity.X;
Info.wParam2 = Client.Entity.Y;
client.Send(SendPacket(Info));
}
}
break;
}
default:
client.Send(packet);
break;
}
}
public static byte[] SendPacket(MsgActionProto obj)
{
using (var memoryStream = new System.IO.MemoryStream())
{
Serializer.SerializeWithLengthPrefix(memoryStream, obj, PrefixStyle.Fixed32);
var pkt = new byte[8 + memoryStream.Length];
memoryStream.ToArray().CopyTo(pkt, 0);
Writer.Write((ushort)memoryStream.Length, 0, pkt);
Writer.Write((ushort)10010, 2, pkt);
return pkt;
}
}
}
}
AuthClient.cs
using System;
using Real_Conquer.Network;
using System.Net.Sockets;
using Real_Conquer.Network.Sockets;
using Real_Conquer.Network.Cryptography;
namespace Real_Conquer.Client
{
public class AuthClient
{
private ClientWrapper _socket;
public Network.AuthPackets.Authentication Info;
public Database.AccountTable Account;
public Network.Cryptography.AuthCryptography Cryptographer;
public int PasswordSeed;
public ConcurrentPacketQueue Queue;
public static uint nextID = 0;
public AuthClient(ClientWrapper socket)
{
Queue = new ConcurrentPacketQueue(0);
_socket = socket;
}
public void Send(byte[] buffer)
{
byte[] _buffer = new byte[buffer.Length];
Buffer.BlockCopy(buffer, 0, _buffer, 0, buffer.Length);
Cryptographer.Encrypt(_buffer);
_socket.Send(_buffer);
}
public void Send(Interfaces.IPacket buffer)
{
Send(buffer.ToArray());
}
// public static uint nextID = 0;
}
}
LoaderEncryption.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Real_Conquer.Network.Cryptography
{
public class LoaderEncryption
{
private static byte[] Key = { 12, 12, 215, 10, 20, 11, 60, 193, 11, 96, 53, 157, 71, 37, 150, 225, 86, 224, 178, 184, 230, 147, 79, 194, 160, 0, 99, 239, 218, 134, 179, 13, 247, 155, 237, 245, 165, 245, 128, 144 };
public static void Encrypt(byte[] arr)
{
int length = Key.Length;
for (int i = 0; i < arr.Length; i++)
{
arr[i] ^= Key[i % length];
arr[i] ^= Key[(i + 1) % length];
}
}
public static void Decrypt(byte[] arr, int size)
{
int length = Key.Length;
for (int i = 0; i < size; i++)
{
arr[i] ^= Key[(i + 1) % length];
arr[i] ^= Key[i % length];
}
}
}
}
عفواً لايمكن عرض الروابط في الإرشيف