Пример #1
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     Byte slotId = packet.GetUint8();
     CharacterEntry character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == cclient.Account.Index && c.Slot == slotId);
     if (character.Index < 1) Log.Error(cclient.Account.Username, "Wrong slot specified!");
     World.World info = null;
     lock (Program.worldListener.Worlds)
     {
         Program.worldListener.Worlds.TryGetValue((uint)character.World, out info);
     }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
     if (info == null) Out.WriteUInt32Reverse(1);
     else
     {
         info.Send(new AccountEnter((uint)cclient.Account.Index, (uint)character.Index, cclient.SessionId));
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(info.IP1);
         Out.WriteByte(info.IP2);
         Out.WriteByte(info.IP3);
         Out.WriteByte(info.IP4);
         Out.WriteUInt16Reverse((UInt16)info.Port);
         Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     }
     cclient.Send(Out);
     return 0;
 }
Пример #2
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     Byte slotId = packet.GetUint8();
     Character character = cclient.Characters.Get(slotId);
     if (character == null) Log.Error(cclient.Account.Email, "Wrong slot specified!");
     World.World info = null;
     lock (Program.worldListener.Worlds)
     {
         Program.worldListener.Worlds.TryGetValue(character.WorldId, out info);
     }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
     if (info == null) Out.WriteUInt32Reverse(1);
     else
     {
         info.Send(new AccountEnter(cclient.Account.Id, character.Id, cclient.SessionId));
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(info.IP1);
         Out.WriteByte(info.IP2);
         Out.WriteByte(info.IP3);
         Out.WriteByte(info.IP4);
         Out.WriteUInt16Reverse((UInt16)info.Port);
         Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     }
     cclient.Send(Out);
     return 0;
 }
Пример #3
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     PacketOut Out = new PacketOut((UInt32)Opcodes.LFG);
     if (cclient.LFG == 0)
     {
         MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 1 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
         try
         {
             cmd.Prepare();
             cmd.Parameters.AddWithValue("@name", cclient.Name);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
         finally { cmd.Dispose(); }
         cclient.LFG = 1;
         Out.WriteByte(1);
     }
     else if (cclient.LFG == 1)
     {
         MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 0 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
         try
         {
             cmd.Prepare();
             cmd.Parameters.AddWithValue("@name", cclient.Name);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
         finally { cmd.Dispose(); }
         cclient.LFG = 0;
         Out.WriteByte(0);
     }
     cclient.Send(Out);
     return 0;
 }
Пример #4
0
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_LOGIN_SUCCESS);
     Out.WriteParsedString("Welcome to rebornAPB", 48);
     Out.WriteUInt32Reverse(client.Account.IsAdmin);
     Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     Out.WriteByte(0x13);
     Out.WriteByte(0x29);
     Out.WriteUInt16Reverse(0x12);
     Out.WriteByte(0x0E);
     Out.WriteByte(0x07);
     Out.WriteUInt16Reverse(9999);
     Out.WriteInt32Reverse(1450);
     Out.WriteUInt32Reverse((uint)client.Account.RTW_Points);
     for (int i = 1; i < 6; ++i) Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)client.Account.Index, i, true, "", ""));
     Out.WriteInt32Reverse(0);
     Out.WriteUInt16(0x957D);
     Out.WriteUInt16(0x0400);
     Out.WriteUInt16(0x5052);
     Out.WriteUInt16(0x4F45);
     Out.WriteUInt16(0x552E);
     Out.WriteUInt16(0x3232);
     Out.WriteUInt16(0x3738);
     Out.WriteUInt16(0x3031);
     Out.WriteUInt16(0);
     Out.WriteUInt16(0x0067);
     Out.WriteUInt64(0x526C624331313256);
     Out.WriteUInt64(0x486E314100000000);
     Out.WriteUInt16(0);
     Out.WriteStringBytes("");
     Out.WriteByte(0);
     client.Send(Out);
 }
Пример #5
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte slotId = packet.GetUint8();
     Character Info = cclient.Characters.Get(slotId);
     MySqlCommand cmd = new MySqlCommand("DELETE FROM `clientstatus` WHERE `name` = @name", Connection.Instance);
     try
     {
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@name", Info.Name);
         cmd.ExecuteNonQuery();
     }
     catch (MySqlException) { }
     finally { cmd.Dispose(); }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
     if (Info == null) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(Info.Slot);
         Out.WriteByte(Info.Gender);
         Out.WriteUInt32Reverse(Info.Playtime);
         Out.WriteUInt32Reverse(Info.Rank);
         Out.WriteByte(Info.Threat);
         Out.WriteUInt32Reverse(Info.Money);
         Out.WriteParsedString("APB-EMU", 60);
         byte[] Custom = Info.getCustom();
         Out.Write(Custom, 0, Custom.Length);
     }
     cclient.Send(Out);
     return 0;
 }
Пример #6
0
 public static void Send(LobbyClient client)
 {
     Log.Debug("LOGIN_SALT", "Sent to " + client.Account.Username);
     client.serverModulus = Auth.computeServerModulus(client.Verifier);
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);
     Out.WriteUInt32Reverse((uint)client.Account.Index);
     Out.Write(client.serverModulus.B.ToByteArrayUnsigned(), 0, 64);
     Out.WriteByte(0x40);
     Out.WriteByte(0);
     Out.Write(client.Salt, 0, 10);
     client.Send(Out);
 }
Пример #7
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);
     Out.WriteInt32Reverse(Program.Version[0]);
     Out.WriteInt32Reverse(Program.Version[1]);
     Out.WriteInt32Reverse(Program.Version[2]);
     Out.WriteInt32Reverse(Program.Build);
     Out.WriteByte(0x05);
     for (int i = 0; i < client.ECrypt.Key.Length; i++) Out.WriteByte(client.ECrypt.Key[i]);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     client.SendTCP(Out);
 }
Пример #8
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     UInt32 accountId = packet.GetUint32Reversed();
     Log.Debug("AskWorldEnter", "New client! Account = " + accountId);
     cclient.Account = Databases.AccountTable.SingleOrDefault(a => a.Index == accountId);
     cclient.Character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == accountId);
     lock (Program.expectingAccounts)
     {
         Program.expectingAccounts.TryGetValue(accountId, out cclient.account);
     }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
     if (cclient.account == null) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
         Out.WriteUInt32Reverse(cclient.account.Character);
         Out.WriteUInt32Reverse((uint)cclient.Account.RTW_Points);
         Out.WriteByte(cclient.Account.IsAdmin);
         Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
         Out.WriteFloat(5.00f);
         Out.WriteByte(0);
         Out.WriteByte(0);
         Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 1, false, Program.WorldName, cclient.account.Character.ToString()));
         Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 2, false, Program.WorldName, cclient.account.Character.ToString()));
         Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 3, false, Program.WorldName, cclient.account.Character.ToString()));
         Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 4, false, Program.WorldName, cclient.account.Character.ToString()));
         Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 5, false, Program.WorldName, cclient.account.Character.ToString()));
         Out.WriteByte(1);
         Out.WriteByte(cclient.Character.LFG);
     }
     cclient.Crypto = new TCP.Encryption(cclient.account.SessionId);
     cclient.Send(new DISTRICT_LIST());
     cclient.Send(Out);
     lock (Program.expectingAccounts)
     {
         foreach (KeyValuePair<uint, Acc> a in Program.expectingAccounts)
         {
             if (a.Value == cclient.account)
             {
                 Program.expectingAccounts.Remove(a.Key);
                 break;
             }
         }
     }
     return 0;
 }
Пример #9
0
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);
     if(Program.version == GameVersion.RTW_CB)
     {
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(6);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(509927);
     }
     else if(Program.version == GameVersion.RTW_DVD)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(534979);
     }
     else if (Program.version == GameVersion.RTW_LAST)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(4);
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(555239);
     }
     else if (Program.version == GameVersion.G1_LATEST)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(19);
         Out.WriteInt32Reverse(4);
         Out.WriteInt32Reverse(766569);
     }
     else if (Program.version == GameVersion.G1_ENGUPD)
     {
         Out.WriteInt32Reverse(2);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(750394);
     }
     Out.WriteByte(0x05);
     for (int i = 0; i < client.ECrypt.Key.Length; i++) Out.WriteByte(client.ECrypt.Key[i]);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     client.SendTCP(Out);
 }
Пример #10
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.WORLD_LIST);
     Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
     lock (Program.worldListener.Worlds)
     {
         Out.WriteUInt16Reverse((UInt16)Program.worldListener.Worlds.Count);
         foreach (KeyValuePair<UInt32, World.World> info in Program.worldListener.Worlds)
         {
             Out.WriteUInt32Reverse((UInt32)info.Key);
             Out.WriteParsedString(info.Value.Name, 32);
             Out.WriteByte(1);
             Out.WriteByte(info.Value.Population);
             Out.WriteByte(info.Value.EnforcerRecommended ? (Byte)1 : (Byte)0);
             Out.WriteByte(info.Value.CriminalRecommended ? (Byte)1 : (Byte)0);
         }
     }
     client.Send(Out);
 }
Пример #11
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     WorldClient cclient = (WorldClient)client;
     PacketOut Out = new PacketOut((UInt32)Opcodes.LFG);
     if (cclient.Character.LFG == 0)
     {
         cclient.Character.LFG = 1;
         Databases.CharacterTable.Update(cclient.Character);
         Out.WriteByte(1);
     }
     else if (cclient.Character.LFG == 1)
     {
         cclient.Character.LFG = 0;
         Databases.CharacterTable.Update(cclient.Character);
         Out.WriteByte(0);
     }
     cclient.Send(Out);
     return 0;
 }
Пример #12
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     byte FileId = packet.GetUint8();
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_LOAD);
     Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
     Out.WriteByte(FileId);
     byte[] Result = ZlibMgr.Compress(Program.FileMgr.GetFileByte((int)cclient.Account.Id, FileId, true, "", ""));
     cclient.Send(Out);
     return 0;
 }
