Example #1
0
        public byte[] changeRsi(string part, int value)
        {
            string[] keys = { "sex", "body", "hat", "face", "shirt", "coat", "pants", "shoes", "gloves", "glasses", "hair", "facialdetail", "shirtcolor", "pantscolor", "coatcolor", "shoecolor", "glassescolor", "haircolor", "skintone", "tattoo", "facialdetailcolor", "leggins" };

            int pos = -1;

            for (int i = 0; i < keys.Length; i++)
            {
                if (part.Equals(keys[i].ToLower()))
                {
                    pos = i;
                    break;
                }
            }

            if (pos >= 0)
            {
                int[] current = Store.currentClient.playerData.getRsiValues();
                current[pos] = value;
                Store.currentClient.playerData.setRsiValues(current);
                byte[] rsiData = PacketsUtils.getRSIBytes(current);

                DynamicArray din             = new DynamicArray();
                byte[]       rsiChangeHeader = { 0x02, 0x00, 0x02, 0x80, 0x89 };
                din.append(rsiChangeHeader);
                din.append(rsiData);

                return(din.getBytes());
            }
            else
            {
                throw new FormatException("body part or clothes not found");
            }
        }
Example #2
0
 public CommandHandler()
 {
     this.au = new ArrayUtils();
     this.su = new StringUtils();
     this.nu = new NumericalUtils();
     this.pu = new PacketsUtils();
 }
Example #3
0
        private static void playerRSIPacket(out DynamicArray rsiPacket, out DynamicArray creationPacket,
                                            WorldClient client, ushort spawnIdCounter)
        {
            //Create the packet for the player

            rsiPacket = new DynamicArray();
            byte[] rsi = PacketsUtils.getRSIBytes(client.playerData.getRsiValues());

            byte[] CurCombatExclusiveAbility = { 0x00, 0x10, 0x00, 0x00 };

            //TODO: fix this 03 01 00
            rsiPacket.append(new byte[] { 0x01, 0x00 });
            /////////////////////////////////////////////
            client.playerInstance.DisableAllAttributes(); //Predisable to just send what we need to spawn

            client.playerInstance.RealFirstName.enable();
            client.playerInstance.RealLastName.enable();
            client.playerInstance.Health.enable();
            client.playerInstance.MaxHealth.enable();
            client.playerInstance.YawInterval.enable(); //ROTATION
            client.playerInstance.OrganizationID.enable();

            client.playerInstance.StealthAwareness.setValue(0x01); // TODO: See what's stealth awareness
            client.playerInstance.InnerStrengthAvailable.enable();
            client.playerInstance.CharacterName.enable();

            client.playerInstance.TitleAbility.enable();
            client.playerInstance.CharacterID.enable(); // It was set when grabbing from database
            client.playerInstance.RSIDescription.setValue(rsi);
            client.playerInstance.InnerStrengthMax.enable();
            client.playerInstance.Position.enable();
            client.playerInstance.Level.enable();
            client.playerInstance.CombatantMode.setValue((byte)0x22);  //TODO: see what's combatantmode

            client.playerInstance.ReputationCypherites.enable();
            client.playerInstance.ReputationGMOrganization.enable();
            client.playerInstance.ReputationNiobe.enable();
            client.playerInstance.ReputationZionMilitary.enable();


            if (NumericalUtils.ByteArrayToUint32(client.playerInstance.FactionID.getValue(), 1) > 0)
            {
                client.playerInstance.FactionID.enable();
            }

            if (NumericalUtils.ByteArrayToUint32(client.playerInstance.CrewID.getValue(), 1) > 0)
            {
                client.playerInstance.CrewID.enable();
            }


            client.playerInstance.CurExclusiveAbility.setValue(CurCombatExclusiveAbility); //TODO: see what's this

            // ok we set all our values - lets get the generated packet for us
            creationPacket =
                Store.world.objMan.GenerateCreationPacket(client.playerInstance, 0x0000, (byte)spawnIdCounter);
        }
Example #4
0
 public BootingHelperRsi()
 {
     packetUtils = new PacketsUtils();
 }
