Beispiel #1
0
        public static void DistributeAP(Character character, CharacterConstants.StatisticType type, short amount = 1)
        {
            switch (type)
            {
            case CharacterConstants.StatisticType.Strength:
                character.Strength += amount;
                break;

            case CharacterConstants.StatisticType.Dexterity:
                character.Dexterity += amount;
                break;

            case CharacterConstants.StatisticType.Intelligence:
                character.Intelligence += amount;
                break;

            case CharacterConstants.StatisticType.Luck:
                character.Luck += amount;
                break;

            case CharacterConstants.StatisticType.MaxHealth:
                // TODO: Get addition based on other factors.
                break;

            case CharacterConstants.StatisticType.MaxMana:
                // TODO: Get addition based on other factors.
                break;
            }
        }
Beispiel #2
0
        public void AutoDistributeAP(Packet inPacket)
        {
            if (AbilityPoints == 0)
            {
                return;
            }

            int ticks = inPacket.ReadInt();
            int count = inPacket.ReadInt(); // NOTE: There are always 2 primary stats for each job, but still.

            int total = 0;

            for (int i = 0; i < count; i++)
            {
                CharacterConstants.StatisticType type = (CharacterConstants.StatisticType)inPacket.ReadInt();
                int amount = inPacket.ReadInt();

                if (amount > AbilityPoints || amount < 0)
                {
                    return;
                }

                DistributeAP(Parent, type, (short)amount);
                total += amount;
            }

            AbilityPoints -= (short)total;
        }
Beispiel #3
0
        public static void FillToFull(Character character, CharacterConstants.StatisticType typeToFill)
        {
            if (character == null)
            {
                return;
            }
            if (IsAtMaxHP(character) || IsAtMaxMP(character))
            {
                return;
            }

            switch (typeToFill)
            {
            case CharacterConstants.StatisticType.Mana:
                character.Stats.Health = character.Stats.MaxHealth;
                Update(character, CharacterConstants.StatisticType.Health);
                break;

            case CharacterConstants.StatisticType.Health:
                character.Stats.Mana = character.Stats.MaxMana;
                Update(character, CharacterConstants.StatisticType.Mana);
                break;

                // TODO: fill other stats?
            }
        }
Beispiel #4
0
        public void CharDistributeAPHandler(Packet inPacket)
        {
            if (AbilityPoints == 0)
            {
                return;
            }

            int ticks = inPacket.ReadInt();

            CharacterConstants.StatisticType type = (CharacterConstants.StatisticType)inPacket.ReadInt();

            DistributeAP(Parent, type);
            AbilityPoints--;
        }
