Пример #1
0
        public static void HandleMovement(Character chr, byte[] tx, byte[] ty, byte mMode)
        {
            if(chr == null) {
                Logger.LogCheat(Logger.HackTypes.NullActive, chr.getAccount().mClient, "Wrong target has been selected by moving packet");
                chr.getAccount().mClient.Close();
                return;
            }

            Area lastArea = chr.getArea();
            Boolean nullify = false;
            if(lastArea == null)
                nullify = true;

            Area newArea = WMap.Instance.getGrid(chr.getMap()).getAreaByRound(chr.getPosition()[0], chr.getPosition()[1]);

            if(newArea == null)
            {
                CharacterFunctions.warpToNearestTown(chr);
                return;
            }

            if(!nullify) {
                if(lastArea != newArea) {
                    lastArea.removeCharacter(chr);
                    newArea.addCharacter(chr);
                    chr.setArea(newArea);
                }
            }
            else if(nullify) {
                newArea.addCharacter(chr);
                chr.setArea(newArea);
            }

            OutPacket p = new OutPacket(56);
            p.WriteInt(56);
            p.WriteShort(0x04);
            p.WriteShort(0x0d);
            p.WriteInt	();
            p.WriteInt	(chr.getuID());
            p.WriteFloat(chr.getPosition()[0]);
            p.WriteFloat(chr.getPosition()[1]);
            p.WriteBytes(tx); //2nd set
            p.WriteBytes(ty);
            p.WriteInt	(newArea.getaID());
            p.WriteShort();
            p.WriteByte	((byte)0x80);
            p.WriteByte	((byte)0x3f);
            p.WriteByte	(mMode);
            p.WriteByte	((byte)0x03);
            p.WriteByte	((byte)0x05);
            p.WriteByte	((byte)0x08);
            p.WriteInt	(chr.getCurHP());
            p.WriteShort(chr.getCurMP());
            p.WriteShort(chr.getCurSP());
            p.WriteInt(newArea.getRegionID());
            chr.getAccount().mClient.WriteRawPacket(p.ToArray());

            OutPacket externalMovement = new OutPacket(48);
            externalMovement.WriteInt(48);
            externalMovement.WriteShort(0x05);
            externalMovement.WriteShort(0x0d);
            externalMovement.WriteInt((newArea != lastArea) ? (0x01) : (-1084232447));
            externalMovement.WriteInt(chr.getuID());
            externalMovement.WriteInt(1078117293);
            externalMovement.WriteFloat(chr.getPosition()[0]);
            externalMovement.WriteFloat(chr.getPosition()[1]);
            externalMovement.WriteBytes(tx);
            externalMovement.WriteBytes(ty);
            externalMovement.WriteShort(mMode); // who knows? | 36
            externalMovement.WriteShort((short)newArea.getaID());
            externalMovement.WriteShort();
            externalMovement.WriteByte(0x80);
            externalMovement.WriteByte(0x3f);
            externalMovement.WriteInt((newArea != lastArea) ? (0x05) : (0x03));

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaMovement(chr, newArea, externalMovement.ToArray());

            bool areaTriggered = false;
            for(int i = 0;i < 3;i++)
            {
                for(int u = 0;u < 3;u++)
                {
                    Area nearCentral = WMap.Instance.getGrid(chr.getMap()).getArea(new int[] { newArea.getAreaPosition()[0] - 1 + i, newArea.getAreaPosition()[1] - 1 + u });
                    if(nearCentral == null) continue;
                    if(nearCentral.getAreaTriggers().Count() == 0) continue;
                    {
                        foreach(AreaTrigger areaTrigger in nearCentral.getAreaTriggers())
                        {
                            if((WMap.distance(chr.getPosition()[0], chr.getPosition()[1], areaTrigger.getFromPosition()[0], areaTrigger.getFromPosition()[1]) > 35)) continue;
                            if(!CharacterFunctions.isCharacterWearingItem(chr, areaTrigger.getRequiredItem())) continue;
                            try
                            {
                                areaTriggered = true;
                                CharacterFunctions.setPlayerPosition(chr, areaTrigger.getToPosition()[0], areaTrigger.getToPosition()[1], areaTrigger.gettMap());
                            }
                            catch(Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }
                    }
                }
            }
            if(!areaTriggered) chr.setPosition(new float[] { (float)BitTools.byteArrayToFloat(tx), (float)BitTools.byteArrayToFloat(ty) });
        }
Пример #2
0
        // Holy Grail ftw
        public static void useItem(Character chr, Item item, byte usingIndex, InPacket p)
        {
            MartialClient c = chr.getAccount().mClient;
            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
            Boolean shouldDecrease = false;
            string determined = null;
            int determiner = 0;
            if(itemData.getIsStackable()) shouldDecrease = true;
            else
            {
                if(itemData.getTimeToExpire() == 0)
                    shouldDecrease = true;
            }

            // well.. we don't care if it's handled by server.. let's just remove them & f**k haterz! qq
            if(shouldDecrease)
                if(!chr.getInventory().decrementItem(usingIndex))
                {
                    Console.WriteLine("something went wrong with decrement..");
                    return;
                }

            switch(itemData.getCategory())
            {
                case 1001: // healingz
                {
                    if(itemData.getHealHP() > 0 || itemData.getHealMana() > 0 || itemData.getHealStamina() > 0)
                        StaticPackets.releaseHealPacket(chr, (int)(chr.getCurHP() + itemData.getHealHP()), (short)(chr.getCurMP() + itemData.getHealMana()), (short)(chr.getCurSP() + itemData.getHealStamina()));
                    break;
                }
                case 1002: // skillz o.o
                {
                    StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "If you'd like to learn any skill, go to skills list and press CTRL+LMB.");
                    break;
                }
                case 1003: // teleport
                {
                    if(chr.getMap() == itemData.getTeleportMap() || chr.getMap() != itemData.getTeleportMap() && itemData.getSpecialEffect() != 0)
                        CharacterFunctions.setPlayerPosition(chr, itemData.getTeleportX(), itemData.getTeleportY(), (short)itemData.getTeleportMap());
                    break;
                }
                case 1007: // reset skills
                {
                    chr.getSkills().resetAll();
                    chr.getSkillBar().getSkillBar().Clear();
                    break;
                }
                case 1011: // effect potions
                {
                    chr.setEffect((byte)itemData.getSpecialEffect());
                    break;
                }
                case 1012: // tae potion
                {
                    break;
                }
                case 1013: // faction change
                {
                    if(chr.getFaction() == 0)
                        return;

                    chr.setFaction(chr.getFaction() == 1 ? (byte)2 : (byte)1);
                    break;
                }
                case 1015: // chuk amulet
                {
                    determiner = BitConverter.ToInt32(p.ReadBytes(4), 0);
                    if(determiner == 0) return;
                    ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner);
                    if(determinedItem == null || determinedItem.getCategory() != 1003 || (determiner < 212100146 && determiner > 212100164 && determiner != 212100185 && determiner != 212100187))
                    {
                        Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ");
                        return;
                    }
                    CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap());
                    break;
                }
                case 1016: // karma amulet
                {
                    chr.setKarmaMessagingTimes((short)(chr.getKarmaMessagingTimes()+1));
                    break;
                }
                case 1020: // name changer
                {
                    p.Skip(4);
                    string charName = MiscFunctions.obscureString(p.ReadString(16));
                    if(charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName))
                    {
                        StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Wrong input " + charName + ".");
                        return;
                    }

                    chr.setName(charName);
                    determined = charName;

                    CharacterFunctions.refreshCharacterForTheWorld(chr);
                    break;
                }
                case 1021: // face changer
                {
                    chr.setFace((byte)itemData.getSpecialEffect());
                    break;
                }
                case 1024:
                {
                    // yy..?
                    break;
                }
                case 1031: // red castle
                {
                    determiner = BitConverter.ToInt32(p.ReadBytes(4), 0);
                    if(determiner == 0) return;
                    ItemData determinedItem = ItemDataCache.Instance.getItemData(determiner);
                    if(determinedItem == null || determinedItem.getCategory() != 56 || ((determiner < 273001255 && determiner > 273001257) && determiner != 283000472 && determiner != 283000543 && determiner != 283000575 && determiner != 283000614 && determiner != 283000934 && determiner != 283001078 && determiner != 283001373 && determiner != 283001376))
                    {
                        Console.WriteLine("I CAN'T TURN 10 INTO 20 CHICKENZ");
                        return;
                    }
                    CharacterFunctions.setPlayerPosition(chr, determinedItem.getTeleportX(), determinedItem.getTeleportY(), (short)determinedItem.getTeleportMap());
                    break;
                }
                default:
                {
                    StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "Feature not implemented yet");
                    return;
                }
            }

            OutPacket op = new OutPacket(52);
            op.WriteInt(52);
            op.WriteShort(0x04);
            op.WriteShort(0x05);
            op.WriteInt(140328705);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0x01);
            op.WriteByte(usingIndex);
            op.WriteInt(item.getQuantity());
            op.WriteInt(793149441);
            op.WriteInt(/*determiner > 0 ? determiner : 0*/);
            op.WritePaddedString(determined, 17);
            op.WriteByte(0x90);
            op.WriteByte(0xd2);
            op.WriteByte(0x2a);
            c.WriteRawPacket(op.ToArray());

            OutPacket ops = new OutPacket(40);
            ops.WriteInt(40);
            ops.WriteShort(0x05);
            ops.WriteShort(0x05);
            ops.WriteInt(779458561);
            ops.WriteInt(chr.getuID());
            ops.WriteInt(item.getItemID());
            ops.WritePaddedString(determined, 17);
            ops.WriteByte(0x9e);
            ops.WriteByte(0x0f);
            ops.WriteByte(0xbf);
            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), ops.ToArray());
        }
