xweetok59 Posted July 13, 2010 Author Share Posted July 13, 2010 Does anybody have a tutorial on how to make quests? I use EE 2.7-Source. I found 2 tutorials for quests, but they sucked to be true… Link to comment Share on other sites More sharing options...
cowin000 Posted July 17, 2010 Share Posted July 17, 2010 search for "Unkown_Raven". He has a VERY VERY simple to use quest script that you can easily implement into your game. ;D Link to comment Share on other sites More sharing options...
cowin000 Posted July 17, 2010 Share Posted July 17, 2010 Actuall here you go:Quest SystemBy Unknown_RavenDifficulty: UnknownSince this is one of the best and probably most useful scripts I have made I have decided to finish up the commenting at the bottom. Originally I did have good descriptions but a forum wipe deleted my post and I never got around to redoing the full descriptions. Now you should be able to see the full tutorial and find it easier to use.Paste this at the bottom of your main.txt' ********************' * QUEST SYSTEM 1.1 *' * By Unknown_Raven *' ********************Function GetFlagHeight(index, flagnum)Dim XX = GetVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum)GetFlagHeight = XEnd FunctionSub RaiseFlag(index, flagnum, height)Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum, GetVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum)+height)End SubSub LowerFlag(index, flagnum, height)Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum, GetVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum)-height)End SubSub SetFlag(index, flagnum, height)Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum, 0)Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum, GetVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum)+height)'Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&flagnum, height)End SubSub GiveItem(index, item, value)SLOT = 1Do While SLOT < 24If GetPlayerInvItemNum(index, SLOT) = 0 ThenCall SetPlayerInvItemNum(index, SLOT, item)Call SetPlayerInvItemValue(index, SLOT, GetPlayerInvItemValue(index, SLOT)+value)Call SendInventoryUpdate(index, SLOT)SLOT = 24End IfSLOT = SLOT+1LoopEnd SubSub TakeItem(index, item)SLOT = 1Do While SLOT < 24If GetPlayerInvItemNum(index, SLOT) = item ThenCall SetPlayerInvItemNum(index, SLOT, 0)Call SetPlayerInvItemValue(index, SLOT, 0)Call SendInventoryUpdate(index, SLOT)SLOT = 24End IfSLOT = SLOT+1LoopEnd SubSub TakeCurrency(index, item, value)SLOT = 1Do While SLOT < 24If GetPlayerInvItemNum(index, SLOT) = item ThenAMOUNT = GetPlayerInvItemValue(index, SLOT)TAKE = Int(AMOUNT-value)If TAKE <= 0 ThenCall SetPlayerInvItemNum(index, SLOT, 0)Call SetPlayerInvItemValue(index, SLOT, 0)Call SendInventoryUpdate(index, SLOT)End IfIf TAKE > 0 ThenCall SetPlayerInvItemNum(index, SLOT, 0)Call SetPlayerInvItemValue(index, SLOT, 0)Call SetPlayerInvItemNum(index, SLOT, item)Call SetPlayerInvItemValue(index, SLOT, TAKE)Call SendInventoryUpdate(index, SLOT)End IfSLOT = 24End IfSLOT = SLOT+1LoopEnd SubFunction FindItemSlot(index, item)slot = 1Do While slot <= 24If GetPlayerInvItemNum(index, Slot) = item ThenFindItemSlot = slotslot = 24ElseFindItemSlot = 0End Ifslot = slot + 1LoopEnd FunctionPaste this at the top in the On Player Join Sub.If GetPlayerLevel(index) = 1 ThenIf GetPlayerExp(index) = 0 ThenNUM = 1'change the 30 to number of flags you want per playerDo While NUM <= 30Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&NUM, 0)NUM = NUM+1LoopCall SetPlayerExp(index, 1)End IfEnd IfHere are all the commands you can now use.Call RaiseFlag(index, flagnum, height)-This command is used to raise the trigger flags for an event.-flagnum specifys the flag number-height is how high you are raising the flag. It takes the current height and adds this value to it.Call LowerFlag(index, flagnum, height)-This command is simply the opposite of the Raiseflag.Call SetFlag(index, flagnum, height)-This command is used to set a flag to an exact height. Whatever the value of height is will be the value the flag is at.Call GiveItem(index, item, value)-This gives the player an item.-Item is for specifying which item to give.-Value is how much. Value only works for currency type items.Call TakeItem(index, item)-This is used specifically for taking away a target item. If the player has two of the same item it will take away the one closes to the top of their inventory.Call TakeCurrency(index, item, value)-This is the same as the command above except it removes only currency type items.GetFlagHeight(index, flagnum)-returns the current height of the flag.FindItemSlot(index, item)-This returns the inventory slot number that the specified item is in. If the player does not have the item in his/her inventory then the value returned will be 0.How it worksThe quest system is actually a series of tools used to create quest scripts much more efficiently. I will briefly outline for you some of the ideas on making quests.First off you might be wondering what is a flag? Whenever a character completes a part of the quest we have to somehow keep track of it. This is done through flags also called triggers. An example would be, the player is told to go to a specific house. We decide that this will be quest 1 so we will use Flag1\. Flag1 is currently at a height of 0\. Once the person enters the house we raise Flag1 up one level. [ Call RaiseFlag(index, 1, 1) ] Now Flag1 = 1\. There are many things we can do with this such as provide a Flag check that says, If Flag1 = 1 then do this. That will allow us to seperate the various steps of the quest.Alright so now you got a brief understanding of what the flags are but now we need to learn a bit of the actual coding structure. Lets make a scripted tile.Case 0' This is the first step of the quest.If GetFlagHeight(index, 1) = 0 Then 'this checks the height of Flag1Call PlayerMsg(index, "Hi, could you do this quest for me? I need you to go to the forest and see if it is muddy.", 10)Call RaiseFlag(index, 1, 1) 'raises the flag a level so the event cannot be repeated.End If' This runs after the player has begun the quest but has not yet completed its next step.If GetFlagHeight(index, 1) = 1 ThenCall PlayerMsg(index, "Please hurry to the forest!", 10)End If' This is the end of the quest where the player comes back to recieve his/her reward.If GetFlagHeight(index, 1) = 2 ThenCall PlayerMsg(index, "Oh thank you please take this reward.", 10)If FindItemSlot(index, 0) = 0 Then 'looks for an empty slot'runs if inventory is fullCall PlayerMsg(index, "I am sorry but your inventory is full.", 12)Else'runs if there is atleast one empty item slotCall GiveItem(index, 20, 1) 'gives them item 20Call PlayerMsg(index, "You recieved item 20." 14)Call RaiseFlag(index, 1, 1) 'raises the flag a level so the event cannot be repeated.End IfEnd IfCase 1' This represents the Forest Trigger.If GetFlagHeight(index, 1) = 1 ThenCall PlayerMsg(index, "You notice that the forest is not very muddy." 10)Call RaiseFlag(index, 1, 1)End IfNow if you look through those two cases which are both scripted tiles, you will see the basic form of the quests as well as how to use some of the commands. There are many ways to take advantage of the quest system and all of them are limited only by your imagination. I hope this helps your understanding of this script Link to comment Share on other sites More sharing options...
Kite Posted July 17, 2010 Share Posted July 17, 2010 http://www.touchofdeathforums.com/smf/index.php/topic,60820.0.htmlBest to start out with a basic one, so you understand better. Link to comment Share on other sites More sharing options...
Icie Juicy Posted August 13, 2010 Share Posted August 13, 2010 Thanks for the great tutorial/guide here. I have been running into some issues though with these functions not working properly. I did notice that I don't have a "OnPlayerJoin" in ES, only a "JoinGame", which is where I implemented the script that should be in OnPlayerJoin sub.Would that effect the script and cause the flag system not to work? I've played with the implementing the flag script into ScriptedNPC for nearly an hour. Just looking for a little insight into my situation. :cheesy:Here is where I posted it:>! Sub JoinGame(Index)>! If GetPlayerLevel(index) = 1 ThenIf GetPlayerExp(index) = 0 ThenNUM = 1'change the 30 to number of flags you want per playerDo While NUM <= 30Call PutVar("FLAGS.ini", GetPlayerName(index), "Flag"&NUM, 0)NUM = NUM+1LoopCall SetPlayerExp(index, 1)End IfEnd If Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now