Пример #13
0
 static public void Send(LobbyClient client)
 {
     client.Characters = Databases.CharacterTable.Select(c => c.AccountIndex == client.Account.Index);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte((Byte)client.Characters.Count);
     lock (Program.worldListener.Worlds)
     {
         foreach (CharacterEntry chr in client.Characters)
         {
             Out.WriteByte(chr.Slot);
             Out.WriteByte(chr.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse((uint)chr.World);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue((uint)chr.World, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(chr.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Count <= 0) WORLD_LIST.Send(client);
 }
Пример #14
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte slotId = packet.GetUint8();
     CharacterEntry Info = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == cclient.Account.Index && c.Slot == slotId);
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
     if (Info.Index < 1) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(Info.Slot);
         Out.WriteByte(Info.Gender);
         Out.WriteUInt32Reverse((uint)Info.Playtime);
         Out.WriteUInt32Reverse((uint)Info.Rank);
         Out.WriteByte(Info.Threat);
         Out.WriteUInt32Reverse((uint)Info.Money);
         Out.WriteParsedString(Info.Clan, 60);
         byte[] Custom = getCustom(Info);
         Out.Write(Custom, 0, Custom.Length);
     }
     cclient.Send(Out);
     return 0;
 }
Пример #15
0
 static public void Send(LobbyClient client)
 {
     client.Characters = new Characters(client.Account.Id);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte(client.Characters.Length);
     lock (Program.worldListener.Worlds)
     {
         foreach (KeyValuePair<Byte, Character> pair in client.Characters.List)
         {
             Out.WriteByte(pair.Value.Slot);
             Out.WriteByte(pair.Value.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse(pair.Value.WorldId);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue(pair.Value.WorldId, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(pair.Value.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Length <= 0) WORLD_LIST.Send(client);
 }
Пример #16
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     byte FileId = packet.GetUint8();
     UInt32 Version = packet.GetUint32Reversed();
     byte[] File = new byte[packet.Length - packet.Position];
     packet.Read(File, 0, File.Length);
     File = ZlibMgr.Decompress(File);
     Log.Debug("ConfigSave", "Config saved! FileId = " + FileId + " | Version = " + Version + " | Size = " + File.Length);
     Program.FileMgr.SaveInfo((int)cclient.Account.Index, FileId, File);
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_SAVE);
     Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
     Out.WriteByte(FileId);
     Out.Write(File, 0, File.Length);
     cclient.Send(Out);
     return 0;
 }
Пример #17
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteUInt32(id);
     outpack.WriteString(name);
     outpack.WriteByte(title);
     outpack.WriteInt32(leader_id);
     outpack.WriteString(leader_name);
     outpack.WriteLong(money);
     outpack.WriteString(notice);
     outpack.WriteInt32(list_member.Count);
     for (int i = 0; i < list_member.Count; i++)
     {
         outpack.WriteBuff(list_member[i].GetBuffer());
     }
      return outpack.GetBuffer();
 }
Пример #18
0
        /// <summary>
        ///     Sends objective's detailed info in upper right corner of the screen.
        /// </summary>
        /// <param name="plr"></param>
        public void SendFlagInfo(Player plr)
        {
            // return;
            var owningRealm     = OwningRealm;
            var assaultingRealm = AssaultingRealm;
            var Out             = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO, 32);

            Out.WriteUInt32((uint)Id);
            Out.WriteByte(0);
            Out.WriteByte((byte)owningRealm); //(byte)OwningRealm
            Out.WriteByte(1);
            Out.WriteUInt16(0);
            Out.WritePascalString(Name);
            //
            //
            //
            Out.WriteByte(2);
            Out.WriteUInt32(0x0000348F);
            Out.WriteByte((byte)assaultingRealm); // (byte)AssaultingRealm

            // Expansion for objective goal
            Out.WriteByte(0);

            Out.WriteUInt16(0xFF00);
            Out.WritePascalString(GetStateText(plr.Realm));
            Out.WriteByte(0);

            switch (State)
            {
            case StateFlags.ZoneLocked:
            case StateFlags.Locked:
                Out.WritePascalString("This area has been captured by ", GetRealmString(OwningRealm),
                                      ". The battle wages on elsewhere!");
                break;

            case StateFlags.Contested:
                if (plr.Realm != OwningRealm)
                {
                    Out.WritePascalString("This Battlefield Objective is being assaulted by ",
                                          GetRealmString(AssaultingRealm),
                                          ". Ensure the timer elapses to claim it for your Realm!");
                }
                else
                {
                    Out.WritePascalString("This Battlefield Objective is being assaulted by ",
                                          GetRealmString(AssaultingRealm),
                                          ". Reclaim this Battlefield Objective for ", GetRealmString(plr.Realm), "!");
                }
                break;

            case StateFlags.Secure:
                if (plr.Realm == OwningRealm)
                {
                    Out.WritePascalString("This Battlefield Objective is generating resources for ",
                                          GetRealmString(OwningRealm),
                                          ". Defend the flag from enemy assault!");
                }
                else
                {
                    Out.WritePascalString("This Battlefield Objective is generating resources for ",
                                          GetRealmString(OwningRealm),
                                          ". Claim this Battlefield Objective for ", GetRealmString(plr.Realm), "!");
                }
                break;

            case StateFlags.Unsecure:
                Out.WritePascalString("This Battlefield Objective is open for capture!");
                break;

            default:
                Out.WritePascalString("");
                break;
            }


            Out.WriteUInt16(0);                        // _displayedTimer
            Out.WriteUInt16((ushort)DisplayedTimer);   // Timer on map UI
            Out.WriteUInt16(0);                        // _displayedTimer
            Out.WriteUInt16((ushort)(DisplayedTimer)); // Timer in top right of UI
            Out.Fill(0, 4);
            Out.WriteByte(0x71);
            Out.WriteByte(1);
            Out.Fill(0, 3);

            plr.SendPacket(Out);
        }
Пример #19
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteByte(ret);
     outpack.WriteInt32(play_id);
     outpack.WriteInt32(legion_id);
     outpack.WriteLong(money);
     outpack.WriteUInt32(boss_id);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #20
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteInt32(accountid);
     outpack.WriteBool(IsExit);
     outpack.WriteString(name);
     outpack.WriteUInt32(lookface);
     outpack.WriteUInt32(hair);
     outpack.WriteByte(level);
     outpack.WriteInt32(exp);
     outpack.WriteUInt32(life);
     outpack.WriteUInt32(mana);
     outpack.WriteByte(profession);
     outpack.WriteInt16(pk);
     outpack.WriteLong(gold);
     outpack.WriteLong(gamegold);
     outpack.WriteLong(stronggold);
     outpack.WriteUInt32(mapid);
     outpack.WriteInt16(x);
     outpack.WriteInt16(y);
     outpack.WriteString(hotkey);
     outpack.WriteULong(guanjue);
     outpack.WriteByte(godlevel);
     outpack.WriteByte(maxeudemon);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #21
0
        /// <summary>
        ///     Sends the flag object to given player.
        /// </summary>
        /// <param name="plr">Player that entered the objective area</param>
        public override void SendMeTo(Player plr)
        {
            var Out = new PacketOut((byte)Opcodes.F_CREATE_STATIC, 64);

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);

            Out.WriteUInt16(_o);
            Out.WriteUInt16(_z);
            Out.WriteUInt32(_x);
            Out.WriteUInt32(_y);

            ushort displayId;

            switch (OwningRealm)
            {
            case Realms.REALMS_REALM_NEUTRAL:
                displayId = 3442;
                break;

            case Realms.REALMS_REALM_ORDER:
                displayId = 3443;
                break;

            case Realms.REALMS_REALM_DESTRUCTION:
                displayId = 3438;
                break;

            default:
                displayId = 3442;
                break;
            }

            Out.WriteUInt16(displayId);

            Out.WriteUInt16(0x1E);
            Out.WriteUInt16(0);
            Out.WriteUInt16(0);
            Out.WriteByte(0);

            BattlefrontLogger.Trace($"{State} / {InteractableFor(plr)}");
            if (InteractableFor(plr))
            {
                BattlefrontLogger.Trace($"4");
                Out.WriteUInt16(4);
            }
            else
            {
                BattlefrontLogger.Trace($"0");
                Out.WriteUInt16(0);
            }

            Out.WriteByte(0);

            Out.WriteUInt16(0);
            Out.WriteByte(0);
            Out.WriteByte(100);

            Out.WriteUInt16(0);
            Out.WriteUInt16(0);
            Out.WriteUInt32(0);

            Out.WritePascalString("Battlefield Objective");
            Out.WriteByte(0);

            plr.SendPacket(Out);
            // does nothing : base.SendMeTo(plr);
        }
Пример #22
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteInt32(id);
     outpack.WriteByte(friendtype);
     outpack.WriteUInt32(friendid);
     outpack.WriteString(friendname);
     return outpack.GetBuffer();
 }
Пример #23
0
        private void Explosion(GroundTarget gt)
        {
            //play explosion effect
            PacketOut Out = new PacketOut((byte)Opcodes.F_CAST_PLAYER_EFFECT, 30);

            Out.WriteUInt16(gt.Oid);
            Out.WriteUInt16(gt.Oid);
            Out.WriteUInt16(14054);
            Out.WriteByte((byte)1);
            Out.WriteByte((byte)0);
            Out.WriteByte((byte)5);
            Out.WriteByte((byte)0);
            Region.DispatchPacket(Out, gt.WorldPosition, 1200);

            //since game objets are sent to players within 400feet, send explosion effect to  players further away (Explosion wont play to dead players)
            for (int i = 0; i < 2; i++)
            {
                foreach (Player plr in Players[i])
                {
                    if (plr == null || plr.IsDisposed || !plr.IsInWorld())
                    {
                        continue;
                    }

                    if (plr.GetDistanceTo(gt.WorldPosition) > 500)
                    {
                        plr.PlayEffect(1272, gt.WorldPosition);
                    }
                }
            }

            var startTime = DateTime.Now;

            AbilityDamageInfo damageThisPass = new AbilityDamageInfo
            {
                Entry           = 14050,
                DisplayEntry    = 0,
                DamageType      = DamageTypes.RawDamage,
                MinDamage       = (ushort)(30000),
                MaxDamage       = (ushort)(30000),
                CastPlayerSubID = 0
            };

            double explosionTime = 5000;
            double explosionSize = 190;

            EvtInterface.AddEvent(() =>
            {
                var elapsed = DateTime.Now.Subtract(startTime).TotalMilliseconds;
                var expSize = explosionSize * elapsed / explosionTime;

                if (elapsed < explosionTime)
                {
                    foreach (var plr in Region.WorldQuery <Player>(gt.WorldPosition, (int)expSize))
                    {
                        if (plr == null || plr.IsDisposed || !plr.IsInWorld() || plr.IsDead)
                        {
                            continue;
                        }

                        CombatManager.InflictDamage(damageThisPass, 20, plr, plr);
                    }
                }
            }, (int)(explosionTime / 20), (int)(20));
        }
Пример #24
0
        public void SendSiegeResponse(Player player, SiegeType type, SiegeControlType controlType, byte maxPlayers = 0, string siegeName = null)
        {
            if (type == SiegeType.RAM)
            {
                maxPlayers = 4;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);

            Out.WriteByte(0x18);              //siege
            Out.WriteByte((byte)controlType); //control type LEADER, HELPER, RELEASE
            Out.WriteByte(0);

            if (controlType != SiegeControlType.Release)
            {
                Out.WriteByte(0x46); //some sort of ID
                Out.WritePascalString(siegeName);
                Out.WriteByte(1);
                Out.WriteByte(0x28);
                Out.WriteByte(0);
                Out.WriteByte(0);

                if (type == SiegeType.OIL)
                {
                    Out.WriteByte(0x18);
                    Out.WriteByte(0x6A);
                }
                else if (type == SiegeType.GTAOE)
                {
                    Out.WriteByte(0x18);
                    Out.WriteByte(0x6A);
                }
                else if (type == SiegeType.RAM)
                {
                    Out.WriteByte(0x5B);
                    Out.WriteByte(0x60);
                }
                else if (type == SiegeType.SNIPER)
                {
                    Out.WriteByte(0x18);
                    Out.WriteByte(0x6A);
                }

                Out.WriteUInt16(_abilityId);

                Out.WriteByte(0);
                Out.WriteByte(04);
                Out.WriteByte(0);
                Out.WriteByte(maxPlayers); //player count
                Out.WriteByte(0x1E);
                Out.WriteByte(0);
                Out.WriteByte(0);
                Out.WriteByte(0);
                Out.WriteByte(0x10);
                Out.WriteByte((byte)type); //aim type
                Out.WriteByte(0);          //time?
                Out.WriteByte(0);
                Out.WriteByte(0x27);
                Out.WriteByte(0x0);
            }

            player.SendPacket(Out);
        }
        public void BuildPreMail(PacketOut Out, Character_mail mail)
        {
            if (mail == null)
            {
                return;
            }

            Out.WriteUInt32(0);
            Out.WriteUInt32((uint)mail.Guid);
            Out.WriteUInt16((ushort)(mail.Opened ? 1 : 0));
            Out.WriteByte((byte)(mail.AuctionType == 0 ? 100 : 0)); // Icon ID

            uint sentTime = (uint)(TCPManager.GetTimeStamp() - mail.SendDate);
            uint readTime = (uint)(TCPManager.GetTimeStamp() - mail.ReadDate);

            Out.WriteUInt32(0xFFFFFFFF - sentTime);    // LastUpdatedTime Sent
            Out.WriteUInt32(0xFFFFFFFF - readTime);    // LastUpdatedTime Read (not displayed afaik)
            Out.WriteUInt32((uint)TimeToExpire(mail)); // Seconds left (expire after 28/3 days)

            if (mail.AuctionType == 0)
            {
                Out.WriteByte(0); // 1 = localized name

                Out.WriteByte(0);
                Out.WriteStringToZero(mail.SenderName);

                Out.WriteByte(0);
                Out.WriteStringToZero(mail.ReceiverName);

                Out.WriteByte(0);
                Out.WriteStringToZero(mail.Title);
            }
            else
            {
                ushort titleLocal = 0;
                if (mail.AuctionType == 1) // Refund (outbid)
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_REFUND;
                }
                else if (mail.AuctionType == 2) // Complete
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_COMPLETE;
                }
                else if (mail.AuctionType == 3) // Cancelled
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_CANCELLED;
                }
                else if (mail.AuctionType == 4) // Expired
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_EXPIRED;
                }
                else if (mail.AuctionType == 5) // Won
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_WON;
                }
                else
                {
                    titleLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_SUBJECT_OTHER;
                }

                Out.WriteByte(0x0D);
                Out.WriteUInt16(0);
                Out.WriteUInt16((ushort)Localized_text.TEXT_AUCTION_MAIL_SENDER_NAME);
                Out.Fill(0, 5);
                Out.WriteByte(1);
                Out.Fill(0, 3);
                Out.WriteUInt16(titleLocal);
                Out.WriteUInt32(0);
            }

            if (mail.Cr && mail.Money > 0)
            {
                Out.WriteUInt32(0xFFFFFFFF);
                Out.WriteUInt32(uint.MaxValue - mail.Money + 1);
            }
            else
            {
                Out.WriteUInt32(0);
                Out.WriteUInt32(mail.Money);
            }

            Out.WriteUInt16((ushort)mail.Items.Count);
            if (mail.Items.Count > 0)
            {
                Out.WriteByte(0);
            }
            if (mail.Items.Count > 8)
            {
                Out.WriteByte(0);
            }

            foreach (MailItem item in mail.Items)
            {
                if (ItemService.GetItem_Info(item.id) != null)
                {
                    Out.WriteUInt32(ItemService.GetItem_Info(item.id).ModelId);
                }
            }
        }
        public void SendMail(Character_mail mail)
        {
            if (mail == null)
            {
                Log.Error("MailInterface", "Attempted to send NULL mail!");
                return;
            }


            if (mail.Content == null)
            {
                Log.Error("MailInterface", "Mail sent with NULL content!");
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_MAIL);

            Out.WriteByte(0x0D);

            if (mail.AuctionType == 0)
            {
                Out.WriteByte(0);
            }
            else
            {
                Out.WriteByte(1);
            }

            BuildPreMail(Out, mail);

            if (mail.AuctionType == 0)
            {
                Out.WriteUInt16((ushort)(mail.Content.Length + 1));
                Out.WriteStringBytes(mail.Content);
                Out.WriteByte(0);
            }
            else
            {
                ushort contentLocal = 0;
                if (mail.AuctionType == 1) // Refund (outbid)
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_REFUND_ITEM_X;
                }
                else if (mail.AuctionType == 2) // Complete
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_COMPLETE_ITEM_X;
                }
                else if (mail.AuctionType == 3) // Cancelled
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_CANCELLED;
                }
                else if (mail.AuctionType == 4) // Expired
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_EXPIRED;
                }
                else if (mail.AuctionType == 5) // Won
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_WON_ITEM_X;
                }
                else
                {
                    contentLocal = (ushort)Localized_text.TEXT_AUCTION_MAIL_BODY_OTHER;
                }

                Out.WriteUInt16(0);
                Out.WriteUInt16(contentLocal);
                Out.WriteUInt16(0);
                Out.WriteByte(0);

                if (mail.Content.Length == 0)
                {
                    Out.WriteByte(0);
                }
                else
                {
                    Out.WriteByte(1);
                    Out.WriteByte(1);

                    Out.WriteByte(0);
                    Out.WritePascalString(mail.Content);
                }
            }

            Out.WriteByte((byte)mail.Items.Count);
            foreach (MailItem item in mail.Items)
            {
                Item.BuildItem(ref Out, null, null, item, 0, item.count);
            }
            GetPlayer().SendPacket(Out);
        }
