Page 1 of 1

StartDialogConversation enhancements

Posted: Sun Aug 11, 2013 10:03 pm
by thefoof
Okay, just posting to let yall know I finished up the cragged spine quests in frostfang today (Sometimes you feel like a knut was the most pain in the ass quest to script. ever.) Also I figured out why single item rewards were't showing - the queries in WorldDatabase.cpp were checking for subtype "Items", when we've always used it looks like (since milestone 1), "Item", so I fixed that.

EDIT: Looks like we don't support players having conversations with themselves so until that happens this quest won't work right.

Re: DB Milestone 2 - Planning

Posted: Sun Aug 11, 2013 11:38 pm
by Jabantiz
thefoof wrote:EDIT: Looks like we don't support players having conversations with themselves so until that happens this quest won't work right.
Have a fix for this just need to do a quick test to make sure nothing unexpected pops up.

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 12:39 am
by Jabantiz
I can start a conversation through an item or NPC with the player talking to themselves, however that is as far as the current system will allow us to go as the server will look for the call back function in the players spawn script...

A simple solution could be to hardcode players to have a spawn script, something like player.lua, then in that script we can have the call back functions.

Another solution could be to attempt to expand StartDialogConversation() lua function to take a third type for conversations like this and have the call back functions in the item/spawn script that starts this type of conversation.

Let me know which you all prefer or if you have another idea how to get past this limitation

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 8:05 am
by John Adams
Jabantiz wrote:Another solution could be to attempt to expand StartDialogConversation() lua function to take a third type for conversations like this and have the call back functions in the item/spawn script that starts this type of conversation.
I'm liking this option. "hard coding" never leaves me feeling happy.

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 1:35 pm
by thefoof
Jabantiz wrote:Another solution could be to attempt to expand StartDialogConversation() lua function to take a third type for conversations like this and have the call back functions in the item/spawn script that starts this type of conversation
Yep that sounds good to me too.

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 2:56 pm
by Jabantiz
Ok implemented the second option and it all seems to work, added a type = 3 and 4, 3 = spawn starts the self convo, 4 = item starts the self convo. Also want to remind you this is StartDialogConversation and not StartConversation. (StartDialogConversation is typically used for the blue box dialogs you get from item examines)

Code: Select all

-- Self convo started through a spawn
StartDialogConversation(conversation, 3, NPC, Player, "Test Dialog")
-- Self convo started through an item
StartDialogConversation(conversation, 4, Item, Player, "Test Dialog")
EDIT: Code committed

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 6:23 pm
by thefoof
Jabantiz wrote:Ok implemented the second option and it all seems to work, added a type = 3 and 4, 3 = spawn starts the self convo, 4 = item starts the self convo. Also want to remind you this is StartDialogConversation and not StartConversation. (StartDialogConversation is typically used for the blue box dialogs you get from item examines)

Code: Select all

-- Self convo started through a spawn
StartDialogConversation(conversation, 3, NPC, Player, "Test Dialog")
-- Self convo started through an item
StartDialogConversation(conversation, 4, Item, Player, "Test Dialog")
EDIT: Code committed
Okay I played around with this today, I can get the bubble for the first conversation to appear, but when selecting an option it doesn't pass you on to the next function for some reason.

Re: DB Milestone 2 - Planning

Posted: Mon Aug 12, 2013 7:34 pm
by Jabantiz
This is the spawn script I used to test this out and it all worked properly, can you try this on your side and see if it works?

Code: Select all

function hailed(NPC, Player)
	FaceTarget(NPC, Player)
	conversation = CreateConversation()

	AddConversationOption(conversation, "Test 1", "Choice1")
	AddConversationOption(conversation, "Exit")
	StartDialogConversation(conversation, 3, NPC, Player, "Test Dialog")
end

function Choice1(NPC, Player)
	con = CreateConversation()
	
	StartDialogConversation(con, 3, NPC, Player, "End Test")
end

Re: DB Milestone 2 - Planning

Posted: Tue Aug 13, 2013 2:07 pm
by thefoof
That script works, I've done some more testing though and I think I know the jist of what's going wrong.

The first bubble will always get called as long as you're using valid pointers, however when the server tries to call the passed function from the conversation option it won't go through if you are'nt close to the spawn that started the convo (it seems anyway).

The scripts I was trying were using item pointers to start the conversation as well so maybe there's some kind of range check when calling the next conversation function?

Re: DB Milestone 2 - Planning

Posted: Tue Aug 13, 2013 3:48 pm
by John Adams
You guys mind if I split this topic into it's own so it doesn't get lost in here?

Re: DB Milestone 2 - Planning

Posted: Tue Aug 13, 2013 4:12 pm
by Jabantiz
Go ahead, would probably be good for it to end up in a public forum.

Re: DB Milestone 2 - Planning

Posted: Sun Aug 25, 2013 11:15 pm
by Jabantiz
thefoof wrote:That script works, I've done some more testing though and I think I know the jist of what's going wrong.

The first bubble will always get called as long as you're using valid pointers, however when the server tries to call the passed function from the conversation option it won't go through if you are'nt close to the spawn that started the convo (it seems anyway).

The scripts I was trying were using item pointers to start the conversation as well so maybe there's some kind of range check when calling the next conversation function?
I was randomly looking at scripts today when I looked in frostfang.lua and saw this

Code: Select all

function GrizChat1(Zone, Spawn)
	if GetQuestStep(Spawn, SometimesKnut) == 1 then
		if HasItemEquipped(Spawn, 157116) then
			conversation = CreateConversation()
			AddConversationOption(conversation, "Ack!  I can hear you?", "GrizChat2")
			StartDialogConversation(conversation, 4, GetEquippedItemByID(Spawn, 157116), Spawn, "Prey's trail cold here.")
		end
	end
end

function GrizChat2(Zone, Spawn)
	conversation = CreateConversation()
	AddConversationOption(conversation, "I will never doubt him again.")
	StartDialogConversation(conversation, 4, GetEquippedItemByID(Spawn, 157116), Spawn, "Yes.  Griz real.  Knut's friend.")
end
While GrizChat1 is correct GrizChat2 should not be in the zone script as it is a callback function, it should be in an item script assigned to the item passed in the StartDialogConversation(). It should also be GrizChat2(Item, Spawn) as it is a call back in an item script.

All callback functions should be in the script assigned to the spawn or item given in StartDialogConversation()

Re: DB Milestone 2 - Planning

Posted: Sun Aug 25, 2013 11:49 pm
by thefoof
Jabantiz wrote:While GrizChat1 is correct GrizChat2 should not be in the zone script as it is a callback function, it should be in an item script assigned to the item passed in the StartDialogConversation(). It should also be GrizChat2(Item, Spawn) as it is a call back in an item script.

All callback functions should be in the script assigned to the spawn or item given in StartDialogConversation()
Okay just to be sure I understand that, running a conversation through an NPC or item whatever, when the function is called from a conversation option, it gets sent to the script on the NPC/item that initiated the conversation?

Re: StartDialogConversation enhancements

Posted: Mon Aug 26, 2013 1:01 am
by Jabantiz
That is correct

Re: StartDialogConversation enhancements

Posted: Mon Aug 26, 2013 3:54 pm
by thefoof
Thanks for the help Jab, reworked the quest scripts last night and this works great now :D