Page 1 of 1

Updating Quests

Posted: Tue Dec 30, 2008 2:54 pm
by JCL
I've been testing npc's and made a couple to test quests. Here is some code: (Built off crab quest)

Code: Select all

    [function Init(Quest)
       RegisterQuest(Quest, "Kill Roots", "Hallmark", "Queen's Colony", 1, "Rayvor is deathly afraid of roots and wants you to kill some of them for him.")

       AddQuestRewardCoin(Quest, 25)

       SetQuestRewardExp(Quest, 200)

       SetQuestPrereqLevel(Quest, 1)
          
       AddQuestStepKill(Quest, 1, "Kill 1 of the roots nearby.", 1, "Kill roots for Sir Rayvor", "Kill roots for

    Sir Rayvor", 65)

       AddQuestStepCompleteAction(Quest, 1, "KilledAllRoots")

       SetCompletedDescription(Quest, "I have killed all of the roots.")

       QuestReturnNPC(Quest, 64)
    end

    function Accepted(Quest, QuestGiver, Player)
       if QuestGiver ~= nil then
          if GetDistance(Player, QuestGiver) < 30 then
             FaceTarget(QuestGiver, Player)
             Say(QuestGiver, "Thank you for accepting this task " .. GetName(Player) .. ". 

    Please return to me when you have completed it.")
             Emote(QuestGiver, " thanks you warmly.", Player)
          end
       end
    end

    function Declined(Quest, QuestGiver, Player)
       if QuestGiver ~= nil then
          if GetDistance(Player, QuestGiver) < 30 then
             FaceTarget(QuestGiver, Player)
             Say(QuestGiver, "If you change your mind " .. GetName(Player) .. ", you know

    where to find me.")
             Emote(QuestGiver, "waves goodbye.", Player)
          end
       end
    end

    function KilledAllRoots(Quest, QuestGiver, Player)
       UpdateQuestStepDescription(Quest, 1, "I killed the roots as Rayvor requested.")
       UpdateQuestDescription(Quest, "I killed some of the roots on the beach.  Return to Rayvor for your

    reward.")
    end
To shorten that up I have this that is not working right:

Code: Select all

AddQuestStepKill(Quest, 1, "Kill 1 of the roots nearby.", 1, "Kill roots for Sir Rayvor", "Kill roots for Sir Rayvor", 65)
Everything works, but I get "You did not find any quest items" when I kill the quest npc.

Edit: Found the problem. I was using this format:

Code: Select all

AddQuestStepKill(Quest, Step ID, Description, Quantity, TaskGroupText, NPC ID(s))
Should have been using this format: (The PercentChance)

Code: Select all

AddQuestStepKill(Quest, Step ID, Description, Quantity, PercentChance,TaskGroupText, NPC ID(s)

Re: Updating Quests

Posted: Tue Dec 30, 2008 3:07 pm
by LethalEncounter
The syntax for AddQuestStepKill and AddQuestStepObtainItem have been changed since that was created. Sorry about the trouble, I forgot to update those examples. The new format is:

Code: Select all

AddQuestStepObtainItem(Quest, Step (int), description (string), quantity (int), percentage (float), taskgroup (string), item_id (int), ...)

AddQuestStepKill(Quest, Step (int), description (string), quantity (int), percentage (float), taskgroup (string), npc_id (int), ...)
Note that the ... at the end of the functions means you can use multiple item_ids (or npc_ids) separated by commas.

Re: Updating Quests

Posted: Tue Dec 30, 2008 3:13 pm
by JCL
Yeah, I finally figured that out after reading the other LUA Functions txt file I had.

Thanks for the updates though. I didn't have the AddQuestStepObtainItem updated like that.

Edit: I did notice this posted in KillCrabs.lua: "These functions are shared, so don't save any character data in them."

So will my quests not be saved to the character after completed?

Re: Updating Quests

Posted: Tue Dec 30, 2008 3:30 pm
by Scatman
They will be saved into the database table character_quests upon completion. I think what he means by a shard function is that anytime a player runs that quest, the same function is used for every player.