Example #1
0
        public static void AttackDefendState(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(0x05);
            op.WriteShort(0x06);
            op.WriteByte(0x01);
            op.WriteByte(0x33);
            op.WriteByte(0x15);
            op.WriteByte(0x08);
            op.WriteInt(chr.getuID());
            op.WriteShort(p.ReadByte());
            op.WriteByte(0x10);
            op.WriteByte(0x29);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), op.ToArray());
        }
Example #2
0
 public byte[] npcSpawn(Character character)
 {
     OutPacket initNPCData = new OutPacket(615);
     initNPCData.WriteInt(615);
     initNPCData.WriteShort(0x04);
     initNPCData.WriteShort(0x04);
     initNPCData.WriteByte(0x01);
     initNPCData.WriteInt(character.getuID());
     initNPCData.WriteInt(character.getArea().getaID());
     initNPCData.WriteFloat(character.getPosition()[0]);
     initNPCData.WriteFloat(character.getPosition()[1]);
     initNPCData.WriteByte(3);
     initNPCData.WriteInt(this.uID);
     initNPCData.WriteInt();
     initNPCData.WritePaddedString(this.getName(), 16);
     initNPCData.Skip(18);
     initNPCData.WriteInt(this.getModule());
     initNPCData.Skip(10);
     initNPCData.WriteInt(this.getmID());
     initNPCData.Skip(16);
     initNPCData.WriteFloat(this.npcPosition[0]);
     initNPCData.WriteFloat(this.npcPosition[1]);
     initNPCData.Skip(502);
     initNPCData.WriteByte(0x22);
     initNPCData.WriteByte(0x08);
     return initNPCData.ToArray();
 }
