コード例 #1
0
        public static void Send(Character talkingTo, NonPlayerCharacterClass talker)
        {
            Client client = talkingTo.Client;

            PacketWriter pw = new PacketWriter();

            pw.PushByte(0xdf);
            pw.PushByte(0xdf);
            pw.PushShort(10);
            pw.PushShort(1);
            pw.PushShort(0);
            pw.PushInt(3086);
            pw.PushInt(client.Character.Id);
            pw.PushInt(0x270a4c62);
            pw.PushIdentity(50000, talkingTo.Id);
            pw.PushByte(0);
            pw.PushShort(2);
            pw.PushIdentity(50000, talker.Id);
            pw.PushInt(5);
            pw.PushInt(0);

            byte[] packet = pw.Finish();
            client.SendCompressed(packet);

            // Closing KnuBot window from server side needs to clear KnuBot's variables
            talker.KnuBot.KnuBotCloseChatWindow(talkingTo);
        }
コード例 #2
0
        public static void Send(Client cli, NonPlayerCharacterClass knubotTarget, AOItem[] items)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(cli.Character.Id);
            packetWriter.PushInt(0x7864401d);
            packetWriter.PushIdentity(cli.Character.Type, cli.Character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushShort(2);
            packetWriter.PushIdentity(knubotTarget.Type, knubotTarget.Id);
            packetWriter.PushInt(items.Length);
            foreach (AOItem item in items)
            {
                packetWriter.PushInt(item.LowID);
                packetWriter.PushInt(item.HighID);
                packetWriter.PushInt(item.Quality);
                packetWriter.PushInt(0x499602d2); // 1234567890  ???????
            }
            packetWriter.PushInt(0);

            byte[] packet = packetWriter.Finish();

            cli.SendCompressed(packet);
        }
コード例 #3
0
        public static void Send(Client cli, NonPlayerCharacterClass knubotTarget, string message)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(cli.Character.Id);
            packetWriter.PushInt(0x5d70532a);
            packetWriter.PushIdentity(cli.Character.Type, cli.Character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushShort(2);
            packetWriter.PushIdentity(knubotTarget.Type, knubotTarget.Id);
            packetWriter.PushInt(0);
            packetWriter.PushInt(message.Length);
            packetWriter.PushString(message);
            packetWriter.PushInt(0);

            byte[] packet = packetWriter.Finish();

            cli.SendCompressed(packet);
        }
コード例 #4
0
        public static void Send(Client cli, NonPlayerCharacterClass knubotTarget, string[] choices)
        {
            PacketWriter pw = new PacketWriter();

            pw.PushByte(0xdf);
            pw.PushByte(0xdf);
            pw.PushShort(0xa);
            pw.PushShort(1);
            pw.PushShort(0);
            pw.PushInt(3086);
            pw.PushInt(cli.Character.Id);
            pw.PushInt(0x55704d31);
            pw.PushIdentity(cli.Character.Type, cli.Character.Id);
            pw.PushByte(0);
            pw.PushShort(2);
            pw.PushIdentity(knubotTarget.Type, knubotTarget.Id);
            pw.PushInt(choices.Length);
            foreach (string choice in choices)
            {
                pw.PushInt(choice.Length);
                pw.PushString(choice);
            }

            byte[] packet = pw.Finish();

            cli.SendCompressed(packet);
        }
コード例 #5
0
        public static void SendResult(Character character, int min, int max, int low, int high)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(character.Id);
            packetWriter.PushInt(0x5E477770);
            packetWriter.PushIdentity(50000, character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(0xE4);
            packetWriter.PushInt(0);
            packetWriter.PushInt(max);
            packetWriter.PushInt(high);
            packetWriter.PushInt(min);
            packetWriter.PushInt(low);
            packetWriter.PushByte(0);
            packetWriter.PushByte(0);
            byte[] pack = packetWriter.Finish();
            character.Client.SendCompressed(pack);
        }
コード例 #6
0
        public static void DespawnPacket(int targetId)
        {
            PacketWriter packetWriter = new PacketWriter();
            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0x1d);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0x36510078);
            packetWriter.PushIdentity(50000, targetId);
            packetWriter.PushByte(1);
            byte[] packet = packetWriter.Finish();

            Dynel dyn = FindDynel.FindDynelById(50000, targetId);
            if (dyn != null)
            {
                NonPlayerCharacterClass npc = dyn as NonPlayerCharacterClass;
                if (npc != null)
                {
                    npc.RemoveFromCache();
                }
                Announce.PlayfieldOthers(dyn.PlayField, packet);
            }
        }
コード例 #7
0
        /// <summary>
        /// Set own stat (no announce)
        /// </summary>
        /// <param name="client">Affected client</param>
        /// <param name="stat">Stat</param>
        /// <param name="value">Value</param>
        /// <param name="announce">Let others on same playfield know?</param>
        public static uint Set(Client client, int stat, uint value, bool announce)
        {
            PacketWriter packetWriter = new PacketWriter();

            uint oldValue = (uint)client.Character.Stats.StatValueByName(stat);
            client.Character.Stats.SetStatValueByName(stat, value);

            packetWriter.PushBytes(new byte[] { 0xDF, 0xDF, });
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x2B333D6E);
            packetWriter.PushIdentity(50000, client.Character.Id);
            packetWriter.PushByte(1);
            packetWriter.PushInt(1);
            packetWriter.PushInt(stat);
            packetWriter.PushUInt(value);

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);

            /* announce to playfield? */
            if (announce)
            {
                Announce.Playfield(client.Character.PlayField, packet);
            }

            return oldValue;
        }
コード例 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        public static void GetDynels(Client client)
        {
            foreach (Client clients in client.Server.Clients)
            {
                PacketWriter packetWriter;
                if ((clients.Character.PlayField == client.Character.PlayField)
                    && (clients.Character.Id != client.Character.Id))
                {
                    SimpleCharFullUpdate.SendToOne(clients.Character, client);

                    // Send CharacterInPlay packet 
                    // TODO: Move this out to own file
                    packetWriter = new PacketWriter();
                    packetWriter.PushByte(0xDF);
                    packetWriter.PushByte(0xDF);
                    packetWriter.PushShort(10);
                    packetWriter.PushShort(1);
                    packetWriter.PushShort(0);
                    packetWriter.PushInt(3086);
                    packetWriter.PushInt(client.Character.Id);
                    packetWriter.PushInt(0x570C2039);
                    packetWriter.PushIdentity(50000, clients.Character.Id);
                    packetWriter.PushByte(0);
                    byte[] reply2 = packetWriter.Finish();
                    client.SendCompressed(reply2);
                }
            }
        }
コード例 #9
0
        public static void SendRequirement(Character character, TradeSkillSkillInfo tradeSkillSkillInfo)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(character.Id);
            packetWriter.PushInt(0x5E477770);
            packetWriter.PushIdentity(50000, character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(0xE3);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);
            packetWriter.PushInt(tradeSkillSkillInfo.Skill);
            packetWriter.PushInt(tradeSkillSkillInfo.Requirement);
            packetWriter.PushByte(0);
            packetWriter.PushByte(0);
            byte[] packet = packetWriter.Finish();
            character.Client.SendCompressed(packet);
        }