Example #5
0
        public void parseCommand(string data)
        {
            Output.WriteLine("[Chat Command helper] Chat command is: '" + data + "'");
            string[] commands = data.Split(' ');

            string command = commands[0].ToLower();

            try{
                if (command.Equals("?fix") && commands.Length > 1)
                {
                    int maxRPC = int.Parse(commands[1]);
                    for (int i = 0; i < maxRPC; i++)
                    {
                        Store.currentClient.playerData.setRPCCounter((UInt16)i);
                        Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Trying to fix! " + i, Store.currentClient));
                    }
                }

                if (command.Equals("?teleport") && commands.Length == 4)
                {
                    // parse the coord parameters parameters as int
                    Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().teleport(int.Parse(commands[1]), int.Parse(commands[2]), int.Parse(commands[3])), false);
                    Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Teleported!", Store.currentClient));
                }

                if (command.Equals("?rsi") && commands.Length == 3)
                {
                    //parse the rsi part and value
                    Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().changeRsi(commands[1], int.Parse(commands[2])), false);
                    Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Rsi changed!", Store.currentClient));
                }


                if (command.StartsWith("?message"))
                {
                    Output.WriteLine("[COMMAND HELPER]MESSAGE RECEIVED");
                    byte[] theMessage = PacketsUtils.createSystemMessageWithoutRPC(commands[1]);
                    Store.world.sendRPCToAllPlayers(theMessage);
                }

                if (command.Equals("?playanim"))
                {
                    string animId = commands[1];
                    if (animId.Length == 4)
                    {
                        ServerPackets pak = new ServerPackets();
                        pak.sendPlayerAnimation(Store.currentClient, animId);
                    }
                }

                if (command.StartsWith("?playfx"))
                {
                    string       fxHEDID = commands[1];
                    DynamicArray din     = new DynamicArray();


                    byte[] animationId = StringUtils.hexStringToBytes(fxHEDID);
                    byte[] viewID      = { 0x02, 0x00 };

                    Random rand = new Random();
                    ushort updateViewCounter = (ushort)rand.Next(3, 200);
                    byte[] updateCount       = NumericalUtils.uint16ToByteArrayShort(updateViewCounter);

                    Output.WriteLine("Check if its really one byte or two : " + StringUtils.bytesToString(updateCount));


                    din.append(viewID);
                    din.append(0x02);
                    din.append(0x80);
                    din.append(0x80);
                    din.append(0x80);
                    din.append(0x90);
                    din.append(0xed);
                    din.append(0x00);
                    din.append(0x30);
                    din.append(animationId);
                    din.append(updateCount);

                    Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false);
                }

                if (command.Contains("?send"))
                {
                    // Sends a packet from a file
                    string     filename   = "packet.txt";
                    TextReader tr         = new StreamReader(filename);
                    string     hexContent = tr.ReadToEnd();
                    hexContent = hexContent.Replace(" ", string.Empty);
                    hexContent = hexContent.Replace(" ", Environment.NewLine);
                    tr.Close();

                    if (hexContent.Length > 0)
                    {
                        Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes(hexContent), false);
                        Output.writeToLogForConsole("[SENDPACK FROM FILE] Content : " + hexContent);
                    }
                }

                if (command.Contains("?combat"))
                {
                    byte[]          dummypak = new byte[4];
                    TestUnitHandler test     = new TestUnitHandler();
                    test.testCloseCombat(ref dummypak);
                }

                if (command.Contains("?mob"))
                {
                    UInt32[] rsiIDs = new UInt32[10];
                    rsiIDs[0] = 0xB7010058;
                    rsiIDs[1] = 0x89090058;
                    rsiIDs[2] = 0xB5010058;
                    rsiIDs[3] = 0x3A030008;
                    rsiIDs[4] = 0x32030008;
                    rsiIDs[5] = 0xD0010058;
                    rsiIDs[6] = 0xD4010058;
                    rsiIDs[7] = 0xB8040004; // Smith
                    rsiIDs[8] = 0x92010058; // Seraph
                    rsiIDs[9] = 0x56050004;
                    Random rand  = new Random();
                    int    index = rand.Next(0, 9);

                    double x = 0; double y = 0; double z = 0;
                    byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue();
                    NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);

                    byte[] xPos = NumericalUtils.floatToByteArray((float)x, 1);
                    byte[] yPos = NumericalUtils.floatToByteArray((float)y, 1);
                    byte[] zPos = NumericalUtils.floatToByteArray((float)z, 1);

                    UInt64 currentEntityId = WorldSocket.entityIdCounter;
                    WorldSocket.entityIdCounter++;
                    uint rotation = 0;

                    npc theMob = new npc();
                    theMob.setEntityId(currentEntityId);
                    theMob.setDistrict(Convert.ToUInt16(data[0].ToString()));
                    theMob.setDistrictName(Store.currentClient.playerData.getDistrict());
                    theMob.setName("HD Protector");
                    theMob.setLevel(255);
                    theMob.setHealthM(UInt16.Parse(data[4].ToString()));
                    theMob.setHealthC(UInt16.Parse(data[5].ToString()));
                    theMob.setMobId((ushort)rsiIDs[index]);
                    theMob.setRsiHex(StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(rsiIDs[index], 1)));
                    theMob.setXPos(x);
                    theMob.setYPos(y);
                    theMob.setZPos(z);
                    theMob.xBase = x;
                    theMob.yBase = y;
                    theMob.zBase = z;
                    theMob.setRotation(rotation);
                    theMob.setIsDead(false);
                    theMob.setIsLootable(false);
                    WorldSocket.npcs.Add(theMob);

                    // we use this for a test to see if we can spawn mobs and how we can handle them
                    // We refactor this
                }



                if (command.Contains("?sendrpc"))
                {
                    // sends a RPC Packet from a File
                    string     filename   = "rpcpacket.txt";
                    TextReader tr         = new StreamReader(filename);
                    string     hexContent = tr.ReadToEnd();
                    hexContent = hexContent.Replace(" ", string.Empty);
                    hexContent = hexContent.Replace(" ", Environment.NewLine);
                    Output.Write("SEND RPC COMMAND : CONTENT : " + hexContent);
                    tr.Close();

                    if (hexContent.Length > 0)
                    {
                        Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(hexContent));
                        Output.writeToLogForConsole("[SENDRPC FROM FILE] Content : " + hexContent);
                    }
                }

                if (command.Contains("?checkrpc"))
                {
                    DynamicArray din = new DynamicArray();
                    din.append(StringUtils.hexStringToBytes("2E1000FF7D020024000000310000000000000000000000000000000000000000000000000B0053796E61707A65373737001D004F6E2079656168204920646F2072656D656D62657220796F75203A2900"));
                    Store.currentClient.messageQueue.addRpcMessage(din.getBytes());
                }

                if (command.Contains("?testrpc"))
                {
                    UInt16 maxRPC = 33279;
                    // Just to reference
                    if (Store.currentClient.playerData.currentTestRPC <= maxRPC)
                    {
                        // Only if it is below we send it - we test with a 5 size packet
                        DynamicArray din = new DynamicArray();
                        if (Store.currentClient.playerData.currentTestRPC < 127)
                        {
                            din.append(NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.currentTestRPC));
                        }
                        else
                        {
                            din.append(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.currentTestRPC, 0));
                        }

                        din.append(0x00);
                        din.append(0x00);
                        din.append(0x00);

                        Store.currentClient.messageQueue.addRpcMessage(din.getBytes());

                        ServerPackets pak = new ServerPackets();
                        pak.sendSystemChatMessage(Store.currentClient, "Test RPC Header : " + Store.currentClient.playerData.currentTestRPC.ToString(), "MODAL");

                        Store.currentClient.playerData.currentTestRPC++;
                    }
                }

                if (command.Equals("?save"))
                {
                    new PlayerHelper().savePlayerInfo(Store.currentClient);

                    ServerPackets pak = new ServerPackets();
                    pak.sendSaveCharDataMessage(Store.currentClient, StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue()));
                }
            }
            catch (Exception e) {
                Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Error parsing command!", Store.currentClient));
                Output.WriteLine("[CHAT COMMAND PARSER] Error parsing request: " + data);
                Output.WriteLine("[CHAT COMMAND PARSER] DEBUG: " + e.Message + "\n" + e.StackTrace);
            }
        }