Beispiel #5
0
        public void UseCashItem(Packet iPacket)
        {
            short slot     = iPacket.ReadShort();
            int   itemID   = iPacket.ReadInt();
            bool  itemUsed = false;

            Item item = this[ItemConstants.ItemType.Cash, slot];

            if (item == null || itemID != item.MapleID)
            {
                return;
            }

            switch (item.MapleID)
            {
                #region TeleportRocks
            case (int)ItemConstants.UsableCashItems.TeleportRock:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.CokeTeleportRock:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.VIPTeleportRock:
            {
                itemUsed = this.Parent.Trocks.Use(itemID, iPacket);
            }
            break;
                #endregion

                #region AP/SP Reset
            case (int)ItemConstants.UsableCashItems.APReset:
            {
                CharacterConstants.StatisticType statDestination = (CharacterConstants.StatisticType)iPacket.ReadInt();
                CharacterConstants.StatisticType statSource      = (CharacterConstants.StatisticType)iPacket.ReadInt();

                CharacterStats.AddAbility(this.Parent, statDestination, 1, true);
                CharacterStats.AddAbility(this.Parent, statSource, -1, true);

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.SPReset1stJob:
            {
                if (!CharacterJobs.IsFirstJob(this.Parent))
                {
                    return;
                }
                //TODO: skill change
                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.SPReset2stJob:
            {
                if (!CharacterJobs.IsSecondJob(this.Parent))
                {
                    return;
                }
                //TODO: skill change
                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.SPReset3stJob:
            {
                if (!CharacterJobs.IsThirdJob(this.Parent))
                {
                    return;
                }
                //TODO: skill change
                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.SPReset4stJob:
            {
                if (!CharacterJobs.IsFourthJob(this.Parent))
                {
                    return;
                }
                //TODO: skill change
                itemUsed = true;
            }
            break;
                #endregion

                #region ItemTags/ItemGuards
            case (int)ItemConstants.UsableCashItems.ItemTag:
            {
                short targetSlot = iPacket.ReadShort();
                if (targetSlot == 0)
                {
                    return;
                }

                Item targetItem = this[ItemConstants.ItemType.Equipment, targetSlot];
                if (targetItem == null)
                {
                    return;
                }

                targetItem.Creator = this.Parent.Name;
                targetItem.Update();     // TODO: This does not seem to update the item's creator.

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.ItemGuard:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.Incubator:     //doest belong here by name only by ordering of usableCashItemsID
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ItemGuard7Days:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ItemGuard30Days:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ItemGuard90Days:
            {
            }
            break;
                #endregion

                #region Megaphones/Messengers
            case (int)ItemConstants.UsableCashItems.CheapMegaphone:
            {
                // NOTE: You can't use a megaphone unless you're over level 10.
                if (this.Parent.Level < 11)
                {
                    return;
                }

                string text    = iPacket.ReadString();
                string message = string.Format($"{this.Parent.Name} : {text}");         // TODO: Include medal name.

                // NOTE: In GMS, this sends to everyone on the current channel, not the map (despite the item's description).
                using (Packet oPacket = new Packet(ServerOperationCode.BroadcastMsg))
                {
                    oPacket
                    .WriteByte((byte)NoticeType.Megaphone)
                    .WriteString(message);

                    //this.Parent.Client.Channel.Broadcast(oPacket);
                }

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.Megaphone:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }

                string text    = iPacket.ReadString();
                string message = string.Format($"{this.Parent.Name} : {text}");         // TODO: Include medal name.

                // NOTE: In GMS, this sends to everyone on the current channel, not the map (despite the item's description).
                using (Packet oPacket = new Packet(ServerOperationCode.BroadcastMsg))
                {
                    oPacket
                    .WriteByte((byte)NoticeType.Megaphone)
                    .WriteString(message);

                    //this.Parent.Client.Channel.Broadcast(oPacket);
                }

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.SuperMegaphone:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }

                string text    = iPacket.ReadString();
                bool   whisper = iPacket.ReadBool();

                string message = string.Format($"{this.Parent.Name} : {text}");         // TODO: Include medal name.

                using (Packet oPacket = new Packet(ServerOperationCode.BroadcastMsg))
                {
                    oPacket
                    .WriteByte((byte)NoticeType.SuperMegaphone)
                    .WriteString(message)
                    .WriteByte(WvsGame.ChannelID)
                    .WriteBool(whisper);

                    //this.Parent.Client.World.Broadcast(oPacket);
                }

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.HeartMegaphone:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.SkullMegaphone:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.MapleTVMessenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.MapleTVStarMessenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.MapleTVHeartMessenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.Megassenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.StarMegassenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.HeartMegassenger:
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }
            }
            break;

            case (int)ItemConstants.UsableCashItems.ItemMegaphone:     // NOTE: Item Megaphone.
            {
                if (this.Parent.Level < 11)
                {
                    return;
                }

                string text        = iPacket.ReadString();
                bool   whisper     = iPacket.ReadBool();
                bool   includeItem = iPacket.ReadBool();

                Item targetItem = null;

                if (includeItem)
                {
                    ItemConstants.ItemType type = (ItemConstants.ItemType)iPacket.ReadInt();
                    short targetSlot            = iPacket.ReadShort();

                    targetItem = this[type, targetSlot];

                    if (targetItem == null)
                    {
                        return;
                    }
                }

                string message = string.Format($"{this.Parent.Name} : {text}");         // TODO: Include medal name.

                using (Packet oPacket = new Packet(ServerOperationCode.BroadcastMsg))
                {
                    oPacket
                    .WriteByte((byte)NoticeType.ItemMegaphone)
                    .WriteString(message)
                    .WriteByte(WvsGame.ChannelID)
                    .WriteBool(whisper)
                    .WriteByte((byte)(targetItem != null ? targetItem.Slot : 0));

                    if (targetItem != null)
                    {
                        oPacket.WriteBytes(targetItem.ToByteArray(true));
                    }

                    //this.Parent.Client.World.Broadcast(oPacket);
                }

                itemUsed = true;
            }
            break;
                #endregion

                #region FloatingMessage
            case (int)ItemConstants.UsableCashItems.KoreanKite:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.HeartBalloon:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.GraduationBanner:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.AdmissionBanner:
            {
            }
            break;
                #endregion

                #region otherStuff
            case (int)ItemConstants.UsableCashItems.Note:     // NOTE: Memo.
            {
                //string targetName = iPacket.ReadString();
                //string message = iPacket.ReadString();

                //if (this.Parent.Client.World.IsCharacterOnline(targetName))
                //{
                //    using (Packet oPacket = new Packet(ServerOperationCode.MemoResult))
                //    {
                //        oPacket
                //            .WriteByte((byte)MemoResult.Error)
                //            .WriteByte((byte)MemoError.ReceiverOnline);

                //        this.Parent.Client.Send(oPacket);
                //    }
                //}
                //else if (!Database.Exists("characters", "Name = {0}", targetName))
                //{
                //    using (Packet oPacket = new Packet(ServerOperationCode.MemoResult))
                //    {
                //        oPacket
                //            .WriteByte((byte)MemoResult.Error)
                //            .WriteByte((byte)MemoError.ReceiverInvalidName);

                //        this.Parent.Client.Send(oPacket);
                //    }
                //}
                //else if (false) // TODO: Receiver's inbox is full. I believe the maximum amount is 5, but need to verify.
                //{
                //    using (Packet oPacket = new Packet(ServerOperationCode.MemoResult))
                //    {
                //        oPacket
                //            .WriteByte((byte)MemoResult.Error)
                //            .WriteByte((byte)MemoError.ReceiverInboxFull);

                //        this.Parent.Client.Send(oPacket);
                //    }
                //}
                //else
                //{
                //    Datum datum = new Datum("memos");

                //    datum["CharacterID"] = Database.Fetch("characters", "ID", "Name = {0}", targetName);
                //    datum["Sender"] = this.Parent.Name;
                //    datum["Message"] = message;
                //    datum["Received"] = DateTime.Now;

                //    datum.Insert();

                //    using (Packet oPacket = new Packet(ServerOperationCode.MemoResult))
                //    {
                //        oPacket.WriteByte((byte)MemoResult.Sent);

                //        this.Parent.Client.Send(oPacket);
                //    }

                //    used = true;
                //}
            }
            break;

            case (int)ItemConstants.UsableCashItems.CongratulatorySong:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.PetNameTag:
            {
                //// TODO: Get the summoned pet.

                //string name = iPacket.ReadString();

                //using (Packet oPacket = new Packet(ServerOperationCode.PetNameChanged))
                //{
                //    oPacket
                //        .WriteInt(this.Parent.ID)
                //        .WriteByte() // NOTE: Index.
                //        .WriteString(name)
                //        .WriteByte();

                //    this.Parent.Map.Broadcast(oPacket);
                //}
            }
            break;

            case (int)ItemConstants.UsableCashItems.BronzeSackofMesos:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.SilverSackofMesos:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.GoldSackofMesos:
            {
                this.Parent.Meso += item.Meso;

                // TODO: We definitely need a GainMeso method with inChat parameter.
                using (Packet oPacket = new Packet(ServerOperationCode.Message))
                {
                    oPacket
                    .WriteByte((byte)MessageType.IncreaseMeso)
                    .WriteInt(item.Meso)
                    .WriteShort();

                    this.Parent.Client.Send(oPacket);
                }

                itemUsed = true;
            }
            break;

            case (int)ItemConstants.UsableCashItems.FungusScroll:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.OinkerDelight:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ZetaNightmare:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ChalkBoard:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ChalkBoard2:
            {
                string text = iPacket.ReadString();
                this.Parent.Chalkboard = text;
            }
            break;

            case (int)ItemConstants.UsableCashItems.ScissorsofKarma:
            {
            }
            break;

            case (int)ItemConstants.UsableCashItems.ViciousHammer:
            {
            }
            break;
                #endregion
            }

            if (itemUsed)
            {
                this.Remove(itemID, 1);
            }
            else
            {
                Character.Release(this.Parent);  // TODO: Blank inventory update.
            }
        }
Beispiel #6
0
        //TODO: hp/mp modification bugs out UI bars, add multiple stats, some kind of message to sideBar/chat
        public static void giveStat(Character player, CharacterConstants.StatisticType stat, short quantity)
        {
            switch (stat)
            {
            case CharacterConstants.StatisticType.Strength:
                int totalStrenght = player.Strength + quantity;

                if (totalStrenght < Int16.MaxValue)
                {
                    player.Strength += quantity;
                    Update(player, CharacterConstants.StatisticType.Strength);
                    break;
                }

                else
                {
                    player.Strength = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Strength);
                    break;
                }

            case CharacterConstants.StatisticType.Dexterity:
                int totalDexterity = player.Dexterity + quantity;

                if (totalDexterity < Int16.MaxValue)
                {
                    player.Dexterity += quantity;
                    Update(player, CharacterConstants.StatisticType.Dexterity);
                    break;
                }

                else
                {
                    player.Dexterity = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Dexterity);
                    break;
                }

            case CharacterConstants.StatisticType.Intelligence:
                int totalIntelligence = player.Intelligence + quantity;

                if (totalIntelligence < Int16.MaxValue)
                {
                    player.Intelligence += quantity;
                    Update(player, CharacterConstants.StatisticType.Intelligence);
                    break;
                }

                else
                {
                    player.Intelligence = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Intelligence);
                    break;
                }

            case CharacterConstants.StatisticType.Luck:
                int totalLuck = player.Luck + quantity;


                if (totalLuck < Int16.MaxValue)
                {
                    player.Luck += quantity;
                    Update(player, CharacterConstants.StatisticType.Luck);
                    break;
                }

                else
                {
                    player.Luck = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Luck);
                    break;
                }

            case CharacterConstants.StatisticType.Health:
                int totalHealth = player.Health + quantity;

                if (totalHealth < Int16.MaxValue)
                {
                    player.Health += quantity;
                    Update(player, CharacterConstants.StatisticType.Health);
                    break;
                }

                else
                {
                    player.Health = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Health);
                    break;
                }

            case CharacterConstants.StatisticType.MaxHealth:
                int totalMaxHealth = player.MaxHealth + quantity;

                if (totalMaxHealth < Int16.MaxValue)
                {
                    player.MaxHealth += quantity;
                    Update(player, CharacterConstants.StatisticType.MaxHealth);
                    break;
                }

                else
                {
                    player.MaxHealth = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.MaxHealth);
                    break;
                }

            case CharacterConstants.StatisticType.Mana:
                int totalMana = player.Mana + quantity;

                if (totalMana < Int16.MaxValue)
                {
                    player.Mana += quantity;
                    Update(player, CharacterConstants.StatisticType.Mana);
                    break;
                }

                else
                {
                    player.Mana = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.Mana);
                    break;
                }

            case CharacterConstants.StatisticType.MaxMana:
                int totalMaxMana = player.MaxMana + quantity;

                if (totalMaxMana < Int16.MaxValue)
                {
                    player.MaxMana += quantity;
                    Update(player, CharacterConstants.StatisticType.MaxMana);
                    break;
                }

                else
                {
                    player.MaxMana = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.MaxMana);
                    break;
                }

            case CharacterConstants.StatisticType.AbilityPoints:
                int totalAbilityPoints = player.AbilityPoints + quantity;

                if (totalAbilityPoints < Int16.MaxValue)
                {
                    player.AbilityPoints += quantity;
                    Update(player, CharacterConstants.StatisticType.AbilityPoints);
                    break;
                }

                else
                {
                    player.AbilityPoints = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.AbilityPoints);
                    break;
                }

            case CharacterConstants.StatisticType.SkillPoints:
                int totalSkillPoints = player.SkillPoints + quantity;

                if (totalSkillPoints < Int16.MaxValue)
                {
                    player.SkillPoints += quantity;
                    Update(player, CharacterConstants.StatisticType.SkillPoints);
                    break;
                }
                else
                {
                    player.SkillPoints = Int16.MaxValue;
                    Update(player, CharacterConstants.StatisticType.SkillPoints);
                    break;
                }

            case CharacterConstants.StatisticType.Skin: break;

            case CharacterConstants.StatisticType.Face: break;

            case CharacterConstants.StatisticType.Hair: break;

            case CharacterConstants.StatisticType.Level: break;

            case CharacterConstants.StatisticType.Job: break;

            case CharacterConstants.StatisticType.Experience: break;

            case CharacterConstants.StatisticType.Fame: break;

            case CharacterConstants.StatisticType.Mesos: break;

            case CharacterConstants.StatisticType.Pet: break;

            case CharacterConstants.StatisticType.GachaponExperience: break;

            default: throw new ArgumentOutOfRangeException(nameof(stat), stat, null);
            }
        }