コード例 #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        public static void Send(Client client)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushBytes(new byte[] { 0xDF, 0xDF });
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x5F4B1A39);
            packetWriter.PushIdentity(40016, client.Character.PlayField);
            packetWriter.PushByte(0);

            packetWriter.PushInt(4);
            packetWriter.PushCoord(client.Character.Coordinates);
            packetWriter.PushByte(97);
            packetWriter.PushIdentity(51100, client.Character.PlayField);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);
            packetWriter.PushIdentity(40016, client.Character.PlayField);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);

            int vendorcount = VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField);
            if (vendorcount > 0)
            {
                packetWriter.PushInt(51035);
                packetWriter.PushInt(1);
                packetWriter.PushInt(1);
                packetWriter.PushInt(vendorcount);
                packetWriter.PushInt(VendorHandler.GetFirstVendor(client.Character.PlayField));
            }
            // TODO: Use correct World Position for each "outdoors" playfield -Suiv-
            // Playfield WorldPos X
            packetWriter.PushInt(Playfields.GetPlayfieldX(client.Character.PlayField));
            // Playfield WorldPos Z
            packetWriter.PushInt(Playfields.GetPlayfieldZ(client.Character.PlayField));

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }
コード例 #11
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // No check needed, its done by CheckCommandArguments
            int gfx = int.Parse(args[3]);

            //begin assembling packet here
            PacketWriter packet = new PacketWriter();
            packet.PushByte(0xDF);
            packet.PushByte(0xDF);
            packet.PushShort(10);
            packet.PushShort(1);
            packet.PushShort(0);
            packet.PushInt(3086);
            packet.PushInt(client.Character.Id);
            packet.PushInt(0x4D450114);
            packet.PushIdentity(target);
            packet.PushByte(0);
            packet.Push3F1Count(1); // effects count
            // effect starts
            packet.PushIdentity(53030, 0); // effect ID (53030 = GfxEffect)
            packet.PushInt(4); // ?
            packet.PushInt(0); // Criterion count
            packet.PushInt(1); // Hits
            packet.PushInt(0); // Delay
            packet.PushInt(0); // 
            packet.PushInt(0); // 
            // effect args
            packet.PushInt(gfx); // Value
            packet.PushInt(0); // GfxLife
            packet.PushInt(0); // GfxSize
            packet.PushInt(0); // GfxRed
            packet.PushInt(0); // GfxGreen
            packet.PushInt(0); // GfxBlue
            packet.PushInt(0); // GfxFade
            // effect args end
            // effect ends
            packet.PushIdentity(50000, client.Character.Id);
            byte[] reply = packet.Finish();
            //done creating the packet
            Announce.Playfield(client.Character.PlayField, reply);
        }
コード例 #12
0
        public static void Send(Client client, Dynel dynel1, Dynel dynel2)
        {
            PacketWriter packetWriter = new PacketWriter();
            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x36284f6e);
            packetWriter.PushIdentity(dynel1.Type, dynel1.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(1); // Knubot sends 2 here
            packetWriter.PushByte(0); // and 2 here too
            packetWriter.PushIdentity(dynel2.Type, dynel2.Id); // knubot 0
            packetWriter.PushIdentity(0xc767, 0x39da2458); // temp bag ID?? Knubot 0, needs more testing....

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }
コード例 #13
0
        public static void SendOwner(Client client, VendingMachine vendingMachine, int itemNumber)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x3b11256f);
            packetWriter.PushIdentity(0xc76e, 0x021fa86f); // whats this one???
            packetWriter.PushByte(0);
            packetWriter.PushInt(11);
            packetWriter.PushIdentity(client.Character.Type, client.Character.Id);
            packetWriter.PushInt(client.Character.PlayField);
            packetWriter.PushInt(0x0f424f);
            packetWriter.PushInt(0);
            packetWriter.PushShort(0x656f); // ??????
            packetWriter.Push3F1Count(6);
            packetWriter.PushInt(0);
            packetWriter.PushByte(0x80);
            packetWriter.PushByte(0);
            packetWriter.PushShort(0x0203);
            packetWriter.PushInt(0x17);
            packetWriter.PushInt(vendingMachine.Inventory[itemNumber].Item.LowID);
            // TODO: Three times low id and no high id?
            packetWriter.PushInt(0x2bd);
            packetWriter.PushInt(1);
            packetWriter.PushInt(0x2be);
            packetWriter.PushInt(vendingMachine.Inventory[itemNumber].Item.LowID);
            packetWriter.PushInt(0x2bf);
            packetWriter.PushInt(vendingMachine.Inventory[itemNumber].Item.LowID);
            packetWriter.PushInt(0x19c);
            packetWriter.PushInt(1);
            packetWriter.PushInt(0);
            // TODO: Actually send the data, probably research needed
        }
コード例 #14
0
        public static void Send(Client client, VendingMachine vendingMachine)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x7f544905); // 20
            packetWriter.PushIdentity(vendingMachine.Type, vendingMachine.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(0xb); // Counter??
            packetWriter.PushInt(0);
            packetWriter.PushInt(0); // 41
            packetWriter.PushCoord(vendingMachine.Coordinates);
            packetWriter.PushQuat(vendingMachine.Heading); // 69
            packetWriter.PushInt(vendingMachine.PlayField);
            packetWriter.PushInt(1000015);
            packetWriter.PushInt(0);
            packetWriter.PushShort(0x6f);
            packetWriter.PushInt(0x2379);
            packetWriter.PushInt(0); // 91
            packetWriter.PushByte(0x80);
            packetWriter.PushByte(2);
            packetWriter.PushShort(0x3603);
            packetWriter.PushInt(0x17);
            packetWriter.PushInt(vendingMachine.TemplateId);
            packetWriter.PushInt(0x2bd);
            packetWriter.PushInt(0); // 111
            packetWriter.PushInt(0x2be);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0x2bf);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0x19c); // 131
            packetWriter.PushInt(1);
            packetWriter.PushInt(0x1f5);
            packetWriter.PushInt(2);
            packetWriter.PushInt(0x1f4);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);
            packetWriter.PushInt(2);
            packetWriter.PushInt(0x32); // 147
            packetWriter.Push3F1Count(0);
            packetWriter.PushInt(3); // 155<

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }
コード例 #15
0
        public static void Send(Client client, NonPlayerCharacterClass knubotTarget)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x3b132d64);
            packetWriter.PushIdentity(client.Character.Type, client.Character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushShort(2);
            packetWriter.PushIdentity(knubotTarget.Type, knubotTarget.Id);
            packetWriter.PushInt(1);
            packetWriter.PushInt(0);

            byte[] packet = packetWriter.Finish();

            client.SendCompressed(packet);
        }
コード例 #16
0
        public static void Send(Client client, int category, int instance, object[] args)
        {
            PacketWriter packetWriter = new PacketWriter();
            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0x206B4B73);
            packetWriter.PushIdentity(50000, client.Character.Id);
            packetWriter.PushByte(1);
            packetWriter.PushInt(0);

            string message = "&~" + Encode85By4(category) + "&:" + Encode85By4(instance);

            foreach (object arg in args)
            {
                if (arg is Int32)
                {
                    message = message + "i" + Encode85By5((Int32)arg);
                }
                string stringArg = arg as string;
                if (stringArg != null)
                {
                    if (stringArg.Length > 255)
                    {
                        message = message + "S";
                        Int16 len = (Int16)stringArg.Length;
                        message = message + ShortToChar(len) + stringArg;
                    }
                    else
                    {
                        message = message + "s" + ByteToChar((byte)(stringArg.Length));
                    }
                }
            }

            Int16 mlen = (Int16)(message.Length);
            packetWriter.PushShort(mlen);
            packetWriter.PushString(message);
            packetWriter.PushInt(1);

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }
コード例 #17
0
 public static void Send(Client client)
 {
     PacketWriter packetWriter = new PacketWriter();
     packetWriter.PushByte(0xdf);
     packetWriter.PushByte(0xdf);
     packetWriter.PushShort(0xa);
     packetWriter.PushShort(1);
     packetWriter.PushShort(0); // Length
     packetWriter.PushInt(3086);
     packetWriter.PushInt(client.Character.Id);
     packetWriter.PushInt(0x343c287f);
     packetWriter.PushIdentity(50000, client.Character.Id);
     packetWriter.PushByte(1);
     packetWriter.PushInt(0);
     packetWriter.PushInt(0);
     packetWriter.PushInt(0);
     packetWriter.Push3F1Count(client.Character.Bank.Count);
     foreach (AOItem item in client.Character.Bank)
     {
         packetWriter.PushInt(item.Flags); // misused the flags for position in the bank
         short flags = 0;
         if (item.isInstanced())
         {
             flags |= 0xa0;
         }
         if (item.LowID == item.HighID)
         {
             flags |= 2;
         }
         else
         {
             flags |= 1;
         }
         // perhaps there are more flags...
         packetWriter.PushShort(flags);
         packetWriter.PushShort((short)item.MultipleCount);
         packetWriter.PushInt(item.Type);
         packetWriter.PushInt(item.Instance);
         packetWriter.PushInt(item.LowID);
         packetWriter.PushInt(item.HighID);
         packetWriter.PushInt(item.Quality);
         packetWriter.PushInt(0); // didnt encounter any other value
     }
     byte[] reply = packetWriter.Finish();
     client.SendCompressed(reply);
 }