Example #6
0
        public void processUnmountItem(ref byte[] rpcData)
        {
            byte sourceSlot = rpcData[0];
            byte destSlot   = rpcData[1];

            UInt32       clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]);
            DataLoader   dataLoader     = DataLoader.getInstance();
            ClothingItem item           = dataLoader.getItemValues(clothingItemId);

            // Update Appeareance as we know which appeareance to update (as we unmount item it should be ok to set zeros for the values)
            string partModel = null;
            string partColor = null;

            switch (item.getClothesType())
            {
            case "1950892361":
            case "FEMALE HAT":
            case "MALE HAT":
                partModel = "hat";
                break;

            case "2001027401":
            case "FEMALE GLASSES":
            case "MALE GLASSES":
                partModel = "glasses";
                partColor = "glassescolor";
                break;

            case "1750286665":     // New Way but lets stay old values there
            case "FEMALE SHIRT":
            case "MALE SHIRT":
                partModel = "shirt";
                partColor = "shirtcolor";
                break;

            case "1816609097":
            case "FEMALE GLOVES":
            case "MALE GLOVES":
                partModel = "gloves";
                break;

            case "2001682761":
            case "FEMALE COAT":
            case "MALE COAT":
                partModel = "coat";
                partColor = "coatcolor";
                break;

            case "1397768521":
            case "MALE PANTS":
            case "FEMALE PANTS":
                partModel = "pants";
                partColor = "pantscolor";
                break;

            case "1733050697":
            case "FEMALE LEGGINGS":
                partModel = "leggins";
                break;

            case "2001092937":
            case "FEMALE SHOES":
            case "MALE SHOES":
                partModel = "shoes";
                partColor = "shoecolor";
                break;
            }

            if (partModel != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, 0);
            }

            if (partColor != null && item.getColorId() > 0)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, 0);
            }
            // Move slot
            UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot();

            Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, newSlotId);

            // Send move packet
            ServerPackets pak = new ServerPackets();

            pak.sendInventoryItemMove(sourceSlot, newSlotId, Store.currentClient);

            Store.dbManager.WorldDbHandler.setRsiValues();

            int[] current = Store.currentClient.playerData.getRsiValues();
            Store.currentClient.playerData.setRsiValues(current);
            byte[] rsiData = PacketsUtils.getRSIBytes(current);
            pak.sendAppeareanceUpdate(Store.currentClient, rsiData);
        }
