예제 #1
0
    /**
     * Everytime players make an action like interact with an npc, kill an npc or collect an object, etc.. QuestManager is notified
     * using this method, to check if that action is part of a mission
     */
    public void sendAction(int id, Task.ActorType type, Task.ActionType action, int quantity = 0, int extraId = 0)
    {
        foreach (Quest quest in quests.Values)
        {
            foreach (Task task in quest.tasks.Values)
            {
                if (task.type == type && task.action == action &&
                    ((task.type != Task.ActorType.NPC && task.id == id) ||
                     (task.type == Task.ActorType.NPC && ((task.idType == Task.IdType.Id && task.id == id) || (task.idType == Task.IdType.Template && task.id == extraId)))
                    )
                    )
                {
                    if (task.quantity > 0)
                    {
                        task.currentQuantity += quantity;
                        // update phrase too as it displays the current quantity
                        task.ui.setPhrase(task.buildPhrase());
                        task.ui.setStatus(task.isCompleted);
                    }

                    if (task.quantity == 0 || task.quantity == task.currentQuantity)
                    {
                        task.isCompleted = true;
                        task.ui.setStatus(task.isCompleted);
                    }
                    task.save();

                    break;
                }
            }
        }
    }
예제 #2
0
    public void addKill(int id, Task.ActorType type, int level, int damage, int totalHealth, int expValue, int templateId = 0)
    {
        int wonExp    = 0;
        int levelDiff = level - level;

        // do not give exp if player has > 3 levels than the killed npc
        if (levelDiff > -2)
        {
            if (damage >= totalHealth)
            {
                wonExp = expValue;
            }
            else
            {
                wonExp = expValue / 2;
            }
            exp += wonExp + (levelDiff * 10);
        }

        QuestManager.Instance.sendAction(id, type, Task.ActionType.Kill, 1, templateId);
    }