コード例 #18
0
        public static void OrgInfoPacket(Character character)
        {
            PacketWriter writer = new PacketWriter();

            writer.PushByte(0xDF);
            writer.PushByte(0xDF);
            writer.PushShort(10);
            writer.PushShort(1);
            writer.PushShort(0);
            writer.PushInt(3086);
            writer.PushInt(character.Id);
            writer.PushInt(0x2E2A4A6B);
            writer.PushIdentity(50000, character.Id);
            writer.PushByte(0);
            writer.PushShort((short)character.OrgName.Length);
            writer.PushBytes(Encoding.ASCII.GetBytes(character.OrgName));
            byte[] mReply = writer.Finish();
            Announce.Playfield(character.PlayField, mReply);
        }
コード例 #19
0
        public static void Send(Client client, InventoryEntries inventoryEntry)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x052e2f0c);
            packetWriter.PushIdentity(client.Character.Type, client.Character.Id);
            packetWriter.PushByte(0);
            packetWriter.PushInt(inventoryEntry.Item.LowID);
            packetWriter.PushInt(inventoryEntry.Item.HighID);
            packetWriter.PushInt(inventoryEntry.Item.Quality);
            packetWriter.PushInt(inventoryEntry.Item.MultipleCount);

            byte[] packet = packetWriter.Finish();

            client.SendCompressed(packet);
        }
コード例 #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="client"></param>
        public static void Read(byte[] packet, Client client)
        {
            // client got all the needed data and
            // wants to enter the world. After we
            // reply to this, the character will really be in game

            byte[] characterID = BitConverter.GetBytes(client.Character.Id);
            Array.Reverse(characterID);
            PacketWriter packetWriter = new PacketWriter();
            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x570C2039);
            packetWriter.PushIdentity(50000, client.Character.Id);
            packetWriter.PushByte(0);
            byte[] reply = packetWriter.Finish();
            Announce.Playfield(client.Character.PlayField, reply);
            Dynels.GetDynels(client);

            // Mobs get sent whenever player enters playfield, BUT (!) they are NOT synchronized, because the mobs don't save stuff yet.
            // for instance: the waypoints the mob went through will NOT be saved and therefore when you re-enter the PF, it will AGAIN
            // walk the same waypoints.
            //TODO: Fix it
            /*foreach (MobType mob in NPCPool.Mobs)
            {
                //TODO: Make cache - use pf indexing somehow.
                if (mob.pf == client.Character.pf)
                {
                    mob.SendToClient(client);
                }
            }*/
        }
コード例 #21
0
        public static void Send(Client client, VendingMachine vendingMachine)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushByte(0xdf);
            packetWriter.PushByte(0xdf);
            packetWriter.PushShort(0xa);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x58362220);
            packetWriter.PushIdentity(vendingMachine.Type, vendingMachine.Id);
            packetWriter.PushByte(1);
            packetWriter.Push3F1Count(vendingMachine.Inventory.Count);
            foreach (InventoryEntries ie in vendingMachine.Inventory)
            {
                packetWriter.PushInt(ie.Item.LowID);
                packetWriter.PushInt(ie.Item.HighID);
                packetWriter.PushInt(ie.Item.Quality);
            }
            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }
コード例 #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="client"></param>
        public void Read(ref byte[] packet, Client client)
        {
            PacketReader reader = new PacketReader(ref packet);

            Header header = reader.PopHeader();
            reader.PopByte();
            byte cmd = reader.PopByte();
            Identity target = reader.PopIdentity();
            int unknown = reader.PopInt();
            string CmdStr = "";
            byte CmdByte = 0;

            #region cmd args
            switch (cmd)
            {
                case 1:
                case 7:
                case 9:
                case 13:
                case 17:
                case 19:
                case 20:
                case 21:
                case 23:
                case 24:
                case 25:
                case 26:
                case 27:
                case 28:
                    short CmdStrLen = reader.PopShort();
                    CmdStr = reader.PopString((int)CmdStrLen);
                    break;
                case 10:
                    CmdByte = reader.PopByte();
                    break;
                default:
                    break;
            }
            reader.Finish();
            #endregion
            DataTable dt;
            #region cmd handlers
            switch (cmd)
            {
                #region /org create <name>
                case 1:
                    {
                        // org create
                        /* client wants to create organization
                         * name of org is CmdStr
                         */

                        string SqlQuery = "SELECT * FROM organizations WHERE Name='" + CmdStr + "'";
                        string guild_name = null;
                        uint orgID = 0;
                        dt = ms.ReadDT(SqlQuery);
                        if (dt.Rows.Count > 0)
                        {
                            guild_name = (string)dt.Rows[0]["Name"];
                        }

                        if (guild_name == null)
                        {
                            client.SendChatText("You have created the guild: " + CmdStr);

                            string CurrDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            string SqlQuery2 = "INSERT INTO organizations (Name, creation, LeaderID, GovernmentForm) VALUES ('" + CmdStr + "', '" + CurrDate + "', '" + client.Character.ID + "', '0')";
                            ms.SqlInsert(SqlQuery2);
                            string SqlQuery3 = "SELECT * FROM organizations WHERE Name='" + CmdStr + "'";
                            dt = ms.ReadDT(SqlQuery3);
                            if (dt.Rows.Count > 0)
                            {
                                orgID = (UInt32)dt.Rows[0]["ID"];
                            }

                            // Make sure the order of these next two lines is not swapped -NV
                            client.Character.Stats.ClanLevel.Set(0);
                            client.Character.orgId = orgID;
                            break;
                        }
                        else
                        {
                            client.SendChatText("This guild already <font color=#DC143C>exists</font>");
                            break;
                        }
                    }
                #endregion

                #region /org ranks
                case 2:
                    // org ranks
                    //Displays Org Rank Structure.
                    /* Select governingform from DB, Roll through display from GovForm */
                    if (client.Character.orgId == 0)
                    {
                        client.SendChatText("You're not in an organization!");
                        break;
                    }
                    string ranksSql = "SELECT GovernmentForm FROM organizations WHERE ID = " + client.Character.orgId;
                    int govForm = -1;
                    dt = ms.ReadDT(ranksSql);
                    if (dt.Rows.Count > 0)
                    {
                        govForm = (Int32)dt.Rows[0]["GovernmentForm"];
                    }
                    client.SendChatText("Current Rank Structure: " + GetRankList(govForm));
                    break;
                #endregion

                #region /org contract
                case 3:
                    // org contract
                    break;
                #endregion

                #region unknown org command 4
                case 4:
                    Console.WriteLine("Case 4 Started");
                    break;
                #endregion

                #region /org info
                case 5:
                    {
                        Client tPlayer = null;
                        if (Misc.FindClient.FindClientByID(target.Instance, out tPlayer))
                        {
                            string orgDescription = "", orgObjective = "", orgHistory = "", orgLeaderName = "";
                            int orgGoverningForm = 0, orgLeaderID = 0;
                            dt = ms.ReadDT("SELECT * FROM organizations WHERE ID=" + tPlayer.Character.orgId);

                            if (dt.Rows.Count > 0)
                            {
                                orgDescription = (string)dt.Rows[0]["Description"];
                                orgObjective = (string)dt.Rows[0]["Objective"];
                                orgHistory = (string)dt.Rows[0]["History"];
                                orgGoverningForm = (Int32)dt.Rows[0]["GovernmentForm"];
                                orgLeaderID = (Int32)dt.Rows[0]["LeaderID"];
                            }

                            dt = ms.ReadDT("SELECT Name FROM characters WHERE ID=" + orgLeaderID);
                            if (dt.Rows.Count > 0)
                            {
                                orgLeaderName = (string)dt.Rows[0][0];
                            }

                            string TextGovForm = null;
                            if (orgGoverningForm == 0) { TextGovForm = "Department"; }
                            else if (orgGoverningForm == 1) { TextGovForm = "Faction"; }
                            else if (orgGoverningForm == 2) { TextGovForm = "Republic"; }
                            else if (orgGoverningForm == 3) { TextGovForm = "Monarchy"; }
                            else if (orgGoverningForm == 4) { TextGovForm = "Anarchism"; }
                            else if (orgGoverningForm == 5) { TextGovForm = "Feudalism"; }
                            else { TextGovForm = "Department"; }
                            string orgRank = GetRank(orgGoverningForm, tPlayer.Character.Stats.ClanLevel.StatBaseValue);
                            PacketWriter writer = new PacketWriter();
                            writer.PushBytes(new byte[] { 0xDF, 0xDF });
                            writer.PushShort(10);
                            writer.PushShort(1);
                            writer.PushShort(0);
                            writer.PushInt(3086);
                            writer.PushInt(client.Character.ID);
                            writer.PushInt(0x64582A07);
                            writer.PushIdentity(50000, tPlayer.Character.ID);
                            writer.PushByte(0);
                            writer.PushByte(2);    // OrgServer case 0x02 (Org Info)
                            writer.PushInt(0);
                            writer.PushInt(0);
                            writer.PushInt(0xDEAA); // Type (org)
                            writer.PushUInt(tPlayer.Character.orgId);    // org ID
                            writer.PushShort((short)tPlayer.Character.orgName.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(tPlayer.Character.orgName));
                            writer.PushShort((short)orgDescription.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(orgDescription));
                            writer.PushShort((short)orgObjective.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(orgObjective));
                            writer.PushShort((short)orgHistory.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(orgHistory));
                            writer.PushShort((short)TextGovForm.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(TextGovForm));
                            writer.PushShort((short)orgLeaderName.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(orgLeaderName));
                            writer.PushShort((short)orgRank.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(orgRank));
                            writer.Push3F1Count(0);
                            byte[] reply = writer.Finish();

                            client.SendCompressed(reply);
                        }
                    }
                    break;
                #endregion

                #region /org disband
                case 6:
                    break;
                #endregion

                #region /org startvote <text> <duration> <entries>
                case 7:
                    // org startvote <"text"> <duration(minutes)> <entries>
                    // arguments (<text> <duration> and <entries>) are in CmdStr
                    break;
                #endregion

                #region /org vote info
                case 8:
                    // org vote info
                    break;
                #endregion

                #region /org vote <entry>
                case 9:
                    // <entry> is CmdStr
                    break;
                #endregion

                #region /org promote
                case 10:
                    {
                        // some arg in CmdByte. No idea what it is

                        //create the target namespace t_promote
                        Client t_promote = null;
                        string promoteSql = "";
                        int targetOldRank = -1;
                        int targetNewRank = -1;
                        int newPresRank = -1;
                        int oldPresRank = 0;
                        if (Misc.FindClient.FindClientByID(target.Instance, out t_promote))
                        {
                            //First we check if target is in the same org as you
                            if (t_promote.Character.orgId != client.Character.orgId)
                            {
                                //not in same org
                                client.SendChatText("Target is not in your organization!");
                                break;
                            }
                            //Target is in same org, are you eligible to promote?  Promoter Rank has to be TargetRank-2 or == 0
                            if ((client.Character.Stats.ClanLevel.Value == (t_promote.Character.Stats.ClanLevel.Value - 2)) || (client.Character.Stats.ClanLevel.Value == 0))
                            {
                                //Promoter is eligible. Start the process

                                //First we get the details about the org itself
                                promoteSql = "SELECT * FROM organizations WHERE ID = " + client.Character.orgId;
                                dt = ms.ReadDT(promoteSql);

                                int promoteGovForm = -1;
                                string promotedToRank = "";
                                string demotedFromRank = "";

                                if (dt.Rows.Count > 0)
                                {
                                    promoteGovForm = (Int32)dt.Rows[0]["GovernmentForm"];
                                }

                                //Check if new rank == 0, if so, demote promoter
                                if ((targetOldRank - 1) == 0)
                                {
                                    /* This is a bit more complex.  Here we need to promote new president first
                                         * then we go about demoting old president
                                         * finally we set the new leader in SQL
                                         * Reset OrgName to set changes
                                         */

                                    // Set new President's Rank
                                    targetOldRank = t_promote.Character.Stats.ClanLevel.Value;
                                    targetNewRank = targetOldRank - 1;
                                    promotedToRank = GetRank(promoteGovForm, (uint)targetNewRank);
                                    t_promote.Character.Stats.ClanLevel.Set(targetNewRank);
                                    // Demote the old president
                                    oldPresRank = client.Character.Stats.ClanLevel.Value;
                                    newPresRank = oldPresRank + 1;
                                    demotedFromRank = GetRank(promoteGovForm, (uint)newPresRank);
                                    client.Character.Stats.ClanLevel.Set(newPresRank);
                                    //Change the leader id in SQL
                                    string newLeadSql = "UPDATE organizations SET LeaderID = " + t_promote.Character.ID + " WHERE ID = " + t_promote.Character.orgId;
                                    ms.SqlUpdate(newLeadSql);
                                    client.SendChatText("You've passed leadership of the organization to: " + t_promote.Character.Name);
                                    t_promote.SendChatText("You've been promoted to the rank of " + promotedToRank + " by " + client.Character.Name);
                                    break;
                                }
                                else
                                {
                                    //Just Promote
                                    targetOldRank = t_promote.Character.Stats.ClanLevel.Value;
                                    targetNewRank = targetOldRank - 1;
                                    promotedToRank = GetRank(promoteGovForm, (uint)targetNewRank);
                                    t_promote.Character.Stats.ClanLevel.Set(targetNewRank);
                                    client.SendChatText("You've promoted " + t_promote.Character.Name + " to " + promotedToRank);
                                    t_promote.SendChatText("You've been promoted to the rank of " + promotedToRank + " by " + client.Character.Name);
                                }
                            }
                            else
                            {
                                //Promoter not eligible to promote
                                client.SendChatText("Your Rank is not high enough to promote " + t_promote.Character.Name);
                                break;
                            }
                        }
                        break;
                    }
                #endregion

                #region /org demote
                case 11:
                    // demote target player
                    //create the target namespace t_demote
                    Client t_demote = null;
                    string demoteSql = "";
                    int targetCurRank = -1;
                    int targetNewerRank = -1;
                    if (Misc.FindClient.FindClientByID(target.Instance, out t_demote))
                    {
                        //First we check if target is in the same org as you
                        if (t_demote.Character.orgId != client.Character.orgId)
                        {
                            //not in same org
                            client.SendChatText("Target is not in your organization!");
                            break;
                        }
                        //Target is in same org, are you eligible to demote?  Promoter Rank has to be TargetRank-2 or == 0
                        if ((client.Character.Stats.GmLevel.Value == (t_demote.Character.Stats.ClanLevel.Value - 2)) || (client.Character.Stats.ClanLevel.Value == 0))
                        {
                            //Promoter is eligible. Start the process

                            //First we get the details about the org itself
                            demoteSql = "SELECT GovernmentForm FROM organizations WHERE ID = " + client.Character.orgId;
                            dt = ms.ReadDT(demoteSql);
                            int demoteGovForm = -1;
                            string demotedToRank = "";
                            if (dt.Rows.Count > 0)
                            {
                                demoteGovForm = (Int32)dt.Rows[0]["GovernmentForm"];
                            }

                            //Check whether new rank would be lower than lowest for current govform
                            if ((targetCurRank + 1) > GetLowestRank(demoteGovForm))
                            {
                                client.SendChatText("You can't demote character any lower!");
                                break;
                            }
                            targetCurRank = t_demote.Character.Stats.GmLevel.Value;
                            targetNewerRank = targetCurRank + 1;
                            demotedToRank = GetRank(demoteGovForm, (uint)targetNewerRank);
                            t_demote.Character.Stats.ClanLevel.Set(targetNewerRank);
                            client.SendChatText("You've demoted " + t_demote.Character.Name + " to " + demotedToRank);
                            t_demote.SendChatText("You've been demoted to the rank of " + demotedToRank + " by " + client.Character.Name);
                            break;
                        }
                        else
                        {
                            //Promoter not eligible to promote
                            client.SendChatText("Your Rank is not high enough to demote " + t_demote.Character.Name);
                            break;
                        }
                    }
                    break;
                #endregion

                #region unknown org command 12
                case 12:
                    Console.WriteLine("Case 12 Started");
                    break;
                #endregion

                #region /org kick <name>
                case 13:
                    // kick <name> from org
                    // <name> is CmdStr

                    //create the t_player Client namespace, using CmdStr to find character id, in replacement of target.Instance
                    uint kickedFrom = client.Character.orgId;
                    string kickeeSql = "SELECT * FROM characters WHERE Name = '" + CmdStr + "'";
                    int kickeeId = 0;
                    dt = ms.ReadDT(kickeeSql);
                    if (dt.Rows.Count > 0)
                    {
                        kickeeId = (Int32)dt.Rows[0]["ID"];
                    }

                    Client target_player = null;
                    if (Misc.FindClient.FindClientByID(kickeeId, out target_player))
                    {
                        //Check if CmdStr is actually part of the org
                        uint kickeeOrgId = target_player.Character.orgId;
                        if (kickeeOrgId != client.Character.orgId)
                        {
                            //Not part of Org. break out.
                            client.SendChatText(CmdStr + "is not a member of your organization!");
                            break;
                        }

                        //They are part of the org, so begin the processing...
                        //First we check if the player is online...
                        string onlineSql = "SELECT online FROM characters WHERE ID = " + client.Character.ID;
                        dt = ms.ReadDT(onlineSql);
                        int onlineStatus = 0;
                        if (dt.Rows.Count > 0)
                        {
                            onlineStatus = (Int32)dt.Rows[0][0];
                        }

                        if (onlineStatus == 0)
                        {
                            //Player isn't online. Org Kicks are processed in a different method
                            break;
                        }

                        //Player is online. Start the kick.
                        target_player.Character.Stats.ClanLevel.Set(0);
                        target_player.Character.orgId = 0;
                        string kickedFromSql = "SELECT Name FROM organizations WHERE ID = " + client.Character.orgId;
                        dt = ms.ReadDT(kickedFromSql);
                        string KickedFromName = "";
                        if (dt.Rows.Count > 0)
                        {
                            KickedFromName = (string)dt.Rows[0][0];
                        }
                        target_player.SendChatText("You've been kicked from the organization " + KickedFromName);

                    }
                    break;
                #endregion

                #region /org invite
                case 14:
                    {
                        Client t_player = null;
                        if (Misc.FindClient.FindClientByID(target.Instance, out t_player))
                        {
                            PacketWriter writer = new PacketWriter();
                            writer.PushBytes(new byte[] { 0xDF, 0xDF });
                            writer.PushShort(10);
                            writer.PushShort(1);
                            writer.PushShort(0);
                            writer.PushInt(3086); //Sender
                            writer.PushInt(t_player.Character.ID);  //Receiver
                            writer.PushInt(0x64582A07); //Packet ID
                            writer.PushIdentity(50000, t_player.Character.ID); //Target Identity
                            writer.PushByte(0);
                            writer.PushByte(5); //OrgServer Case 0x05 (Invite)
                            writer.PushInt(0);
                            writer.PushInt(0);
                            writer.PushIdentity(0xDEAA, (int)client.Character.orgId); // Type (org)
                            writer.PushShort((short)client.Character.orgName.Length);
                            writer.PushBytes(Encoding.ASCII.GetBytes(client.Character.orgName));
                            writer.PushInt(0);
                            byte[] reply = writer.Finish();

                            t_player.SendCompressed(reply);
                        }
                    }
                    break;
                #endregion

                #region Org Join
                case 15:
                    {
                        //target.Instance holds the OrgID of the Org wishing to be joined.
                        int orgIdtoJoin = target.Instance;
                        string JoinSql = "SELECT * FROM organizations WHERE ID = '" + orgIdtoJoin + "' LIMIT 1";
                        int gov_form = 0;
                        dt = ms.ReadDT(JoinSql);
                        if (dt.Rows.Count > 0)
                        {
                            gov_form = (Int32)dt.Rows[0]["GovernmentForm"];
                        }

                        // Make sure the order of these next two lines is not swapped -NV
                        client.Character.Stats.ClanLevel.Set(GetLowestRank(gov_form));
                        client.Character.orgId = (uint)orgIdtoJoin;
                    }
                    break;
                #endregion

                #region /org leave
                case 16:
                    // org leave
                    // TODO: Disband org if it was leader that left org. -Suiv-
                    // I don't think a Disband happens if leader leaves. I don't think leader -can- leave without passing lead to another
                    // Something worth testing on Testlive perhaps ~Chaz
                    // Just because something happens on TL, doesnt mean its a good idea. Really tbh id prefer it if you had to explicitly type /org disband to disband rather than /org leave doing it... -NV
                    // Agreeing with NV.  Org Leader can't leave without passing lead on.  org disband requires /org disband to specifically be issued, with a Yes/No box.
                    string LeaveSql = "SELECT * FROM organizations WHERE ID = " + client.Character.orgId;
                    int govern_form = 0;
                    dt = ms.ReadDT(LeaveSql);
                    if (dt.Rows.Count > 0)
                    {
                        govern_form = (Int32)dt.Rows[0]["GovernmentForm"];
                    }

                    if ((client.Character.Stats.ClanLevel.Value == 0) && (govern_form != 4))
                    {
                        client.SendChatText("Organization Leader cannot leave organization without Disbanding or Passing Leadership!");
                    }
                    else
                    {
                        client.Character.orgId = 0;
                        client.SendChatText("You left the guild");

                    }
                    break;
                #endregion

                #region /org tax | /org tax <tax>
                case 17:
                    // gets or sets org tax
                    // <tax> is CmdStr
                    // if no <tax>, then just send chat text with current tax info

                    if (CmdStr == null)
                    {
                        client.SendChatText("The current organization tax rate is: ");
                        break;
                    }
                    else
                    {
                        break;
                    }
                #endregion

                #region /org bank
                case 18:
                    {
                        // org bank
                        dt = ms.ReadDT("SELECT * FROM organizations WHERE ID=" + client.Character.orgId);
                        if (dt.Rows.Count > 0)
                        {
                            UInt64 bank_credits = (UInt64)dt.Rows[0]["Bank"];
                            client.SendChatText("Your bank has " + bank_credits + " credits in its account");
                        }
                    }
                    break;
                #endregion

                #region /org bank add <cash>
                case 19:
                    {
                        if (client.Character.orgId == 0)
                        {
                            client.SendChatText("You are not in an organisation.");

                            break;
                        }

                        // org bank add <cash>
                        int minuscredits_fromplayer = Convert.ToInt32(CmdStr);
                        int characters_credits = client.Character.Stats.Cash.Value;

                        if (characters_credits < minuscredits_fromplayer)
                        {
                            client.SendChatText("You do not have enough Credits");
                        }
                        else
                        {
                            int total_Creditsspent = characters_credits - minuscredits_fromplayer;
                            client.Character.Stats.Cash.Set(total_Creditsspent);

                            ms.SqlUpdate("UPDATE `organizations` SET `Bank` = `Bank` + " + minuscredits_fromplayer + " WHERE `ID` = " + client.Character.orgId);
                            client.SendChatText("You have donated " + minuscredits_fromplayer + " to the organization");
                        }
                    }

                    break;
                #endregion

                #region /org bank remove <cash>
                case 20:
                    // org bank remove <cash>
                    // <cash> is CmdStr
                    // player wants to take credits from org bank
                    // only leader can do that
                    if ((client.Character.Stats.ClanLevel.Value != 0) || (client.Character.orgId == 0))
                    {
                        client.SendChatText("You're not the leader of an Organization");
                        break;
                    }
                    int remove_credits = Convert.ToInt32(CmdStr);
                    long org_bank = 0;
                    dt = ms.ReadDT("SELECT Bank FROM organizations WHERE ID = " + client.Character.orgId);
                    if (dt.Rows.Count > 0)
                    {
                        org_bank = (Int64)dt.Rows[0][0];
                    }
                    if (remove_credits > org_bank)
                    {
                        client.SendChatText("Not enough credits in Organization Bank!");
                        break;
                    }
                    else
                    {
                        long neworgbank = org_bank - remove_credits;
                        int existingcreds = 0;
                        existingcreds = client.Character.Stats.Cash.Value;
                        int newcreds = existingcreds + remove_credits;
                        ms.SqlUpdate("UPDATE organizations SET Bank = " + neworgbank + " WHERE ID = " + client.Character.orgId);
                        client.Character.Stats.Cash.Set(newcreds);
                        client.SendChatText("You've removed " + remove_credits + " credits from the organization bank");
                    }
                    break;
                #endregion

                #region /org bank paymembers <cash>
                case 21:
                    // <cash> is CmdStr
                    // give <cash> credits to every org member
                    // credits are taken from org bank
                    // only leader can do it
                    break;
                #endregion

                #region /org debt
                case 22:
                    // send player text about how big is his/her tax debt to org
                    break;
                #endregion

                #region /org history <text>
                case 23:
                    {
                        if (client.Character.Stats.ClanLevel.Value == 0)
                        {
                            // org history <history text>
                            ms.SqlUpdate("UPDATE organizations SET history = '" + CmdStr + "' WHERE ID = '" + client.Character.orgId + "'");
                            client.SendChatText("History Updated");
                        }
                        else { client.SendChatText("You must be the Organization Leader to perform this command!"); }
                    }
                    break;
                #endregion

                #region /org objective <text>
                case 24:
                    {
                        if (client.Character.Stats.ClanLevel.Value == 0)
                        {
                            // org objective <objective text>
                            ms.SqlUpdate("UPDATE organizations SET objective = '" + CmdStr + "' WHERE ID = '" + client.Character.orgId + "'");
                            client.SendChatText("Objective Updated");
                        }
                        else { client.SendChatText("You must be the Organization Leader to perform this command!"); }
                    }
                    break;
                #endregion

                #region /org description <text>
                case 25:
                    {
                        if (client.Character.Stats.ClanLevel.Value == 0)
                        {
                            // org description <description text>
                            ms.SqlUpdate("UPDATE organizations SET description = '" + CmdStr + "' WHERE ID = '" + client.Character.orgId + "'");
                            client.SendChatText("Description Updated");
                        }
                        else { client.SendChatText("You must be the Organization Leader to perform this command!"); }
                    }
                    break;
                #endregion

                #region /org name <text>
                case 26:
                    {
                        // org name <name>
                        /* Renames Organization
                         * Checks for Existing Orgs with similar name to stop crash
                         * Chaz
                         */
                        if (client.Character.Stats.ClanLevel.Value == 0)
                        {
                            string SqlQuery26 = "SELECT * FROM organizations WHERE Name LIKE '" + CmdStr + "' LIMIT 1";
                            string CurrentOrg = null;
                            dt = ms.ReadDT(SqlQuery26);
                            if (dt.Rows.Count > 0)
                            {
                                CurrentOrg = (string)dt.Rows[0]["Name"];
                            }

                            if (CurrentOrg == null)
                            {
                                string SqlQuery27 = "UPDATE organizations SET Name = '" + CmdStr + "' WHERE ID = '" + client.Character.orgId + "'";
                                ms.SqlUpdate(SqlQuery27);
                                client.SendChatText("Organization Name Changed to: " + CmdStr);

                                // Forces reloading of org name and the like
                                // XXXX TODO: Make it reload for all other members in the org
                                client.Character.orgId = client.Character.orgId;
                                break;
                            }
                            else
                            {
                                client.SendChatText("An Organization already exists with that name");
                                break;
                            }
                        }
                        else { client.SendChatText("You must be the organization leader to perform this command!"); }
                        break;
                    }
                #endregion

                #region /org governingform <text>
                case 27:
                    {
                        // org governingform <form>
                        /* Current Governing Forms:
                         * Department, Faction, Republic, Monarchy, Anarchism, Feudalism
                         */
                        //Check on whether your President or not
                        if (client.Character.Stats.ClanLevel.Value == 0)
                        {
                            //first we drop the case on the input, just to be sure.
                            Int32 GovFormNum = -1;
                            if (CmdStr == null)
                            {
                                //list gov forms
                                client.SendChatText("List of Accepted Governing Forms is: department, faction, republic, monarchy, anarchism, feudalism");
                                break;
                            }
                            //was correct input passed?
                            switch (CmdStr.ToLower())
                            {
                                case "department":
                                    GovFormNum = 0;
                                    break;
                                case "faction":
                                    GovFormNum = 1;
                                    break;
                                case "republic":
                                    GovFormNum = 2;
                                    break;
                                case "monarchy":
                                    GovFormNum = 3;
                                    break;
                                case "anarchism":
                                    GovFormNum = 4;
                                    break;
                                case "feudalism":
                                    GovFormNum = 5;
                                    break;
                                default:
                                    client.SendChatText(CmdStr + " Is an invalid Governing Form!");
                                    client.SendChatText("Accepted Governing Forms are: department, faction, republic, monarchy, anarchism, feudalism");
                                    break;
                            }
                            if (GovFormNum != -1)
                            {
                                ms.SqlUpdate("UPDATE organizations SET GovernmentForm = '" + GovFormNum + "' WHERE ID = '" + client.Character.orgId + "'");
                                foreach (int currentCharId in OrgMisc.GetOrgMembers(client.Character.orgId, true))
                                {
                                    client.Character.Stats.ClanLevel.Set(GetLowestRank(GovFormNum));
                                }
                                client.SendChatText("Governing Form is now: " + CmdStr);
                                break;
                            }
                        }
                        else
                        {
                            //Haha! You're not the org leader!
                            client.SendChatText("You must be the Org Leader to perform this command");
                            break;
                        }
                    }
                    break;
                #endregion

                #region /org stopvote <text>
                case 28:
                    // <text> is CmdStr
                    break;
                #endregion

                #region unknown command
                default:
                    break;
                #endregion
            }
            #endregion

            reader.Finish();
        }
