Пример #1
0
        public static void Read(byte[] packet, Client client)
        {
            PacketReader packetReader = new PacketReader(packet);

            Header header = packetReader.PopHeader();

            packetReader.PopByte();
            packetReader.PopShort();
            Identity identity = packetReader.PopIdentity();

            NonPlayerCharacterClass npc =
                (NonPlayerCharacterClass)FindDynel.FindDynelById(identity.Type, identity.Instance);
            Character character = FindClient.FindClientById(header.Sender).Character;

            packetReader.PopInt();
            packetReader.PopInt();
            packetReader.PopInt();
            int container = packetReader.PopInt();
            int place     = packetReader.PopInt();

            InventoryEntries ie  = character.GetInventoryAt(place);
            AOItem           aoi = ie.Item.ShallowCopy();

            character.Inventory.Remove(ie); // Silent remove, no message given to client. Client handles this on its own
            npc.KnuBotTrade(character, aoi);
        }
Пример #2
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);
            }
        }
Пример #3
0
        // This will be called by ZoneServer at startup after loading all Spawns/Vendors etc.
        // The Character parameter is not used here, but has to be defined (yet)
        public void Init(Character ch)
        {
            NonPlayerCharacterClass target = (NonPlayerCharacterClass)FindDynel.FindDynelById(50000, 100001);

            if (target != null)
            {
                target.KnuBot = new KnuBotNPC100001(target);
                Console.WriteLine("Registered KnuBot100001 Script with NPC");
            }
        }
Пример #4
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            Dynel _target = FindDynel.FindDynelById(target.Type, target.Instance);

            if (_target == null)
            {
                this.CommandHelp(client);
                return;
            }

            if ((_target is Character) && (!(_target is NonPlayerCharacterClass)))
            {
                this.CommandHelp(client);
                return;
            }

            Vector3 v3 = new Vector3(0, 0, 0);

            switch (args[1].ToLower())
            {
            case "north":
            case "n":
                v3.z = 1;
                break;

            case "west":
            case "w":
                v3.x = 1;
                break;

            case "south":
            case "s":
                v3.z = -1;
                break;

            case "east":
            case "e":
                v3.x = -1;
                break;

            case "me":
                Vector3 tempchar   = new Vector3(client.Character.Coordinates.x, 0, client.Character.Coordinates.z);
                Vector3 temptarget = new Vector3(_target.Coordinates.x, 0, _target.Coordinates.z);
                v3   = temptarget - tempchar;
                v3.z = -v3.z;
                break;

            default:
                this.CommandHelp(client);
                return;
            }
            v3.y = 0.0000000;
            _target.RawHeading = _target.RawHeading.GenerateRotationFromDirectionVector(v3.Normalize());
            client.Teleport(client.Character.RawCoord, client.Character.RawHeading, client.Character.PlayField);
        }
Пример #5
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            int   id = int.Parse(args[1]);
            Dynel d  = FindDynel.FindDynelById(50000, id);

            if (d == null)
            {
                client.SendChatText("Couldn't find Dynel " + id);
            }
            else
            {
                client.Teleport(d.Coordinates, d.Heading, d.PlayField);
            }
        }
Пример #6
0
        public static void Read(byte[] packet)
        {
            PacketReader packetReader = new PacketReader(packet);

            Header header = packetReader.PopHeader();

            packetReader.PopByte();
            packetReader.PopShort();
            int type     = packetReader.PopInt();
            int instance = packetReader.PopInt();
            NonPlayerCharacterClass npc = (NonPlayerCharacterClass)FindDynel.FindDynelById(type, instance);
            Character character         = FindClient.FindClientById(header.Sender).Character;

            character.KnuBotTarget = npc;
        }
Пример #7
0
        public static void Read(byte[] packet, Client cli)
        {
            PacketReader pr = new PacketReader(packet);

            Header header = pr.PopHeader();

            pr.PopByte();
            pr.PopShort();
            Identity id = pr.PopIdentity();
            NonPlayerCharacterClass npc = (NonPlayerCharacterClass)FindDynel.FindDynelById(id.Type, id.Instance);

            if (npc != null)
            {
                npc.KnuBotStartTrade(cli.Character);
            }
        }
Пример #8
0
        public static void Read(byte[] packet, Client client)
        {
            PacketReader packetReader = new PacketReader(packet);

            Header header = packetReader.PopHeader();

            packetReader.PopByte();
            packetReader.PopShort();
            int type     = packetReader.PopInt();
            int instance = packetReader.PopInt();
            NonPlayerCharacterClass npc = (NonPlayerCharacterClass)FindDynel.FindDynelById(type, instance);
            Character ch = FindClient.FindClientById(header.Sender).Character;

            if (npc != null)
            {
                npc.KnuBotFinishTrade(ch, packetReader.PopInt());
            }
        }
