Esempio n. 1
0
        public void Rewards(Aisling user, bool equipLoot)
        {
            foreach (var items in SkillRewards.Where(items => !Skill.GiveTo(user.Client, items)))
            {
            }

            foreach (var items in SpellRewards.Where(items => !Spell.GiveTo(user, items)))
            {
            }

            foreach (var obj in from items in ItemRewards
                     where ServerContextBase.GlobalItemTemplateCache.ContainsKey(items)
                     select ServerContextBase.GlobalItemTemplateCache[items]
                     into template
                     select Item.Create(user, template)
                     into obj
                     where !obj.GiveTo(user)
                     select obj)
            {
                obj.Release(user, user.Position);
            }

            foreach (var legends in LegendRewards)
            {
                user.LegendBook.AddLegend(new Legend.LegendItem
                {
                    Category = "Quest Reward",
                    Color    = legends.Color,
                    Icon     = legends.Icon,
                    Value    = legends.Value
                });
            }

            if (ExpRewards.Count > 0)
            {
                ExpRewards.ForEach(i => Monster.DistributeExperience(user, i));
            }

            if (GoldReward > 0)
            {
                user.GoldPoints += (int)GoldReward;
                user.Client.SendMessage(0x02, $"You are awarded {GoldReward} gold.");
            }

            if (equipLoot)
            {
                EquipRewards(user);
                user.Client.Refresh();
            }

            user.Client.SendStats(StatusFlags.All);
        }
Esempio n. 2
0
        public void OnCompleted(Aisling user)
        {
            var completeStages = QuestStages.Where(i => i.StepComplete).SelectMany(i => i.Prerequisites);

            foreach (var step in completeStages)
            {
                if (step.Type == QuestType.ItemHandIn)
                {
                    var obj = user.Inventory.Get(o => o.Template.Name == step.TemplateContext.Name)
                              .FirstOrDefault();

                    if (obj != null && obj.Template.Flags.HasFlag(ItemFlags.QuestRelated))
                    {
                        if (step.IsMet(user, b => b(obj.Template)))
                        {
                            user.Inventory.RemoveRange(user.Client, obj, step.Amount);
                        }
                    }
                }
            }


            Completed     = true;
            TimeCompleted = DateTime.Now;

            foreach (var items in SkillRewards)
            {
                if (!Skill.GiveTo(user.Client, items.Name))
                {
                    Completed = false;
                    return;
                }
            }

            foreach (var legends in LegendRewards)
            {
                user.LegendBook.AddLegend(new Legend.LegendItem
                {
                    Category = "Quest Reward",
                    Color    = legends.Color,
                    Icon     = legends.Icon,
                    Value    = legends.Value
                });
            }

            Rewarded = true;
        }
Esempio n. 3
0
        public void Rewards(Aisling user, bool equipLoot)
        {
            foreach (var items in SkillRewards)
            {
                if (!Skill.GiveTo(user.Client, items))
                {
                }
            }


            foreach (var items in SpellRewards)
            {
                if (!Spell.GiveTo(user, items))
                {
                }
            }

            foreach (var items in ItemRewards)
            {
                if (ServerContext.GlobalItemTemplateCache.ContainsKey(items))
                {
                    var template = ServerContext.GlobalItemTemplateCache[items];

                    var obj = Item.Create(user, template);
                    if (!obj.GiveTo(user))
                    {
                        obj.Release(user, user.Position);
                    }
                }
            }

            foreach (var legends in LegendRewards)
            {
                user.LegendBook.AddLegend(new Legend.LegendItem
                {
                    Category = "Quest Reward",
                    Color    = legends.Color,
                    Icon     = legends.Icon,
                    Value    = legends.Value
                });
            }


            if (ExpRewards.Count > 0)
            {
                ExpRewards.ForEach(i => Monster.DistributeExperience(user, i));
            }


            if (GoldReward > 0)
            {
                user.GoldPoints += (int)GoldReward;
                user.Client.SendMessage(0x02, string.Format("You are awarded {0} gold.", GoldReward));
            }

            if (equipLoot)
            {
                EquipRewards(user);
                user.Client.Refresh();
            }

            user.Client.SendStats(StatusFlags.All);
        }