Пример #27
0
        public void BuildPreMail(PacketOut Out, Character_mail Mail)
        {
            if (Mail == null)
            {
                return;
            }

            Out.WriteUInt32(0);
            Out.WriteUInt32((UInt32)Mail.Guid);
            Out.WriteUInt16((UInt16)(Mail.Opened ? 1 : 0));
            Out.WriteByte(0x64);                             // Icon ID

            Out.WriteUInt32(0xFFE4D486);                     // Time
            Out.WriteUInt32(0xFFE4D486);                     // Sent time

            Out.WriteUInt32((UInt32)Mail.CharacterIdSender); // Sender ID
            Out.WriteByte(0);                                // 1 = localized name

            Out.WriteByte(0);
            Out.WriteByte((byte)(Mail.SenderName.Length + 1));
            Out.WriteStringBytes(Mail.SenderName);
            Out.WriteByte(0);

            Out.WriteByte(0);

            Out.WriteByte((byte)(Mail.ReceiverName.Length + 1));
            Out.WriteStringBytes(Mail.ReceiverName);
            Out.WriteByte(0);

            Out.WriteByte(0);
            Out.WriteByte((byte)(Mail.Title.Length + 1));
            Out.WriteStringBytes(Mail.Title);
            Out.WriteByte(0);

            Out.WriteUInt32(0);

            Out.WriteUInt32(Mail.Money);
            Out.WriteUInt16((ushort)Mail.ItemsReqInfo.Count);
            if (Mail.ItemsReqInfo.Count > 0)
            {
                Out.WriteByte(0);
            }
            if (Mail.ItemsReqInfo.Count > 8)
            {
                Out.WriteByte(0);
            }

            foreach (Character_items item in Mail.ItemsReqInfo)
            {
                Out.WriteUInt32(item.ModelId);
            }
        }
        private void CheckDropOff(GameObject flagDrop, Player capturer)
        {
            if (flagDrop == _flagDrops[0])
            {
                if (capturer.Realm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    capturer.SendClientMessage("This is the enemy realm's flag drop off point", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            else if (flagDrop == _flagDrops[1])
            {
                if (capturer.Realm == Realms.REALMS_REALM_ORDER)
                {
                    capturer.SendClientMessage("This is the enemy realm's flag drop off point", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            else
            {
                return;
            }

            HoldObject destFlag = null;

            foreach (HoldObject flag in _flags)
            {
                if (flag.Holder == capturer)
                {
                    destFlag = flag;
                }

                else if (flag.HeldState != EHeldState.Carried)
                {
                    capturer.SendClientMessage("You can only drop off the enemy flag if both flags are held", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            if (destFlag == null)
            {
                capturer.SendClientMessage("You are not holding a flag", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                return;
            }

            GivePoints((int)capturer.Realm, 50);

            PacketOut Out = new PacketOut((byte)Opcodes.F_PLAY_SOUND);

            Out.WriteByte(0);
            Out.WriteUInt16(capturer.Realm == Realms.REALMS_REALM_ORDER ? (ushort)0x0C : (ushort)0x332);
            Out.Fill(0, 10);

            for (int i = 0; i < 2; ++i)
            {
                foreach (Player player in Players[i])
                {
                    player.SendClientMessage($"{capturer.Name} of {(capturer.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction")} has dropped off the {destFlag.name}!", ChatLogFilters.CHATLOGFILTERS_C_WHITE);
                    player.SendPacket(Out);
                }
            }

            foreach (HoldObject flag in _flags)
            {
                flag.ResetTo(EHeldState.Home);
            }
        }
        private void CheckCapture(GameObject flagBase, Player capturer)
        {
            if (flagBase == _flagBases[0])
            {
                if (capturer.Realm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    capturer.SendClientMessage("This is the enemy realm's flag return point", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            else if (flagBase == _flagBases[1])
            {
                if (capturer.Realm == Realms.REALMS_REALM_ORDER)
                {
                    capturer.SendClientMessage("This is the enemy realm's flag return point", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            else
            {
                return;
            }

            HoldObject destFlag = null;

            foreach (HoldObject flag in _flags)
            {
                if (flag.Holder == capturer)
                {
                    destFlag = flag;
                }

                else if (flag.HeldState != EHeldState.Home)
                {
                    capturer.SendClientMessage("You cannot capture the enemy flag if your own is held", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                    return;
                }
            }

            if (destFlag == null)
            {
                capturer.SendClientMessage("You must be holding the flag to capture", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR);
                return;
            }

            GivePoints((int)capturer.Realm, _captureScore);

            PacketOut Out = new PacketOut((byte)Opcodes.F_PLAY_SOUND);

            Out.WriteByte(0);
            Out.WriteUInt16(capturer.Realm == Realms.REALMS_REALM_ORDER ? (ushort)0x0C : (ushort)0x332);
            Out.Fill(0, 10);

            for (int i = 0; i < 2; ++i)
            {
                foreach (Player player in Players[i])
                {
                    player.SendLocalizeString(new[] { capturer.Name, capturer.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction", destFlag.name }, ChatLogFilters.CHATLOGFILTERS_C_WHITE, Localized_text.TEXT_FLAG_CAPTURE);
                    player.SendPacket(Out);
                }
            }

            foreach (HoldObject flag in _flags)
            {
                flag.ResetTo(EHeldState.Home);
            }
        }
Пример #30
0
        /// <summary>
        ///     Sends the state of the objective in user's map, can announce state changing.
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="announce"></param>
        /// <param name="update"></param>
        public void SendFlagState(Player plr, bool announce, bool update = true)
        {
            if (!Loaded)
            {
                return;
            }

            var flagState = GetStateFlags();

            var Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_STATE, 16);

            Out.WriteUInt32((uint)Id);

            if (
                State == StateFlags
                .Contested /*|| (State == StateFlags.Secure && MAX_SECURE_PROGRESS == _secureProgress)*/)
            {
                Out.Fill(0, 2);
                Out.WriteUInt16((ushort)_displayedTimer);
                Out.Fill(0xFF, 2);
                Out.WriteUInt16(0);
            }

            /*else if (GeneratingSupplies && _tier > 1 && _displayedTimer == 0)
             * {
             *  Out.Fill(0xFF, 4);
             *  Out.WriteByte(0);
             *  Out.WriteByte((byte)Math.Max(0, _generationTimerEnd - TCPManager.GetTimeStamp())); // Unk6 - time till next resource release
             *  Out.WriteUInt16(175); // Unk7 - vertical offset for drawing overlay - Unk6 may not exceed
             * }*/
            else if (State == StateFlags.Secure)
            {
                //Out.Fill(0xFF, 4);
                Out.Fill(0, 2);
                Out.WriteUInt16((ushort)_displayedTimer);
                //Out.WriteByte((byte)(SECURE_PROGRESS_MAX - _lastSecureProgress)); // Unk6 - time till next resource release
                //Out.WriteByte(0);
                //if (SECURE_PROGRESS_MAX == _lastSecureProgress)
                //{
                //    Out.Fill(0xFF, 2);
                //} else
                //{
                //    Out.WriteUInt16((ushort)(SECURE_PROGRESS_MAX - _lastSecureProgress)); // Unk6 - time till next resource release
                //}
                Out.WriteByte(0);
                Out.WriteByte((byte)(MAX_SECURE_PROGRESS - _secureProgress)); // Unk6 - time till next resource release
                Out.WriteUInt16(
                    (ushort)MAX_SECURE_PROGRESS);                             // Unk7 - vertical offset for drawing overlay - Unk6 may not exceed
            }
            else
            {
                Out.Fill(0xFF, 6);
                Out.WriteUInt16(0);
            }

            Out.WriteByte((byte)OwningRealm);
            Out.WriteByte(update ? (byte)1 : (byte)0);
            Out.WriteByte(flagState);
            Out.WriteByte(0);

            if (!announce)
            {
                if (plr != null)
                {
                    plr.SendPacket(Out);
                }
                else
                {
                    foreach (var player in Region.Players)
                    {
                        player.SendPacket(Out);
                    }
                }
                return;
            }

            string message     = null;
            var    largeFilter = OwningRealm == Realms.REALMS_REALM_ORDER
                ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE
                : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE;
            PacketOut snd = null;

            switch (State)
            {
            //case StateFlags.Unsecure:
            //    message = string.Concat(Name, " is now open for capture !");
            //    break;
            case StateFlags.Contested:
                if (_lastBroadCastState != State)
                {
                    _lastBroadCastState = State;
                    _lastSecutedState   = false;
                    message             = string.Concat(Name, " is under assault by the forces of ",
                                                        GetRealmString(AssaultingRealm), "!");
                }
                break;

            case StateFlags.Secure:
                var securedState = _secureProgress == MAX_SECURE_PROGRESS;
                if (_lastBroadCastState != State || _lastSecutedState != securedState)
                {
                    _lastBroadCastState = State;
                    _lastSecutedState   = securedState;

                    if (_secureProgress == MAX_SECURE_PROGRESS)
                    {
                        message = string.Concat($"The forces of ", GetRealmString(OwningRealm), " have taken ",
                                                Name, "!");
                        snd = new PacketOut((byte)Opcodes.F_PLAY_SOUND);
                        snd.WriteByte(0);
                        snd.WriteUInt16(OwningRealm == Realms.REALMS_REALM_ORDER ? (ushort)0x0C : (ushort)0x332);
                        snd.Fill(0, 10);
                    }
                    else
                    {
                        message = string.Concat($"The forces of ", GetRealmString(OwningRealm), " are securing ",
                                                Name, "!");
                    }
                }
                break;
            }

            if (plr != null)
            {
                plr.SendPacket(Out);
            }
            else
            {
                foreach (var player in Region.Players)
                {
                    player.SendPacket(Out); // Objective's state

                    if (string.IsNullOrEmpty(message) || !player.CbtInterface.IsPvp)
                    {
                        continue;
                    }

                    // Notify RvR flagged players of activity
                    //player.SendLocalizeString(message, ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT);
                    //player.SendLocalizeString(message, largeFilter, Localized_text.CHAT_TAG_DEFAULT);
                    if (snd != null)
                    {
                        player.SendPacket(snd);
                    }
                }
            }
        }
Пример #31
0
        public override void SendInteract(Player Plr, InteractMenu Menu)

        {
            Log.Success("SendInteract", "" + Name + " -> " + Plr.Name + ",Type=" + InteractType);


            PacketOut Out = new PacketOut((byte)Opcodes.F_SET_ABILITY_TIMER);

            Out.WriteByte(0);                    // 00
            Out.WriteByte(1);                    // 01
            Out.WriteByte(1);                    // 01
            Out.WriteByte(5);                    // 05
            Out.WriteUInt16(0);                  //00 00
            Out.WriteUInt16(Spawn.GameObjTimer); // 13 88 =5000
            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);
            Plr.SendPacket(Out);


            if (Spawn.GameObjTimer == 0)

            {
                Out = new PacketOut((byte)Opcodes.F_SET_ABILITY_TIMER);
                Out.WriteByte(0);   // 00
                Out.WriteByte(1);   // 01
                Out.WriteByte(1);   // 01
                Out.WriteUInt16(0); //00 00
                Out.WriteUInt16(0); // 13 88
                Out.WriteUInt16(0);
                Out.WriteUInt16(0);
                Out.WriteByte(0);

                Plr.SendPacket(Out);
            }


            Out = new PacketOut((byte)Opcodes.F_PLAY_EFFECT);
            Out.WriteUInt16((UInt16)0x0144);
            Out.WriteByte(0);// 00
            Out.WriteUInt16((UInt16)Spawn.WorldZ);
            Out.WriteUInt32((UInt32)Spawn.WorldX);
            Out.WriteUInt32((UInt32)Spawn.WorldY);
            Out.WriteUInt16(0x0017);// 00 17
            Out.Fill(0, 5);
            Plr.SendPacket(Out);



            Tok_Info Info = WorldMgr.GetTok(Spawn.Proto.TokUnlock);

            if (!IsDead)
            {
                Plr.QtsInterface.HandleEvent(Objective_Type.QUEST_USE_GO, Spawn.Entry, 1);
            }

            if (Spawn.Proto.TokUnlock != 0)
            {
                Plr.TokInterface.AddTok(Info);
            }

            Loot Loots = LootsMgr.GenerateLoot(this, Plr);

            if (Loots != null)
            {
                Loots.SendInteract(Plr, Menu);
                // If object has been looted, make it unlootable
                // and then Reset its lootable staus in XX seconds
                if (!Loots.IsLootable())
                {
                    Looted = true;
                    foreach (Object Obj in this._ObjectRanged)
                    {
                        if (Obj.IsPlayer())
                        {
                            this.SendMeTo(Obj.GetPlayer());
                        }
                    }
                    EvtInterface.AddEvent(ResetLoot, RELOOTABLE_TIME, 1);
                }
            }



            if (Spawn.DoorId != 0)
            {
                if (DoorOpen)
                {
                    CloseDoor();
                }
                else
                {
                    OpenDoor();
                }
            }



            base.SendInteract(Plr, Menu);
        }
Пример #32
0
        /// <summary>
        ///     Sends objective's detailed info in upper right corner of the screen.
        /// </summary>
        /// <param name="plr"></param>
        public void SendFlagInfo(Player plr)
        {
            // return;
            var owningRealm     = OwningRealm;
            var assaultingRealm = AssaultingRealm;

            if (_tier == 4)
            {
                var prFrnt = (ProximityProgressingBattlefront)Region.Bttlfront;
                if (prFrnt != null && ZoneId != prFrnt.Zones[prFrnt._battlefrontStatus.OpenZoneIndex].ZoneId)
                {
                    owningRealm     = OwningRealm;
                    assaultingRealm = OwningRealm;
                }
            }

            // Log.Info("Name", ID.ToString());
            // Log.Info("OwningRealm", Enum.GetName(typeof(Realms), owningRealm));
            // Log.Info("AssaultingRealm", Enum.GetName(typeof(Realms), assaultingRealm));

            var Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO, 32);

            Out.WriteUInt32((uint)Id);
            Out.WriteByte(0);
            Out.WriteByte((byte)owningRealm); //(byte)OwningRealm
            Out.WriteByte(1);
            Out.WriteUInt16(0);
            Out.WritePascalString(Name);
            //
            //
            //
            Out.WriteByte(2);
            Out.WriteUInt32(0x0000348F);
            Out.WriteByte((byte)assaultingRealm); // (byte)AssaultingRealm

            // Expansion for objective goal
            Out.WriteByte(0);

            Out.WriteUInt16(0xFF00);
            Out.WritePascalString(GetStateText(plr.Realm));
            Out.WriteByte(0);

            switch (State)
            {
            case StateFlags.ZoneLocked:
            case StateFlags.Locked:
                Out.WritePascalString("This area has been captured by ", GetRealmString(OwningRealm),
                                      ". The battle wages on elsewhere!");
                break;

            case StateFlags.Contested:
                if (plr.Realm != OwningRealm)
                {
                    Out.WritePascalString("This Battlefield Objective is being assaulted by ",
                                          GetRealmString(AssaultingRealm),
                                          ". Ensure the timer elapses to claim it for your Realm!");
                }
                else
                {
                    Out.WritePascalString("This Battlefield Objective is being assaulted by ",
                                          GetRealmString(AssaultingRealm),
                                          ". Reclaim this Battlefield Objective for ", GetRealmString(plr.Realm), "!");
                }
                break;

            case StateFlags.Secure:
                if (plr.Realm == OwningRealm)
                {
                    Out.WritePascalString("This Battlefield Objective is generating resources for ",
                                          GetRealmString(OwningRealm),
                                          ". Defend the flag from enemy assault!");
                }
                else
                {
                    Out.WritePascalString("This Battlefield Objective is generating resources for ",
                                          GetRealmString(OwningRealm),
                                          ". Claim this Battlefield Objective for ", GetRealmString(plr.Realm), "!");
                }
                break;

            case StateFlags.Unsecure:
                Out.WritePascalString("This Battlefield Objective is open for capture!");
                break;

            default:
                Out.WritePascalString("");
                break;
            }

            // Displayed transition timer in seconds
            var transitionTimer = _nextTransitionTimestamp == 0
                ? (ushort)0
                : (ushort)((_nextTransitionTimestamp - TCPManager.GetTimeStampMS()) / 1000);

            transitionTimer = (ushort)_displayedTimer;
            // Log.Info("transitionTimer", _displayedTimer.ToString());

            Out.WriteUInt16(0);                       // _displayedTimer
            Out.WriteUInt16((ushort)_displayedTimer); // _displayedTimer
            Out.WriteUInt16(0);                       // _displayedTimer
            Out.WriteUInt16((ushort)_displayedTimer); // _displayedTimer
            Out.Fill(0, 4);
            Out.WriteByte(0x71);
            Out.WriteByte(1);
            Out.Fill(0, 3);

            plr.SendPacket(Out);
        }
        /// <summary>
        /// <para>Cancels the currently casting ability.</para>
        /// <para>If FailCode is specified, will display a message on the client.</para>
        /// <para>If FailCode is omitted, will reset the client's GCD and ability-specific cooldown.</para>
        /// </summary>
        /// <param name="failCode"></param>
        public void CancelCast(ushort failCode, bool force = true)
        {
            if (_inCastCompletion)
            {
                return;
            }
            if (_channelHandler.HasInfo())
            {
                // Cannot interrupt morale channels
                if (AbInfo.SpecialCost == -4 && !force)
                {
                    return;
                }

                _channelHandler.Interrupt();
            }

            else
            {
                if (failCode == (ushort)AbilityResult.ABILITYRESULT_NOTVISIBLECLIENT && (TCPManager.GetTimeStampMS() - _castStartTime) > AbInfo.CastTime * 0.75f)
                {
                    return;
                }

                // Interruptions on spells with a cast time reset the GCD
                if (AbInfo.CastTime > 0 && _abInterface.Cooldowns.ContainsKey(0))
                {
                    _abInterface.Cooldowns.Remove(0);
                }
            }

            if (AbInfo == null)
            {
                Log.Error("Ability System", "Cancellation on NULL ABILITY - Caster is " + _caster.Name);
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_USE_ABILITY, 20);

            Out.WriteUInt16(0);
            Out.WriteUInt16(AbInfo.Entry);
            Out.WriteUInt16(_caster.Oid);
            Out.WriteUInt16(AbInfo.ConstantInfo.EffectID);
            Out.WriteUInt16(AbInfo.Target?.Oid ?? 0);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.WriteUInt16(failCode);
            // If a value is sent here, the GCD and cooldown will both reset.
            // TODO: Experiment with positive values.
            if (failCode == 0)
            {
                Out.WriteInt16((short)-(TCPManager.GetTimeStampMS() - _castStartTime));
            }
            else
            {
                Out.WriteInt16(0);
            }
            Out.WriteByte(_castSequence);
            Out.WriteUInt16(0);
            Out.WriteByte(0);

            _caster.DispatchPacket(Out, force);

            // This packet hides the cast bar when a spell is cast, so I guess it signals the end of the ability.
            // Seems to be sent on forced interrupts and on instant cast ability completion.
            if (force)
            {
                Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE, 10);

                Out.WriteUInt16(_caster.Oid);
                Out.WriteByte((byte)StateOpcode.CastCompletion);
                Out.WriteUInt16(0);
                Out.WriteByte(0);
                Out.WriteUInt16(AbInfo.Entry);
                Out.WriteByte(0);
                Out.WriteByte(0);

                (_caster as Player)?.SendPacket(Out);
            }

            Clear();
        }
Пример #34
0
        public void HandleEvent(Player player, Objective_Type type, uint entry, int count, ushort contributionGain, string pqGoClicked = null)
        {
            if (Stage == null)
            {
                return;
            }

            byte   objid    = 0;
            string objectID = "0";

            foreach (PQuestObjective obj in Stage.Objectives)
            {
                if (obj.IsDone())
                {
                    objid++;
                    continue;
                }
                if (obj.Objective.Type != (int)type)
                {
                    objid++;
                    continue;
                }
                int oldCount = obj.Count;

                switch (type)
                {
                case Objective_Type.QUEST_SPEAK_TO:
                case Objective_Type.QUEST_KILL_MOB:

                    uint outVal = 0;
                    //More than one type of NPC can count to the same PQ objective kill count
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId) == entry))
                    {
                        objectID   = obj.Objective.ObjectId;
                        obj.Count += count;
                        break;
                    }
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId2, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId2) == entry))
                    {
                        objectID   = obj.Objective.ObjectId2;
                        obj.Count += count;
                        break;
                    }
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId3, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId3) == entry))
                    {
                        objectID   = obj.Objective.ObjectId3;
                        obj.Count += count;
                        break;
                    }
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId4) == entry))
                    {
                        objectID   = obj.Objective.ObjectId4;
                        obj.Count += count;
                        break;
                    }
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId5) == entry))
                    {
                        objectID   = obj.Objective.ObjectId4;
                        obj.Count += count;
                        break;
                    }
                    if (obj.Objective.Creature != null && (UInt32.TryParse(obj.Objective.ObjectId4, out outVal) && Convert.ToUInt32(obj.Objective.ObjectId6) == entry))
                    {
                        objectID   = obj.Objective.ObjectId4;
                        obj.Count += count;
                        break;
                    }

                    break;

                case Objective_Type.QUEST_PROTECT_UNIT:
                    if (obj.Objective.Creature != null && entry == obj.Objective.Creature.Entry)
                    {
                        obj.Count += count;
                    }
                    break;

                case Objective_Type.QUEST_USE_GO:
                    if (obj.Objective.GameObject != null && entry == obj.Objective.GameObject.Entry)
                    {
                        // This will turn off Interactable flag on clicked GO, some more work can be
                        // done with GO despawning and UNKs[3] unk modification
                        // Default respawn time: 60 seconds
                        Object target = player.CbtInterface.GetCurrentTarget();
                        if (target != null)
                        {
                            GameObject go = target.GetGameObject();
                            if (go != null && go.IsGameObject())
                            {
                                if (go.Spawn.AllowVfxUpdate == 1)
                                {
                                    go.VfxState = 1;
                                }
                                go.Interactable = false;
                                go.EvtInterface.AddEvent(MakeGOInteractable, 60000, 1, target);
                            }
                        }

                        obj.Count += count;
                    }
                    break;

                case Objective_Type.QUEST_KILL_GO:
                    if (obj.Objective.GameObject != null && entry == obj.Objective.GameObject.Entry)
                    {
                        obj.Count += count;
                    }
                    break;

                case Objective_Type.QUEST_UNKNOWN:
                    if (obj.Objective.Guid == entry)
                    {
                        obj.Count += count;
                    }
                    break;
                }

                if (obj.Count != oldCount)
                {
                    if (player != null)
                    {
                        uint influenceid;

                        if (Info.Type == 0 && player.CurrentArea != null)
                        {
                            if (player.Realm == GameData.Realms.REALMS_REALM_ORDER)
                            {
                                influenceid = player.CurrentArea.OrderInfluenceId;
                            }
                            else
                            {
                                influenceid = player.CurrentArea.DestroInfluenceId;
                            }
                        }
                        else // normaly we should only use the area inf but to not break every pq we keep it like this for now
                        {
                            influenceid = Info.ChapterId;
                        }



                        if (player.WorldGroup == null)
                        {
                            player.AddInfluence((ushort)influenceid, (ushort)(100));
                        }
                        else
                        {
                            player.WorldGroup.AddInfluenceCount(player, (ushort)influenceid, (ushort)(100 * player.WorldGroup.GetPlayersCloseTo(player, 300).Count));
                        }

                        if (!Players.ContainsKey(player.CharacterId))
                        {
                            Players.Add(player.CharacterId, new ContributionInfo(player));
                        }

                        if (Players.ContainsKey(player.CharacterId))
                        {
                            Players[player.CharacterId].BaseContribution += contributionGain;
                            Players[player.CharacterId].ActiveTimeEnd     = TCPManager.GetTimeStamp() + 5;
                        }
                    }
                    else
                    {
                        foreach (uint plr in ActivePlayers)
                        {
                            if (Players.ContainsKey(plr))
                            {
                                Players[plr].BaseContribution += contributionGain;
                            }
                        }
                    }

                    foreach (uint plr in ActivePlayers)
                    {
                        Player targPlayer = Player.GetPlayer(plr);
                        if (targPlayer != null)
                        {
                            PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_UPDATE);
                            Out.WriteUInt32(Info.Entry);
                            Out.WriteByte(1);
                            Out.WriteByte(Info.Type);                                                   //realm
                            Out.WriteUInt32(UInt32.Parse(Stage.Objectives.First().Objective.ObjectId)); //ephermal id, sent in main packet for PQ_INFO
                            Out.WriteByte(objid);                                                       //index of objective to update
                            Out.WriteUInt16((ushort)obj.Count);                                         // new total
                            targPlayer.SendPacket(Out);
                        }
                    }
                }
                objid++;
            }

            if (Stage.IsDone())
            {
                NextStage();
            }
        }
