Window-based quest log
From VbGORE Visual Basic Online RPG Engine
Contents |
[edit] Information
This guide was written for v1.0.11, but should be applicable to most all of the 1.0.x releases. The goal of this guide is to add a visual quest log window that you can interact with rather than just having it all in the chat box.
[edit] Starting Off
To start things off, you'll need to edit a fair few things. Firstly, we will need to add the GRHs that we are going to use, in this example I have created 2 GRHs. These are named 145.png and 146.png
*Please click on these links and save the GRHs into GRH folder*
http://vbgore.com/Image:145.PNG
http://vbgore.com/Image:146.PNG
After adding both GRH 145 and 146 to the GRH folder, go to your vbGORE folder and open up Data2\GrhRaw.txt and add the following to entries at the end of the list:
Grh1500=1-145-0-0-128-256 Grh1501=1-146-0-0-256-256
Then simply run the ToolGRHDatMaker to create the Grh.dat file so the values can be used. If your GRHs are already in use, make sure to rename them and remember to rename the to the proper Grh values where appropriate.
[edit] The Skins
After adding the GRH and the values, we have to work on the skins to add the new window. Firstly, go to your edition of vbGORE. Just go to your vbGORE folder, then head off to Data\Skins and modify the appropriate skins (which in this case would be all - but for testing purposes edit the default one; it is usually Bluewave.ini).
Add the following to the end of the file:
[QUESTLOG] ScreenX=100 ScreenY=60 Alpha=200 ScreenWidth1=128 ScreenHeight1=256 Grh1=1500 ScreenWidth2=256 ScreenHeight2=256 Grh2=1501
Ok, your probably familiar with all of these values except for ALPHA. This is just a new value added for this window so you can specify the alpha (transparency, where 255 is opaque, 0 is invisible, and 128 is 50% transparency). Basically, I wanted the Quest Log to be super special, you are able to modify the transparency value of it, in case the user isn't happy with the damn thing :D
Next we need to modify the Custom Positions file (again, preferably all of them but for testing purposes just modify the default one - which in this case would be bluewave.dat).
Double click on bluewave.dat and open it with notepad... nice, you can open other things with notepad?
Anyways, add the following information to the end of the file
[QUESTLOG] ScreenX=100 ScreenY=100 Alpha=200
These values are important, or vbGORE would crash when it loads since the data is missing.
[edit] The code
Well... this part gets a teeny bit more annoying than usual, since we're going to have to add some code. Firstly, load up your vbGORE project, then head off down to and double click on TileEngine module.
Within TileEngine, find (Ctrl + F):
Public DrawSkillList As Byte 'If the skills list is to be drawn Public QuickBarSetSlot As Byte 'What slot on the quickbar was clicked to be set Public DragSourceWindow As Byte 'The window the item was dragged from Public DragItemSlot As Byte 'Holds what slot an item is being dragged from in the inventory
After, add:
Public QuestLogSelected As Byte
Find:
Public Const NumGameWindows As Byte = 13
Replace with:
Public Const QuestLogWindow As Byte = 14 Public Const NumGameWindows As Byte = 14
This will give an index to our new window, and tell the engine we have a total of 14 windows now.
Find:
Public Type GameWindow 'List of all the different game windows QuickBar As WindowQuickBar Inventory As WindowInventory Shop As WindowInventory Mailbox As WindowMailbox ViewMessage As WindowMessage WriteMessage As WindowMessage Amount As WindowAmount Menu As WindowMenu ChatWindow As ChatWindow StatWindow As StatWindow Bank As WindowInventory NPCChat As WindowNPCChat Trade As TradeWindow End Type
Replace with:
'Information for our new quest window Public Type dQuestLogWindow Screen As Rectangle Screen2 As Rectangle SkinGrh As Grh SkinGrh2 As Grh Alpha As Byte End Type Public Type GameWindow 'List of all the different game windows QuickBar As WindowQuickBar Inventory As WindowInventory Shop As WindowInventory Mailbox As WindowMailbox ViewMessage As WindowMessage WriteMessage As WindowMessage Amount As WindowAmount Menu As WindowMenu ChatWindow As ChatWindow StatWindow As StatWindow Bank As WindowInventory NPCChat As WindowNPCChat Trade As TradeWindow QuestLog As dQuestLogWindow 'A link to the quest window information End Type
OK! Now after replacing the old type, now...go and find Sub Engine_INIT_GUI(). Go near the bottom (before End Sub) and add this code in:
'Load the Quest log window With GameWindow.QuestLog If LoadCustomPos Then .Screen.X = Var_Get(t, "QUESTLOG", "ScreenX") / 1 .Screen.Y = Var_Get(t, "QUESTLOG", "ScreenY") / 1 .Alpha = Var_Get(t, "QUESTLOG", "Alpha") / 1 Else .Screen.X = Var_Get(s, "QUESTLOG", "ScreenX") / 1 .Screen.Y = Var_Get(s, "QUESTLOG", "ScreenY") / 1 .Alpha = Var_Get(s, "QUESTLOG", "Alpha") / 1 End If .Screen.Height = Var_Get(s, "QUESTLOG", "ScreenHeight1") / 1 .Screen.Width = Var_Get(s, "QUESTLOG", "ScreenWidth1") / 1 .Screen2.X = .Screen.X + .Screen.Width .Screen2.Y = .Screen.Y .Screen2.Height = Var_Get(s, "QUESTLOG", "ScreenHeight2") / 1 .Screen2.Width = Var_Get(s, "QUESTLOG", "ScreenHeight2") / 1 End With Engine_Init_Grh GameWindow.QuestLog.SkinGrh, Var_Get(s, "QUESTLOG", "Grh1") / 1 Engine_Init_Grh GameWindow.QuestLog.SkinGrh2, Var_Get(s, "QUESTLOG", "Grh2") / 1 'Reset text position If CurMap > 0 Then Engine_UpdateChatArray
Yay! Lovely, we added some more code... Now head off to General.bas and find the Sub GAME_Config_Save() and add these three lines in (anywhere within the sub):
Var_Write t, "QUESTLOG", "ScreenX", GameWindow.QuestLog.Screen.X / 1 Var_Write t, "QUESTLOG", "ScreenY", GameWindow.QuestLog.Screen.Y / 1 Var_Write t, "QUESTLOG", "Alpha", GameWindow.QuestLog.Alpha / 1
Find the code (somewhere within sub Engine_MoveUser())
If LastClickedWindow = MailboxWindow Or LastClickedWindow = ShopWindow Or LastClickedWindow = ViewMessageWindow Or _ LastClickedWindow = AmountWindow Or LastClickedWindow = BankWindow Then LastClickedWindow = 0
Replace with:
If LastClickedWindow = MailboxWindow Or LastClickedWindow = ShopWindow Or LastClickedWindow = ViewMessageWindow Or _ LastClickedWindow = AmountWindow Or LastClickedWindow = BankWindow Or LastClickedWindow = QuestLogWindow Then LastClickedWindow = 0
Go to Input.bas and find Input_Mouse_LeftClick_Window(ByVal WindowIndex As Byte) As Byte.
Find:
Select Case WindowIndex
After, add:
Case QuestLogWindow If ShowGameWindow(QuestLogWindow) Then With GameWindow.QuestLog If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X, .Screen.Y, .Screen.Width, .Screen.Height) Then Input_Mouse_LeftClick_Window = 1 SelGameWindow = QuestLogWindow LastClickedWindow = QuestLogWindow End If End With End If
Now, goto Sub Input_Mouse_Move().
Find:
If MouseLeftDown = 0 Then Select Case SelGameWindow
After, add:
Case QuestLogWindow
With GameWindow.QuestLog.Screen
.X = .X + MousePosAdd.X
.Y = .Y + MousePosAdd.Y
If WindowsInScreen Then
If .X < 0 Then .X = 0
If .Y < 0 Then .Y = 0
If .X > ScreenWidth - .Width Then .X = ScreenWidth - .Width
If .Y > ScreenHeight - .Height Then .Y = ScreenHeight - .Height
End If
End With
Go to TileEngine.bas again. Find Engine_Render_GUI_Window(ByVal WindowIndex As Byte).
Find:
Select Case WindowIndex
After, add:
Case QuestLogWindow
With GameWindow.QuestLog
j = D3DColorARGB(.Alpha / 1, 255, 255, 255)
Engine_Render_Grh .SkinGrh, .Screen.X, .Screen.Y, 0, 1, True, j, j, j, j
For i = 1 To QuestInfoUBound
If Engine_Collision_Rect(MousePos.X / 1, MousePos.Y / 1, 1, 1, .Screen.X + 10, .Screen.Y + 5 + i * 18, 128, 16) Then
Engine_Render_Text Font_Default, QuestInfo(i).Name, .Screen.X + 10, .Screen.Y + 5 + i * 18, D3DColorARGB(255, 255, 0, 0)
If MouseLeftDown > 0 Then
QuestLogSelected = i
End If
Else
Engine_Render_Text Font_Default, QuestInfo(i).Name, .Screen.X + 10, .Screen.Y + 5 + i * 18, -1
End If
Next i
If QuestInfoUBound = 0 Then
QuestLogSelected = 0
Else
If QuestLogSelected > 0 Then
.Screen2.X = .Screen.X + .Screen.Width
.Screen2.Y = .Screen.Y
Engine_Render_Grh .SkinGrh2, .Screen2.X, .Screen2.Y, 0, 1, True, j, j, j, j
Engine_Render_Text Font_Default, QuestInfo(QuestLogSelected).Desc, .Screen2.X + 8, .Screen2.Y + 8, -1
End If
End If
End With
Goto sub Input_HandleCommands
and find
ElseIf Input_GetCommand("/QUEST") Then
Replace
ElseIf Input_GetCommand("/QUEST") Then If QuestInfoUBound = 0 Then 'No quests in place Engine_AddToChatTextBuffer Message(103), FontColor_Quest Else j = Val(Input_GetBufferArgs) If j < 1 Or j > QuestInfoUBound Then 'No valid number specified, give the list Engine_AddToChatTextBuffer Message(104), FontColor_Quest For i = 1 To QuestInfoUBound Engine_AddToChatTextBuffer " " & i & ". " & QuestInfo(i).Name, FontColor_Quest Next i Else 'Give the info on the specific quest Engine_AddToChatTextBuffer QuestInfo(j).Name & ":", FontColor_Quest Engine_AddToChatTextBuffer QuestInfo(j).Desc, FontColor_Quest End If End If
with
ElseIf Input_Getcommand("/QUEST") Then If QuestInfoUbound = 0 then 'No quests in place Engine_AddToChatTextBuffer Message(103), FontColor_Quest Else ShowGameWindow(QuestLogWindow) = IIf(ShowGameWindow(QuestLogWindow) = True, False, True) End if
[edit] Additional Features
Cancel your quest without /cancelquest.
Case QuestLogWindow With GameWindow.QuestLog j = D3DColorARGB(.Alpha / 1, 255, 255, 255) Engine_Render_Grh .SkinGrh, .Screen.X, .Screen.Y, 0, 1, True, j, j, j, j For i = 1 To QuestInfoUBound If Engine_Collision_Rect(MousePos.X / 1, MousePos.Y / 1, 1, 1, .Screen.X + 10, .Screen.Y + 5 + i * 18, 128, 16) Then Engine_Render_Text Font_Default, QuestInfo(i).Name, .Screen.X + 10, .Screen.Y + 5 + i * 18, D3DColorARGB(255, 255, 0, 0) If MouseLeftDown > 0 Then QuestLogSelected = i End If Else Engine_Render_Text Font_Default, QuestInfo(i).Name, .Screen.X + 10, .Screen.Y + 5 + i * 18, -1 End If Next i If QuestInfoUBound = 0 Then QuestLogSelected = 0 Else If QuestLogSelected > 0 Then .Screen2.X = .Screen.X + .Screen.Width .Screen2.Y = .Screen.Y Engine_Render_Grh .SkinGrh2, .Screen2.X, .Screen2.Y, 0, 1, True, j, j, j, j Engine_Render_Text Font_Default, QuestInfo(QuestLogSelected).Desc, .Screen2.X + 8, .Screen2.Y + 8, -1 Engine_Render_Text Font_Default, "Cancel", .Screen2.X + 128, .Screen2.Y + 236, -1 If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen2.X + 128, .Screen.Y + 230, Engine_GetTextWidth(Font_Default, "Cancel"), 16) Then If MouseLeftDown > 0 Then sndBuf.Put_Byte DataCode.User_CancelQuest sndBuf.Put_Byte QuestLogSelected QuestLogSelected = 0 End If End If End If End If End With
If you want too, you can also remove the /CANCELQUEST command.
[edit] Anything else?
Solution for the issue about to me mentioned: simply use Engine_WordWrap() to have the client automatically format the text to fit inside the box like so:
Engine_Render_Text Font_Default, Engine_WordWrap(QuestInfo(QuestLogSelected).Desc, 225), .Screen2.X + 20, .Screen2.Y + 25, -922747136
Don't forget to change to numbers to fit your menu.
If you have a code error, make sure you have not written in any duplicate code. I am not the best person to describe things, but.. I manage somehow sometimes dont I?
Oh! A word of advice and warning, the Quest description has to have alot of Enters, as the Render_Text does not work by width, for example the first quest description becomes something like this in the SQL GUI editor so it can be displayed properly within the client
The Headless Man has told you
about some dangerous bandits
that have nested in the cave
under the |waterfall| in the
west side of the island,
outside of town.
They have been stealing junk
from the only two houses on
this pathetic island, and
it is important that we get
it back, since without our junk,
we are useless.
Talk to the Headless Man after
you kill the 3 bandits for your reward.
Anyways, thank you for reading. I hope it worked out well for you..and I hope I didn't miss anything out.
Final Result after editing the mysql database.