Example #3
0
        protected override void OnDisconnected()
        {
            if(account != null) {
                if(account.characters != null)
                {
                    CharacterFunctions.quitGameWorld(this);
                    foreach(Character character in account.characters.Values) {
                        character.Save();
                    }
                    account.clearCharacters();
                }
            }

            OutPacket wayToHell = new OutPacket(9);
            wayToHell.WriteInt(9);
            wayToHell.WriteShort(3);
            wayToHell.WriteRepeatedByte(6, 3); // just for lulz
            WriteRawPacket(wayToHell.ToArray());

            if(m_processor != null)
            {
                Logger.WriteLog(Logger.LogTypes.Disconnect, "[{0}] Client {1} disconnected.", m_processor.Label, Label);
                m_deathAction(this);
            }
        }
        public static void HandleFriends(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook HandleFriends while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte communityIndex = p.ReadByte();
            string personName = MiscFunctions.obscureString(p.ReadString(16));

            Community com = chr.getCommunity();

            switch(managementType)
            {
                case 0:
                    case 1:
                    {
                        if(!com.addPersona(managementType, communityIndex, personName))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                case 2:
                    case 3:
                    {
                        if(!com.removePersona((byte)(managementType - 2), communityIndex))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                default:
                {
                    //tuffnucks you!
                    return;
                }
            }

            OutPacket op = new OutPacket(40);
            op.WriteInt(40);
            op.WriteShort(0x04);
            op.WriteShort(0x31);
            op.WriteInt(134652417);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(communityIndex);
            op.WritePaddedString(personName, 16);
            op.WriteInt(-1089495552);
            c.WriteRawPacket(op.ToArray());
        }
Example #5
0
        public static void MoveFromInv(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte fromInvIndex = p.ReadByte();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();

            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3} | {4}", managementType, fromInvIndex, toCargoSlot, toCargoLine, toCargoRow);
            if(!cargo.insertItemFromInventory(chr.getInventory(), fromInvIndex, toCargoRow, toCargoLine))
            {
                Console.WriteLine("da fuaaark");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(44);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(fromInvIndex);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            op.WriteByte(42);
            c.WriteRawPacket(op.ToArray());
        }
Example #6
0
        public static void Move(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo movement while not being ingame.");
                c.Close();
                return;
            }

            byte fromCargoIndex = p.ReadByte();
            short unknownMovement = p.ReadShort();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();
            Character chr = c.getAccount().activeCharacter;
            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toCargoSlot, toCargoLine, toCargoRow);

            if(!cargo.moveItem(fromCargoIndex, toCargoSlot, toCargoRow, toCargoLine))
            {
                Console.WriteLine("problem with move item");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(46);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteShort(unknownMovement);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            c.WriteRawPacket(op.ToArray());
        }
Example #7
0
 public static byte[] getPickItemPacket(Character chr, Item item, int amount, int uidInt, byte line, byte row, byte stuff)
 {
     OutPacket op = new OutPacket(40);
     op.WriteInt(40);
     op.WriteShort(0x04);
     op.WriteShort(0x0F);
     op.WriteInt(134519809);
     op.WriteInt(chr.getuID());
     op.WriteShort(0x01);
     op.WriteInt(208335);
     op.WriteShort();
     op.WriteByte(line);
     op.WriteByte(row);
     op.WriteShort(stuff);
     op.WriteShort((short)uidInt);
     op.WriteByte(row);
     op.WriteByte(stuff);
     op.WriteInt(item.getItemID());
     op.WriteInt(amount > 0 ? amount : 1);
     return op.ToArray();
 }
Example #8
0
 public static byte[] chatRelay(Character chr, byte messageType, string message)
 {
     OutPacket p = new OutPacket(message.Length + 44);
     p.WriteInt(message.Length + 44);
     p.WriteShort(0x05);
     p.WriteShort(0x07);
     p.WriteInt(0x01);
     p.WriteInt(chr.getuID());
     p.WriteZero(1);
     p.WriteByte(0x01);
     p.WriteShort(messageType);
     p.WritePaddedString(chr.getName(), 20);
     p.WriteInt(message.Length);
     p.WriteString(message);
     return p.ToArray();
 }
Example #9
0
 public static byte[] getInventoryDeletePacket(Character chr, byte invIndex, byte amount)
 {
     OutPacket op = new OutPacket(20);
     op.WriteInt(20);
     op.WriteShort(0x04);
     op.WriteShort(0x15);
     op.WriteInt();
     op.WriteInt(chr.getuID());
     op.WriteShort(0x01);
     op.WriteByte(amount);
     op.WriteByte(invIndex);
     return op.ToArray();
 }
Example #10
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());
        }
Example #11
0
        public static byte[] quitGuildForInternal(Character chr)
        {
            /* This packet shows teh laziness of koreanz, they use one f*****g shit probably for everything - 3 packets just in one case ;
             * to show teh playa, that he has a guild or na ;
             * that he lives / joinz guild etc ;
             * oh lulz at u koreanz, I'd not like to work on Karma too ;
             * I already see on my eyez how much0 CRSpace team was butthurted to work on this shit XD*/

            OutPacket op = new OutPacket(1748);
            op.WriteInt		(32);
            op.WriteShort	(4);
            op.WriteShort	(97);
            op.WriteInt		(1);
            op.WriteInt		(chr.getuID()); // 12-15
            op.Skip			(16); // 16-31

            op.WriteInt		(72); // yeah - new packet & f**k rzaah 32-35
            op.WriteShort	(4);  // 36 - 37
            op.WriteShort	(63); // 38 - 39
            op.WriteInt		(1); // 40 - 43
            op.WriteInt		(chr.getuID()); // 44 - 47
            op.WriteInt		(1); // 48 - 51
            op.WriteInt		(chr.getuID()); // 52 - 55
            op.WriteInt		(3487029); // 555 - but wut for? // 56 - 59
            op.Skip			(12); // 60 - 71
            op.WriteInt		(135570688); // lukz f4mili4r <: // 72 - 75
            op.WriteInt		(chr.getuID()); // 76 - 79
            op.WriteInt		(3487029); // 555 - n again, wut for???? // 80 - 83
            op.Skip			(12); // 84 - 95
            op.WriteInt		(781505280); // damn koreanz, trying to stop us by their hash identificator shit! but we g0n4 fight to da last sold13r!! // 96 - 99
            op.WriteInt		(); // first skipped integer? :0 wutwut // 100 - 103

            op.WriteInt		(32); // another p4ck3t ; n yeah, it was already here ^ // 104 - 107
            op.WriteShort	(4); // 108 - 109
            op.WriteShort	(97); // 110 - 111
            op.WriteInt		(1); // 112 - 115
            op.WriteInt		(chr.getuID()); // 116 - 119
            op.Skip			(16); // 120 - 135

            op.WriteInt		(1612); // 4nd y34h, gi4nt sh1t upc0min qq & nother pckt & another dick in rzaah's ass // 136 - 139
            op.WriteShort	(4); // 140 - 141
            op.WriteShort	(65); // 142 - 143
            op.WriteInt		(1); // 144 - 147
            op.WriteInt		(chr.getuID()); // 148 - 152
            return op.ToArray();
        }