コード例 #23
0
ファイル: Character.cs プロジェクト: semirs/CellAO
 /// <summary>
 /// Write inventory data into packetwriter
 /// </summary>
 /// <param name="writer">ref of the packetwriter</param>
 public void writeInventorytoPacket(ref PacketWriter writer)
 {
     int count;
     lock (Inventory)
     {
         writer.Push3F1Count(Inventory.Count);
         for (count = 0; count < Inventory.Count; count++)
         {
             writer.PushInt(Inventory[count].Placement);
             writer.PushShort((short)Inventory[count].Item.flags);
             writer.PushShort((short)Inventory[count].Item.multiplecount);
             writer.PushIdentity(Inventory[count].Item.Type, Inventory[count].Item.Instance);
             writer.PushInt(Inventory[count].Item.lowID);
             writer.PushInt(Inventory[count].Item.highID);
             writer.PushInt(Inventory[count].Item.Quality);
             writer.PushInt(Inventory[count].Item.Nothing);
         }
     }
 }
コード例 #24
0
ファイル: Client.cs プロジェクト: semirs/CellAO
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Text"></param>
        /// <returns></returns>
        public bool SendChatText(string Text)
        {
            PacketWriter _writer = new PacketWriter();

            _writer.PushByte(0xDF);
            _writer.PushByte(0xDF);
            _writer.PushShort(10);
            _writer.PushShort(1);
            _writer.PushShort(0);
            _writer.PushInt(3086);
            _writer.PushInt(this.Character.Id);
            _writer.PushInt(0x5F4B442A);
            _writer.PushIdentity(50000, this.Character.Id);
            _writer.PushByte(0);
            _writer.PushShort((short)Text.Length);
            _writer.PushBytes(Encoding.ASCII.GetBytes(Text));
            _writer.PushShort(0x1000);
            _writer.PushInt(0);
            byte[] reply = _writer.Finish();
            this.SendCompressed(reply);
            return true;
        }
