Page 1 of 1

Quest check GTK

Posted: Wed Jul 08, 2015 4:47 pm
by Emera Nova
So much like my shops I'm having some issues getting my quests to work correctly with GTK.

As it is I have a npc ask the player to go check on something. But much to my displeaseure if you accept the quest then talk to him afterwards u can turn it in for the reward.. I need a way to force the player to u know do the quest..

So what I was thinking might work is to do something like

Code: Select all

function checkquest()
	counter_2:getValue()
		if counter_2:getValue() = 1 then
		nextPage = "questfinished"
		else
		nextPage = "questinprogress"
	end
end
My problem is one I don't know if that is set up correctly as I don't program so I stumble around with setting stuff up. I think this is correct but my worry is the start of the if statement.
If you have suggestions of a better way of coding that section let me know.

Re: Quest check GTK

Posted: Wed Jul 08, 2015 6:10 pm
by cromcrom
Corrected two errors it seems, although I am not a great coder :-(

Code: Select all

function checkquest()
   if counter_2:getValue() == 1 then
      nextPage = "questfinished"
      else
      nextPage = "questinprogress"
   end
end

Re: Quest check GTK

Posted: Wed Jul 08, 2015 6:15 pm
by THOM
I think in LoG2 it has to be

Code: Select all

counter_2.counter:getValue() 

Re: Quest check GTK

Posted: Wed Jul 08, 2015 6:49 pm
by Emera Nova
Welp I ran this

Code: Select all

function checkquest()
   if counter_2.counter:getValue() == 1 then
      nextPage = "questfinished"
      else
      nextPage = "questinprogress"
   end
end
And nothing happens, everything talks correctly up until it runs that then it just ends the convo..

Re: Quest check GTK

Posted: Wed Jul 08, 2015 7:08 pm
by Emera Nova
For those intrested this is the entire script atm in my .lua file..

Code: Select all

isDone = false;
givenQuest = false;

function key()
	setMouseItem(spawn("skull_key").item);
	givenQuest = true;
end

function shop2()
	setMouseItem(spawn("long_sword").item);
end


function checkquest()
   if counter_2.counter:getValue() == 1 then
      nextPage = "questfinished"
      else
      nextPage = "questinprogress"
   end
end


function showDemoDialogue(sender)
	if ( isDone == true ) then
		return;
	end

	local startPage = nil;

	if ( givenQuest == false ) then
		startPage = "first";
		givenQuest = false;
	else 
		startPage = "return";
	end

	local dialogue = {
		lockParty = true,
		startPage = startPage,
		pages = {
			{
				id = "first",
				speakerName = "Talo'gaz",
				speakerMessage = "O'ye! You look like a tough lot, prehaps I could get you to check on something for me.",
				responses = {
					{ text = "Guess that depends on what it is..", nextPage = "onabout" },
					{ text = "We don't have time for this..", nextPage = "goodbye" },					
				} 
			},
			{
				id = "onabout",
				speakerName = "Talo'gaz",
				speakerMessage = "I think someone has been getting into the graves out back and pull up the bodies for fun, could I get you to go look around back there?",
				responses = {
					{ text = "Sure we have nothing better to do with out time.", nextPage = "key" },
					{ text = "Why don't you check it out?", nextPage = "toobusy"},
					{ text = "We don't have time to run errans at the moment.", nextPage = "goodbye"},
				}
			},				
			{
				id = "return",
				speakerName = "Talo'gaz",
				speakerMessage = "Have you finished those errans?",
				responses = {
					{ text = "Yes we have", onSelect = self.go.id .. ".script.checkquest" },
					{ text = "Nope just passing through..", nextPage = "goodbye" },					
				} 
			},
			{
				id = "questinprogress",
				speakerName = "Talo'gaz",
				speakerMessage = "No you havn't, otherwise my key would have come back to me.",
				responses = {
					{ text = "<Leave awkwardly because you got caught lying>", nextPage = "awkward" },
				}
			},
			{
				id = "questfinished",
				speakerName = "Talo'gaz",
				speakerMessage = "Thank goodness, what was it?",
				responses = {
					{ text = "<Lie> It was just some kids pulling a prank on you.", nextPage = "reward" },
					{ text = "<Truth> The bodies seem to be reanimating, we had to fight one of them off because it attacked us.", nextPage = "reward2" },
				}
			},
			{
				id = "key",
				speakerName = "Talo'gaz",
				speakerMessage = "Thanks here's the key to open the gate.",
				responses = {
					{ text = "Thanks.", onSelect = self.go.id .. ".script.key" },
				}
			},
			{
				id = "reward",
				speakerName = "Talo'gaz",
				speakerMessage = "Oh dear, just as I thought.. Bet it was the child from around the corner.. Well thanks for your help, take this it should help some with your journeys.",
				responses = {
					{ text = "Thanks.", onSelect = self.go.id .. ".script.shop2" },
				}
			},
			{
				id = "reward2",
				speakerName = "Talo'gaz",
				speakerMessage = "Oh dear, worse than I thought.. Guess I need to put up some enchantments.. Well thanks for your help, take this it should help some with your journeys.",
				responses = {
					{ text = "Thanks.", onSelect = self.go.id .. ".script.shop2" },
				}
			},
			{
				id = "goodbye",
				speakerName = "Talo'gaz",
				speakerMessage = "Until next time..",
				responses = {
					{ text = "<Leave>" },
				}
			},			
		}
	}

	GTKGui.Dialogue.startDialogue(dialogue);
end

function hideDemoDialogue()
	GTKGui.Dialogue.hideDialogue();
end
The dialogue is just place holding until I can get this to work better..

Re: Quest check GTK

Posted: Wed Jul 08, 2015 8:50 pm
by cromcrom
try this:

Code: Select all

questlevel = {}

function questStarted()
	questlevel.accomplishment = 1
	hudPrint("Party just received quest")
end
function questFinished()
	questlevel.accomplishment = 2
	hudPrint("Party just finished quest")
end


function giveReward()
  for i=1,4 do
         party.party:getChampion(i):gainExp(100)
      end 
end



function showDemoDialogue(sender)

   local startPage = nil;

	if questlevel.accomplishment == nil then
      startPage = "first";
   elseif questlevel.accomplishment == 1 then
      startPage = "return";
   elseif questlevel.accomplishment == 2 then 
       startPage = "quest_done";  
   end

   local dialogue = {
      lockParty = true,
      startPage = startPage,
      pages = {
         {
            id = "first",
            speakerName = "Talo'gaz",
            speakerMessage = "Hello, I want to give you a quest.",
            responses = {
               { text = "Mmmmkay, we accept", onSelect = self.go.id .. ".script.questStarted" },
               { text = "Too busy, so nope", nextPage = "goodbye" },               
            } 
         },
         {
            id = "return",
            speakerName = "Talo'gaz",
            speakerMessage = "Have you finished this quest?",
            responses = {
               { text = "Yes we have", onSelect = self.go.id .. ".script.questFinished", nextPage = "congratulations" },
               { text = "Nope just passing through..", nextPage = "goodbye" },               
            } 
         },
         {
            id = "congratulations",
            speakerName = "Talo'gaz",
            speakerMessage = "Thank goodness, you guys rock, and deserve a little experience.",
            responses = {
               { text = "My, thank you !", onSelect = self.go.id .. ".script.giveReward", nextPage = "quest_done" },
            }
         },
         {
            id = "quest_done",
            speakerName = "Talo'gaz",
            speakerMessage = "Thank you for doing this quest.",
            responses = {
               { text = "You are welcome" },

            }
         },		 
         {
            id = "goodbye",
            speakerName = "Talo'gaz",
            speakerMessage = "Until next time..",
            responses = {
               { text = "<Leave>" },
            }
         },         
      }
   }

   GTKGui.Dialogue.startDialogue(dialogue);
end

function hideDemoDialogue()
   GTKGui.Dialogue.hideDialogue();
end
Link it to a pressure plate or whatever to start it.
It's a very basic quest procedure.
3 stages:
giver give quest to party
giver ask party if quest is done.
giver thank party for fulfilling the quest (and party get a little XP reward)
But I think the exemple "Ogre" dialogue in grimTK would be more suited for this kind of quest.
Hope it helps.

Re: Quest check GTK

Posted: Thu Jul 09, 2015 10:45 am
by JohnWordsworth
Sorry for the slow response - I have had a look into this and I will add something to GrimTK at the weekend so that it's much easier to jump between pages from a callback method. In the current system, you would have to provide the full page object in a function call, which is a bit messy - so instead I will make it so that you can just do this...

Code: Select all

function checkquest()
   local nextPage = "questinprogress"

   if counter_2.counter:getValue() == 1 then
      nextPage = "questfinished"
   end

   return nextPage;
   -- OR
   GTKGui.Dialogue.showDialoguePage(nextPage);
end
NOTE: This won't work yet, but I will make it work over the weekend and upload a new version of GrimTK on Sunday!

Re: Quest check GTK

Posted: Thu Jul 09, 2015 5:47 pm
by cromcrom
Sounds great John, thank you so much :-)

Re: Quest check GTK

Posted: Sun Jul 12, 2015 9:38 pm
by JohnWordsworth
Done! You can now do something like the following in a response's onSelect callback to determine which page to show next dynamically...

Requires GrimTK Alpha 008

Code: Select all

function callback()
  if something == true then
    -- Jump to "page_name"
    GTKGui.Dialogue.showDialoguePage("page_name")
  end

  if somethingElse == true then
    -- Another way to jump, this time to "another_page_name".
    return "another_page_name"
  end

  -- Else close the dialogue
  return
end
Enjoy!