Пример #9
0
            public void Execute(Client cli, Statel parent, int Eventnumber)
            {
                bool      reqs_met   = true;
                int       childop    = -1;
                Character ftarget    = null;
                bool      reqresult  = true;
                Character chartarget =
                    (Character)FindDynel.FindDynelById(cli.Character.Target.Type, cli.Character.Target.Instance);

                for (int r = 0; r < this.Requirements.Count; r++)
                {
                    switch (this.Requirements[r].Target)
                    {
                    case itemtarget_user:
                        ftarget = cli.Character;
                        break;

                    case itemtarget_wearer:
                        ftarget = cli.Character;
                        break;

                    case itemtarget_target:
                        ftarget = chartarget;
                        break;

                    case itemtarget_fightingtarget:
                        // Fighting target
                        break;

                    case itemtarget_self:
                        ftarget = cli.Character;
                        break;

                    case itemtarget_selectedtarget:
                        ftarget = chartarget;
                        break;
                    }
                    if (ftarget == null)
                    {
                        reqs_met = false;
                        return;
                    }
                    int statval = ftarget.Stats.StatValueByName(this.Requirements[r].AttributeNumber);
                    switch (this.Requirements[r].Operator)
                    {
                    case operator_and:
                        reqresult = ((statval & this.Requirements[r].AttributeValue) != 0);
                        break;

                    case operator_or:
                        reqresult = ((statval | this.Requirements[r].AttributeValue) != 0);
                        break;

                    case operator_equalto:
                        reqresult = (statval == this.Requirements[r].AttributeValue);
                        break;

                    case operator_lessthan:
                        reqresult = (statval < this.Requirements[r].AttributeValue);
                        break;

                    case operator_greaterthan:
                        reqresult = (statval > this.Requirements[r].AttributeValue);
                        break;

                    case operator_unequal:
                        reqresult = (statval != this.Requirements[r].AttributeValue);
                        break;

                    case operator_true:
                        reqresult = (statval != 0);
                        break;

                    case operator_false:
                        reqresult = (statval == 0);
                        break;

                    case operator_bitand:
                        reqresult = ((statval & this.Requirements[r].AttributeValue) != 0);
                        break;

                    case operator_bitor:
                        reqresult = ((statval | this.Requirements[r].AttributeValue) != 0);
                        break;

                    default:
                        reqresult = true;
                        break;
                    }

                    switch (childop)
                    {
                    case operator_and:
                        reqs_met &= reqresult;
                        break;

                    case operator_or:
                        reqs_met |= reqresult;
                        break;

                    case -1:
                        reqs_met = reqresult;
                        break;

                    default:
                        break;
                    }
                    childop = this.Requirements[r].ChildOperator;
                }

                if (!reqs_met)
                {
                    cli.SendChatText("Requirements not met. (better errormessage not coded yet)");
                    return;
                }

                if (
                    !Program.FunctionC.CallFunction(
                        this.FunctionNumber, cli.Character, cli.Character, parent, this.Arguments.ToArray()))
                {
#if DEBUG
                    cli.SendChatText(
                        "Statel " + parent.Type.ToString() + ":" + parent.Instance.ToString() + " handling "
                        + Eventnumber.ToString() + " Function " + this.FunctionNumber.ToString() + " "
                        + cli.Character.Coordinates);
                    foreach (string arg in this.Arguments)
                    {
                        cli.SendChatText("Argument: " + arg);
                    }
#endif
                }
            }
Пример #10
0
        public static void Read(byte[] packet, Client client, Dynel dynel)
        {
            PacketReader reader       = new PacketReader(packet);
            PacketWriter packetWriter = new PacketWriter();
            Header       header       = reader.PopHeader();

            reader.PopByte();
            reader.PopInt();                       // unknown
            byte     action    = reader.PopByte(); // unknown
            Identity ident     = reader.PopIdentity();
            int      container = reader.PopInt();
            int      place     = reader.PopInt();

            Character character  = (Character)FindDynel.FindDynelById(ident.Type, ident.Instance);
            Character chaffected =
                (Character)FindDynel.FindDynelById(header.AffectedId.Type, header.AffectedId.Instance);

            // If target is a NPC, call its Action 0
            if ((character is NonPlayerCharacterClass) && (action == 0))
            {
                if (((NonPlayerCharacterClass)character).KnuBot != null)
                {
                    character.KnuBotTarget = character;
                    ((NonPlayerCharacterClass)character).KnuBot.TalkingTo = chaffected;
                    ((NonPlayerCharacterClass)character).KnuBot.Action(0);
                }
                return;
            }

            int cashDeduct = 0;
            int inventoryCounter;
            InventoryEntries inventoryEntry;

            switch (action)
            {
            case 1:     // end trade
                inventoryCounter = client.Character.Inventory.Count - 1;
                while (inventoryCounter >= 0)
                {
                    inventoryEntry = client.Character.Inventory[inventoryCounter];
                    AOItem aoItem;
                    if (inventoryEntry.Container == -1)
                    {
                        int nextFree = client.Character.GetNextFreeInventory(104);
                        aoItem = ItemHandler.GetItemTemplate(inventoryEntry.Item.LowID);
                        int price = aoItem.getItemAttribute(74);
                        int mult  = aoItem.getItemAttribute(212);    // original multiplecount
                        if (mult == 0)
                        {
                            mult = 1;
                            inventoryEntry.Item.MultipleCount = 1;
                        }
                        // Deduct Cash (ie.item.multiplecount) div mult * price
                        cashDeduct +=
                            Convert.ToInt32(
                                mult * price
                                *
                                (100
                                 - Math.Floor(Math.Min(1500, client.Character.Stats.ComputerLiteracy.Value) / 40.0))
                                / 2500);
                        // Add the Shop modificator and exchange the CompLit for skill form vendortemplate table
                        inventoryEntry.Placement = nextFree;
                        inventoryEntry.Container = 104;
                        if (!aoItem.isStackable())
                        {
                            int multiplicator = inventoryEntry.Item.MultipleCount;
                            inventoryEntry.Item.MultipleCount = 0;
                            while (multiplicator > 0)
                            {
                                AddTemplate.Send(client, inventoryEntry);
                                multiplicator--;
                            }
                        }
                        else
                        {
                            AddTemplate.Send(client, inventoryEntry);
                        }
                    }
                    if (inventoryEntry.Container == -2)
                    {
                        aoItem = ItemHandler.interpolate(
                            inventoryEntry.Item.LowID, inventoryEntry.Item.HighID, inventoryEntry.Item.Quality);
                        double multipleCount = aoItem.getItemAttribute(212);     // original multiplecount
                        int    price         = aoItem.getItemAttribute(74);
                        if (multipleCount == 0.0)
                        {
                            multipleCount = 1.0;
                        }
                        else
                        {
                            multipleCount = inventoryEntry.Item.MultipleCount / multipleCount;
                        }
                        cashDeduct -=
                            Convert.ToInt32(
                                multipleCount * price
                                *
                                (100
                                 + Math.Floor(Math.Min(1500, client.Character.Stats.ComputerLiteracy.Value) / 40.0))
                                / 2500);
                        // Add the Shop modificator and exchange the CompLit for skill form vendortemplate table
                        client.Character.Inventory.Remove(inventoryEntry);
                    }
                    inventoryCounter--;
                }

                client.Character.Stats.Cash.Set((uint)(client.Character.Stats.Cash.Value - cashDeduct));
                //                    Packets.Stat.Set(client, 61, client.Character.Stats.Cash.StatValue - cashdeduct, false);
                byte[] reply0 = new byte[32];
                Array.Copy(packet, reply0, 32);

                // pushing in server ID
                reply0[8]  = 0;
                reply0[9]  = 0;
                reply0[10] = 12;
                reply0[11] = 14;

                // pushing in Client ID
                reply0[12] = (byte)(client.Character.Id >> 24);
                reply0[13] = (byte)(client.Character.Id >> 16);
                reply0[14] = (byte)(client.Character.Id >> 8);
                reply0[15] = (byte)(client.Character.Id);

                packetWriter.PushBytes(reply0);
                packetWriter.PushByte(1);
                packetWriter.PushByte(4);
                packetWriter.PushIdentity(client.Character.LastTrade);
                packetWriter.PushIdentity(client.Character.LastTrade);
                client.Character.LastTrade = new Identity {
                    Instance = 0, Type = 0
                };

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

            case 2:
                // Decline trade
                inventoryCounter = client.Character.Inventory.Count - 1;
                while (inventoryCounter >= 0)
                {
                    inventoryEntry = client.Character.Inventory[inventoryCounter];
                    if (inventoryEntry.Container == -1)
                    {
                        client.Character.Inventory.Remove(inventoryEntry);
                    }
                    else
                    {
                        if (inventoryEntry.Container == -2)
                        {
                            inventoryEntry.Placement = client.Character.GetNextFreeInventory(104);
                            inventoryEntry.Container = 104;
                        }
                    }
                    inventoryCounter--;
                }

                byte[] replyCopy = new byte[50];
                Array.Copy(packet, replyCopy, 50);

                // pushing in server ID
                replyCopy[8]  = 0;
                replyCopy[9]  = 0;
                replyCopy[10] = 12;
                replyCopy[11] = 14;

                // pushing in Client ID
                replyCopy[12] = (byte)(client.Character.Id >> 24);
                replyCopy[13] = (byte)(client.Character.Id >> 16);
                replyCopy[14] = (byte)(client.Character.Id >> 8);
                replyCopy[15] = (byte)(client.Character.Id);

                packetWriter.PushBytes(replyCopy);
                byte[] rep1 = packetWriter.Finish();

                client.SendCompressed(rep1);
                break;

            case 3:
                break;

            case 4:
                break;

            case 5:     // add item to trade window
            case 6:     // remove item from trade window
                byte[] reply = new byte[50];
                Array.Copy(packet, reply, 50);
                if (character.Inventory.Count == 0)
                {
                    ((VendingMachine)character).LoadTemplate(((VendingMachine)character).TemplateId);
                }

                // pushing in server ID
                reply[8]  = 0;
                reply[9]  = 0;
                reply[10] = 12;
                reply[11] = 14;

                // pushing in Client ID
                reply[12] = (byte)(client.Character.Id >> 24);
                reply[13] = (byte)(client.Character.Id >> 16);
                reply[14] = (byte)(client.Character.Id >> 8);
                reply[15] = (byte)(client.Character.Id);

                //PacketWriter pw = new PacketWriter();
                packetWriter.PushBytes(reply);
                byte[] replyRemoveItemFromTradeWindow = packetWriter.Finish();
                client.SendCompressed(replyRemoveItemFromTradeWindow);

                if (client.Character == character)
                {
                    if (action == 5)
                    {
                        inventoryEntry           = character.GetInventoryAt(place);
                        inventoryEntry.Placement = character.GetNextFreeInventory(-2);
                        inventoryEntry.Container = -2;
                    }
                    if (action == 6)
                    {
                        inventoryEntry           = character.GetInventoryAt(place, -2);
                        inventoryEntry.Placement = character.GetNextFreeInventory(104);
                        inventoryEntry.Container = 104;
                    }
                }
                else
                {
                    InventoryEntries inew = new InventoryEntries
                    {
                        Container = -1, Placement = character.GetNextFreeInventory(-1)
                    };
                    int oldPlacement         = ((packet[46] >> 24) + (packet[47] >> 16) + (packet[48] >> 8) + packet[49]);
                    InventoryEntries totrade = character.GetInventoryAt(oldPlacement);
                    inew.Item.LowID         = totrade.Item.LowID;
                    inew.Item.HighID        = totrade.Item.HighID;
                    inew.Item.MultipleCount = totrade.Item.MultipleCount;
                    if (action == 6)     // Remove item from trade window
                    {
                        inew.Item.MultipleCount = -inew.Item.MultipleCount;
                    }
                    inew.Item.Quality = totrade.Item.Quality;
                    chaffected.InventoryReplaceAdd(inew);
                }
                break;
            }
        }