Пример #35
0
        static public void F_PLAYER_STATE2(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null || !cclient.Plr.IsInWorld())
                return;

            Player Plr = cclient.Plr;

            try
            {
                long Pos = packet.Position;

                PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_STATE2);
                Out.Write(packet.ToArray(), (int)packet.Position, (int)packet.Size);
                Out.WriteByte(0);
                Plr.DispatchPacket(Out, false);

                packet.Position = Pos;
            }
            catch (Exception e)
            {
                Log.Error("F_PLAYER_STATE2", e.ToString());
            }

            if (packet.Size < 17)
            {
                Plr.IsMoving = false;
                return;
            }

            UInt16 Key = packet.GetUint16();

            byte MoveByte = packet.GetUint8();
            byte UnkByte = packet.GetUint8();
            byte CombatByte = packet.GetUint8();
            byte RotateByte = packet.GetUint8();

            UInt16 Heading = packet.GetUint16R();
            UInt16 X = packet.GetUint16R();
            UInt16 Y = packet.GetUint16R();
            byte Unk1 = packet.GetUint8();
            UInt16 Z = packet.GetUint16R();
            //byte Unk2 = packet.GetUint8();

            Heading /= 8;
            X /= 2;
            Y /= 2;
            Z /= 2;

            if (CombatByte >= 50 && CombatByte < 0x92 || CombatByte == 0xDF)
            {
                if (Plr.LastCX != 0 && Plr.LastCY != 0)
                {
                    if (Plr.LastCX > 12288 && X < 4096)
                        Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset);
                    else if (X > 12288 && Plr.LastCX < 4096)
                        Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset);

                    if (Plr.LastCY > 24576 && Y < 8192)
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1));
                    else if (Y > 24576 && Plr.LastCY < 8192)
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1));
                }

                Plr.LastCX = X;
                Plr.LastCY = Y;

                X = Plr.Zone.CalculCombat(X, Plr.XOffset, true);
                Y = Plr.Zone.CalculCombat(Y, Plr.YOffset, false);
                Heading /= 2;
                Z += 32768;
                Z /= 4;
            }
            else
            {
                if (Plr.LastX != 0 && Plr.LastY != 0)
                {
                    if (Plr.LastX > 24576 && X < 4096)
                        Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset);
                    else if (Plr.LastX < 4096 && X > 24576)
                        Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset);

                    if (Plr.LastY > 24576 && Y < 4096)
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1));
                    else if (Plr.LastY < 4096 && Y > 24576)
                        Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1));

                }

                Plr.LastX = X;
                Plr.LastY = Y;

                X = Plr.Zone.CalculPin(X, Plr.XOffset, true);
                Y = Plr.Zone.CalculPin(Y, Plr.YOffset, false);
            }

            Plr.SetPosition(X, Y, Z, Heading);
        }
