Quests?

Quick question:

How would i go about adding quests into a game?

For example, Steve wants you to kill 5 rats, how will i register when i have killed 5 rats and returned to steve?

This is just a question as i am far from quests just yet.

Thanks

  • Josh

This belongs in the coding section. Anyways.

Create a variable that is the value of rats. Each time a rat is killed += the variable by 1. Give steve a trigger so when the player reaches the trigger a boolean is then triggered true.

Thanks, not that a fully understood it but i should be able to implement it :slight_smile:

rat death = rats killed + 1
if rats killed = 5 then
rat quest = complete

Shitty pseudo code coming from someone who doesn’t code. but it should function fine.

using System;
using System.Collections.Generic;
using UnityEngine;


public class RatQuest : MonoBehaviour {
   public int RatsKilled=0;
   public bool KilledFiveRats=false;

public void RatKilled()
{
   RatsKilled++;
   if (RatsKilled>=5)
   {
     KilledFiveRats=true;
    }
  }
}

Not so pseudo as Charlie’s but just as crappy.

Haha, i understand all the code, just how to implement it and make it work is kind of beyond me, i understand it :stuck_out_tongue:

You would need to add a script to the rats that calls RatKilled() if it is killed only by the player.

Steve will need a code that tells the player “Hey, if you kill five rats, I will reward you” when the character enters a trigger by using OnTrigerEnter or OnCollisionEnter and some sort of GUI for the text.

When you kill a rat, have it send a message to the player; i.e. player.SendMessage (“RatKilled”); (you’ll need to set the player, but that is easy to do with tags)

When you reenter Steve’s trigger, make his script check the RatQuest script for KilledFiveRats to be true and have him say “thanks! here is your reward.”
If it’s false, Steve will say “keep at it! I know you can kill five rats!” You could even have it check the number of rats killed and subtract it from five and have Steve say “you need to kill 3 more rats”.