Пример #11
0
        public static void Read(byte[] packet, Client client)
        {
            SqlWrapper mys = new SqlWrapper();

            // Packet Reader Unknown Values are Returning 0 Integers, Unable to Store Needed Packet data To Reply.

            #region PacketReader
            PacketReader packetReader = new PacketReader(packet);
            Header       m_header     = packetReader.PopHeader();   // 0 - 28
            byte         unknown      = packetReader.PopByte();     // 29
            int          actionNum    = packetReader.PopInt();      // 30 - 33
            int          unknown1     = packetReader.PopInt();      // 34 - 37
            Identity     m_ident      = packetReader.PopIdentity(); // 38 - 35
            int          unknown2     = packetReader.PopInt();      // 36 - 39
            int          unknown3     = packetReader.PopInt();      // 40 - 43
            short        unknown4     = packetReader.PopShort();    // 44 - 45
            #endregion

            switch (actionNum)
            {
                #region Cast nano
            case 19:     // Cast nano
            {
                // CastNanoSpell
                PacketWriter castNanoSpell = new PacketWriter();
                castNanoSpell.PushByte(0xDF);
                castNanoSpell.PushByte(0xDF);
                castNanoSpell.PushShort(10);
                castNanoSpell.PushShort(1);
                castNanoSpell.PushShort(0);
                castNanoSpell.PushInt(3086);
                castNanoSpell.PushInt(client.Character.Id);
                castNanoSpell.PushInt(0x25314D6D);
                castNanoSpell.PushIdentity(50000, client.Character.Id);
                castNanoSpell.PushByte(0);
                castNanoSpell.PushInt(unknown3);                        // Nano ID
                castNanoSpell.PushIdentity(m_ident);                    // Target
                castNanoSpell.PushInt(0);
                castNanoSpell.PushIdentity(50000, client.Character.Id); // Caster
                byte[] castNanoSpellA = castNanoSpell.Finish();
                Announce.Playfield(client.Character.PlayField, castNanoSpellA);

                // CharacterAction 107
                PacketWriter characterAction107 = new PacketWriter();
                characterAction107.PushByte(0xDF);
                characterAction107.PushByte(0xDF);
                characterAction107.PushShort(10);
                characterAction107.PushShort(1);
                characterAction107.PushShort(0);
                characterAction107.PushInt(3086);
                characterAction107.PushInt(client.Character.Id);
                characterAction107.PushInt(0x5E477770);
                characterAction107.PushIdentity(50000, client.Character.Id);
                characterAction107.PushByte(0);
                characterAction107.PushInt(107);
                characterAction107.PushInt(0);
                characterAction107.PushInt(0);
                characterAction107.PushInt(0);
                characterAction107.PushInt(1);
                characterAction107.PushInt(unknown3);
                characterAction107.PushShort(0);
                byte[] characterAction107A = characterAction107.Finish();
                Announce.Playfield(client.Character.PlayField, characterAction107A);

                // CharacterAction 98
                PacketWriter characterAction98 = new PacketWriter();
                characterAction98.PushByte(0xDF);
                characterAction98.PushByte(0xDF);
                characterAction98.PushShort(10);
                characterAction98.PushShort(1);
                characterAction98.PushShort(0);
                characterAction98.PushInt(3086);
                characterAction98.PushInt(client.Character.Id);
                characterAction98.PushInt(0x5E477770);
                characterAction98.PushIdentity(m_ident);
                characterAction98.PushByte(0);
                characterAction98.PushInt(98);
                characterAction98.PushInt(0);
                characterAction98.PushInt(0xCF1B);
                characterAction98.PushInt(unknown3);
                characterAction98.PushInt(client.Character.Id);
                characterAction98.PushInt(0x249F0);         // duration?
                characterAction98.PushShort(0);
                byte[] characterAction98A = characterAction98.Finish();
                Announce.Playfield(client.Character.PlayField, characterAction98A);
            }
            break;
                #endregion

                #region search

            /* this is here to prevent server crash that is caused by
             * search action if server doesn't reply if something is
             * found or not */
            case 66:     // If action == search
            {
                /* Msg 110:136744723 = "No hidden objects found." */
                client.SendFeedback(110, 136744723);
            }
            break;
                #endregion

                #region info
            case 105:     // If action == Info Request
            {
                Client tPlayer = null;
                if ((tPlayer = FindClient.FindClientById(m_ident.Instance)) != null)
                {
                    #region Titles
                    uint   LegacyScore = tPlayer.Character.Stats.PvpRating.StatBaseValue;
                    string LegacyTitle = null;
                    if (LegacyScore < 1400)
                    {
                        LegacyTitle = "";
                    }
                    else if (LegacyScore < 1500)
                    {
                        LegacyTitle = "Freshman";
                    }
                    else if (LegacyScore < 1600)
                    {
                        LegacyTitle = "Rookie";
                    }
                    else if (LegacyScore < 1700)
                    {
                        LegacyTitle = "Apprentice";
                    }
                    else if (LegacyScore < 1800)
                    {
                        LegacyTitle = "Novice";
                    }
                    else if (LegacyScore < 1900)
                    {
                        LegacyTitle = "Neophyte";
                    }
                    else if (LegacyScore < 2000)
                    {
                        LegacyTitle = "Experienced";
                    }
                    else if (LegacyScore < 2100)
                    {
                        LegacyTitle = "Expert";
                    }
                    else if (LegacyScore < 2300)
                    {
                        LegacyTitle = "Master";
                    }
                    else if (LegacyScore < 2500)
                    {
                        LegacyTitle = "Champion";
                    }
                    else
                    {
                        LegacyTitle = "Grand Master";
                    }
                    #endregion

                    int        orgGoverningForm = 0;
                    SqlWrapper ms = new SqlWrapper();
                    DataTable  dt =
                        ms.ReadDatatable(
                            "SELECT `GovernmentForm` FROM organizations WHERE ID=" + tPlayer.Character.OrgId);

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

                    string orgRank = OrgClient.GetRank(
                        orgGoverningForm, tPlayer.Character.Stats.ClanLevel.StatBaseValue);
                    // Uses methods in ZoneEngine\PacketHandlers\OrgClient.cs

                    /* Known packetFlags--
                     * 0x40 - No org | 0x41 - Org | 0x43 - Org and towers | 0x47 - Org, towers, player has personal towers | 0x50 - No pvp data shown
                     * Bitflags--
                     * Bit0 = hasOrg, Bit1 = orgTowers, Bit2 = personalTowers, Bit3 = (Int32) time until supression changes (Byte) type of supression level?, Bit4 = noPvpDataShown, Bit5 = hasFaction, Bit6 = ?, Bit 7 = null.
                     */
                    byte packetFlags = 0x40;         // Player has no Org
                    if (tPlayer.Character.OrgId != 0)
                    {
                        packetFlags = 0x41;         // Player has Org, no towers
                    }
                    PacketWriter infoPacket = new PacketWriter();

                    // Start packet header
                    infoPacket.PushByte(0xDF);
                    infoPacket.PushByte(0xDF);
                    infoPacket.PushShort(10);
                    infoPacket.PushShort(1);
                    infoPacket.PushShort(0);
                    infoPacket.PushInt(3086);                             // sender (server ID)
                    infoPacket.PushInt(client.Character.Id);              // receiver
                    infoPacket.PushInt(0x4D38242E);                       // packet ID
                    infoPacket.PushIdentity(50000, tPlayer.Character.Id); // affected identity
                    infoPacket.PushByte(0);                               // ?
                    // End packet header

                    infoPacket.PushByte(packetFlags);                                    // Based on flags above
                    infoPacket.PushByte(1);                                              // esi_001?
                    infoPacket.PushByte((byte)tPlayer.Character.Stats.Profession.Value); // Profession
                    infoPacket.PushByte((byte)tPlayer.Character.Stats.Level.Value);      // Level
                    infoPacket.PushByte((byte)tPlayer.Character.Stats.TitleLevel.Value); // Titlelevel
                    infoPacket.PushByte((byte)tPlayer.Character.Stats.VisualProfession.Value);
                    // Visual Profession
                    infoPacket.PushShort(0);                                   // Side XP Bonus
                    infoPacket.PushUInt(tPlayer.Character.Stats.Health.Value); // Current Health (Health)
                    infoPacket.PushUInt(tPlayer.Character.Stats.Life.Value);   // Max Health (Life)
                    infoPacket.PushInt(0);                                     // BreedHostility?
                    infoPacket.PushUInt(tPlayer.Character.OrgId);              // org ID
                    infoPacket.PushShort((short)tPlayer.Character.FirstName.Length);
                    infoPacket.PushBytes(Encoding.ASCII.GetBytes(tPlayer.Character.FirstName));
                    infoPacket.PushShort((short)tPlayer.Character.LastName.Length);
                    infoPacket.PushBytes(Encoding.ASCII.GetBytes(tPlayer.Character.LastName));
                    infoPacket.PushShort((short)LegacyTitle.Length);
                    infoPacket.PushBytes(Encoding.ASCII.GetBytes(LegacyTitle));
                    infoPacket.PushShort(0);         // Title 2

                    // If receiver is in the same org as affected identity, whom is not orgless, send org rank and city playfield
                    if ((client.Character.OrgId == tPlayer.Character.OrgId) && (tPlayer.Character.OrgId != 0))
                    {
                        infoPacket.PushShort((short)orgRank.Length);
                        infoPacket.PushBytes(Encoding.ASCII.GetBytes(orgRank));
                        infoPacket.PushInt(0);
                        //infoPacket.PushIdentity(0, 0); // City (50201, Playfield) // Pushed 1 zero to much and screwed info for characters in orgs, but I´ll leave it for later just incase.
                    }

                    infoPacket.PushUInt(tPlayer.Character.Stats.InvadersKilled.Value);     // Invaders Killed
                    infoPacket.PushUInt(tPlayer.Character.Stats.KilledByInvaders.Value);   // Killed by Invaders
                    infoPacket.PushUInt(tPlayer.Character.Stats.AlienLevel.Value);         // Alien Level
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpDuelKills.Value);       // Pvp Duel Kills
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpDuelDeaths.Value);      // Pvp Duel Deaths
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpProfessionDuelDeaths.Value);
                    // Pvp Profession Duel Kills
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpRankedSoloKills.Value);   // Pvp Solo Kills
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpRankedSoloDeaths.Value);  // Pvp Team Kills
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpSoloScore.Value);         // Pvp Solo Score
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpTeamScore.Value);         // Pvp Team Score
                    infoPacket.PushUInt(tPlayer.Character.Stats.PvpDuelScore.Value);         // Pvp Duel Score

                    byte[] infoPacketA = infoPacket.Finish();
                    client.SendCompressed(infoPacketA);
                }
                else
                {
                    NonPlayerCharacterClass npc =
                        (NonPlayerCharacterClass)FindDynel.FindDynelById(m_ident.Type, m_ident.Instance);
                    if (npc != null)
                    {
                        PacketWriter infoPacket = new PacketWriter();

                        // Start packet header
                        infoPacket.PushByte(0xDF);
                        infoPacket.PushByte(0xDF);
                        infoPacket.PushShort(10);
                        infoPacket.PushShort(1);
                        infoPacket.PushShort(0);
                        infoPacket.PushInt(3086);                // sender (server ID)
                        infoPacket.PushInt(client.Character.Id); // receiver
                        infoPacket.PushInt(0x4D38242E);          // packet ID
                        infoPacket.PushIdentity(50000, npc.Id);  // affected identity
                        infoPacket.PushByte(0);                  // ?
                        // End packet header

                        infoPacket.PushByte(0x50);                                   // npc's just have 0x50
                        infoPacket.PushByte(1);                                      // esi_001?
                        infoPacket.PushByte((byte)npc.Stats.Profession.Value);       // Profession
                        infoPacket.PushByte((byte)npc.Stats.Level.Value);            // Level
                        infoPacket.PushByte((byte)npc.Stats.TitleLevel.Value);       // Titlelevel
                        infoPacket.PushByte((byte)npc.Stats.VisualProfession.Value); // Visual Profession

                        infoPacket.PushShort(0);                                     // no idea for npc's
                        infoPacket.PushUInt(npc.Stats.Health.Value);                 // Current Health (Health)
                        infoPacket.PushUInt(npc.Stats.Life.Value);                   // Max Health (Life)
                        infoPacket.PushInt(0);                                       // BreedHostility?
                        infoPacket.PushUInt(0);                                      // org ID
                        infoPacket.PushShort(0);
                        infoPacket.PushShort(0);
                        infoPacket.PushShort(0);
                        infoPacket.PushShort(0);
                        infoPacket.PushInt(0x499602d2);
                        infoPacket.PushInt(0x499602d2);
                        infoPacket.PushInt(0x499602d2);
                        byte[] infoPacketA = infoPacket.Finish();
                        client.SendCompressed(infoPacketA);
                    }
                }
            }
            break;
                #endregion

                #region logout
            case 120:     // If action == Logout
            {
                //Start 30 second logout timer if client is not a GM (statid 215)
                if (client.Character.Stats.GMLevel.Value == 0)
                {
                    client.startLogoutTimer();
                }
                else         // If client is a GM, disconnect without timer
                {
                    client.Server.DisconnectClient(client);
                }
            }
            break;

            case 121:     // If action == Stop Logout
            {
                //Stop current logout timer and send stop logout packet
                client.Character.UpdateMoveType((byte)client.Character.PreviousMoveMode);
                client.CancelLogOut();
            }
            break;
                #endregion

                #region stand
            case 87:     // If action == Stand
            {
                client.Character.UpdateMoveType(37);
                //Send stand up packet, and cancel timer/send stop logout packet if timer is enabled
                client.StandCancelLogout();
            }
            break;
                #endregion

                #region Team
            case 22:     //Kick Team Member
            {
            }
            break;

            case 24:     //Leave Team
            {
                TeamClass team = new TeamClass();
                team.LeaveTeam(client);
            }
            break;

            case 25:     //Transfer Team Leadership
            {
            }
            break;

            case 26:     //Team Join Request
            {
                // Send Team Invite Request To Target Player

                TeamClass team = new TeamClass();
                team.SendTeamRequest(client, m_ident);
            }
            break;

            case 28:     //Request Reply
            {
                // Check if positive or negative response

                // if positive

                TeamClass team   = new TeamClass();
                uint      teamID = TeamClass.GenerateNewTeamId(client, m_ident);

                // Destination Client 0 = Sender, 1 = Reciever

                // Reciever Packets
                ///////////////////

                // CharAction 15
                team.TeamRequestReply(client, m_ident);
                // CharAction 23
                team.TeamRequestReplyCharacterAction23(client, m_ident);

                // TeamMember Packet
                team.TeamReplyPacketTeamMember(1, client, m_ident, "Member1");
                // TeamMemberInfo Packet
                team.TeamReplyPacketTeamMemberInfo(1, client, m_ident);
                // TeamMember Packet
                team.TeamReplyPacketTeamMember(1, client, m_ident, "Member2");

                // Sender Packets
                /////////////////

                // TeamMember Packet
                team.TeamReplyPacketTeamMember(0, client, m_ident, "Member1");
                // TeamMemberInfo Packet
                team.TeamReplyPacketTeamMemberInfo(0, client, m_ident);
                // TeamMember Packet
                team.TeamReplyPacketTeamMember(0, client, m_ident, "Member2");
            }
            break;
                #endregion

                #region Delete Item
            case 0x70:
                mys.SqlDelete(
                    "DELETE FROM " + client.Character.GetSqlTablefromDynelType() + "inventory WHERE placement="
                    + m_ident.Instance.ToString() + " AND container=" + m_ident.Type.ToString());
                InventoryEntries i_del = client.Character.GetInventoryAt(m_ident.Instance);
                client.Character.Inventory.Remove(i_del);
                byte[] action2 = new byte[0x37];
                Array.Copy(packet, action2, 0x37);
                action2[8]  = 0x00;
                action2[9]  = 0x00;
                action2[10] = 0x0C;
                action2[11] = 0x0E;
                client.SendCompressed(action2);
                break;
                #endregion

                #region Split item
            case 0x34:
                int nextid         = client.Character.GetNextFreeInventory(m_ident.Type);
                InventoryEntries i = client.Character.GetInventoryAt(m_ident.Instance);
                i.Item.MultipleCount -= unknown3;
                InventoryEntries i2 = new InventoryEntries();
                i2.Item = i.Item.ShallowCopy();
                i2.Item.MultipleCount = unknown3;
                i2.Placement          = nextid;
                client.Character.Inventory.Add(i2);
                client.Character.WriteInventoryToSql();
                break;
                #endregion

                #region Join item
            case 0x35:
                InventoryEntries j1 = client.Character.GetInventoryAt(m_ident.Instance);
                InventoryEntries j2 = client.Character.GetInventoryAt(unknown3);
                j1.Item.MultipleCount += j2.Item.MultipleCount;
                client.Character.Inventory.Remove(j2);
                client.Character.WriteInventoryToSql();

                byte[] joined = new byte[0x37];
                Array.Copy(packet, joined, 0x37);
                joined[8]  = 0x00;
                joined[9]  = 0x00;
                joined[10] = 0x0C;
                joined[11] = 0x0E;
                client.SendCompressed(joined);
                break;
                #endregion

                #region Sneak Action
            // ###################################################################################
            // Spandexpants: This is all i have done so far as to make sneak turn on and off,
            // currently i cannot find a missing packet or link which tells the server the player
            // has stopped sneaking, hidden packet or something, will come back to later.
            // ###################################################################################

            // Sneak Packet Received

            case 163:
            {
                PacketWriter Sneak = new PacketWriter();
                // TODO: IF SNEAKING IS ALLOWED RUN THIS CODE.
                // Send Action 162 : Enable Sneak
                Sneak.PushByte(0xDF);
                Sneak.PushByte(0xDF);
                Sneak.PushShort(0xA);
                Sneak.PushShort(1);
                Sneak.PushShort(0);
                Sneak.PushInt(3086);                            // Send
                Sneak.PushInt(client.Character.Id);             // Reciever
                Sneak.PushInt(0x5e477770);                      // Packet ID
                Sneak.PushIdentity(50000, client.Character.Id); // TYPE / ID
                Sneak.PushInt(0);
                Sneak.PushByte(0xA2);                           // Action ID
                Sneak.PushInt(0);
                Sneak.PushInt(0);
                Sneak.PushInt(0);
                Sneak.PushInt(0);
                Sneak.PushInt(0);
                Sneak.PushShort(0);
                byte[] sneakpacket = Sneak.Finish();
                client.SendCompressed(sneakpacket);
                // End of Enable sneak
                // TODO: IF SNEAKING IS NOT ALLOWED SEND REJECTION PACKET
            }
            break;
                #endregion

                #region Use Item on Item
            case 81:
            {
                Identity item1 = new Identity();
                Identity item2 = new Identity();

                item1.Type     = m_ident.Type;
                item1.Instance = m_ident.Instance;

                item2.Type     = unknown2;
                item2.Instance = unknown3;

                Tradeskill cts = new Tradeskill(client, item1.Instance, item2.Instance);
                cts.ClickBuild();
                break;
            }
                #endregion

                #region Change Visual Flag
            case 166:
            {
                client.Character.Stats.VisualFlags.Set(unknown3);
                // client.SendChatText("Setting Visual Flag to "+unknown3.ToString());
                AppearanceUpdate.AnnounceAppearanceUpdate(client.Character);
                break;
            }
                #endregion

                #region Tradeskill Source Changed
            case 0xdc:
                TradeSkillReceiver.TradeSkillSourceChanged(client, unknown2, unknown3);
                break;
                #endregion

                #region Tradeskill Target Changed
            case 0xdd:
                TradeSkillReceiver.TradeSkillTargetChanged(client, unknown2, unknown3);
                break;
                #endregion

                #region Tradeskill Build Pressed
            case 0xde:
                TradeSkillReceiver.TradeSkillBuildPressed(client, m_ident.Instance);
                break;
                #endregion

                #region default
            default:
            {
                byte[] action = new byte[0x37];
                Array.Copy(packet, action, 0x37);
                action[8]  = 0x00;
                action[9]  = 0x00;
                action[10] = 0x0C;
                action[11] = 0x0E;
                Announce.Playfield(client.Character.PlayField, action);
            }
            break;
                #endregion
            }
            packetReader.Finish();
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <param name="messageNumber"></param>
        public static void Parse(Client client, byte[] packet, int messageNumber)
        {
            // Some of these messages are never sent from
            // client to server, but I left them in just
            // in case I'm wrong about some packet. And to
            // allow server to log/disconnect clients that
            // send unexpected messages. *Suiv*

            int type    = (((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23]));
            int dynelId = (((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27]));

            Dynel dynel = FindDynel.FindDynelById(type, dynelId);

            switch (messageNumber)
            {
            case 0x000a0c5a:
                //KnuBotNPCDescription
                break;

            case 0x052e2f0c:
                //AddTemplate
                break;

            case 0x0639474d:
                //GridDestinationSelect
                break;

            case 0x0C5a5d6d:
                //WeatherControl
                break;

            case 0x0d381f02:
                //PetToMaster
                break;

            case 0x1078735a:
                //FlushRDBCaches
                break;

            case 0x1330734f:
                //ShopSearchResult
                break;

            case 0x145a4f66:
                //ShopSearchRequest
                break;

            case 0x166a435e:
                //AcceptBSInvite
                break;

            case 0x194e4f76:
                //AddPet
                break;

            case 0x195e496e:
                //SetPos
                break;

            case 0x1c3a4f77:
                //ReflectAttack
                break;

            case 0x1d3c0f1c:
                //SpecialAttackWeapon
                break;

            case 0x2001377e:
                //MentorInvite
                break;

            case 0x2049527c:
                //Action
                break;

            case 0x204f4871:
                //Script
                break;

            case 0x206b4b73:
                //FormatFeedback
                break;

            case 0x2103247d:
                //KnuBotAnswer
                KnuBotAnswer.Read(packet, client);
                break;

            case 0x212c487a:
                //Quest
                break;

            case 0x215b5678:
                //MineFullUpdate
                break;

            case 0x2252445f:
                //LookAt
                if (dynel != null)
                {
                    ((Character)dynel).SetTarget(packet);
                }
                break;

            case 0x25192476:
                //ShieldAttack
                break;

            case 0x25314d6d:
                //CastNanoSpell
                break;

            case 0x253d024c:
                //ResearchUpdate
                break;

            case 0x260f3671:
                //FollowTarget
                FollowTarget.Read(packet, client, dynel);
                break;

            case 0x264b514b:
                //RelocateDynels
                break;

            case 0x264e5f61:
                //Absorb
                break;

            case 0x26515e61:
                //Reload
                break;

            case 0x270a4c62:
                //KnuBotCloseChatWindow
                KnuBotCloseChatWindow.Read(packet, client);
                break;

            case 0x271b3a6b:
                //SimpleCharFullUpdate
                break;

            case 0x28251f01:
                //StartLogout
                break;

            case 0x28494070:
                //Attack
                break;

            case 0x28784248:
                //TeamMemberInfo
                break;

            case 0x29304349:
                //FullCharacter
                break;

            case 0x2933154f:
                //LaserTargetList
                break;

            case 0x2a253f5f:
                //TrapDisarmed
                break;

            case 0x2a293d0f:
                //Fov
                break;

            case 0x2b333d6e:
                //Stat
                break;

            case 0x2c2f061c:
                //QueueUpdate
                break;

            case 0x2d212407:
                //KnuBotRejectedItems
                break;

            case 0x2e072a78:
                //PlayerShopFullUpdate
                break;

            case 0x2e2a4a6b:
                //OrgInfoPacket
                break;

            case 0x30161355:
                //n3PlayfieldFullUpdate
                break;

            case 0x3115534d:
                //ResearchRequest
                break;

            case 0x3129233b:
                //AreaFormula
                break;

            case 0x3301337a:
                //InfromPlayer
                break;

            case 0x333b2867:
                //Mail
                break;

            case 0x342c1d1d:
                //ApplySpells
                break;

            case 0x343c287f:
                //Bank
                break;

            case 0x353f4f52:
                //ShopInventory
                break;

            case 0x35505644:
                //TemplateAction
                break;

            case 0x36284f6e:
                //Trade
                OnTrade.Read(packet, client, dynel);
                break;

            case 0x365a5071:
                //DoorFullUpdate
                break;

            case 0x365e555b:
                //CityAdvantages
                break;

            case 0x3710256c:
                //HealthDamage
                break;

            case 0x371d0542:
                //FightModeUpdate
                break;

            case 0x373e3513:
                //SetShopName
                break;

            case 0x39343c68:
                //Buff
                break;

            case 0x3a1b2c0c:
                //KnuBotTrade
                KnuBotTrade.Read(packet, client);
                break;

            case 0x3a243f41:
                //DropTemplate
                break;

            case 0x3a322a4a:
                //GridSelected
                break;

            case 0x3b11256f:
                //SimpleItemFullUpdate
                break;

            case 0x3b132d64:
                //KnuBotOpenChatWindow
                break;

            case 0x3b1d2268:
                //WeaponItemFullUpdate
                break;

            case 0x3b290771:
                //SocialActionCmd
                SocialActionCmd.Read(packet, client);
                break;

            case 0x3b3b2878:
                //Raid
                break;

            case 0x3c1e2803:
                //ShadowLevel
                break;

            case 0x3c265179:
                //Clone
                break;

            case 0x3d5b4544:
                //ShopCommission
                break;

            case 0x3d746c7c:
                //ServerPathPosDebugInfo
                break;

            case 0x3e205660:
                //Skill
                SkillUpdate.Read(packet, client);
                break;

            case 0x3f3a1914:
                //LeaveBattle
                break;

            case 0x405b4f27:
                //ShopInfo
                break;

            case 0x41624f0d:
                //AppearanceUpdate
                break;

            case 0x43197d22:
                //n3Teleport
                break;

            case 0x435f7023:
                //PerkUpdate
                break;

            case 0x44483b3a:
                //SendScore
                break;

            case 0x445f2a0b:
                //Resurrect
                break;

            case 0x45072a0b:
                //UpdateClientVisual
                break;

            case 0x45273f0a:
                //HouseDemolishStart
                break;

            case 0x455d2938:
                //PlaySound
                break;

            case 0x46002f16:
                //AttackInfo
                break;

            case 0x46312d2e:
                //TeamMember
                break;

            case 0x464d000a:
                //SpawnMech
                break;

            case 0x465a4061:
                //QuestFullUpdate
                break;

            case 0x465a5d73:
                //ChestItemFullUpdate
                break;

            case 0x4727213e:
                //NanoAttack
                break;

            case 0x47483633:
                //DropDynel
                break;

            case 0x47537a24:
                //ContainerAddItem
                ContainerAddItem.AddItemToContainer(packet, client);
                break;

            case 0x49222612:
                //Visibility
                break;

            case 0x4a41203e:
                //StopFight
                break;

            case 0x4b062919:
                //BattleOver
                break;

            case 0x4b5e7202:
                //InventoryUpdated
                break;

            case 0x4c7d403b:
                //DoorStatusUpdate
                break;

            case 0x4d2a3a38:
                //TeamInvite
                break;

            case 0x4d333027:
                //ShopStatus
                break;

            case 0x4d38242e:
                //InfoPacket
                break;

            case 0x4d450114:
                //SpellList
                break;

            case 0x4e536976:
                //InventoryUpdate
                break;

            case 0x4f474e05:
                //CorpseFullUpdate
                break;

            case 0x50544d19:
                //Feedback
                break;

            case 0x51492120:
                //CharSecSpecAttack
                break;

            case 0x52213420:
                //BankCorpse
                break;

            case 0x52526858:
                //GenericCmd
                GenericCmd.Read(packet, client, dynel);
                break;

            case 0x5266632a:
                //PathMoveCmd
                break;

            case 0x540e3b27:
                //ArriveAtBs
                break;

            case 0x54111123:
                //CharDCMove
                CharacterDCMove.Read(packet, client);
                break;

            case 0x55220726:
                //PlayfieldAllTowers
                break;

            case 0x55682b24:
                //KnuBotFinishTrade
                KnuBotFinishTrade.Read(packet, client);
                break;

            case 0x55704d31:
                //KnuBotAnswerList
                break;

            case 0x56353038:
                //StopLogout
                break;

            case 0x570c2039:
                //CharInPlay
                CharacterInPlay.Read(packet, client);
                break;

            case 0x58362220:
                //ShopUpdate
                break;

            case 0x58574239:
                //MechInfo
                break;

            case 0x58742a0f:
                //RemovePet
                break;

            case 0x59210126:
                //PlayfieldAllCities
                break;

            case 0x59313928:
                //TrapItemFullUpdate
                break;

            case 0x5a585f65:
                //Inspect
                break;

            case 0x5b1e052c:
                //PlayfieldTowerUpdateClient
                break;

            case 0x5c240404:
                //ServerPosDebugInfo
                break;

            case 0x5c436609:
                //QuestAlternative
                break;

            case 0x5c4a493a:
                //FullAuto
                break;

            case 0x5c525a7b:
                ChatCommandHandler.Read(packet, client);
                break;

            case 0x5c654b28:
                //MissedAttackInfo
                break;

            case 0x5d70532a:
                //KnuBotAppendText
                break;

            case 0x5e477770:
                CharacterAction.Read(packet, client);
                break;

            case 0x5e5b6007:
                //HouseDisappeared
                break;

            case 0x5f4a4c6c:
                //Impulse
                break;

            case 0x5f4b1a39:
                //PlayfieldAnarchyF
                break;

            case 0x5f4b442a:
                //ChatText
                break;

            case 0x5f52412e:
                //GameTime
                break;

            case 0x60201d0e:
                //SetWantedDirection
                break;

            case 0x62741e15:
                //AOTransportSignal
                break;

            case 0x63333303:
                //PetCommand
                break;

            case 0x64582a07:
                //OrgServer
                break;

            case 0x6e5f566e:
                //SetStat
                break;

            case 0x734e5a7b:
                //SetName
                break;

            case 0x742e2314:
                //StopMovingCmd
                break;

            case 0x754f1115:
                //SpecialAttackInfo
                break;

            case 0x77230927:
                //GiveQuestToMember
                break;

            case 0x7864401d:
                //KnuBotStartTrade
                KnuBotStartTrade.Read(packet, client);
                break;

            case 0x7a222202:
                //GfxTrigger
                break;

            case 0x7e00312f:
                //ShopItemPrice
                break;

            case 0x7f405a16:
                //NewLevel
                break;

            case 0x7f4b3108:
                //OrgClient
                OrgClient.Read(packet, client);
                break;

            case 0x7f544905:
                //VendingMachineFullUpdate
                break;

            default:
                client.Server.Warning(client, "Client sent unknown N3Message {0:x8}", messageNumber.ToString());
                break;
            }
        }