Пример #36
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteInt32(key);
     outpack.WriteInt32(key2);
     outpack.WriteByte(ret);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #37
0
        public byte[] BuildRealms(uint sequence)
        {
            try
            {
                PacketOut Out = new PacketOut((byte)0);
                Out.Position = 0;

                Out.WriteUInt32(sequence);
                Out.WriteUInt16(0);
                lock (_Realms)
                {
                    Log.Info("BuildRealm", "Envoi de " + _Realms.Count + " royaumes");
                    Out.WriteUInt32((uint)_Realms.Count);

                    foreach (Realm Rm in _Realms.Values)
                    {
                        Out.WriteByte(Rm.RealmId);
                        Out.WriteByte((byte)(Rm.RpcId != 0 ? 1 : 0));
                        Out.WriteUInt32(1);
                        Out.WriteByte(Rm.RealmId);
                        Out.WriteByte(Rm.RealmId);
                        Out.WriteString("[" + Rm.Language + "] " + Rm.Name);
                        Out.WriteUInt32(19);
                        Out.WriteString("setting.allow_trials");
                        Out.WriteString(Rm.AllowTrials);
                        Out.WriteString("setting.charxferavailable");
                        Out.WriteString(Rm.CharfxerAvailable);
                        Out.WriteString("setting.language");
                        Out.WriteString(Rm.Language);
                        Out.WriteString("setting.legacy");
                        Out.WriteString(Rm.Legacy);
                        Out.WriteString("setting.manualbonus.realm.destruction");
                        Out.WriteString(Rm.BonusDestruction);
                        Out.WriteString("setting.manualbonus.realm.order");
                        Out.WriteString(Rm.BonusOrder);
                        Out.WriteString("setting.name");
                        Out.WriteString(Rm.Name);
                        Out.WriteString("setting.net.address");
                        Out.WriteString(Rm.Adresse);
                        Out.WriteString("setting.net.port");
                        Out.WriteString(Rm.Port.ToString());
                        Out.WriteString("setting.redirect");
                        Out.WriteString(Rm.Redirect);
                        Out.WriteString("setting.region");
                        Out.WriteString(Rm.Region);
                        Out.WriteString("setting.retired");
                        Out.WriteString(Rm.Retired);
                        Out.WriteString("status.queue.Destruction.waiting");
                        Out.WriteString(Rm.WaitingDestruction);
                        Out.WriteString("status.queue.Order.waiting");
                        Out.WriteString(Rm.WaitingOrder);
                        Out.WriteString("status.realm.destruction.density");
                        Out.WriteString(Rm.DensityDestruction);
                        Out.WriteString("status.realm.order.density");
                        Out.WriteString(Rm.DensityOrder);
                        Out.WriteString("status.servertype.openrvr");
                        Out.WriteString(Rm.OpenRvr);
                        Out.WriteString("status.servertype.rp");
                        Out.WriteString(Rm.Rp);
                        Out.WriteString("status.status");
                        Out.WriteString(Rm.Status);
                    }
                }
                Out.WriteUInt32(0);

                return Out.ToArray();
            }
            catch (Exception e)
            {
                return new byte[0];
            }
        }
Пример #38
0
        public byte[] GetBuffer()
        {
            PacketOut outpack = new PacketOut();
            //  outpack.WriteBuff(InternalPacket.HEAD);
            //  outpack.WriteUInt16(mParam);
            outpack.WriteUInt32(id);
            outpack.WriteInt32(playerid);
            outpack.WriteUInt32(itemid);
            outpack.WriteUInt16(postion);
            outpack.WriteByte(stronglv);

            outpack.WriteUInt32(gem1);
            outpack.WriteUInt32(gem2);
            outpack.WriteString(forgename);
            outpack.WriteUInt16(amount);
            outpack.WriteInt32(war_ghost_exp);
            outpack.WriteByte(di_attack);
            outpack.WriteByte(shui_attack);
            outpack.WriteByte(huo_attack);
            outpack.WriteByte(feng_attack);
            outpack.WriteInt32(property);
            outpack.WriteUInt32(gem3);
            outpack.WriteInt32(god_strong);
            outpack.WriteInt32(god_exp);

            //  outpack.WriteBuff(InternalPacket.TAIL);

            return outpack.GetBuffer();
        }
        }  //  d4 c0 01

        public void PersonalScoreboard(ContributionInfo playerRoll, byte bagWon)
        {
            Player targPlayer = Player.GetPlayer(playerRoll.PlayerCharId);

            if (targPlayer == null)
            {
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_PQLOOT_TRIGGER, 1723);

            Out.WriteStringBytes(_publicQuestInfo.Name);
            Out.Fill(0, 24 - _publicQuestInfo.Name.Length);
            Out.WriteByte(_bags[gold]);  // gold
            Out.WriteByte(_bags[purple]);
            Out.WriteByte(_bags[blue]);
            Out.WriteByte(_bags[green]);
            Out.WriteByte(_bags[white]); // white
            Out.Fill(0, 3);
            ContributionInfo curRoll = playerRoll;

            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)curRoll.RandomBonus);
            Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
            for (int i = 1; i < 24; i++)
            {
                Out.Fill(0, 32);
            }

            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteUInt16(1); // place
            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)curRoll.RandomBonus);
            Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
            Out.WriteByte(1);              // ???
            Out.WriteByte(curRoll.BagWon); // bag won
            for (int i = 1; i < 24; i++)
            {
                Out.Fill(0, 34); // i just send empty once here
            }
            Out.WriteUInt16(1);  // place
            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteByte(1);                 // ???
            Out.WriteByte(playerRoll.BagWon); // bag won

            Out.Fill(0, 2);
            //Out.WriteUInt16(TIME_PQ_RESET);
            Out.WriteByte(0);
            Out.WriteByte(3);


            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.Fill(0, 27);
            //
            // no clue yet seams to be if you didnt won anything you get that item


            /*
             * Out.WritePacketString(@"|d4 c0 01 |...d............|
             |57 61 72 20 43 72 65 73 74 00 00 00 00 00 00 00 |War Crest.......|
             |00 00 00 00 00 00 00 00 00 00 00                |...........     |
             * ");
             */
            targPlayer.SendPacket(Out);
            // Info.SendCurrentStage(plr);
        }  //  d4 c0 01