Example #7
0
        public void processMountItem(ref byte[] rpcData)
        {
            byte sourceSlot = rpcData[0];
            byte destSlot   = rpcData[1];


            UInt32       clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]);
            DataLoader   dataLoader     = DataLoader.getInstance();
            ClothingItem item           = dataLoader.getItemValues(clothingItemId);


            string partModel = null;
            string partColor = null;

            UInt16 toRealSlotId = 0;

            switch (item.getClothesType())
            {
            case "1950892361":
            case "FEMALE HAT":
            case "MALE HAT":
                toRealSlotId = 0x61;
                partModel    = "hat";
                break;

            case "2001027401":
            case "FEMALE GLASSES":
            case "MALE GLASSES":
                toRealSlotId = 0x62;
                partModel    = "glasses";
                partColor    = "glassescolor";
                break;

            case "1750286665":     // New Way but lets stay old values there
            case "FEMALE SHIRT":
            case "MALE SHIRT":
                toRealSlotId = 0x63;
                partModel    = "shirt";
                partColor    = "shirtcolor";
                break;

            case "1816609097":
            case "FEMALE GLOVES":
            case "MALE GLOVES":
                toRealSlotId = 0x64;
                partModel    = "gloves";
                break;

            case "2001682761":
            case "FEMALE COAT":
            case "MALE COAT":
                toRealSlotId = 0x65;
                partModel    = "coat";
                partColor    = "coatcolor";
                break;

            case "1397768521":
            case "MALE PANTS":
            case "FEMALE PANTS":
                toRealSlotId = 0x66;
                partModel    = "pants";
                partColor    = "pantscolor";
                break;

            case "1733050697":
            case "FEMALE LEGGINGS":
                toRealSlotId = 0x67;
                partModel    = "leggins";
                break;

            case "2001092937":
            case "FEMALE SHOES":
            case "MALE SHOES":
                toRealSlotId = 0x68;
                partModel    = "shoes";
                partColor    = "shoecolor";
                break;
            }

            if (partModel != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, item.getModelId());
            }

            if (partColor != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, item.getColorId());
            }
            Store.dbManager.WorldDbHandler.setRsiValues();

            int[] current = Store.currentClient.playerData.getRsiValues();
            Store.currentClient.playerData.setRsiValues(current);
            byte[] rsiData = PacketsUtils.getRSIBytes(current);


            // Move the wear item from the wearing slot to the next new slot (but maybe doesnt work if inventory is full)

            ServerPackets pak = new ServerPackets();

            if (Store.dbManager.WorldDbHandler.isSlotinUseByItem(toRealSlotId))
            {
                UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot();
                Store.dbManager.WorldDbHandler.updateInventorySlot(toRealSlotId, newSlotId);
                pak.sendInventoryItemMove(toRealSlotId, newSlotId, Store.currentClient);
            }
            pak.sendAppeareanceUpdate(Store.currentClient, rsiData);
            Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, toRealSlotId);
            pak.sendInventoryItemMove(sourceSlot, toRealSlotId, Store.currentClient);
        }
