RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RMXP] Simple Quest System HOWTO + Sample

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 88
Hello!  I got a PM asking about expanding a tutorial I wrote a few years ago about a questing system.  I haven't used RPGMaker in a long looong time, but here goes.

Simple Quest System - A Beginner's Guide


What this tutorial will cover:
  • Having an NPC react differently depending on what part of a quest you are on
  • Keeping record of multiple enemies killed.

For this tutorial, we are going to use the following example.  You can of course, follow along with your own example if you want.

The innkeeper at the town you are visiting is having a pest problem.
Her attic is filled with bats and she can't get them out herself because she is allergic.
If you help her clear 5 bats from the attic, she will give you 100 gold and
let you stay at her inn for free in the future.


If you'd like an example to follow along with, or to try out, you can download the finished tutorial > here <
Edit: Here is a link to my 2007 tutorial that is similar.

Now, the first thing we need to do is set up the quest.  Make an NPC and have her ask you to get rid of the bats for her.



Now that we have the option to start the quest set up, you'll want to keep track of how far the player is in that quest.  Since you just accepted it, you'll want to add another event after the quest is taken (Below the "Thank you so much" message in this example).  Pick Control Variables and then set the variable for this quest to "1" since we just accepted it.



Now, your event should look something like this:



Now that you have accepted the quest, there is no need to have the innkeeper give it to you again, so you'll want to do two things.
  • Make another variable to count how many bats have been killed
  • Make another event page for the innkeeper for telling you that you haven't finished the quest yet

Click "New Event Page" and look at the section on the left that says "Conditions".  This is what is required for this page to appear.  Since we want it to appear after you've accepted the quest, change it so that the requirement is that your quest variable is at 1 or above.  Make sure you set the NPC's graphic as well.

Now, when you talk to her, she is going to see if you've killed five bats or not.  For this, you'll use a Conditional Branch.



You want it to check the Variable BatsKilled to make sure it is greater than or equal to 5.  The reason you want it to be greater than or equal to is because if you kill six bats, she will not finish the quest for you.

You also want the box at the bottom to be checked so that if you haven't killed the five bats yet, she will act differently.

Now, fill in her behavior for each scenario.  Make sure in the >=5 branch, you set the quest variable to 2.



Once the quest is over, you will want to make a last page for how the NPC will behave after you have finished the quest.  Make the Conditions that the variable for your quest is 2.



The following portion applies to enemies you encounter randomly for your quest, or enemies that you specifically place for your quest.

Now that we have the NPC's behavior set up, we need to give the variable for the amount of enemies defeated to go up.  Go into the Troops tab in your database and make the troops for enemies that you'll be fighting on your quest.

Once you've set up the encounters, Look at the Conditions section.

Change the Span to "Turn" (This is important), and the Condition to "Enemy: (Whichever enemy is the quest target)'s HP" and set the condition to "0% or below".



Then in the events bar, add a Control Variable event that will Add 1 to the counter variable you set up earlier.

Then repeat this step for each target enemy in each encounter.



Now, just set up the encounters (you can either have enemies that you can see on the map, or use random encounters) and your quest is finished!

If the quest targets can be encountered while you are not on the quest, you may want to add a Conditional Branch to the events in the Troop that only adds 1 to the variable if you are on the correct stage of the quest.








« Last Edit: June 25, 2011, 08:58:38 AM by Yami »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Wow, this tutorial is really well done - all the pictures are great. I can't imagine anyone walking away from this tutorial not knowing how to accomplish this task. Really great job Yami!

**
Rep: +0/-0Level 66
RMRK Junior
Hi, your tutorial is very well made.  It is also one of the only things I can find on how to do this.  But for some reason it just does not work.  I kill my monster that is needed to be killed, and the guy who is supposed to reward me just simply does not.  It's like the variable just does not go up like it's supposed to.  It's driving me batty, excuse the pun =)  Please, any ideas?!?

edit:  i have it just on a battle processing event to test.  when i change the battle processing to 2 monsters, it works, and increases the variable 2 like it should.  when i change it back to 1 monster, it doesn't work again.  tearing my hair out....

edit:  i just tried a few more times with other groups, it seems when there's just one it doesn't register, when there's more than 1 or just 1 and other kinds of monsters with it, it counts it.  wtf?

