Ejemplo n.º 1
0
        private static void HandleUpgradeBuff(GameSession session, PacketReader packet)
        {
            int buffId = packet.ReadInt();

            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null)
            {
                return;
            }

            GuildBuff buff = guild.Buffs.First(x => x.Id == buffId);

            // get next level's data
            GuildBuffLevel metadata = GuildBuffMetadataStorage.GetGuildBuffLevelData(buffId, buff.Level + 1);

            GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp);

            if (guildProperty.Level < metadata.LevelRequirement)
            {
                return;
            }

            if (guild.Funds < metadata.UpgradeCost)
            {
                return;
            }

            guild.ModifyFunds(session, guildProperty, -metadata.UpgradeCost);
            buff.Level++;
            guild.BroadcastPacketGuild(GuildPacket.UpgradeBuff(buffId, buff.Level, session.Player.Name));
        }
Ejemplo n.º 2
0
        protected override List <GuildBuffMetadata> Parse()
        {
            List <GuildBuffMetadata> buffs = new List <GuildBuffMetadata>();
            Dictionary <int, List <GuildBuffLevel> > buffLevels = new Dictionary <int, List <GuildBuffLevel> >();

            foreach (PackFileEntry entry in Resources.XmlFiles)
            {
                if (!entry.Name.StartsWith("table/guildbuff"))
                {
                    continue;
                }

                // Parse XML
                XmlDocument document      = Resources.XmlMemFile.GetDocument(entry.FileHeader);
                XmlNodeList contributions = document.SelectNodes("/ms2/guildBuff");

                foreach (XmlNode contribution in contributions)
                {
                    int   buffId                = int.Parse(contribution.Attributes["id"].Value);
                    byte  level                 = byte.Parse(contribution.Attributes["level"].Value);
                    int   additionalEffectId    = int.Parse(contribution.Attributes["additionalEffectId"].Value);
                    byte  additionalEffectLevel = byte.Parse(contribution.Attributes["additionalEffectLevel"].Value);
                    byte  levelRequirement      = byte.Parse(contribution.Attributes["requireLevel"].Value);
                    int   upgradeCost           = int.Parse(contribution.Attributes["upgradeCost"].Value);
                    int   cost     = int.Parse(contribution.Attributes["cost"].Value);
                    short duration = short.Parse(contribution.Attributes["duration"].Value);

                    GuildBuffLevel buffLevel = new GuildBuffLevel()
                    {
                        Level            = level,
                        EffectId         = additionalEffectId,
                        EffectLevel      = additionalEffectLevel,
                        LevelRequirement = levelRequirement,
                        UpgradeCost      = upgradeCost,
                        Cost             = cost,
                        Duration         = duration
                    };

                    if (buffLevels.ContainsKey(buffId))
                    {
                        buffLevels[buffId].Add(buffLevel);
                    }
                    else
                    {
                        buffLevels[buffId] = new List <GuildBuffLevel>()
                        {
                            buffLevel
                        };
                    }
                }
                foreach (KeyValuePair <int, List <GuildBuffLevel> > buffData in buffLevels)
                {
                    GuildBuffMetadata metadata = new GuildBuffMetadata();
                    metadata.BuffId = buffData.Key;
                    metadata.Levels.AddRange(buffData.Value);
                    buffs.Add(metadata);
                }
            }
            return(buffs);
        }
Ejemplo n.º 3
0
        private static void HandleUseBuff(GameSession session, PacketReader packet)
        {
            int buffId = packet.ReadInt();

            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null)
            {
                return;
            }

            int buffLevel = guild.Buffs.FirstOrDefault(x => x.Id == buffId).Level;

            GuildBuffLevel buff = GuildBuffMetadataStorage.GetGuildBuffLevelData(buffId, buffLevel);

            if (buff == null)
            {
                return;
            }

            if (buffId > 1000)
            {
                if (!session.Player.Wallet.Meso.Modify(-buff.Cost))
                {
                    return;
                }
            }
            else
            {
                if (buff.Cost > guild.Funds)
                {
                    return;
                }
                guild.Funds -= buff.Cost;
            }
            session.Send(GuildPacket.ActivateBuff(buffId));
            session.Send(GuildPacket.UseBuffNotice(buffId));
        }