Example #8
0
 public byte[] teleport(int x, int y, int z)
 {
     return(PacketsUtils.createTeleportPacket(x, y, z));
 }
        public void processObjectStatic(ref byte[] packet)
        {
            byte[] objectID = new byte[4];
            byte[] sectorID = new byte[2];
            ArrayUtils.copyTo(packet, 0, objectID, 0, 4);
            ArrayUtils.copyTo(objectID, 2, sectorID, 0, 2);


            UInt32 numericObjectId = NumericalUtils.ByteArrayToUint32(objectID, 1);

            // Ok sector Bytes are something like 30 39 (reversed but the result must be 39 03)
            UInt16 numericSectorId = NumericalUtils.ByteArrayToUint16(sectorID, 1);
            // strip out object id
            string id = StringUtils.bytesToString_NS(objectID);


            // get the type
            byte[] objectType = new byte[1];
            ArrayUtils.copy(packet, 4, objectType, 0, 1);
            int objectTypeID = packet[4];

            DataLoader        objectLoader = DataLoader.getInstance();
            StaticWorldObject objectValues = objectLoader.getObjectValues(NumericalUtils.ByteArrayToUint32(objectID, 1));


            // create a new System message but fill it in the switch block
            ServerPackets pak = new ServerPackets();

            switch (objectTypeID)
            {
            case (int)objectTypesStatic.DOOR:
                Output.writeToLogForConsole("[OI HELPER] INTERACT WITH DOOR | Object ID :" + id + " Sector ID : " + numericSectorId);

                // just a test

                if (objectValues != null && objectValues.type != null)
                {
                    GameObjectItem item = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1));
                    Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("[OI HELPER] Door StrType: !" + item.getName() + " with Type ID " + StringUtils.bytesToString_NS(objectValues.type), Store.currentClient));
                    this.processOpenDoor(objectValues);
                }

                break;

            case (int)objectTypesStatic.HARDLINE_SYNC:

                pak.sendSystemChatMessage(Store.currentClient, "Hardline Interaction(not done yet)!", "MODAL");
                break;

            case (int)objectTypesStatic.HARDLINE_UPLOAD:
                Output.writeToLogForConsole("[OBJECT HELPER] Upload Hardline will be used for combat tests");
                Store.currentClient.playerData.lastClickedObjectId = numericObjectId;
                new TestUnitHandler().processTestCombat(ref packet);
                break;

            case (int)objectTypesStatic.HARDLINE_LAEXIT:
                // Exit LA
                pak.sendSystemChatMessage(Store.currentClient, "Exit to LA Dialog should popup", "MODAL");
                new TeleportHandler().processHardlineExitRequest(ref packet);
                //new TestUnitHandler().processTestCombat(ref packet);
                break;

            case (int)objectTypesStatic.HUMAN_NPC:
                pak.sendSystemChatMessage(Store.currentClient, "NPC Interaction (not done yet)!", "MODAL");
                this.processVendorOpen(ref objectID);
                break;

            case (int)objectTypesStatic.COLLECTOR:
                pak.sendSystemChatMessage(Store.currentClient, "Collector Interaction (not done yet)!", "MODAL");
                break;

            case (int)objectTypesStatic.PIPE:
                pak.sendSystemChatMessage(Store.currentClient, "Collector Interaction (not done yet)!", "MODAL");
                break;


            default:
                pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL");
                break;
            }
        }