private static void SetEnchantStats(GameSession session, ItemEnchant itemEnchantStats, Item item)
    {
        Dictionary <StatAttribute, ItemStat> statDiff = GetEnchantStatDiff(item.Stats.Enchants, itemEnchantStats.Stats);

        foreach (ItemStat stat in itemEnchantStats.Stats.Values)
        {
            if (!item.Stats.Enchants.ContainsKey(stat.ItemAttribute))
            {
                item.Stats.Enchants[stat.ItemAttribute] = new BasicStat(stat.ItemAttribute, stat.Rate, StatAttributeType.Rate);
                continue;
            }
            item.Stats.Enchants[stat.ItemAttribute].Flat = stat.Flat;
            item.Stats.Enchants[stat.ItemAttribute].Rate = stat.Rate;
        }
        item.EnchantLevel++;
        item.EnchantExp = 0;
        item.Charges   -= itemEnchantStats.Rates.ChargesAdded;
        if (item.EnchantLevel > 11)
        {
            string message = $"3,{item.Uid},{ChatLinkType.Enchant},{session.Player.Name}"; //unk what 3 is
            MapleServer.BroadcastPacketAll(ItemLinkPacket.SendLinkItem(new()
            {
                item
            }));
            MapleServer.BroadcastPacketAll(ChatPacket.Send(session.Player, message, ChatType.ItemEnchant));
        }

        session.Send(ItemEnchantPacket.EnchantSuccess(item, statDiff.Values.ToList()));
        //TODO: If item is equipped, update stats
    }
    private static void HandleGetHelp(GameSession session, PacketReader packet)
    {
        int dungeonId = packet.ReadInt();

        if (session.Player.DungeonHelperAccessTime > session.ClientTick)
        {
            session.Send(PartyPacket.DungeonHelperCooldown(session.Player.DungeonHelperAccessTime - session.ClientTick));
            return;
        }

        Party party = session.Player.Party;

        if (party is null)
        {
            party = new(session.Player);
            GameServer.PartyManager.AddParty(party);

            session.Send(PartyPacket.Create(party, false));
            session.Send(PartyPacket.PartyHelp(dungeonId));
            MapleServer.BroadcastPacketAll(DungeonHelperPacket.BroadcastAssist(party, dungeonId));
            return;
        }

        session.Player.DungeonHelperAccessTime = session.ClientTick + 30000; // 30 second cooldown

        party.BroadcastPacketParty(PartyPacket.PartyHelp(dungeonId));
        MapleServer.BroadcastPacketAll(DungeonHelperPacket.BroadcastAssist(party, dungeonId));
    }
Example #3
0
        public static void Process(GameSession session, string command)
        {
            string[] args = command.ToLower().Split(" ", 2);
            switch (args[0])
            {
            case "item":
                ProcessItemCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "npc":
                ProcessNpcCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "map":
                ProcessMapCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "coord":
                session.SendNotice(session.FieldPlayer.Coord.ToString());
                break;

            case "battleof":
                session.Send(UserBattlePacket.UserBattle(session.FieldPlayer, false));
                break;

            case "notice":
                if (args.Length <= 1)
                {
                    break;
                }
                MapleServer.BroadcastPacketAll(NoticePacket.Notice(args[1]));
                break;
            }
        }
        public async Task Start()
        {
            MapleServer.BroadcastPacketAll(GlobalPortalPacket.Notice(this));

            await Task.Delay(60000);

            MapleServer.BroadcastPacketAll(GlobalPortalPacket.Clear(this));
            GameServer.GlobalEventManager.RemoveEvent(this);
        }
        public override void Handle(GameSession session, PacketReader packet)
        {
            ChatType type      = (ChatType)packet.ReadInt();
            string   message   = packet.ReadUnicodeString();
            string   recipient = packet.ReadUnicodeString();

            packet.ReadLong();

            GameCommandActions.Process(session, message);

            switch (type)
            {
            case ChatType.Channel:     //TODO: Send to all players on current channel
                break;

            case ChatType.Super:
            case ChatType.World:
                //Send to all players online
                MapleServer.BroadcastPacketAll(ChatPacket.Send(session.Player, message, type));
                break;

            case ChatType.GuildNotice:
            case ChatType.Guild:
                //TODO: Send to all in guild
                break;

            case ChatType.Party:
                Party party = GameServer.PartyManager.GetPartyById(session.Player.PartyId);
                if (party != null)
                {
                    party.BroadcastPacketParty(ChatPacket.Send(session.Player, message, type));
                }
                break;

            case ChatType.WhisperTo:
                Player recipientPlayer = GameServer.Storage.GetPlayerByName(recipient);

                if (recipientPlayer != null)
                {
                    recipientPlayer.Session.Send(ChatPacket.Send(session.Player, message, ChatType.WhisperFrom));
                    session.Send(ChatPacket.Send(recipientPlayer, message, ChatType.WhisperTo));
                }
                else
                {
                    session.Send(ChatPacket.Send(session.Player, "Player not found or they are not online.", ChatType.WhisperFail));
                }
                break;

            default:
                session.FieldManager.SendChat(session.Player, message, type);
                break;
            }
        }