edit:  just tried a brand new game, with 1 ghost in a battle process.  set it up to increase variable +1 upon it's death.  set up a guy to tell me 'you did it!' if the variable=1.  it never equaled 1 =(  i killed the ghost 5 times, it never went up.
« Last Edit: September 18, 2011, 01:32:57 AM by djskagnetti »

***
Rep:
Level 88
Does it just skip directly to two?
If that is the case, just change your == to >=.  That way, if you kill more than the needed amount, you can still complete it.


It sounds like the battle is ending before the variable gets changed.  I don't have RMXP installed right now, so I can't troubleshoot it though.

**
Rep: +0/-0Level 66
RMRK Junior
Does it just skip directly to two?
If that is the case, just change your == to >=.  That way, if you kill more than the needed amount, you can still complete it.


It sounds like the battle is ending before the variable gets changed.  I don't have RMXP installed right now, so I can't troubleshoot it though.

This is exactly what is happening! 
Let's say I'm fighting 2 goblins and 1 snake, and I want the variable to increase with the 2 goblins:
If I have it set to turn, like you say, and kill the first goblin, and then the second goblin, and then it takes 3 more turns to kill the snake, for each turn that the hps of both goblins are below 0 it increases the variable.

I countered this with a conditional branch
if self-switch A is on
[do nothing]
else
increase variable +1
self-switch A = On

Which seems to work.  EDIT:  This doesn't work after all =(

Ok well, anyways
Let's say I'm fighting just 2 goblins:
-  If I kill both in the same turn, it registers as only 1.
-  If I use an attack that attacks all enemies and kills both at the same time, it registers as 0!

Please help!  I have a whole job system I set up and a bunch of the jobs are 'Kill X amount of this monster and come back to get X XP and X Gold.'  This kinda messes that all up =)  Please help!

ps I scoured google on how to find out how to do this quest, and your post is the only one I could find.  Thanks for posting it! =)

--Problem Solved!
EDIT:

Thanks to ForeverZero for making me this script.  This adds 1 to the variable at the end of battle to whatever enemy is specified, completely fixing all my problems!  Thanks again ForeverZero!


"Place the script anywhere below Game_Enemy and fill out the simple configuration at the top of the script."

Code: [Select]
class Game_Enemy
 
#-------------------------------------------------------------------------------
# CONFIGURATION
#-------------------------------------------------------------------------------
#  Define the variable used for each enemy here. Follow this pattern:
#
#    when ENEMY_ID then VARIABLE_ID
#
#  If more than one eneky share the same variable, you can define multiple
#  IDs on one line. For example, say you had a Goblin whose ID was 1, and an
#  Orc whose ID was 17. You wanted both of them to be of the same "type", and
#  use the variable with ID of 6:
#
#     when 1, 17 then 6
#
#-------------------------------------------------------------------------------

  def enemy_variable(enemy_id)
    return case enemy_id
    when 1 then 1
    when 2 then 2
    when 3 then 3
    when 4 then 4
    when 5 then 5
    end
  end
 
#-------------------------------------------------------------------------------
# END CONFIGURATION
#-------------------------------------------------------------------------------
 
  def increase_count(enemy_id)
    var_id = enemy_variable(enemy_id)
    if var_id != nil
      $game_variables[var_id] += 1
    end
  end
 
  alias zer0_enemy_type_attack attack_effect
  def attack_effect(attacker)
    result = zer0_enemy_type_attack(attacker)
    if self.dead? && @counted == nil
      increase_count(@enemy_id)
      @counted = true
    end
    return result
  end
 
  alias zer0_enemy_type_skill skill_effect
  def skill_effect(user, skill)
    result = zer0_enemy_type_skill(user, skill)
    if self.dead? && @counted == nil
      increase_count(@enemy_id)
      @counted = true
    end
    return result
  end
 
  alias zer0_enemy_type_item item_effect
  def item_effect(item)
    result = zer0_enemy_type_item(item)
    if self.dead? && @counted == nil
      increase_count(@enemy_id)
      @counted = true
    end
    return result
  end
end
« Last Edit: September 26, 2011, 10:41:36 AM by djskagnetti »

***
Rep:
Level 88
Glad to see that helped!

**
Rep: +0/-0Level 66
RMRK Junior
I just playtested it.  Everything that was going wrong now does not.  You kill 2 in a battle, you get 2 increases to the specified variable, no matter how they are killed, when they are killed, or how many turns apart they are killed.  It works flawlessly!