コード例 #25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="client"></param>
        public static void Read(byte[] packet, Client client)
        {
            PacketWriter packetWriter = new PacketWriter();
            PacketReader packetReader = new PacketReader(packet);

            Header header = packetReader.PopHeader();
            byte unknown1 = packetReader.PopByte();
            uint[] nanodelta = { 3, 3, 4, 2 };
            uint[] healdelta = { 3, 3, 2, 4 };

            uint baseIP = 0;
            uint characterLevel;

            characterLevel = client.Character.Stats.Level.StatBaseValue; // 54 = Level

            // Calculate base IP value for character level
            if (characterLevel > 204)
            {
                baseIP += (characterLevel - 204) * 600000;
                characterLevel = 204;
            }
            if (characterLevel > 189)
            {
                baseIP += (characterLevel - 189) * 150000;
                characterLevel = 189;
            }
            if (characterLevel > 149)
            {
                baseIP += (characterLevel - 149) * 80000;
                characterLevel = 149;
            }
            if (characterLevel > 99)
            {
                baseIP += (characterLevel - 99) * 40000;
                characterLevel = 99;
            }
            if (characterLevel > 49)
            {
                baseIP += (characterLevel - 49) * 20000;
                characterLevel = 49;
            }
            if (characterLevel > 14)
            {
                baseIP += (characterLevel - 14) * 10000; // Change 99 => 14 by Wizard
                characterLevel = 14;
            }
            baseIP += 1500 + (characterLevel - 1) * 4000;

            // Prepare reply packet

            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(0x0a);
            packetWriter.PushShort(0x01);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(header.Sender);
            packetWriter.PushInt(0x3e205660);
            packetWriter.PushIdentity(50000, header.Sender);
            packetWriter.PushByte(0);

            int count = packetReader.PopInt();
            uint statval;
            List<int> statlist = new List<int>();
            while (count > 0)
            {
                int statNumber = packetReader.PopInt();
                statval = packetReader.PopUInt();
                client.Character.Stats.SetBaseValue(statNumber, statval);
                statlist.Add(statNumber);
                count--;
            }

            packetReader.Finish();

            statlist.Add(53); // IP
            uint usedIP = baseIP - (uint)Math.Floor(CalculateIP(client));
            client.Character.Stats.IP.StatBaseValue = usedIP;

            // Send the changed stats back to the client
            packetWriter.PushInt(statlist.Count);
            count = 0;
            while (count < statlist.Count)
            {
                statval = client.Character.Stats.GetBaseValue(statlist[count]);
                packetWriter.PushInt(statlist[count]);
                packetWriter.PushUInt(statval);
                count++;
            }

            byte[] reply = packetWriter.Finish();
            client.SendCompressed(reply);

            // and save the changes to the statsdb
            client.Character.WriteStats();
            client.Character.CalculateSkills();
        }