Example #12
0
 public static void releaseGeneralQuestPacket(Character chr, byte karma = 0x0, byte penance = 0x0, int fame = 0x0, long exp = 0x0, long money = 0x0, byte guildPos = 0x0, byte faction = 0x0)
 {
     OutPacket op = new OutPacket(64);
     op.WriteInt(64);
     op.WriteShort(0x05);
     op.WriteShort(0x3b);
     op.WriteInt(715218689);
     op.WriteInt(chr.getuID());
     op.WriteByte(0x0); // karma
     op.WriteByte(0x0); // penance
     op.WriteShort(); // ?
     op.WriteByte(FameNickNames.Instance.getFameNickID(fame != 0x0 ? fame : chr.getFame()) > 0 ? (byte)1 : (byte)0); // appear player name above the head
     op.WriteByte(FameNickNames.Instance.getFameNickID(fame != 0x0 ? fame : chr.getFame())); // fame nickname
     op.WriteByte(chr.getAccount().gmLvl > 0 ? (byte)1 : (byte)0); // blue nickname??
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteByte(4); // ?
     op.WriteInt(fame != 0x0 ? fame : chr.getFame()); // fame
     op.WriteReversedLong(exp != 0x0 ? exp : chr.getExp()); // exp
     op.WriteLong(money != 0x0 ? money : chr.getCoin()); // money
     op.WriteByte(guildPos != 0x0 ? guildPos : (byte)0x0); // Guild Pos | TODO
     op.WriteByte(faction != 0x0 ? faction : chr.getFaction()); // Faction
     op.WriteByte(2); // 0 - gives an yellow message (?) | 1 - hides inventory
     Console.WriteLine(BitConverter.ToString(op.ToArray()));
     chr.getAccount().mClient.WriteRawPacket(op.ToArray());
 }
Example #13
0
        public static void releaseHealPacket(Character chr, int hpParam = 1000, short mpParam = 1000, short spParam = 1000)
        {
            if(hpParam > chr.getMaxHP())
            {
                hpParam = chr.getMaxHP();
                chr.setCurHP(chr.getMaxHP());
            }
            else
            {
                chr.setCurHP(hpParam);
            }

            if(mpParam > chr.getMaxMP())
            {
                mpParam = chr.getMaxMP();
                chr.setCurMP(chr.getMaxMP());
            }
            else
            {
                chr.setCurMP(mpParam);
            }

            if(spParam > chr.getMaxSP())
            {
                spParam = chr.getMaxSP();
                chr.setCurSP(chr.getMaxSP());
            }
            else
            {
                chr.setCurSP(spParam);
            }

            OutPacket p = new OutPacket(32);
            p.WriteInt(32);
            p.WriteShort(0x05);
            p.WriteShort(0x35);
            p.WriteInt(1158393864);
            p.WriteInt(chr.getuID());
            p.WriteInt(131076);
            p.WriteInt();
            p.WriteInt(hpParam);
            p.WriteShort(mpParam);
            p.WriteShort(spParam);
            chr.getAccount().mClient.WriteRawPacket(p.ToArray());
        }
