Пример #1
0
        public static IEnumerable <Rag2Item> UserQuestLoot(uint NpcId, Character Target)
        {
            Predicate <ObjectiveList.Loot> FindLootObjective =
                delegate(ObjectiveList.Loot Objective)
            {
                return(Objective.Npc == NpcId);
            };

            List <ObjectiveList.Loot> Loots =
                Target.QuestObjectives.LootObjectives.FindAll(FindLootObjective);

            if (Loots != null)
            {
                for (int i = 0; i < Loots.Count; i++)
                {
                    Rag2Item           myItem;
                    ObjectiveList.Loot objective = Loots[i];

                    if (Singleton.Item.TryGetItem(objective.ItemId, out myItem))
                    {
                        if (Singleton.Itemdrops.CheckAgainstDroprate(myItem, objective.Ratio, Target._DropRate))
                        {
                            yield return(myItem);
                        }
                    }
                }
            }
        }
Пример #2
0
        public static void UserObtainedItem(uint ItemId, Character Target)
        {
            Predicate <ObjectiveList.Loot> FindLootObjective =
                delegate(ObjectiveList.Loot Objective)
            {
                return(Objective.ItemId == ItemId);
            };


            ObjectiveList.Loot LootObjective =
                Target.QuestObjectives.LootObjectives.Find(FindLootObjective);
            ObjectiveList.SubStep Substep =
                null;

            if (LootObjective != null)
            {
                //Find Substep
                Predicate <ObjectiveList.SubStep> SubStepInfo =
                    delegate(ObjectiveList.SubStep Objective)
                {
                    return(Objective.StepId == LootObjective.StepId &&
                           Objective.SubStepId == LootObjective.SubStepId);
                };

                Substep = Target.QuestObjectives.Substeps.Find(SubStepInfo);
                if (Substep != null && Substep.current < Substep.max)
                {
                    //Send update
                    SMSG_QUESTSUBSTEPUPDATE spkt = new SMSG_QUESTSUBSTEPUPDATE();
                    spkt.Amount    = (byte)(++Substep.current);
                    spkt.QuestID   = LootObjective.Quest;
                    spkt.SessionId = Target.id;
                    spkt.StepID    = Substep.StepId;
                    spkt.SubStep   = (byte)Substep.SubStepId;
                    spkt.Unknown   = 1;
                    Target.client.Send((byte[])spkt);

                    //Find Objective
                    if (Substep.current >= Substep.max)
                    {
                        Substep.Completed = true;
                        Target.QuestObjectives[LootObjective.Quest].CheckQuest(Target);
                    }
                }
            }
        }