Example #6
0
    public override void Execute(GameCommandTrigger trigger)
    {
        string[] args = trigger.Get <string[]>("message");

        if (args == null || args.Length <= 1)
        {
            trigger.Session.SendNotice("No message provided.");
            return;
        }

        string message = CommandHelpers.BuildString(args, trigger.Session.Player.Name);

        MapleServer.BroadcastPacketAll(NoticePacket.Notice(message));
    }
Example #7
0
        private static void HandleWorldChat(GameSession session, string message, ChatType type)
        {
            Item voucher = session.Player.Inventory.Items.Values.FirstOrDefault(x => x.Tag == "FreeWorldChatCoupon");

            if (voucher != null)
            {
                session.Send(NoticePacket.Notice(SystemNotice.UsedWorldChatVoucher, NoticeType.ChatAndFastText));
                InventoryController.Consume(session, voucher.Uid, 1);
            }
            else if (!session.Player.Wallet.RemoveMerets(30))
            {
                session.Send(ChatPacket.Error(session.Player, SystemNotice.InsufficientMerets, ChatType.NoticeAlert));
                return;
            }

            MapleServer.BroadcastPacketAll(ChatPacket.Send(session.Player, message, type));
        }
Example #8
0
    private static void HandleGetHelp(GameSession session, PacketReader packet)
    {
        int dungeonId = packet.ReadInt();

        if (session.Player.Party == null)
        {
            Party newParty = new(session.Player);
            GameServer.PartyManager.AddParty(newParty);

            session.Send(PartyPacket.Create(newParty, false));
            session.Send(PartyPacket.PartyHelp(dungeonId));
            MapleServer.BroadcastPacketAll(DungeonHelperPacket.BroadcastAssist(newParty, dungeonId));

            return;
        }

        Party party = session.Player.Party;

        party.BroadcastPacketParty(PartyPacket.PartyHelp(dungeonId));
        MapleServer.BroadcastPacketAll(DungeonHelperPacket.BroadcastAssist(party, dungeonId));
    }
Example #9
0
        private static void HandleSuperChat(GameSession session, string message, ChatType type)
        {
            if (session.Player.SuperChat == 0)
            {
                return;
            }

            Item superChatItem = session.Player.Inventory.Items.Values.FirstOrDefault(x => x.Function.Id == session.Player.SuperChat);

            if (superChatItem == null)
            {
                session.Player.SuperChat = 0;
                session.Send(SuperChatPacket.Deselect(session.FieldPlayer));
                session.Send(ChatPacket.Error(session.Player, SystemNotice.InsufficientSuperChatThemes, ChatType.NoticeAlert));
                return;
            }

            MapleServer.BroadcastPacketAll(ChatPacket.Send(session.Player, message, type));
            InventoryController.Consume(session, superChatItem.Uid, 1);
            session.Send(SuperChatPacket.Deselect(session.FieldPlayer));
            session.Player.SuperChat = 0;
        }
        public static void Process(GameSession session, string command)
        {
            string[] args = command.ToLower().Split(" ", 2);
            switch (args[0])
            {
            case "setprestigelevel":
                session.Player.Levels.SetPrestigeLevel(ParseInt(session, args.Length > 1 ? args[1] : ""));
                break;

            case "setlevel":
                session.Player.Levels.SetLevel(ParseShort(session, args.Length > 1 ? args[1] : ""));
                break;

            case "gainprestigeexp":
                session.Player.Levels.GainPrestigeExp(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "gainexp":
                session.Player.Levels.GainExp(ParseInt(session, args.Length > 1 ? args[1] : ""));
                break;

            case "setvalor":
                session.Player.Wallet.ValorToken.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "settreva":
                session.Player.Wallet.Treva.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "setrue":
                session.Player.Wallet.Rue.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "sethavi":
                session.Player.Wallet.HaviFruit.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "setmeso":
                session.Player.Wallet.Meso.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "setmeret":
                session.Player.Wallet.Meret.SetAmount(ParseLong(session, args.Length > 1 ? args[1] : ""));
                break;

            case "item":
                ProcessItemCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "npc":
                ProcessNpcCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "mob":
                ProcessMobCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "map":
                ProcessMapCommand(session, args.Length > 1 ? args[1] : "");
                break;

            case "coord":
                session.SendNotice(session.FieldPlayer.Coord.ToString());
                break;

            case "battleoff":
                session.Send(UserBattlePacket.UserBattle(session.FieldPlayer, false));
                break;

            case "notice":
                if (args.Length <= 1)
                {
                    break;
                }
                MapleServer.BroadcastPacketAll(NoticePacket.Notice(args[1]));
                break;
            }
        }