Example #14
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) });
        }
Example #15
0
        public static void initNPCsForCharacter(Character chr, List<NPC> npcs)
        {
            if(npcs.Count == 0)
                return;

            OutPacket all = new OutPacket((npcs.Count() * 589) + 30);
            all.WriteInt((npcs.Count() * 589) + 30);
            all.WriteShort(4);
            all.WriteShort(4);
            all.WriteByte(1);
            all.WriteInt(chr.getuID());
            all.WriteInt(chr.getArea().getaID());
            all.WriteFloat(chr.getPosition()[0]);
            all.WriteFloat(chr.getPosition()[1]);
            foreach(NPC npc in npcs)
            {
                all.WriteBytes(npc.npcSpawnChained(chr));
            }
            all.WriteByte();
            all.WriteInt(3560);
            chr.getAccount().mClient.WriteRawPacket(all.ToArray());

            Console.WriteLine("npc init package length: {0}", all.ToArray().Length);
        }
Example #16
0
 public static byte[] initAccount(Account acc)
 {
     OutPacket op = new OutPacket(52);
     op.WriteInt(52);
     op.WriteShort(3);
     op.WriteShort(5);
     op.WritePaddedString(acc.name, 24);
     op.WriteInt(109);
     op.WriteInt(acc.MHPoints);
     op.WriteLong();
     op.WriteInt(acc.characters != null ? acc.characters.Count : 0);
     return op.ToArray();
 }
Example #17
0
        public static byte[] initCharacters(Account acc, bool backSpawn = false)
        {
            OutPacket all = new OutPacket((acc.characters.Count() * 653) + 8 + 3);
            all.WriteInt((acc.characters.Count() * 653) + 8 + 3);
            all.WriteShort(0x03);
            all.WriteShort((!backSpawn) ? ((byte)0x04) : ((byte)0x01));
            all.WriteBytes(new byte[] { (byte)0x01, (byte)0x01, (byte)0x01 });

            int multipier_keeper = 0x01;
            Boolean multiplied = false;

            foreach(Character chara in acc.characters.Values) {
                all.WriteBytes(CharacterPackets.initCharPacket(chara));

                if(multiplied)
                    multipier_keeper = (multipier_keeper * 2) + 1;
                if(!multiplied)
                    multiplied = true;
            }

            all.Position = 10;
            all.WriteByte((byte)multipier_keeper);
            return all.ToArray();
        }
Example #18
0
 public static byte[] removeDroppedItemForCharacter(Character chr, int uID)
 {
     OutPacket op = new OutPacket(20);
     op.WriteInt(20);
     op.WriteShort(0x05);
     op.WriteShort(0x0f);
     op.WriteInt(0x01);
     op.WriteInt(chr.getuID());
     op.WriteInt(uID);
     return op.ToArray();
 }
Example #19
0
 public static byte[] createDroppedItem(int itemuID, float posX, float posY, int itemID, int itemQuantity)
 {
     OutPacket op = new OutPacket(56);
     op.WriteInt(56);
     op.WriteShort(5);
     op.WriteShort(14);
     op.Skip(12);
     op.WriteInt(itemID);
     op.Skip(4);
     op.WriteInt(itemQuantity);
     op.WriteInt(itemuID);
     op.WriteFloat(posX);
     op.WriteFloat(posY);
     return op.ToArray();
 }
