Mirage Engine
My Quest System (Updated to use tiles) - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: My Quest System (Updated to use tiles) (/showthread.php?tid=160)



My Quest System (Updated to use tiles) - Leighland - 03-07-2006

Okay, I've possessed myself to expand on this a bit.

Difficulty: 4/5 Requires knowledge of VB/MSE programming :evil:

Original Post can be found here: http://ms.shannaracorp.com/forums/viewtopic.php?t=174

The flag idea and quest was taken from Unkown_raven

This version of the code uses tile, which you can set with the Mapeditor. I'll give an example of how to set up each quest at the end of this tutorial. There are probably easier ways to do what I have but this works for me Smile.

Let's do the client side first:

Open up frmMirage

On picMapEditor add an option button to your attributes frame, name it optQuest.

Double click it and add this to the code:
Code:
Private Sub optQuest_Click()
    frmQuest.Show vbModal
End Sub

Now, Open up modGameLogic and in the Sub GameLoop find:

Code:
If .Type = TILE_TYPE_KEYOPEN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "O", QBColor(White))

Under it add:

Code:
If .Type = TILE_TYPE_QUEST Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "Q", QBColor(BrightRed))

Then in Sub EditorMouseDown find:

Code:
If frmMirage.optKeyOpen.Value = True Then
                        .Type = TILE_TYPE_KEYOPEN
                        .Data1 = KeyOpenEditorX
                        .Data2 = KeyOpenEditorY
                        .Data3 = 0
                    End If

Under it, add:

Code:
If frmMirage.optQuest.Value = True Then
                        .Type = TILE_TYPE_QUEST
                        .Data1 = QuestEditorNum
                        .Data2 = 0
                        .Data3 = 0
                    End If

Now, open modConstants and find:

Code:
Public Const TILE_TYPE_KEYOPEN = 6

And under it, add:

Code:
Public Const TILE_TYPE_QUEST = 7

Now open modGlobals:

Anywhere in that module, add:
Code:
' Used for Quest Chooser
Public QuestEditorNum As Long

Okay, now we're going to create the form that will be used to choose which quest we want to start when the player walks over the specified tile.

So, add a new form and name it frmQuest

Add a scroll bar:
Name: scrlQuestNum
Max: 250

Add a Label:
Name: lblQuestNum

Add a command button:
Name: cmdOK
Caption: Okay

Add a command button:
Name: cmdCancel
Caption: Cancel

Double click the form and add the following:
Code:
Private Sub cmdOk_Click()
    QuestEditorNum = scrlQuestNum.Value
    Unload Me
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub scrlQuestNum_Change()
    lblQuestnum.Caption = STR(scrlQuestNum.Value)
End Sub

That's all for the client side. Now on to the server.

Open frmServer and add a new timer to it.
Name: QuestMapNotice
Enabled: False
Interval: 5000

Double click on it and add the following to its sub routine:
Code:
CHECKQUEST = True

Open modGameLogic and in the PlayerWarp sub find:
Code:
' Sets it so we know to process npcs on the map
    PlayersOnMap(MapNum) = YES

Under it, add:
Code:
frmServer.tmrQuestMapNotice.Enabled = True
    
    If CHECKQUEST = True Then
        If Dir(App.Path & "\Quest Maps\" & GetPlayerName(index) & ".ini")  "" Then
            If GetQuestMap(index, GetPlayerMap(index)) = 1 Then
                Call QuestMapData(index)
                frmServer.tmrQuestMapNotice.Enabled = False
            Else
                frmServer.tmrQuestMapNotice.Enabled = False
            End If
        End If
    End If

Now find:
Code:
' They tried to hack
    If Moved = NO Then
        Call HackingAttempt(index, "Position Modification")
    End If

And under it add:
Code:
If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_QUEST Then
        Call CheckQuestTile(index)
    End If

In Sub JoinGame, find:
Code:
' Warp the player to his saved location
    Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index))

and under it add:

[code]
filename = App.Path & "\Flags\" & GetPlayerName(index) & ".ini"
If Dir(filename) = "" Then
Num = 1
'Change the 3 to number of flags you want per player
Do While Num


- Krloz - 03-07-2006

Amagad what a great work from you =) I will be adding this soon


- Leighland - 03-07-2006

Don't add it so soon :p, I just tested it this morning and it gave me an error when trying to create the folders. I'll fix it and post back after work.

EDIT: Minor Error, the LCase and Ucas eget me every time lol. Fixed it above.


- Xlithan - 21-01-2007

Would there be any chance of making a proper editor for this instead of hard-coding it? I'm creating a closed source engine so it would be great to have that ability.


- William - 22-01-2007

GameBoy Wrote:Would there be any chance of making a proper editor for this instead of hard-coding it? I'm creating a closed source engine so it would be great to have that ability.
Would not be hard at all.


- Leighland - 25-01-2007

William Wrote:
GameBoy Wrote:Would there be any chance of making a proper editor for this instead of hard-coding it? I'm creating a closed source engine so it would be great to have that ability.
Would not be hard at all.

Sorry haven't been around for a bit. William is right. All the subs are there on the server side, which should make it exceptionally easy to create an editor.


- Boo - 23-03-2007

does this work?


- Reece - 23-03-2007

Boo Wrote:does this work?

Try it and find out.


- Leighland - 24-03-2007

Yes Boo, it does work. Not very well though I have to admit. I threw this together when I first started with Mirage and it could probably be done a whole lot better, actually I know it can lol. Go ahead and implement it if you wish, but it's verybasic and probably not the most sufficient way of doing this.

BTW: 200th post DING DING


- Boo - 24-03-2007

ya my friend just said he'll program me 1 thats better xD.


- Leighland - 25-03-2007

Boo Wrote:ya my friend just said he'll program me 1 thats better xD.

THat's probably a good idea Wink