Пример #40
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteInt32(ownerid);
     outpack.WriteInt32(key);
     outpack.WriteInt32(key2);
     outpack.WriteInt32(mListMagic.Count);
     for (int i = 0; i < mListMagic.Count; i++)
     {
         MagicInfo item = mListMagic[i];
         outpack.WriteInt32(item.id);
         outpack.WriteUInt32(item.magicid);
         outpack.WriteByte(item.level);
         outpack.WriteUInt32(item.exp);
     }
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #41
0
        public override void SendMeTo(Player Plr)
        {
            //Log.Success("Creature", "SendMe " + Name);

            PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_MONSTER);

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);

            Out.WriteUInt16((UInt16)Heading);
            Out.WriteUInt16((UInt16)WorldPosition.Z);
            Out.WriteUInt32((UInt32)WorldPosition.X);
            Out.WriteUInt32((UInt32)WorldPosition.Y);
            Out.WriteUInt16(0); // Speed Z
            // 18
            Out.WriteUInt16(Spawn.Proto.Model1);
            Out.WriteByte((byte)Spawn.Proto.MinScale);
            Out.WriteByte(Level);
            Out.WriteByte(Faction);

            Out.Fill(0, 4);
            Out.WriteByte(Spawn.Emote);
            Out.WriteByte(0); // ?
            Out.WriteUInt16(Spawn.Proto._Unks[1]);
            Out.WriteByte(0);
            Out.WriteUInt16(Spawn.Proto._Unks[2]);
            Out.WriteUInt16(Spawn.Proto._Unks[3]);
            Out.WriteUInt16(Spawn.Proto._Unks[4]);
            Out.WriteUInt16(Spawn.Proto._Unks[5]);
            Out.WriteUInt16(Spawn.Proto._Unks[6]);
            Out.WriteUInt16(Spawn.Title);

            long TempPos = Out.Position;
            byte TempLen = (byte)(Spawn.bBytes.Length + States.Count);

            Out.WriteByte(TempLen);
            Out.Write(Spawn.bBytes, 0, Spawn.bBytes.Length);
            Out.Write(States.ToArray(), 0, States.Count);
            if (QtsInterface.CreatureHasStartQuest(Plr))
            {
                Out.WriteByte(5);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }
            else if (QtsInterface.CreatureHasQuestToAchieve(Plr))
            {
                Out.WriteByte(4);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }
            else if (QtsInterface.CreatureHasQuestToComplete(Plr))
            {
                Out.WriteByte(7);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }

            Out.Position = Out.Length;

            Out.WriteByte(0);

            Out.WriteStringBytes(Name);

            Out.Fill(0, 48);
            Plr.SendPacket(Out);

            base.SendMeTo(Plr);
        }
Пример #42
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteInt32(accountid);
     outpack.WriteString(name);
     outpack.WriteUInt32(lookface);
     outpack.WriteByte(profession);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #43
0
        public override void SendInteract(Player Plr, InteractMenu Menu)
        {
            Plr.QtsInterface.HandleEvent(Objective_Type.QUEST_SPEACK_TO, Spawn.Entry, 1);

            if (!IsDead)
            {
                switch (InteractType)
                {
                case GameData.InteractType.INTERACTTYPE_DYEMERCHANT:
                {
                    string Text = WorldMgr.GetCreatureText(Spawn.Entry);

                    if (Menu.Menu == 9)         // List des objets a vendre
                    {
                        WorldMgr.SendVendor(Plr, Spawn.Entry);
                    }
                    else if (Menu.Menu == 11)         // Achat d'un item
                    {
                        WorldMgr.BuyItemVendor(Plr, Menu, Spawn.Entry);
                    }
                    else if (Menu.Menu == 14)         // Vend un Item
                    {
                        Plr.ItmInterface.SellItem(Menu);
                    }
                    else if (Menu.Menu == 36)         // Rachette un item
                    {
                        Plr.ItmInterface.BuyBackItem(Menu);
                    }
                    else
                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);
                        Out.WriteByte(0);
                        Out.WriteUInt16(Oid);
                        Out.WriteUInt16(0);
                        Out.WriteByte(0x40);         // Dye
                        Out.WriteByte(0x22);         // Vendors
                        Out.WriteByte(0);
                        Out.WritePascalString(Text);
                        Out.WriteByte(0);
                        Plr.SendPacket(Out);
                    }
                } break;

                case GameData.InteractType.INTERACTTYPE_FLIGHT_MASTER:
                {
                    byte[] data = new byte[62]
                    {
                        0x01, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x42, 0x39, 0x00, 0x00, 0x00, 0xC0, 0xE3,
                        0x03, 0x39, 0xA0, 0xD1, 0x6F, 0x00, 0xC8, 0xA8, 0x1D, 0x37, 0x28, 0x94, 0x79, 0x33, 0xB2, 0x24,
                        0x32, 0x44, 0xDB, 0xD7, 0x1C, 0x5D, 0x18, 0x5D, 0xDD, 0x1C, 0xA4, 0x0D, 0x00, 0x00, 0xA8, 0x6B,
                        0x21, 0x36, 0x11, 0x00, 0x00, 0x00, 0xC8, 0xD0, 0xAF, 0x3A, 0x78, 0xD1, 0x6F, 0x00
                    };

                    UInt16 Counts = 1;

                    PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);
                    Out.WriteUInt16(0x0A12);
                    foreach (Zone_Taxi Taxi in WorldMgr.GetTaxis(Plr))
                    {
                        Out.WriteUInt16(Counts);
                        Out.WriteByte(2);
                        Out.WriteUInt16(Taxi.Info.Price);
                        Out.WriteUInt16(Taxi.Info.ZoneId);
                        Out.WriteByte(1);
                        ++Counts;
                    }
                    Out.Write(data);
                    Plr.SendPacket(Out);
                } break;

                case GameData.InteractType.INTERACTTYPE_TRAINER:
                {
                    if (Menu.Menu == 7)
                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);
                        Out.WriteByte(5);
                        Out.WriteByte(0x0F);
                        Out.WriteByte(6);
                        Out.WriteUInt16(0);
                        Plr.SendPacket(Out);
                    }
                    else
                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);
                        Out.WriteByte(0);
                        Out.WriteUInt16(Oid);

                        if (Plr.Realm == GameData.Realms.REALMS_REALM_ORDER)
                        {
                            Out.WritePacketString(@"|00 00 00 21 00 94 48 61 69 6C |.........!..Hail|
|20 64 65 66 65 6E 64 65 72 20 6F 66 20 74 68 65 | defender of the|
|20 45 6D 70 69 72 65 21 20 20 59 6F 75 72 20 70 | Empire!  Your p|
|65 72 66 6F 72 6D 61 6E 63 65 20 69 6E 20 62 61 |erformance in ba|
|74 74 6C 65 20 69 73 20 74 68 65 20 6F 6E 6C 79 |ttle is the only|
|20 74 68 69 6E 67 20 74 68 61 74 20 6B 65 65 70 | thing that keep|
|73 20 74 68 65 20 68 6F 72 64 65 73 20 6F 66 20 |s the hordes of |
|43 68 61 6F 73 20 61 74 20 62 61 79 2E 20 4C 65 |Chaos at bay. Le|
|74 27 73 20 62 65 67 69 6E 20 79 6F 75 72 20 74 |t's begin your t|
|72 61 69 6E 69 6E 67 20 61 74 20 6F 6E 63 65 21 |raining at once!|
|00                                              |.               |");
                        }
                        else
                        {
                            Out.WritePacketString(@"|00 00 00 21 00 AA 4C 65 61 72 |.........!..Lear|
|6E 20 74 68 65 73 65 20 6C 65 73 73 6F 6E 73 20 |n these lessons |
|77 65 6C 6C 2C 20 66 6F 72 20 67 61 69 6E 69 6E |well, for gainin|
|67 20 74 68 65 20 66 61 76 6F 72 20 6F 66 20 74 |g the favor of t|
|68 65 20 52 61 76 65 6E 20 67 6F 64 20 73 68 6F |he Raven god sho|
|75 6C 64 20 62 65 20 6F 66 20 75 74 6D 6F 73 74 |uld be of utmost|
|20 69 6D 70 6F 72 74 61 6E 63 65 20 74 6F 20 79 | importance to y|
|6F 75 2E 20 4F 74 68 65 72 77 69 73 65 2E 2E 2E |ou. Otherwise...|
|20 54 68 65 72 65 20 69 73 20 61 6C 77 61 79 73 | There is always|
|20 72 6F 6F 6D 20 66 6F 72 20 6D 6F 72 65 20 53 | room for more S|
|70 61 77 6E 20 77 69 74 68 69 6E 20 6F 75 72 20 |pawn within our |
|72 61 6E 6B 73 2E 00                            |.......         |");
                        }
                        Plr.SendPacket(Out);
                    }
                } break;

                case GameData.InteractType.INTERACTTYPE_BANKER:
                {
                    PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE);
                    Out.WriteByte(0x1D);
                    Out.WriteByte(0);
                    Plr.SendPacket(Out);
                } break;

                default:
                    QtsInterface.HandleInteract(Plr, this, Menu);
                    break;
                }
                ;
            }

            base.SendInteract(Plr, Menu);
        }
Пример #44
0
 public byte[] GetBuff()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteByte(mType);
     outpack.WriteString(text);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Пример #45