Example #20
0
        public static byte[] refreshGuild(Character chr)
        {
            Guild guild = chr.getGuild();

            OutPacket op = new OutPacket(1644);
            op.WriteInt		(32);
            op.WriteShort	(4);
            op.WriteShort	(97);
            op.WriteInt		(1);
            op.WriteInt		(chr.getuID());
            op.Skip			(16);

            op.WriteInt		(1612);
            op.WriteShort	(4);
            op.WriteShort	(65);
            op.WriteInt		(1);
            op.WriteInt		(chr.getuID());
            op.WriteShort	(1);
            op.WritePaddedString(guild.guildName, 18);
            op.WriteShort	(guild.guildIcon);
            op.WriteShort	(guild.guildType);
            op.WriteInt		((guild.guildFame / 100) + (guild.guildGold / 10));
            op.WriteInt		(guild.guildFame);
            op.WriteLong	(guild.guildGold);
            op.WriteInt		(guild.guildHat);

            for(int i = 0;i < 50;i++)
            {
                op.WriteInt(guild.guildMembers.ElementAt(i) == null ? 0 : guild.guildMembers.ElementAt(i).getuID());
            } // 60 - 259

            for(int i = 0;i < 50;i++)
            {
                op.WriteByte(guild.guildMembers.ElementAt(i) == null ? (byte)0 : guild.guildMembers.ElementAt(i).getGuildRank());
            } // 260 - 309

            for(int i = 0;i < 50;i++)
            {
                if(guild.guildMembers.ElementAt(i) == null)
                {
                    op.Skip(17);
                    continue;
                }
                if(guild.guildMembers.ElementAt(i).getOnlineCharacter() == null)
                {
                    op.Skip(17);
                    continue;
                }
                Character tmp = guild.guildMembers.ElementAt(i).getOnlineCharacter();
                op.WritePaddedString(tmp.getName(), 17);
            } // 310 - 1159

            for(int i = 0;i < 50;i++)
            {
                if(guild.guildMembers.ElementAt(i) == null)
                {
                    op.Skip(1);
                    continue;
                }
                if(guild.guildMembers.ElementAt(i).getOnlineCharacter() == null)
                {
                    op.Skip(1);
                    continue;
                }
                Character tmp = guild.guildMembers.ElementAt(i).getOnlineCharacter();
                op.WriteByte(tmp.getcClass());
            }
            return op.ToArray();
        }
Example #21
0
        public static byte[] getUpgradePacket(Character chr, Item newItem, byte newItemIndex, int newItemHash)
        {
            byte x, y, suc;
            if(newItemHash != -1)
            {
                x = (byte)(newItemHash % 100);
                y = (byte)(newItemHash / 100);
                suc = 1;
            }
            else
            {
                x = (byte)0xFF;
                y = (byte)0xFF;
                suc = 0;
            }

            OutPacket op = new OutPacket(36);
            op.WriteInt(36);
            op.WriteShort(0x04);
            op.WriteShort(0x32);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteShort(suc);
            op.WriteByte();
            op.WriteByte(newItemIndex);
            op.WriteInt(134612548);
            op.WriteShort();
            op.WriteByte(y);
            op.WriteByte(x);
            op.WriteInt(newItem.getItemID());
            op.WriteInt(newItem.getQuantity());
            return op.ToArray();
        }
Example #22
0
 public static byte[] getRefreshNewsGuildPacket(string message)
 {
     OutPacket op = new OutPacket(212);
     op.WriteInt		(212);
     op.WriteShort	(4);
     op.WriteShort	(103);
     op.WriteInt		(1);
     op.WritePaddedString(message, 195);
     return op.ToArray();
 }
Example #23
0
 public static byte[] playerIsntConnected(Character chr)
 {
     OutPacket p = new OutPacket(48);
     p.WriteInt(48);
     p.WriteShort(0x05);
     p.WriteShort(0x07);
     p.WriteInt(0x01);
     p.WriteInt(chr.getuID());
     p.WriteZero(2);
     p.WriteShort(0x01);
     p.WriteZero(20);
     p.WriteInt(0x04);
     p.WriteByte(0x34);
     p.WriteByte(0x33);
     p.WriteByte(0x34);
     p.WriteByte(0x33);
     return p.ToArray();
 }