Пример #3
0
        public static byte[] initCharPacket(Character chr)
        {
            OutPacket op = new OutPacket(653);
            op.WritePaddedString(chr.getName(), 17); // 0-16
            op.WriteRepeatedByte(0x30, 16); // 17-32
            op.WriteByte();
            op.WriteShort(chr.getFaction()); // 34-35
            op.WriteInt(chr.getFame()); // 36-39
            op.WriteShort(chr.getcClass() == 2 ? (byte)0x02 : (byte)0x01); // 40-41
            op.WriteShort(chr.getFace()); // 42-43
            op.WriteInt(1);
            op.WriteShort(chr.getcClass()); // 48-49
            op.WriteShort(157); // 50-51 ; 1 -> hide player nick above the head & toggles guild on [1] / off [0] | 157 for random 154 warrior [probably guildType or guildIcon!! (important!!)]
            op.WriteShort(2); // 52-53 ; 7 -> 137 monk // your guild pos master/member etc.
            op.WriteShort(chr.getLevel()); // 54-55
            op.WriteInt(chr.getCurHP()); // 56-59
            op.WriteInt(chr.getCurMP()); // 60-63 but wtf.. mana is short o.o
            op.WriteInt(chr.getMap()); // 64-67 let's guess.. a map?
            op.WriteFloat(chr.getPosition()[0]); // 68-71
            op.WriteFloat(chr.getPosition()[1]); // 72-75
            for(byte i = 0;i < 17;i++)
            {
                if(chr.getEquipment().getEquipments().ContainsKey(i))
                {
                    op.WriteByte();
                    op.WriteByte(chr.getEquipment().getEquipments()[i].getEnding() > 0 ? (byte)0xff : (byte)0);
                    op.WriteShort();
                    op.WriteInt(chr.getEquipment().getEquipments()[i].getItemID());
                    op.WriteInt(chr.getEquipment().getEquipments()[i].getEnding() > 0 ? (int)chr.getEquipment().getEquipments()[i].getEnding() / 1000 : 1);
                } else op.WriteZero(12);
            }

            op.Position = 465;
            op.WriteByte(70);

            op.Position = 314;
            for(byte i = 0;i < 16;i++)
            {
                /*if(character.getBuffs().getBuffs().ContainsKey(i)) {
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffSlot());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffID());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffTime());
                    op.WriteShort(character.getBuffs().getBuffs()[i].getBuffValue());
                } else*/
                op.Skip(8);
            }

            op.Skip(16);

            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(/*character.getKao()*/);
            op.WriteByte(/*character.getPenance()*/);
            op.WriteByte(chr.getEffect());
            op.WriteByte(0); // no explanation
            op.WriteByte(FameNickNames.Instance.getFameNickID(chr.getFame()));
            op.WriteByte(chr.getVp()); // 465
            op.WriteByte((byte)chr.getAccount().gmLvl); // 466
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // -> 1 -> tells the client that UI mutation effect should be toggled off | 468
            op.WriteByte((byte)(chr.getInvPages() - 3)); // inventory pages | 469
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteShort(0); /*weird PK thing*/ // 472 - 473 but in fact.. it has some date time etc.
            op.WriteLong(0); // 474 - 481

            op.Position = 560;
            op.WriteInt(1); // ok.. so this is kinda weird - last place where you've leveled / died with your character?
            op.WriteFloat(-2558); // unknown posX
            op.WriteFloat(8950); // unknown posY
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            op.WriteByte(0); // no explanation
            for(int i = 0;i < chr.getCStats().Length;i++) op.WriteShort(chr.getCStats()[i]); // 576-577 / 578-579 / 580-581 / 582-583 / 584-585
            op.WriteShort(chr.getCurSP());
            op.WriteInt();
            op.WriteInt();

            op.WriteLong();
            op.WriteShort(chr.getStatPoints());
            op.WriteShort(chr.getSkillPoints()); // 606-607
            op.Position = 648;
            op.WriteByte(Convert.ToByte(chr.getDeleteState()));
            return op.ToArray();
        }