0
        static public void BuildItem(ref PacketOut Out, Item Itm, Item_Info Info, ushort SlotId, ushort Count)
        {
            SlotId = SlotId == 0 ? (Itm == null ? SlotId : Itm.SlotId) : SlotId;
            Count  = Count == 0 ? (Itm == null ? Count : Itm.Count) : Count;
            Info   = Info == null ? (Itm == null ? null : Itm.Info) : Info;


            if (SlotId != 0)
            {
                Out.WriteUInt16(SlotId);
            }

            Out.WriteByte(0);
            Out.WriteUInt32((uint)(Info != null ? Info.Entry : 0));

            if (Info == null)
            {
                return;
            }

            Out.WriteUInt32(Info.ModelId);
            Out.WriteUInt16(Info.SlotId);
            Out.WriteByte(Info.Type);
            Out.WriteByte(Info.MinRank);

            Out.WriteByte((byte)(Info.MinRank + 1)); // 1.3.5
            Out.WriteByte(Info.MinRenown);           // 1.3.5

            Out.WriteByte(Info.MinRenown);
            Out.WriteByte(Info.MinRenown);
            Out.WriteByte(Info.Rarity);
            Out.WriteByte(Info.Bind);
            Out.WriteByte(Info.Race);
            Out.WriteUInt32(Info.Career);

            Out.WriteUInt32(0);
            Out.WriteUInt32(Info.SellPrice);

            Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1));

            Out.WriteUInt32(0);

            Out.WriteUInt32(Info.Skills);
            Out.WriteUInt16(Info.Dps > 0 ? Info.Dps : Info.Armor);
            Out.WriteUInt16(Info.Speed);
            Out.WritePascalString(Info.Name);

            Out.WriteByte((byte)Info._Stats.Count);
            foreach (KeyValuePair <byte, UInt16> Key in Info._Stats)
            {
                Out.WriteByte(Key.Key);
                Out.WriteUInt16(Key.Value);
                Out.Fill(0, 5);
            }

            Out.WriteByte(0);
            Out.WriteByte(0); // SpellCounts
            // (uint32)Entry, uint16 X, uint16 Y

            Out.WriteByte(0); // Artisana Info , 3 bytes pour chaque artisana
            Out.WriteByte(0);

            Out.WriteByte(Info.TalismanSlots);
            for (int i = 0; i < Info.TalismanSlots; ++i)
            {
                Out.WriteUInt32(0); // Entry;
            }
            Out.WritePascalString(Info.Description);

            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);

            Out.WriteUInt16(0x0302);

            Out.Fill(0, 8);
            Out.WriteByte(0); // Type , Culture, etc etc
            Out.WriteByte(0); // Type, Recipian , Soil , etc etc
            Out.Fill(0, 11);
        }
        public static void F_CONNECT(BaseClient client, PacketIn packet)
        {
            Log.Success("F_CONNECT", "Entering F_CONNECT " + client.Id.ToString() + " " + packet.Opcode.ToString());
            GameClient cclient = (GameClient)client;

            packet.Skip(8);
            uint   Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

#if DEBUG
            Result = AuthResult.AUTH_SUCCESS;
#endif

            if (Result == AuthResult.AUTH_ACCT_SUSPENDED)
            {
                Log.Error("F_CONNECT", "Banned Account =" + Username);
                cclient.Disconnect("Banned account");
            }
            else if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username + " " + Result);

                // Kick people who spam the god damn button for 5 minutes straight before they clock on.
                PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_QUIT, 4);
                Out.WriteHexStringBytes("01000000");
                cclient.SendPacket(Out);

                cclient.Disconnect("Invalid token");
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect("Invalid account");
                }
                else
                {
                    Log.Success("F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = ((TCPServer)cclient.Server).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect("Failed to get GameClient for account");
                    }

                    // Check if ip is banned. (they may have been just banned so launcher server wouldnt have picked it up)
                    if (!Program.AcctMgr.CheckIp(cclient.GetIp().Split(':')[0]))
                    {
                        Log.Error("F_CONNECT", "Banned IP =" + Username);
                        cclient.Disconnect("Banned by IP");
                    }

                    // Load characters before connection instead of later on
                    CharMgr.LoadCharacters(cclient._Account.AccountId);

                    {
                        cclient.PacketLog = cclient._Account.PacketLog;

                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED, 48);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0); // TRANSFER_FLAG (1 - Low population server..free transfers...)
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }
Пример #47
0
        public override void SendMeTo(Player plr)
        {
            // Log.Info("STATIC", "Creating static oid=" + Oid + " name=" + Name + " x=" + Spawn.WorldX + " y=" + Spawn.WorldY + " z=" + Spawn.WorldZ + " doorID=" + Spawn.DoorId);
            PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_STATIC, 46 + (Name?.Length ?? 0));

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(VfxState); //ie: red glow, open door, lever pushed, etc

            Out.WriteUInt16((ushort)Spawn.WorldO);
            Out.WriteUInt16((ushort)Spawn.WorldZ);
            Out.WriteUInt32((uint)Spawn.WorldX);
            Out.WriteUInt32((uint)Spawn.WorldY);
            Out.WriteUInt16((ushort)Spawn.DisplayID);

            Out.WriteByte((byte)(Spawn.GetUnk(0) >> 8));

            // Get the database if the value hasnt been changed (currently only used for keep doors)
            if (Realm == GameData.Realms.REALMS_REALM_NEUTRAL)
            {
                Out.WriteByte((byte)(Spawn.GetUnk(0) & 0xFF));
            }
            else
            {
                Out.WriteByte((byte)Realm);
            }

            Out.WriteUInt16(Spawn.GetUnk(1));
            Out.WriteUInt16(Spawn.GetUnk(2));
            Out.WriteByte(Spawn.Unk1);

            int flags = Spawn.GetUnk(3);

            if (Realm != GameData.Realms.REALMS_REALM_NEUTRAL && !IsInvulnerable)
            {
                flags |= 8; // Attackable (stops invalid target errors)
            }
            LootContainer lootsContainer = LootsMgr.GenerateLoot(this, plr, 1);

            if ((lootsContainer != null && lootsContainer.IsLootable()) || ((plr.QtsInterface.PublicQuest != null) && Interactable) || (plr.QtsInterface.GameObjectNeeded(Spawn.Entry) && Interactable) || Spawn.Entry == 188 || Spawn.DoorId != 0)
            {
                flags |= 4; // Interactable
            }

            if (Flags.HasValue)
            {
                Out.WriteUInt16(Flags.Value);
            }
            else
            {
                Out.WriteUInt16((ushort)flags);
            }

            Out.WriteByte(Spawn.Unk2);
            Out.WriteUInt32(Spawn.Unk3);
            Out.WriteUInt16(Spawn.GetUnk(4));
            Out.WriteUInt16(Spawn.GetUnk(5));
            Out.WriteUInt32(Spawn.Unk4);

            Out.WritePascalString(Name);

            if (Spawn.DoorId != 0)
            {
                Out.WriteByte(0x04);

                Out.WriteUInt32(Spawn.DoorId);
            }
            else
            {
                Out.WriteByte(0x00);
            }

            plr.SendPacket(Out);

            base.SendMeTo(plr);
        }
Пример #48
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient = (WorldClient)client;
            UInt32 accountId = packet.GetUint32Reversed();
            cclient.AccountId = accountId;
            Log.Debug("AskWorldEnter", "New client! Account = " + accountId);
            Acc account = null;
            lock (Program.expectingAccounts) Program.expectingAccounts.TryGetValue(accountId, out account);

            #region Character stuff

            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `characters` WHERE `id` = @id", WorldServer.Database.Connection.Instance);
            try
            {
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@id", account.Character.ToString());
                cmd.ExecuteNonQuery();
                MySqlDataReader reader = cmd.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        cclient.CharacterId = getID(reader);
                        cclient.Name = getName(reader);
                        cclient.Faction = getFaction(reader);
                        cclient.Gender = getGender(reader);
                        cclient.Rank = getRank(reader);
                        cclient.Money = getMoney(reader);
                        cclient.Threat = getThreat(reader);
                        cclient.Playtime = getPlayTime(reader);
                        cclient.Clan = getClan(reader);
                        cclient.districtID = 0;
                        cclient.districtType = 0;
                        cclient.groupInvite = 0;
                        cclient.groupStatus = 0;
                        cclient.groupPublic = 0;
                    }
                }
                catch (MySqlException e) { Log.Error("MySQL", e.ToString()); }
                finally { reader.Dispose(); }
            }
            catch (MySqlException e) { Log.Error("MySQL", e.ToString()); }
            finally { cmd.Dispose(); }

            #endregion

            #region Account stuff
            MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM `accounts` WHERE `id` = @id", WorldServer.Database.Connection.Instance);
            try
            {
                cmd2.Prepare();
                cmd2.Parameters.AddWithValue("@id", accountId.ToString());
                cmd2.ExecuteNonQuery();
                MySqlDataReader reader2 = cmd2.ExecuteReader();
                try
                {
                    while (reader2.Read())
                    {
                        cclient.Email = getEmail(reader2);
                        cclient.isGM = getGm(reader2);
                        cclient.isBanned = getBanned(reader2);
                        cclient.Points = getPoints(reader2);
                    }
                }
                catch (MySqlException e) { Log.Error("MySQL", e.ToString()); }
                finally { reader2.Dispose(); }
            }
            catch (MySqlException e) { Log.Error("MySQL", e.ToString()); }
            finally { cmd2.Dispose(); }
            #endregion

            #region Client status

            MySqlCommand cmd3 = new MySqlCommand("INSERT INTO `clientstatus` VALUES(@name, 0, 0, 1, 0, 0, 0, 0)", WorldServer.Database.Connection.Instance);
            try
            {
                cmd3.Prepare();
                cmd3.Parameters.AddWithValue("@name", cclient.Name);
                cmd3.ExecuteNonQuery();
            }
            catch (MySqlException e) { Log.Error("MySQL", e.ToString()); }
            finally { cmd3.Dispose(); }

            #endregion

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
            if (account == null) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED);
            else
            {
                Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
                Out.WriteUInt32Reverse(account.Character);
                Out.WriteUInt32Reverse(cclient.Points);
                Out.WriteByte(cclient.isGM);
                Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
                Out.WriteFloat(5.00f);
                Out.WriteByte(0);
                Out.WriteByte(0);
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 1, false, Program.WorldName, account.Character.ToString()));
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 2, false, Program.WorldName, account.Character.ToString()));
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 3, false, Program.WorldName, account.Character.ToString()));
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 4, false, Program.WorldName, account.Character.ToString()));
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)accountId, 5, false, Program.WorldName, account.Character.ToString()));
                Out.WriteByte(1);
                Out.WriteByte(cclient.LFG);
            }
            cclient.Crypto = new TCP.Encryption(account.SessionId);
            cclient.Send(new DISTRICT_LIST());
            cclient.Send(Out);
            return 0;
        }
Пример #49
0
        public override void SendMeTo(Player plr)
        {
            PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_MONSTER, 128);

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);

            Out.WriteUInt16(Heading);
            Out.WriteUInt16((ushort)WorldPosition.Z);
            Out.WriteUInt32((uint)WorldPosition.X);
            Out.WriteUInt32((uint)WorldPosition.Y);
            Out.WriteUInt16(0);            // Speed Z
            Out.WriteUInt16(Proto.Model1); // model ID

            Out.WriteByte(0x32);           // scale

            Out.WriteByte(Owner.Level);
            Out.WriteByte(Faction);
            Out.Fill(0, 6);
            Out.WriteUInt16(1); // Unk5
            Out.Fill(0, 13);

            // State 19?
            Out.WriteByte(1);    // Spawn Length
            Out.WriteByte(0x19); // Spawn Data

            Out.WriteByte(0);

            Out.WriteCString(Name);
            Out.WriteUInt32(3);
            Out.WriteUInt16(0x010A); // Fig leaf data
            Out.WriteByte(0);
            Out.WriteUInt16(Owner.Oid);
            Out.WriteByte(18); // Cheating - length of embedded OBJECT_STATE packet which is for heading only
            Out.WriteByte(5);  // Cheating - length of embedded PLAYER_INVENTORY packet which is empty
            Out.WriteByte(0);

            // F_OBJECT_STATE 00
            Out.WriteUInt16(Oid);
            Out.WriteUInt16((ushort)X);
            Out.WriteUInt16((ushort)Y);
            Out.WriteUInt16((ushort)Z);
            Out.WriteByte(PctHealth);
            Out.WriteByte(0);   // flags
            Out.WriteByte((byte)Zone.ZoneId);
            Out.WriteByte(4);   // 0
            Out.WriteUInt32(3); // 0
            Out.WriteUInt16R(Heading);

            // F_PLAYER_INVENTORY
            Out.WriteUInt16(Oid);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);

            plr.SendPacket(Out);

            Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE);
            Out.WriteUInt16(Oid);
            Out.WriteByte(1);
            Out.WriteByte(7);
            Out.Fill(0, 6);
            plr.SendPacket(Out);

            base.SendMeTo(plr);
        }
Пример #50
0
        private void SendBerserkOwner(byte newState)
        {
            PacketOut Out = new PacketOut((byte)Opcodes.F_INIT_EFFECTS, 20);

            Out.WriteByte(1);
            Out.WriteByte(BUFF_ADD);
            Out.WriteUInt16(0xBDFF);     // unk3
            Out.WriteUInt16(_Owner.Oid);
            Out.WriteByte(254);          // Buff ID
            Out.WriteByte(0);
            Out.WriteUInt16R(_selfBuff); // Enrage/Berserk Owner
            Out.WriteByte(0);            // Duration
            Out.WriteUInt16R(_Owner.Oid);

            if (newState == 1)
            {
                Out.WriteByte(2); // Line count

                Out.WriteByte(0);
                Out.WriteZigZag(1);

                Out.WriteByte(3);
                Out.WriteZigZag(1);
            }

            else
            {
                Out.WriteByte(3); // Line count

                Out.WriteByte(0);
                Out.WriteZigZag(1);

                Out.WriteByte(3);
                Out.WriteZigZag(1);

                Out.WriteByte(4);
                Out.WriteZigZag(1);
            }

            Out.WriteByte(00);
            myPlayer.SendPacket(Out);
        }