Example #24
0
 public static byte[] getLearnSkillPacket(Character chr, int skillIdInt, int skillNumberInt)
 {
     OutPacket op = new OutPacket(32);
     op.WriteInt(32);
     op.WriteShort(0x04);
     op.WriteShort(0x29);
     op.WriteInt(0x01);
     op.WriteInt(chr.getuID());
     op.WriteShort(0x01);
     op.WriteByte(0x06);
     op.WriteByte(0x08);
     op.WriteInt(skillNumberInt);
     op.WriteInt(skillIdInt);
     op.WriteShort(chr.getSkillPoints());
     op.WriteByte(0x5f);
     op.WriteByte(0x08);
     return op.ToArray();
 }
Example #25
0
 public static byte[] getExtEquipPacket(Character chr, byte slot, int itemID)
 {
     OutPacket op = new OutPacket(24);
     op.WriteInt(24);
     op.WriteShort(0x05);
     op.WriteShort(0x0c);
     op.WriteInt(0x01);
     op.WriteInt(chr.getuID());
     op.WriteInt(itemID);
     op.WriteByte(slot);
     op.WriteByte(0x9e);
     op.WriteByte(0x0f);
     op.WriteByte(0xbf);
     return op.ToArray();
 }
Example #26
0
 public static byte[] getMediPacket(Character chr, int skillID, byte activationID)
 {
     OutPacket op = new OutPacket(28);
     op.WriteInt(28);
     op.WriteShort(5);
     op.WriteShort(0x34);
     op.WriteInt(134521345);
     op.WriteInt(chr.getuID());
     op.WriteInt(135528449);
     op.WriteInt(skillID);
     op.WriteByte(activationID);
     op.WriteShort(3566);
     return op.ToArray();
 }
Example #27
0
 public static void sendSystemMessageToClient(MartialClient c, byte messageType, string message, string sender = null)
 {
     OutPacket p = new OutPacket(45 + message.Length);
     p.WriteInt(45 + message.Length);
     p.WriteShort(0x05);
     p.WriteShort(0x07);
     p.WriteShort(0x01);
     p.WriteZero(7);
     p.WriteByte(0x01);
     p.WriteShort(messageType);
     if(sender == null)
         p.WritePaddedString("*", 20);
     else
         p.WritePaddedString(sender, 20);
     p.WriteInt(0x3e);
     p.WriteString(message);
     c.WriteRawPacket(p.ToArray());
 }
Example #28
0
 public static byte[] getTurboPacket(Character chr, int skillID, bool activate)
 {
     OutPacket op = new OutPacket(28);
     op.WriteInt(28);
     op.WriteShort(5);
     op.WriteShort(0x34);
     op.WriteInt(activate ? 135632385 : 134521345);
     op.WriteInt(chr.getuID());
     op.WriteInt(activate ? -1089535999 : 135528449);
     op.WriteInt(skillID);
     op.WriteInt(activate ? 303818 : 913099);
     return op.ToArray();
 }
Example #29
0
 public static byte[] getCastSkillPacket(Character chr, int targets, int skillID, byte activationID)
 {
     OutPacket op = new OutPacket(28 + targets * 24);
     op.WriteInt(28 + targets * 24);
     op.WriteShort(5);
     op.WriteShort(0x34);
     op.WriteInt(1);
     op.WriteInt(chr.getuID());
     op.WriteInt(1);
     op.WriteInt(skillID);
     op.WriteByte(activationID);
     op.WriteByte(7);
     op.WriteByte();
     op.WriteByte((byte)targets);
     return op.ToArray();
 }
Example #30
0
 public static byte[] quitGuildForExternals(Character chr)
 {
     OutPacket op = new OutPacket(40);
     op.WriteInt		(40);
     op.WriteShort	(0x05);
     op.WriteShort	(0x41);
     op.WriteInt		(1);
     op.WriteInt		(chr.getuID());
     return op.ToArray();
 }