Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Quest System
#1
This was based on the following script at:
http://www.touchofdeathproductions.com/scripts.html
By Unknown_raven

Difficulty: 4/5 (Requires some programming ability)

It uses a flag system which can become confusing but I'll leave a sample quest at the end of this tutorial for all to see.

Server Side

Create a new Module.

Name it modQuest and add the folowing:

Code:
Option Explicit

Function GetFlagHeight(ByVal index As Integer, ByVal Flagnum As Integer) As Long
    Dim X
    Dim filename As String
        filename = App.Path & "\flags\" & getplayername(index) & ".ini"
        X = GetVar(filename, GetPlayerName(index), "Flag" & Flagnum)
        GetFlagHeight = X
        Call SendDataTo(index, ("FLAGHEIGHT" & SEP_CHAR & X & SEP_CHAR & Flagnum & SEP_CHAR & END_CHAR))
End Function

Sub RaiseFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
    Dim filename As String
       filename = App.Path & "\flags\" & getplayername(index) & ".ini"
    Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) + height))
End Sub

Sub LowerFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
    Dim filename As String
        filename = App.Path & "\flags\" & getplayername(index) & ".ini"
    Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) - height))
End Sub

Sub SetFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
    Dim filename As String
        filename = App.Path & "\flags\" & getplayername(index) & ".ini"
    Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(0))
    Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) + height))
    Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(height))
End Sub

Now I'll explain how this works. Basically you are using a system of flags to detrmine how much of the quest has been completed, and it also prevents parts of the quest which were allready finished from being done again, such as recieveing the reward for the quest.

Function GetFlagHeight - This function is pretty self explanatory. It access the file 'flags.ini" and checks to see what the current flag's height is. This is specified by the "flagnum". An example of how this could be used is:

Code:
If GetFlagHeight(index, 1) = 0 Then [b] ' Check the height of flag 1[/b]
            Call PlayerMsg(index, "Janelle Says: 'Hi, could you do this quest for me? I need you to go to the forest and see if it is muddy.'", 10) ' Give the player the quest.
            Call RaiseFlag(index, 1, 1) ' Raise the flag by one so that flag 1's height now = 1, and since it = 1 and not 0, the above event can't happen again.
        End If

Sub RaiseFlag - This again is quite obvious. It raises the flag specified by "flagnum" so that any event that allready happened cannot happen again. See the above code example to see how it works.

Sub LowerFlag - This again is quite obvious. It lowers the flag specified by "flagnum" so that any event that allready happened can happen again. I haven't exactly thought of any real way this might come into play during a quest but maybe someone else can.

Sub SetFlag - This is used to set the height of a flag to a specific height. I haven't needed to use it in my quests yet because they're all hide and go seek quests, so a few IF statements with the getflagheight and raiseflag commands is suitable.

There, now that we have a basic understanding of what each function/sub routine does, let's move on to getting these quests to work.

First fo all we want to make sure that each players has some flags, otherwise the quests won't work.

Open up modGameLogic (still server side):

Find:
Code:
Sub JoinGame(ByVal index As Long)

And right under it add:

[code]
Dim BeenFlagged As Boolean, Num As Integer
Dim filename1 As String
filename1 = App.Path & "\flags\" & GetPlayerName(index) & ".ini"

If Not FileExist(filename1) Then
BeenFlagged = False
End If

If BeenFlagged = False Then
Num = 1
'Change the 3 to number of flags you want per player
Do While Num
Reply
#2
I've read most of it, and that seems like a very logical way to set it out. Kudos. Would seem quite annoying though if you have a large player base and a limited amount of quests.. Because there'll be nothing to do?
Reply
#3
The system seems very interesting but so simple. Nice job
Reply
#4
nice system could use a few changes to make it more adptible
for larger games with more quests
maybe scripting of sorts to add new quests to it or a quest editor
a decent idea well thought out
Reply
#5
Had something similar to this on my game for a year, but more advanced. Pretty nice base, though.
Reply
#6
I agree with all of you. It does the job for now, for me and it was modified to fit MSE from that touchofdeath tutorial, which used scripted tiles. Like I said though, if anyone wants to expand on it, feel free. Should the day come along that I need to expand it, I'll be sure to post a new tutorial for it.
Reply
#7
Woah this is really cool. While i'm not going to actually use any code, the whole flag idea seems pretty cool, and would greatly improve my quest system. Nice job on this. =x
Reply
#8
Nice tutorial, it really helped. It would be neat though if the quest starts when the player steps on a tile instead of when he enters the map, but I'll be able the figure that out myself I think Smile
Reply
#9
You should greatly improve upon it, by making npc's start the quest instead. Would make your game more realistic. I mean, who steps on a tile or walks into an area and is suddenly given a quest to do? Lol.

It's a very good base for a quest system though. Nicely done.
Reply
#10
Advocate Wrote:I mean, who steps on a tile or walks into an area and is suddenly given a quest to do? Lol.

some quests could work with that... like you enter a room with like a dragon in it, (a non-killing NPC kinda thing) and it gives you a quest... without speaking to it... as you don't know how to speak in dragon-ite or w.e. lol

oh i'm just making stuff up sorry lol

yeh, it's a great basis to make a quest system from... but i don't think he'd be willing to make the most UBER quest system and then just release it... i mean... my house system (which is complete) could sell... but i gave away the base code (which i'll post a complete tutorial (without mistakes) here later)
Reply
#11
Well, I meant a new tile type, so the quest would start when you see a wanted poster or something, but yea, it would be even better if the quest starts when you talk to a npc Tongue , it isn't that difficult to do, great tut man.
Reply
#12
Since I now have a computer around here, I MIGHT, if I FEEL like it, improve upon this, and add in the NPC stuff. But I'll make it to where you can still have it the base way as well. ^_^

(If someone doesn't beat me to it, as I have currently much on my plate.)
Reply
#13
Major flaw on my server which was just worked out. It wasn't checking if the file existed right on the joingame sub. I've changed it to look as such:

Replace:

[code]
If Not FileExist(filename1) Then
BeenFlagged = False
End If

If BeenFlagged = False Then
Num = 1
'Change the 3 to number of flags you want per player
Do While Num
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)