Beispiel #7
0
        public static void AddAbility(Character character, CharacterConstants.StatisticType statistic, short mod, bool isReset)
        {
            short maxStat    = Int16.MaxValue; // TODO: Should this be a setting?
            bool  isSubtract = mod < 0;

            lock (character)
            {
                switch (statistic)
                {
                case CharacterConstants.StatisticType.Strength:
                    if (character.Strength >= maxStat)
                    {
                        return;
                    }

                    character.Strength += mod;
                    break;

                case CharacterConstants.StatisticType.Dexterity:
                    if (character.Dexterity >= maxStat)
                    {
                        return;
                    }

                    character.Dexterity += mod;
                    break;

                case CharacterConstants.StatisticType.Intelligence:
                    if (character.Intelligence >= maxStat)
                    {
                        return;
                    }

                    character.Intelligence += mod;
                    break;

                case CharacterConstants.StatisticType.Luck:
                    if (character.Luck >= maxStat)
                    {
                        return;
                    }

                    character.Luck += mod;
                    break;

                case CharacterConstants.StatisticType.MaxHealth:
                case CharacterConstants.StatisticType.MaxMana:
                {
                    // TODO: character is way too complicated for now.
                }
                break;
                }

                if (!isReset)
                {
                    character.AbilityPoints -= mod;
                }

                // TODO: Update bonuses.
            }
        }