Пример #13
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target.Type     = client.Character.Type;
                target.Instance = client.Character.Id;
            }

            int statId = StatsList.GetStatId(args[1]);

            if (statId == 1234567890)
            {
                client.SendChatText("Unknown Stat name " + args[1]);
                return;
            }
            uint statNewValue = 1234567890;

            try
            {
                statNewValue = uint.Parse(args[2]);
            }
            catch
            {
                try
                {
                    // For values >= 2^31
                    statNewValue = (uint.Parse(args[2]));
                }
                catch (FormatException)
                {
                }
                catch (OverflowException)
                {
                }
            }
            Character tempch = (Character)FindDynel.FindDynelById(target.Type, target.Instance);
            uint      statOldValue;

            try
            {
                statOldValue = tempch.Stats.GetBaseValue(statId);
                tempch.Stats.SetStatValueByName(statId, statNewValue);
                if (tempch.Client != null)
                {
                    tempch.Stats.Send(tempch.Client, statId);
                }
            }
            catch
            {
                client.SendChatText("Unknown StatId " + statId);
                return;
            }

            string response = "Character " + tempch.Name + " (" + target.Instance + "): Stat "
                              + StatsList.GetStatName(statId) + " (" + statId + ") =";

            response += " Old: " + statOldValue;
            response += " New: " + statNewValue;
            client.SendChatText(response);
        }