コード例 #26
0
        public static void SendStat(Client client, int statnum, int value, Boolean announce)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushBytes(new byte[] { 0xDF, 0xDF, });
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x2B333D6E);
            packetWriter.PushIdentity(50000, client.Character.Id);
            packetWriter.PushByte(1);
            packetWriter.PushInt(1);
            packetWriter.PushInt(statnum);
            packetWriter.PushInt(value);

            byte[] reply = packetWriter.Finish();
            client.SendCompressed(reply);

            /* announce to playfield? */
            if (announce)
            {
                Announce.Playfield(client.Character.PlayField, reply);
            }
        }
コード例 #27
0
ファイル: CharacterListPacket.cs プロジェクト: semirs/CellAO
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="accountName"></param>
        public void SendPacket(Client client, string accountName)
        {
            #region Expansions Checker
            Int32 expansions = 0;
            Int32 allowedCharacters = 0;
            /* This checks your expansions and
               number of characters allowed (num. of chars doesn't work)*/
            string sqlQuery = "SELECT `Expansions`,`Allowed_Characters` FROM `login` WHERE Username = '******'";
            SqlWrapper ms = new SqlWrapper();
            DataTable dt = ms.ReadDatatable(sqlQuery);
            if (dt.Rows.Count > 0)
            {
                expansions = Int32.Parse((string)dt.Rows[0][0]);
                allowedCharacters = (Int32)dt.Rows[0][1];
            }
            #endregion

            List<CharacterEntry> characters = CharacterList.LoadCharacters(accountName);
            PacketWriter pwriter = new PacketWriter();

            pwriter.PushByte(0xDF);
            pwriter.PushByte(0xDF);
            pwriter.PushShort(1); // packet type
            pwriter.PushShort(1); // ?
            pwriter.PushShort(0); // packet length (writer will take care of this)
            pwriter.PushInt(1);
            pwriter.PushInt(0x615B);
            pwriter.PushInt(0xE);
            pwriter.PushInt(characters.Count); // number of characters
            foreach (CharacterEntry character in characters)
            {
                pwriter.PushInt(4); // ?
                pwriter.PushInt(character.Id); // character ID

                // PlayfieldProxy starts
                pwriter.PushByte(0x61); // PlayfieldProxy version
                pwriter.PushIdentity(0xC79D, character.Playfield);
                pwriter.PushInt(1);
                pwriter.PushInt(0);
                pwriter.PushIdentity(0, 0);
                // PlayfieldProxy ends
                // TODO: what is it?
                pwriter.PushInt(1); // ?

                // CharacterInfo starts
                pwriter.PushInt(4); // CharacterInfo version
                // if CharacterInfo version == 2
                {
                    // pwriter.PushInt(character.Breed);
                    // pwriter.PushInt(character.Gender);
                    // pwriter.PushBytes(Encoding.ASCII.GetBytes(character.Name.PadRight(0x20,char.MinValue)));
                }
                // else
                {
                    pwriter.PushInt(character.Id); // character ID
                    {
                        // if there is problem with name
                        //pwriter.PushInt(256); //(will set name to "ERROR-CHANGE-NAME")

                        // if name is ok
                        pwriter.PushInt(character.Name.Length);
                        pwriter.PushBytes(Encoding.ASCII.GetBytes(character.Name));
                    }
                    pwriter.PushInt(character.Breed);
                    pwriter.PushInt(character.Gender);
                    pwriter.PushInt(character.Profession);
                    pwriter.PushInt(character.Level);
                    {
                        // lets just leave it like that for now..
                        string areaName = "area unknown";
                        pwriter.PushInt(areaName.Length);
                        pwriter.PushBytes(Encoding.ASCII.GetBytes(areaName));
                    }
                    // TODO: What are these?
                    pwriter.PushInt(0); // ?
                    pwriter.PushInt(0); // some string (int is string length)
                    // if CharacterVersion > 3
                    {
                        // TODO: what are these 3 ints?
                        pwriter.PushInt(0); // ?
                        pwriter.PushInt(0); // ?
                        pwriter.PushInt(0); // ?
                    }
                    // CharacterInfo ends
                }
            }
            // TODO: find out what this really is
            pwriter.PushInt(allowedCharacters); // not really allowed characters..
            pwriter.PushInt(expansions);

            byte[] reply = pwriter.Finish();
            client.Send(reply);
        }
