Beispiel #1
0
        public static void SetMHP(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs.Length != 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setmhp [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);

            if (player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found.");
                return;
            }

            int amount = -1;

            if (!Int32.TryParse(cmd.commandArgs[1], out amount))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse amount of MHPoints.");
                return;
            }

            player.getAccount().MHPoints = amount;
            StaticPackets.setMHPoints(player.getAccount().mClient, amount);
            return;
        }
Beispiel #2
0
        public static void RequestSpawn(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter != null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to spawn a character while being ingame.");
                c.Close();
                return;
            }

            byte selected_character = p.ReadByte();

            if (!c.getAccount().characters.ContainsKey(selected_character))
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by selection packet", selected_character);
                c.Close();
                return;
            }

            Character target = c.getAccount().characters[selected_character];

            c.getAccount().activeCharacter = target;

            WMap.Instance.addToCharacters(target);
            CharacterFunctions.setPlayerPosition(target, target.getPosition()[0], target.getPosition()[1], target.getMap());
            CharacterFunctions.calculateCharacterStatistics(target);
            StaticPackets.sendSystemMessageToClient(c, 1, Constants.WelcomeMessage);
        }
Beispiel #3
0
        public static void SetLevel(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs.Length < 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setlevel [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);

            if (player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Wrong player name has been given.");
                return;
            }

            byte level;

            if (!Byte.TryParse(cmd.commandArgs[1], out level))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                return;
            }

            if (level < 0 || level > 255)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Setlevel range goes from 0 - 255.");
                return;
            }

            StaticPackets.setCharacterLevel(player, level);
            StaticPackets.sendSystemMessageToClient(c, 1, player.getName() + "'s level has been set up to: " + level + "!");
            return;
        }
Beispiel #4
0
        public static void SetFame(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setfame [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);

            if (player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Wrong player name has been given.");
                return;
            }

            int fameAmount;

            if (!Int32.TryParse(cmd.commandArgs[1], out fameAmount))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                return;
            }

            if (fameAmount < 0 || fameAmount > 2147483647)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Setfame range goes from 0 - 2147483647.");
                return;
            }

            StaticPackets.setCharacterFame(player, fameAmount);
            StaticPackets.sendSystemMessageToClient(c, 1, player.getName() + "'s fame has been set up to: " + fameAmount + "!");
            return;
        }
Beispiel #5
0
 public static void ListCommands(MartialClient c, InCommand cmd)
 {
     StaticPackets.sendSystemMessageToClient(c, 1, "Available commands: ");
     foreach (string cmdName in CommandProcessor.getCommandHandlers().Keys)
     {
         StaticPackets.sendSystemMessageToClient(c, 1, cmdName);
     }
 }
Beispiel #6
0
        public static void Announce(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/announce [text]");
                return;
            }
            string announcing = string.Join(" ", cmd.commandArgs);

            StaticPackets.sendWorldAnnounce(announcing);
            return;
        }
Beispiel #7
0
        public static void MoveToInv(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 fromCargoIndex = p.ReadByte();
            byte toInvSlot      = p.ReadByte();
            byte toInvLine      = p.ReadByte();
            byte toInvRow       = p.ReadByte();

            Cargo     cargo = chr.getCargo();
            Inventory inv   = chr.getInventory();

            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toInvSlot, toInvLine, toInvRow);

            cargo.updateCargo();

            if (!cargo.getCargoSaved().ContainsKey((byte)fromCargoIndex))
            {
                Console.WriteLine("Cannot moveItemToInv [item missing]");
                return;
            }
            Item itemF = cargo.getCargoSaved()[(byte)fromCargoIndex];

            if (!inv.moveFromCargo(itemF, fromCargoIndex, toInvRow, toInvLine))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "do kurwy nendzy");
                return;
            }
            cargo.saveCargo();

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(45);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteByte(toInvSlot);
            op.WriteByte(toInvLine);
            op.WriteByte(toInvRow);
            op.WriteShort(-16625);
            c.WriteRawPacket(op.ToArray());
        }
        public static void warpToNearestTown(Character chr)
        {
            Waypoint closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(chr.getMap(), new Waypoint(chr.getPosition()[0], chr.getPosition()[1]));

            if (closestTown == null)
            {
                Area vvArea = WMap.Instance.getGrid(1).getAreaByRound(-1660, 2344);
                if (vvArea == null)
                {
                    Logger.WriteLog(Logger.LogTypes.Error, "Pure warpToNearestTown error {0}|{1}|{2}", chr.getPosition()[0], chr.getPosition()[1], chr.getMap());
                    StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "We're sorry, but an hard error has occured. Please report it to an admin.");
                    chr.getAccount().mClient.Close();
                    return;
                }
                setPlayerPosition(chr, -1660, 2344, 1);
            }
        }