Пример #14
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target.Type     = client.Character.Type;
                target.Instance = client.Character.Id;
            }
            if (target.Type != 50000)
            {
                client.SendChatText("Target must be player/monster/NPC");
                return;
            }
            Dynel targetDynel = FindDynel.FindDynelById(target.Type, target.Instance);

            if (targetDynel != null)
            {
                Character targetCharacter = (Character)targetDynel;
                // May be obsolete in the future, let it stay in comment yet
                // ch.CalculateSkills();
                int statId = StatsList.GetStatId(args[1]);
                if (statId == 1234567890)
                {
                    client.SendChatText("Unknown Stat name " + args[1]);
                    return;
                }

                uint statValue;
                int  effectiveValue;
                int  trickle;
                int  mod;
                int  perc;
                try
                {
                    statValue      = targetCharacter.Stats.GetBaseValue(statId);
                    effectiveValue = targetCharacter.Stats.StatValueByName(statId);
                    trickle        = targetCharacter.Stats.GetStatbyNumber(statId).Trickle;
                    mod            = targetCharacter.Stats.GetStatbyNumber(statId).StatModifier;
                    perc           = targetCharacter.Stats.GetStatbyNumber(statId).StatPercentageModifier;
                }
                catch (StatDoesNotExistException)
                {
                    client.SendChatText("Unknown Stat Id " + statId);
                    return;
                }

                string response = "Character " + targetCharacter.Name + " (" + targetCharacter.Id + "): Stat "
                                  + StatsList.GetStatName(statId) + " (" + statId + ") = " + statValue;

                client.SendChatText(response);
                if (statValue != targetCharacter.Stats.StatValueByName(args[1]))
                {
                    response = "Effective value Stat " + StatsList.GetStatName(statId) + " (" + statId + ") = "
                               + effectiveValue;
                    client.SendChatText(response);
                }
                response = "Trickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc;
                client.SendChatText(response);
            }
            else
            {
                // Shouldnt be happen again (fallback to self)
                client.SendChatText("Unable to find target.");
            }
        }