Пример #51
0
        /// <summary>
        ///     Sends the state of the objective in user's map, can announce state changing.
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="announce"></param>
        /// <param name="update"></param>
        public void SendState(Player plr, bool announce, bool update = true)
        {
            if (!Loaded)
            {
                return;
            }

            var State = GetStateFlags();

            var Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_STATE, 16);

            Out.WriteUInt32((uint)Id);

            if (State == StateFlags.Contested)
            {
                Out.Fill(0, 2);
                Out.WriteUInt16((ushort)DisplayedTimer);
                Out.Fill(0xFF, 2);
                Out.WriteUInt16(0);
            }
            else if (State == StateFlags.Secure)
            {
                //Out.Fill(0xFF, 4);
                Out.Fill(0, 2);
                Out.WriteUInt16((ushort)DisplayedTimer);

                Out.WriteByte(0);
                Out.WriteByte((byte)(MAX_SECURE_PROGRESS - _secureProgress)); // Unk6 - time till next resource release
                Out.WriteUInt16(
                    (ushort)MAX_SECURE_PROGRESS);                             // Unk7 - vertical offset for drawing overlay - Unk6 may not exceed
            }
            else
            {
                Out.Fill(0xFF, 6);
                Out.WriteUInt16(0);
            }

            Out.WriteByte((byte)OwningRealm);
            Out.WriteByte(update ? (byte)1 : (byte)0);
            Out.WriteByte((byte)State);
            Out.WriteByte(0);

            if (!announce)
            {
                if (plr != null)
                {
                    plr.SendPacket(Out);
                }
                else
                {
                    foreach (var player in Region.Players)
                    {
                        player.SendPacket(Out);
                    }
                }
                return;
            }

            string message     = null;
            var    largeFilter = OwningRealm == Realms.REALMS_REALM_ORDER
                ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE
                : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE;

            foreach (var player in Region.Players)
            {
                player.SendPacket(Out);
            }
            PacketOut snd = null;

            switch (State)
            {
            case StateFlags.Unsecure:
                message = string.Concat(Name, " is now open for capture !");
                break;

            case StateFlags.Contested:
                message = string.Concat(Name, " is under assault by the forces of ", GetRealmString(AssaultingRealm), "!");
                break;

            case StateFlags.Secure:
                var securedState = _secureProgress == MAX_SECURE_PROGRESS;

                if (_secureProgress == MAX_SECURE_PROGRESS)
                {
                    message = string.Concat($"The forces of ", GetRealmString(OwningRealm), " have taken ",
                                            Name, "!");
                    snd = new PacketOut((byte)Opcodes.F_PLAY_SOUND);
                    snd.WriteByte(0);
                    snd.WriteUInt16(OwningRealm == Realms.REALMS_REALM_ORDER ? (ushort)0x0C : (ushort)0x332);
                    snd.Fill(0, 10);
                    break;
                }
                else
                {
                    message = string.Concat($"The forces of ", GetRealmString(OwningRealm), " are securing ", Name, "!");
                    break;
                }

            default:
                message = string.Empty;
                break;
            }
            try
            {
                if (plr != null)
                {
                    plr.SendPacket(Out);
                }
                else
                {
                    foreach (var player in Region.Players)
                    {
                        player.SendPacket(Out); // Objective's state


                        if (string.IsNullOrEmpty(message) || !player.CbtInterface.IsPvp)
                        {
                            continue;
                        }

                        // Notify RvR flagged players of activity
                        player.SendLocalizeString(message, ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT);
                        player.SendLocalizeString(message, largeFilter, Localized_text.CHAT_TAG_DEFAULT);

                        if (snd != null)
                        {
                            player.SendPacket(snd);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception", e.Message + "\r\b" + e.StackTrace);
                return;
            }
        }
Пример #52
0
        public void Update()
        {
            Log.Debug("Group", "Updating Group");

            if (Leader == null || Members.Count < 1 || (Members.Count == 1 && Leader == Members.First()))
            {
                Delete();
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_CHARACTER_INFO);

            Out.WriteUInt16(0x0602); // Group info
            Out.WriteUInt16(0xB536); // Group id
            Out.WriteByte((byte)Members.Count);
            foreach (Player Plr in Members)
            {
                Out.WriteUInt32(0xA8BF3B0C);
                Out.WriteByte((byte)Plr._Info.ModelId);
                Out.WriteByte((byte)Plr._Info.Race);
                Out.WriteByte((byte)Plr.Level);
                Out.WriteUInt16((ushort)Plr._Info.CareerLine);
                Out.WriteByte(1);
                Out.WriteByte(0); // Will be 1 for at least one member. Perhaps Leader?
                Out.WriteByte(0);
                Out.WriteByte(1); // Online = 1, Offline = 0
                Out.WriteByte((byte)Plr.Name.Length);
                Out.Fill(0, 3);
                Out.WriteStringBytes(Plr.Name);
                Out.WriteByte(0); // Name length. Pet? Target?
                Out.Fill(0, 3);
                //Out.WriteStringBytes(Pet name? Target?);

                Out.WriteByte(0x8B);
                Out.WriteUInt16R((ushort)650); // X ?
                Out.WriteByte(0xD3);
                Out.WriteUInt16R((ushort)650); // y ?
                byte[] data = { 0xC8, 0x50, 0x27, 0x25, 0x05, 0x40, 0x01, 0x02 };
                Out.Write(data);

                Out.WriteByte((byte)(Plr._Value.ZoneId * 2));
                Out.WriteByte(1);
                Out.WriteByte(1);

                Out.WriteByte((byte)Plr.PctHealth);
                Out.WriteByte((byte)Plr.PctAp); // action points
                Out.WriteByte(0);
            }

            SendToGroup(Out);
        }
Пример #53
0
        public void SendCurrentStage(Player player)
        {
            player.QtsInterface.UpdateObjects();

            if (Stage == null)
            {
                //Log.Error("Public Quest Object", "No Stage!");
                return;
            }
            if (_ended)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO);
                Out.WriteUInt32(Info.Entry);
                Out.WriteByte(1);
                Out.WriteByte(0);
                Out.WriteByte(1);  // 1 1 condition 2 or condition
                Out.WriteUInt16(0);
                Out.WritePascalString(Info.Name);
                Out.WriteUInt32((UInt32)(_stageTimeEnd - TCPManager.GetTimeStamp()));       // time left
                Out.Fill(0, 4);
                player.SendPacket(Out);
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECTIVE_INFO);
                Out.WriteUInt32(Info.Entry);
                Out.WriteByte(0); // Type
                Out.WriteByte(Info.Type);
                Out.WriteByte(1); // 1 1 condition 2 or condition
                Out.WriteUInt16(0);
                Out.WritePascalString(Info.Name);
                Out.WriteByte(Info.Type);
                Out.WriteUInt32(UInt32.Parse(Stage.Objectives.First().Objective.ObjectId));
                Out.WriteByte(0);
                Out.WriteByte((byte)Stage.Objectives.Count);
                byte i = 0;
                foreach (PQuestObjective obj in Stage.Objectives)
                {
                    Out.WriteByte(i);
                    Out.WriteUInt16((ushort)obj.Objective.Count);  // kill count
                    Out.WriteUInt16((ushort)obj.Count);
                    Out.WriteByte(0);
                    Out.WritePascalString(obj.Objective.Objective);
                    i++;
                }

                Out.WriteByte((byte)(Info.PQDifficult > 0 ? (Info.PQDifficult - 1) : 0 - 1));    // difficulty 0 - 2
                Out.WriteByte(0);
                Out.WritePascalString(Stage.StageName);
                Out.WriteByte(0);
                Out.WritePascalString(Stage.Objectives.First().Objective.Description);
                Out.WriteUInt16(0);
                if (Stage.Number == 0)
                {
                    Out.WriteUInt16(0);
                }
                else
                {
                    Out.WriteUInt16(1);
                }
                Out.WriteUInt32((UInt32)(_stageTimeEnd - TCPManager.GetTimeStamp()));       // time left
                Out.WriteUInt32(0);
                Out.WriteByte(0x48);
                Out.WriteUInt32(0);
                player.SendPacket(Out);


                if (player.DebugMode)
                {
                    player.SendLocalizeString("PQ STAGE ID: " + Stage.Objectives.First().ObjectiveID, ChatLogFilters.CHATLOGFILTERS_ALLIANCE, GameData.Localized_text.CHAT_TAG_MONSTER_EMOTE);
                }
            }
        }
Пример #54
0
        public override void SendMeTo(Player plr)
        {
            PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_STATIC);

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);

            Out.WriteUInt16(Heading);
            Out.WriteUInt16((ushort)_z);
            Out.WriteUInt32((uint)_x);
            Out.WriteUInt32((uint)_y);

            int displayId = 3442;

            if (Owner == 0)
            {
                displayId = 3442;
            }
            else if (Owner == 1)
            {
                displayId = 3443;
            }
            else
            {
                displayId = 3438;
            }

            Out.WriteUInt16((ushort)displayId);

            Out.WriteUInt16(0x1E00);
            Out.WriteUInt16(0);
            Out.WriteUInt16(0);
            Out.WriteByte(0);

            // flags
            if (Open)
            {
                Out.WriteUInt16(0x24);
            }
            else
            {
                Out.WriteUInt16(0x21);
            }

            Out.WriteByte(0);

            Out.WriteUInt16(0);
            Out.WriteByte(0);
            Out.WriteByte(100);

            Out.WriteUInt16(0x91C0);
            Out.WriteUInt16(0xCB42);
            Out.WriteUInt32(0);

            Out.WritePascalString(ObjectiveName);
            Out.WriteByte(0);

            plr.SendPacket(Out);

            base.SendMeTo(plr);
        }
Пример #55
0
        static public byte[] BuildCharacters(int AccountId)
        {
            Log.Debug("BuildCharacters", "AcocuntId = " + AccountId);

            Character[] Chars = GetAccountChar(AccountId)._Chars;
            UInt16      Count = 0;

            // On Compte le nombre de personnages existant du joueur
            for (UInt16 c = 0; c < Chars.Length; ++c)
            {
                if (Chars[c] != null)
                {
                    ++Count;
                }
            }

            PacketOut Out = new PacketOut(0);

            Out.Position = 0;
            Out.WriteUInt16(Count);

            Character Char = null;

            for (int i = 0; i < MAX_SLOT; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                {
                    Out.Write(new byte[280], 0, 280);
                }
                else
                {
                    List <Character_items> Items = CharMgr.GetItemChar(Char.CharacterId);

                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Value[0].Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Value[0].ZoneId);
                    Out.Write(new byte[5], 0, 5);

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);
                        if (Item == null)
                        {
                            Out.WriteUInt32(0);
                        }
                        else
                        {
                            Out.WriteUInt32R(Item.ModelId);
                        }

                        Out.Write(new byte[4], 0, 4);
                    }

                    Out.Write(new byte[6], 0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Write(new byte[6], 0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                        {
                            Out.WriteUInt16(0);
                        }
                        else
                        {
                            Out.WriteUInt16R((ushort)Item.ModelId);
                        }
                    }

                    Out.Write(new byte[10], 0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Write(new byte[10], 0, 10);
                }
            }
            return(Out.ToArray());
        }
Пример #56
0
        public byte[] BuildCharacters()
        {
            PacketOut Out = new PacketOut((byte)0);
            Out.Position = 0;
            Out.WriteUInt16(GetCharacterCount());

            Character Char = null;
            for (int i = 0; i < MAX_CHARS; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                    Out.Write(new byte[280], 0, 280);
                else
                {
                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Info[0].Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Info[0].ZoneId);
                    Out.Write(new byte[5], 0, 5);

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);

                        Out.Write(new byte[6], 0, 6);
                    }

                    Out.Write(new byte[6], 0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Write(new byte[6], 0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);
                    }

                    Out.Write(new byte[10], 0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Write(new byte[10], 0, 10);
                }
            }
            return Out.ToArray();
        }
        public void Scoreboard(ContributionInfo playerRoll, int preIndex, int postIndex)
        {
            Player targPlayer = Player.GetPlayer(playerRoll.PlayerCharId);

            if (targPlayer == null)
            {
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_PQLOOT_TRIGGER, 1723);

            Out.WriteStringBytes(_publicQuestInfo.Name);
            Out.Fill(0, 24 - _publicQuestInfo.Name.Length);
            Out.WriteByte(_bags[gold]);  // gold
            Out.WriteByte(_bags[purple]);
            Out.WriteByte(_bags[blue]);
            Out.WriteByte(_bags[green]);
            Out.WriteByte(_bags[white]); // white
            Out.Fill(0, 3);

            WritePreRolls(Out);

            Out.WriteStringBytes(playerRoll.PlayerName);
            Out.Fill(0, 24 - playerRoll.PlayerName.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteUInt16((ushort)(preIndex + 1)); // place

            WritePostRolls(Out);

            Out.WriteUInt16((ushort)(postIndex + 1)); // place
            Out.WriteStringBytes(playerRoll.PlayerName);
            Out.Fill(0, 24 - playerRoll.PlayerName.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteByte(1);                 // ???
            Out.WriteByte(playerRoll.BagWon); // bag won

            Out.Fill(0, 2);
            //Out.WriteUInt16(TIME_PQ_RESET);
            Out.WriteByte(0);
            Out.WriteByte(3);


            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.Fill(0, 27);
            //
            // no clue yet seams to be if you didnt won anything you get that item


            /*
             * Out.WritePacketString(@"|d4 c0 01 |...d............|
             |57 61 72 20 43 72 65 73 74 00 00 00 00 00 00 00 |War Crest.......|
             |00 00 00 00 00 00 00 00 00 00 00                |...........     |
             * ");
             */

            targPlayer.SendPacket(Out);
            // Info.SendCurrentStage(plr);
        }  //  d4 c0 01