Beispiel #9
0
        public static void ItemCreate(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/item [itemid] [*amount]");
                return;
            }

            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            int itemID = 0;

            Int32.TryParse(cmd.commandArgs[0], out itemID);
            if (itemID < 200000000 || itemID > 299999999)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Item ID range goes from 200.000.000 - 299.999.999.");
                return;
            }
            if (ItemDataCache.Instance.getItemData(itemID).getID() == 0)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Selected item wasn't found.");
                return;
            }

            short itemQuantity = 1;

            Int16.TryParse(cmd.commandArgs[1], out itemQuantity);
            if (itemQuantity > short.MaxValue)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Items amount, can't be bigger than 100!");
                return;
            }

            c.WriteRawPacket(ItemPackets.createDroppedItem(WMap.Instance.items.Count, chr.getPosition()[0], chr.getPosition()[1], itemID, itemQuantity));
            StaticPackets.sendSystemMessageToClient(c, 1, "Item of ID: " + itemID + "|" + WMap.Instance.items.Count + "|" + itemQuantity + ", has been created at coords: ");
            StaticPackets.sendSystemMessageToClient(c, 1, chr.getPosition()[0] + ":" + chr.getPosition()[1] + ":" + chr.getMap() + "!");
            WMap.Instance.items.Add(WMap.Instance.items.Count, new Item(itemID, itemQuantity));
            return;
        }
Beispiel #10
0
        public static void ParseCommand(MartialClient c, string[] cmd)
        {
            InCommand p = new InCommand(cmd[0].ToLower(), cmd.Length == 1 ? null : cmd.Skip(1).ToArray());

            CommandHandler handler = null;

            handler = c_processor[p.commandName];

            if (handler != null)
            {
                handler(c, p);
            }
            else
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Command '" + cmd[0] + "' wasn't found.");
                return;
            }
        }
Beispiel #11
0
        public static void LearnSkill(MartialClient c, InPacket p)
        {
            Character chr = c.getAccount().activeCharacter;

            byte[] skillNumber = p.ReadBytes(4);
            byte[] skillId     = p.ReadBytes(4);

            int skillNumberInt = BitTools.byteArrayToInt(skillNumber);
            int skillIdInt     = BitTools.byteArrayToInt(skillId);

            if (!SkillDataCache.Instance.canLearnSkill(chr, skillIdInt))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "You can't learn this skill! [" + skillIdInt + "]");
                return;
            }
            chr.getSkills().learnSkill(skillIdInt, true);

            byte[] learnskill = SkillPackets.getLearnSkillPacket(chr, skillIdInt, skillNumberInt);
            c.WriteRawPacket(learnskill);
        }
Beispiel #12
0
        public static void Pickup(MartialClient c, InPacket p)
        {
            byte[] decrypted = p.ReadBytes(7);
            byte[] uid       = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                uid[i] = decrypted[i];
            }
            int uID = BitTools.byteArrayToInt(uid);
            int col = (int)decrypted[4] & 0xFF;
            int row = (int)decrypted[5] & 0xFF;

            Item item = null;

            if (WMap.Instance.items.ContainsKey(uID))
            {
                item = WMap.Instance.items[uID];
            }

            if (item == null)
            {
                Console.WriteLine("item null qq");
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            if (!chr.getInventory().pickItem(item, item.getQuantity()))
            {
                Console.WriteLine("InvManagement > Cannot pick item [coin limit]");
                return;
            }

            c.WriteRawPacket(StaticPackets.getPickItemPacket(chr, item, item.getQuantity(), uID, decrypted[4], decrypted[5], decrypted[6]));

            Console.WriteLine("amount {0}", item.getQuantity());

            WMap.Instance.getGrid(c.getAccount().activeCharacter.getMap()).sendTo3x3AreaRemoveItem(chr.getArea(), uID);

            WMap.Instance.items.Remove(uID);
        }