コード例 #28
0
ファイル: Client.cs プロジェクト: semirs/CellAO
        /// <summary>
        /// 
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="heading"></param>
        /// <param name="playfield"></param>
        /// <returns></returns>
        public bool TeleportProxy(
            AOCoord destination,
            Quaternion heading,
            int playfield,
            Identity pfinstance,
            int GS,
            int SG,
            Identity R,
            Identity dest)
        {
            PacketWriter writer = new PacketWriter();
            // header starts
            writer.PushByte(0xDF);
            writer.PushByte(0xDF);
            writer.PushShort(10);
            writer.PushShort(1);
            writer.PushShort(0);
            writer.PushInt(3086);
            writer.PushInt(this.Character.Id);
            writer.PushInt(0x43197D22);
            writer.PushIdentity(50000, this.Character.Id);
            writer.PushByte(0);
            // Header ends
            writer.PushCoord(this.Character.RawCoord);
            writer.PushQuat(this.Character.RawHeading);
            writer.PushByte(97);
            writer.PushIdentity(pfinstance.Type, pfinstance.Instance);
            writer.PushInt(GS);
            writer.PushInt(SG);
            writer.PushIdentity(40016, playfield);
            // Dont know for sure if its correct to only transfer the playfield here
            writer.PushInt(0);
            writer.PushInt(0);
            writer.PushIdentity(dest.Type, dest.Instance);
            writer.PushInt(0);
            byte[] tpreply = writer.Finish();
            this.Character.DoNotDoTimers = true;
            Despawn.DespawnPacket(this.Character.Id);
            this.SendCompressed(tpreply);
            this.Character.DoNotDoTimers = true;
            this.Character.Stats.LastConcretePlayfieldInstance.Value = this.Character.PlayField;
            this.Character.Stats.ExtenalDoorInstance.Value = SG;

            this.Character.StopMovement();
            this.Character.RawCoord = destination;
            this.Character.RawHeading = heading;
            this.Character.PlayField = playfield;
            this.Character.Resource = 0x3c000;
            this.Character.Purge(); // Purge character information to DB before client reconnect

            IPAddress tempIP;
            if (IPAddress.TryParse(Config.Instance.CurrentConfig.ZoneIP, out tempIP) == false)
            {
                IPHostEntry zoneHost = Dns.GetHostEntry(Config.Instance.CurrentConfig.ZoneIP);
                foreach (IPAddress ip in zoneHost.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        tempIP = ip;
                        break;
                    }
                }
            }
            int zoneIP = IPAddress.HostToNetworkOrder(BitConverter.ToInt32(tempIP.GetAddressBytes(), 0));
            short zonePort = Convert.ToInt16(Config.Instance.CurrentConfig.ZonePort);

            Thread.Sleep(1000);

            PacketWriter writer2 = new PacketWriter();
            writer2.PushByte(0xDF);
            writer2.PushByte(0xDF);
            writer2.PushShort(1);
            writer2.PushShort(1);
            writer2.PushShort(0);
            writer2.PushInt(3086);
            writer2.PushInt(this.Character.Id);
            writer2.PushInt(60);
            writer2.PushInt(zoneIP);
            writer2.PushShort(zonePort);
            byte[] connect = writer2.Finish();
            this.SendCompressed(connect);
            return true;
        }
コード例 #29
0
ファイル: Client.cs プロジェクト: semirs/CellAO
        /* Called from CharacterAction class in case of 'stand' (0x57)
         * Sends Stand packet back to client
         * In case of logout CancelLogOut (above) stops it.
        */

        public void StandCancelLogout()
        {
            PacketWriter standUp = new PacketWriter();

            // start packet header
            standUp.PushByte(0xDF);
            standUp.PushByte(0xDF);
            standUp.PushShort(10);
            standUp.PushShort(1);
            standUp.PushShort(0);
            standUp.PushInt(3086); // Sender (server ID)
            standUp.PushInt(this.Character.Id); // Receiver
            standUp.PushInt(0x5E477770); // CharacterAction packet ID
            standUp.PushIdentity(50000, this.Character.Id); // affected identity
            standUp.PushByte(0);
            // end packet header

            standUp.PushByte(0);
            standUp.PushShort(0);
            standUp.PushByte(0x57); // stand packet flag
            standUp.PushInt(0);
            standUp.PushInt(0);
            standUp.PushInt(0);
            standUp.PushInt(0);
            standUp.PushInt(0);
            standUp.PushShort(0);
            byte[] standUpPacket = standUp.Finish();
            Announce.Playfield(this.Character.PlayField, standUpPacket);
            //            SendCompressed(standUpPacket);

            if (LogoutTimer.Enabled)
            {
                this.CancelLogOut();
            } // If logout timer is running, CancelLogOut method stops it.
        }
コード例 #30
0
ファイル: Client.cs プロジェクト: semirs/CellAO
        /* Called from CharacterAction class in case of 'stop logout packet'
         * Stops the 30 second timer and sends 'stop logout packet' back to client
        */

        public void CancelLogOut()
        {
            LogoutTimer.Enabled = false;
            PacketWriter stopLogout = new PacketWriter();

            // start packet header
            stopLogout.PushByte(0xDF);
            stopLogout.PushByte(0xDF);
            stopLogout.PushShort(10);
            stopLogout.PushShort(1);
            stopLogout.PushShort(0);
            stopLogout.PushInt(3086); // Sender (server ID)
            stopLogout.PushInt(this.Character.Id); // Receiver
            stopLogout.PushInt(0x5E477770); // CharacterAction packet ID
            stopLogout.PushIdentity(50000, this.Character.Id); // affected identity
            stopLogout.PushByte(0);
            // end packet header

            stopLogout.PushByte(0);
            stopLogout.PushShort(0);
            stopLogout.PushByte(0x7A); // stop logout flag?
            stopLogout.PushInt(0);
            stopLogout.PushInt(0);
            stopLogout.PushInt(0);
            stopLogout.PushInt(0);
            stopLogout.PushInt(0);
            stopLogout.PushShort(0);
            byte[] stoplogOutPacket = stopLogout.Finish();
            this.SendCompressed(stoplogOutPacket);
        }