Beispiel #8
0
        public override void Execute(Character caller, string[] args)
        {
            if (args.Length < 1)
            {
                ShowSyntax(caller);
            }
            else
            {
                short quantity = 0;

                if (args.Length > 1)
                {
                    short.TryParse(args[args.Length - 1], out quantity);
                }

                if (quantity < 1)
                {
                    quantity = 1;
                }

                string stat = args[0];
                CharacterConstants.StatisticType type = CharacterConstants.StatisticType.None;

                switch (stat)
                {
                case "str":
                    type = CharacterConstants.StatisticType.Strength;
                    break;

                case "dex":
                    type = CharacterConstants.StatisticType.Dexterity;
                    break;

                case "int":
                    type = CharacterConstants.StatisticType.Intelligence;
                    break;

                case "luck":
                    type = CharacterConstants.StatisticType.Luck;
                    break;

                case "hp":
                    type = CharacterConstants.StatisticType.Health;
                    break;

                case "maxhp":
                    type = CharacterConstants.StatisticType.MaxHealth;
                    break;

                case "mp":
                    type = CharacterConstants.StatisticType.Mana;
                    break;

                case "maxmp":
                    type = CharacterConstants.StatisticType.MaxMana;
                    break;

                case "ap":
                    type = CharacterConstants.StatisticType.AbilityPoints;
                    break;

                case "sp":
                    type = CharacterConstants.StatisticType.SkillPoints;
                    break;
                }

                CharacterStats.giveStat(caller, type, quantity);
            }
        }