Beispiel #13
0
        public static void Chat(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked chat with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte   messageType   = (byte)p.ReadShort();
            string receiver      = MiscFunctions.obscureString(p.ReadString(17));
            byte   messageLength = (byte)p.ReadInt();

            if (messageLength > 65)
            {
                Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to send a message of size {0}", messageLength);
                c.Close();
                return;
            }
            string message = p.ReadString(messageLength);

            switch (messageType)
            {
            case 0: WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), StaticPackets.chatRelay(chr, messageType, message)); break;

            case 1:
            {
                if (receiver == null)
                {
                    return;
                }

                Character player = WMap.Instance.findPlayerByName(receiver);
                if (player == null)
                {
                    chr.getAccount().mClient.WriteRawPacket(StaticPackets.playerIsntConnected(chr));
                    break;
                }

                player.getAccount().mClient.WriteRawPacket(StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 6:                     // karma notice
            {
                if (chr.getKarmaMessagingTimes() == 0)
                {
                }

                WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 7:                     // "GM Shout"
            {
                if (chr.getAccount().gmLvl == 0 && chr.getGMShoutMessagingCounts() == 0)
                {
                }

                WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                break;
            }

            case 9:                     // admin commands
            {
                string[] cmd = Regex.Split(message, " ");
                if (chr.getAccount().gmLvl == 0)
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse GM Command {0}", cmd[0]);
                    c.Close();
                    break;
                }

                if (cmd.Length == 0)
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse null GM Command");
                    c.Close();
                    break;
                }

                if (cmd[0][0] != '/')
                {
                    Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse command without '/' slash");
                    c.Close();
                    break;
                }

                CommandProcessor.ParseCommand(c, cmd);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Beispiel #14
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());
        }
        public static void calculateCharacterStatistics(Character chr)
        {
            Boolean[] pureHeal = new Boolean[] { chr.getCurHP() == chr.getMaxHP(), chr.getCurMP() == chr.getMaxMP(), chr.getCurSP() == chr.getMaxSP() };

            chr.getEquipment().calculateEquipStats();

            short bonusMaxhp = 0;
            //if(bonusAttributes.containsKey("maxhp"))
            //	bonusMaxhp = (Short)bonusAttributes.get("maxhp");

            short bonusDmg = 0;
            //if(bonusAttributes.containsKey("bonusDmg"))
            //	bonusDmg = (Short)bonusAttributes.get("bonusDmg");

            short bonusAtkSucces = 0;

            //if(bonusAttributes.containsKey("bonusAtkSucces"))
            //	bonusAtkSucces = (Short)bonusAttributes.get("bonusAtkSucces");

            short[] stats   = new short[5];
            short[] eqstats = chr.getEquipment().getStats();
            for (int i = 0; i < 5; i++)
            {
                stats[i] = (short)(chr.getCStats()[i] + eqstats[i]);
            }
            chr.setMaxHP((int)(30 + bonusMaxhp + chr.getEquipment().getHp() + stats[0] * 2.2 + stats[1] * 2.4 + stats[2] * 2.5 + stats[3] * 1.6 + stats[4] * 1.5));
            chr.setMaxMP((short)(30 + chr.getEquipment().getMana() + stats[0] * 1.4 + stats[1] * 1.7 + stats[2] * 1.5 + stats[3] * 3.5 + stats[4] * 1.5));
            chr.setMaxSP((short)(30 + chr.getEquipment().getStamina() + stats[0] * 0.9 + stats[1] * 1.3 + stats[2] * 1.5 + stats[3] * 1.7 + stats[4] * 1.3));
            chr.setRegHP((short)(stats[2] / 2 + stats[0] / 4));
            chr.setRegMP((short)(stats[3] / 2 + stats[1] / 4));
            chr.setRegSP((short)(stats[4] * 0.1));
            chr.setAtk((int)(chr.getLevel() / 2 + chr.getEquipment().getAtk() + stats[0] * 0.53 + stats[1] * 0.5 + stats[2] * 0.44 + stats[3] * 0.25 + stats[4] * 0.25)
                       + chr.getEquipment().getMaxDmg());
            chr.setDef((int)(chr.getLevel() / 2 + chr.getEquipment().getDeff() + stats[0] * 0.28 + stats[1] * 0.3 + stats[2] * 0.53 + stats[3] * 0.22 + stats[4] * 0.42));
            chr.setMinDmg((int)(bonusDmg + chr.getEquipment().getMinDmg()));
            chr.setMaxDmg((int)(bonusDmg + chr.getEquipment().getMaxDmg()));
            chr.setBasicAtkSuc((int)(stats[0] * 0.5 + stats[1] * 0.6 + stats[2] * 0.3 + stats[3] * 1 + stats[4] * 0.8 + chr.getLevel() * 6));
            chr.setBasicDefSuc((int)(stats[0] * 0.2 + stats[1] * 0.2 + stats[2] * 0.5 + stats[3] * 0.7 + stats[4] * 0.6 + chr.getLevel() * 4));
            chr.setBasicCritRate((int)(stats[0] * 0.1 + stats[1] * 1 + stats[2] * 0.1 + stats[3] * 0.5 + stats[4] * 0.3 + chr.getLevel() * 2) - 300);
            chr.setAdditionalAtkSuc(1000 + bonusAtkSucces);
            chr.setAdditionalDefSuc(500);
            chr.setAdditionalCritRate(2000);
            float atkSucMul   = chr.getEquipment().getAtkSucMul();
            float defSucMul   = chr.getEquipment().getDefSucMul();
            float critRateMul = chr.getEquipment().getCritRateMul();

            chr.setAtkSuc((int)(chr.getBasicAtkSuc() + chr.getAdditionalAtkSuc() * atkSucMul));
            chr.setDefSuc((int)(chr.getBasicDefSuc() + chr.getAdditionalDefSuc() * defSucMul));
            chr.setCritRate((int)(chr.getBasicCritRate() + chr.getAdditionalCritRate() * critRateMul));
            chr.setCritDmg((short)(chr.getEquipment().getCritDmg() + stats[1] - 10));

            if (chr.getCurHP() > chr.getMaxHP())
            {
                chr.setCurHP(chr.getMaxHP());
            }
            if (chr.getCurMP() > chr.getMaxMP())
            {
                chr.setCurMP(chr.getMaxMP());
            }
            if (chr.getCurSP() > chr.getMaxSP())
            {
                chr.setCurSP(chr.getMaxSP());
            }

            if (chr.getAccount().activeCharacter != null)
            {
                if (chr.getAccount().activeCharacter == chr)
                {
                    StaticPackets.releaseHealPacket(chr, pureHeal[0] ? chr.getMaxHP() : chr.getCurHP(),
                                                    pureHeal[1] ? chr.getMaxMP() : chr.getCurMP(),
                                                    pureHeal[2] ? chr.getMaxSP() : chr.getCurSP());
                }
            }

            Console.WriteLine("{0} {1}", chr.getAtk(), chr.getDef());
        }
Beispiel #16
0
        public static void Warp(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs.Length < 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                return;
            }

            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            short goMap = -1;
            float goX   = -1;
            float goY   = -1;

            if (cmd.commandArgs.Length == 2)
            {
                switch (cmd.commandArgs[0].ToLower())
                {
                case "npc":
                {
                    int npcID = -1;
                    if (!Int32.TryParse(cmd.commandArgs[1], out npcID))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse NPC's ID.");
                        return;
                    }

                    if (WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null)
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find NPC of ID " + npcID + "!");
                        return;
                    }

                    NPC npc = WMap.Instance.getNpcs()[npcID];

                    goMap = npc.getMap();
                    goX   = npc.getPosition()[0];
                    goY   = npc.getPosition()[1];
                    break;
                }

                /*case "mob":
                 * {
                 *      int mobID = -1;
                 *      if(!Int32.TryParse(cmd.commandArgs[1], out mobID))
                 *      {
                 *              StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse Mob's ID.");
                 *              return;
                 *      }
                 *
                 *      Mob mob = WMap.Instance.getGrid(chr.getMap()).findMobByuID(mobID);
                 *      if(mob == null)
                 *      {
                 *              StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find Mob of ID " + mobID + "!");
                 *              return;
                 *      }
                 *
                 *      goMap = mob.getMap();
                 *      goX = mob.getPosition()[0];
                 *      goY = mob.getPosition()[1];
                 *      break;
                 * }*/
                case "player":
                {
                    Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[1]);
                    if (player == null)
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found.");
                        return;
                    }

                    goMap = player.getMap();
                    goX   = player.getPosition()[0];
                    goY   = player.getPosition()[1];
                    break;
                }

                default:
                {
                    if (!MiscFunctions.IsNumeric(cmd.commandArgs[0]) || cmd.commandArgs[1] != "true" && !MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                        return;
                    }

                    Waypoint closestTown = null;
                    short    _desiredMap = -1;
                    if (!Int16.TryParse(cmd.commandArgs[0], out _desiredMap))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired map's ID!");
                        return;
                    }

                    if (cmd.commandArgs[1] == "true")
                    {
                        closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(_desiredMap, new Waypoint(0, 0));
                        if (closestTown == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + "!");
                            return;
                        }
                    }
                    else if (MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                    {
                        int _desiredTown = -1;
                        if (!Int32.TryParse(cmd.commandArgs[1], out _desiredTown))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired town's index!");
                            return;
                        }

                        closestTown = TownCoordsCache.Instance.getWaypointAtIndexForMap(_desiredMap, _desiredTown);
                        if (closestTown == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + " with index " + _desiredTown + "!");
                            return;
                        }
                    }

                    goMap = Convert.ToInt16(cmd.commandArgs[0]);
                    goX   = closestTown.getX();
                    goY   = closestTown.getY();
                    break;
                }
                }
            }
            else if (cmd.commandArgs.Length == 3)
            {
                foreach (string parser in cmd.commandArgs)
                {
                    if (!MiscFunctions.IsNumeric(parser))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                        return;
                    }
                }

                goMap = Convert.ToInt16(cmd.commandArgs[2]);
                goX   = Convert.ToSingle(cmd.commandArgs[0]);
                goY   = Convert.ToSingle(cmd.commandArgs[1]);
            }
            else
            {
                return;
            }

            CharacterFunctions.setPlayerPosition(c.getAccount().activeCharacter, goX, goY, goMap);
            return;
        }
Beispiel #17
0
        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());
        }
Beispiel #18
0
        public static void UpgradeItem(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook upgradeItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[]    decrypted     = p.ReadBytes(10);
            byte      oldItemIndex  = decrypted[8];
            byte      upgraderIndex = decrypted[9];
            Inventory inv           = chr.getInventory();

            inv.updateInv();

            List <int>             seq   = new List <int>(inv.getSeqSaved());
            Dictionary <int, Item> items = new Dictionary <int, Item>(inv.getInvSaved());

            int oldItemHash  = seq[oldItemIndex];
            int upgraderHash = seq[upgraderIndex];

            if (oldItemHash == -1 || upgraderHash == -1)
            {
                Console.WriteLine("can't upgrade items.. cause they don't exist o.o");
                return;
            }

            Item oldItem = items[oldItemHash];

            if (oldItem == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }
            if (oldItem.getQuantity() > 1)
            {
                Console.WriteLine("wtf..");
                return;
            }
            Item upgrader = items[upgraderHash];

            if (upgrader == null)
            {
                Console.WriteLine("Tried to use not existing item..");
                return;
            }

            Upgrade upgrade = Upgrades.Instance.getUpgradeClasse(oldItem.getItemID(), upgrader.getItemID());

            if (upgrade == null)
            {
                Console.WriteLine("not found dla {0} | {1}", oldItem.getItemID(), upgrader.getItemID());
                return;
            }
            else
            {
                Console.WriteLine("znaleziony upgrade: {0} | {1}", upgrade.getOldit(), upgrade.getNewit());
            }

            //if(!SkillMaster.canUpgrade(chr, upgrade.getUpgradeskill())){
            //	throw new InventoryException("Cannot upgrade item [your upgrade lvl is too low]");
            //}

            byte newItemIndex = 0;
            int  newItemHash  = -1;

            //change item
            oldItem.setItemID(upgrade.getNewit());
            oldItem.setQuantity(1);
            //position of new item
            newItemIndex = oldItemIndex;
            newItemHash  = oldItemHash;

            //remove upgrader
            inv.removeItem(upgraderIndex, 1);
            if (inv.getSeq()[upgraderIndex] == -1)
            {
                Console.WriteLine("usuwamy itemek");
                c.WriteRawPacket(StaticPackets.getInventoryDeletePacket(chr, upgraderIndex, 1));
            }
            else
            {
                Console.WriteLine("co kurwa");
            }

            inv.saveInv();
            c.WriteRawPacket(StaticPackets.getUpgradePacket(chr, oldItem, newItemIndex, newItemHash));
        }
        public static void setPlayerPosition(Character chr, float goX, float goY, short map)
        {
            MartialClient c = chr.getAccount().mClient;

            Logger.WriteLog(Logger.LogTypes.Debug, goX + " | " + goY + " | " + map);

            Area lastArea = chr.getArea();
            Area newArea  = WMap.Instance.getGrid(map).getAreaByRound(goX, goY);

            if (newArea == null)
            {
                StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "The position " + goX + "|" + goY + "|" + map + " can't be reached.");
                Waypoint closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(map, new Waypoint(goX, goY));
                if (closestTown == null)
                {
                    Area vvArea = WMap.Instance.getGrid(1).getAreaByRound(-1660, 2344);
                    if (vvArea == null)
                    {
                        Logger.WriteLog(Logger.LogTypes.Error, "Pure setPlayerPosition error {0}|{1}|{2}", goX, goY, map);
                        StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "We're sorry, but an hard error has occured. Please report it to an admin.");
                        c.Close();
                        return;
                    }
                    else
                    {
                        goX     = -1660;
                        goY     = 2344;
                        map     = 1;
                        newArea = vvArea;
                    }
                }
                else
                {
                    goX     = closestTown.getX();
                    goY     = closestTown.getY();
                    newArea = WMap.Instance.getGrid(map).getAreaByRound(goX, goY);
                }
            }

            if (lastArea != null)
            {
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaLeave(chr, lastArea);
                lastArea.removeCharacter(chr);
            }

            if (newArea != null)
            {
                chr.setArea(newArea);
            }
            else
            {
                chr.getAccount().mClient.Close();
                return;
            }

            newArea.addCharacter(chr);

            chr.setMap(map);
            chr.setPosition(new float[] { goX, goY });

            OutPacket op = new OutPacket(5840);

            op.WriteInt(5824);
            op.WriteShort(4);                                                          // 4 - 5
            op.WriteShort(1);                                                          // 6 - 7
            op.WriteInt(1);                                                            // 8 - 11
            op.WriteInt(chr.getuID());                                                 // 12 - 15
            op.WriteShort(1);                                                          // 16 - 19
            op.WriteShort(1);                                                          // 16 - 19
            op.WriteInt(chr.getMap());                                                 // 20 - 23
            op.WriteInt(DateTime.Now.Year - 2000);                                     // 24 - 27
            op.WriteByte((byte)DateTime.Now.Month);                                    // 28
            op.WriteByte(DateTime.Now.Day > 30 ? (byte)0x1e : (byte)DateTime.Now.Day); // 29
            op.WriteInt(DateTime.Now.Hour);                                            // 30 - 37

            for (int i = 0; i < 120; i++)
            {
                if (chr.getCargo().getSeqSaved()[i] != -1 && chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]] != null)
                {
                    op.WriteInt();
                    op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] / 100));
                    op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] % 100));
                    Item item = chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]];
                    op.WriteInt(item.getItemID());
                    ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
                    if (itemData.getTimeToExpire() > 0)
                    {
                    }
                    op.WriteShort(item.getQuantity());
                }
                else
                {
                    op.WriteZero(12);
                }
            }             // 38 - 1477

            op.Position = 1476;

            for (int i = 0; i < chr.getCommunity().getFriendsList().Capacity; i++)
            {
                if (chr.getCommunity().getFriendsList().ElementAtOrDefault(i) != null)
                {
                    op.WritePaddedString(chr.getCommunity().getFriendsList()[i], 17);
                }
                else
                {
                    op.WriteZero(17);
                }
            }             // 1476 - 1934

            op.WriteRepeatedByte(0x58, 40);

            op.Position = 1986;

            for (int i = 0; i < chr.getCommunity().getIgnoresList().Capacity; i++)
            {
                if (chr.getCommunity().getIgnoresList().ElementAtOrDefault(i) != null)
                {
                    op.WritePaddedString(chr.getCommunity().getIgnoresList()[i], 17);
                }
                else
                {
                    op.WriteZero(17);
                }
            }                 // 1987 - 2157

            op.WriteInt(363); // questsy
            op.WriteLong();
            op.WriteLong(138769276674441706);
            op.WriteLong(21692910);
            op.WriteShort();
            op.WriteShort(1);

            op.Position = 2248;

            for (byte i = 0; i < 240; i++)
            {
                if (chr.getInventory().getSeqSaved()[i] != -1 && chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]] != null)
                {
                    op.WriteShort();
                    op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] / 100));
                    op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] % 100));
                    Item item = chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]];
                    op.WriteInt(item.getItemID());
                    op.WriteInt(item.getQuantity());
                }
                else
                {
                    op.WriteZero(12);
                }
            }             // 2252 - 5133

            op.WriteLong(chr.getCoin());

            op.Position = 5140;

            for (byte i = 0; i < 21; i++)
            {
                if (chr.getSkillBar().getSkillBar().ContainsKey(i))
                {
                    int barID = chr.getSkillBar().getSkillBar()[i];
                    if (barID > 200000000)
                    {
                        op.WriteInt(1);
                    }
                    else if (barID > 511)
                    {
                        op.WriteInt(5); barID -= 512;
                    }
                    else if (barID > 255)
                    {
                        op.WriteInt(6); barID -= 256;
                    }
                    else
                    {
                        SkillData skill = SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills().ElementAtOrDefault(barID));
                        if (skill == null)
                        {
                            op.WriteInt(0);
                        }
                        else if (skill.getTypeSpecific() == 6)
                        {
                            op.WriteInt(3);
                        }
                        else if (skill.getTypeSpecific() == 7)
                        {
                            op.WriteInt(4);
                        }
                        else
                        {
                            op.WriteInt(2);
                        }
                    }
                    op.WriteInt(barID);
                }
                else
                {
                    op.WriteZero(8);
                }
            }             // 5140 - 5299

            op.Position = 5320;

            for (int i = 0; i < 60; i++)
            {
                if (chr.getSkills().getLearnedSkills().Count > i && chr.getSkills().getLearnedSkills()[i] != 0)
                {
                    op.WriteInt(chr.getSkills().getLearnedSkills()[i]);
                    op.WriteInt(SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills()[i]).getSkillPoints());
                }
                else
                {
                    op.WriteLong();
                }
            }             // 5320 - 5799

            op.WriteFloat(chr.getPosition()[0]);
            op.WriteFloat(chr.getPosition()[1]);
            op.WriteInt(0x0c);
            op.WriteInt(140338688);
            op.WriteInt();
            op.WriteShort();
            op.WriteShort(10962);

            //s3c0nd p4ck3t
            op.WriteInt(16);
            op.WriteInt(7929861);
            op.WriteInt(chr.getuID());
            c.WriteRawPacket(op.ToArray());

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaSpawn(chr, chr.getArea());
        }