mob/var/list/questdone = list() //holds the list of finished quest npc id
mob/proc
Getitem(obj/get,getamount) //insert an item and amount
var/obj/New = get
for(var/i=0,i < getamount,i++)
src.Items+= New
Delitem(obj/reqitem,reqamount)
var/obj/M = reqitem
if(src.Items.Find(M))
for(var/i=0,i<reqamount,i++)
src.Items.Remove(M)
proc/Getitemname(obj/item)
return item.name
mob/proc/Countitem(obj/item)
//This proc will return the number of items for the specified item that the
//invoking character has in the inventory.
var/tmp/C = 0
var/obj/M = item
for(M in src.Items)
C+=1
return C
mob/Questnpcs
icon = 'NPC.dmi';icon_state="Quest"
name = "Quest NPC"
//note the item require and rewards must have objs in the same element as the amount
//ex: Rewards = list(obj/noob)
// RewardsAmount = list(10) must be lined up in the same order or else you get different amount
var/list/Rewards = list(/obj/dummyitem) //list of objs, rewarded after a quest
var/list/RewardAmount = list(2) //the quantity of the reward
var/list/Itemrequire = list(/obj/dummyitem)//a list of objs required for the reward
var/list/Reqitemamount = list(2)//the amount of the objs required for the reward
var/doable//still under construction
var/goldreq = 1000 //amount of gold required to get items
var/id = 1
var/alreadydonemes = "Hey, You already done my quest before!"
var/rewardedmes = "Thanks, Here is your reward"
var/getmes = "Ok, Ill wait here for you to bring the items"
var/noitems = "You Liar!, You don't have the items I asked you to get!"
proc
Quest(mob/M)
var/itemlist = ""
var/rewardslist = ""
for(var/n = 0, n<Itemrequire.len,n++) //a loop to get the text list
itemlist += "[text2num(Reqitemamount[n])] [Getitemname(Itemrequire[n])]<BR>"//amount and itemname
for(var/n = 0, n<Rewards.len,n++) //a loop to get the text list
rewardslist += "[RewardAmount[n]] [Getitemname(Rewards[n])]<BR>" //amount and itemname
if(id in usr.questdone) //make sure they dont do the quest again
alert(M,alreadydonemes)
return
var/mes
if(goldreq > 0)
alert(M,itemlist)
alert(M,rewardslist)
alert(M,"Dont forget to bring [goldreq] GP")
if(goldreq <= 0)
goldreq = 0 //if there was a ever a negitive number, go to 0
alert(M,itemlist)
alert(M,rewardslist)
switch(alert(M,mes,"","I got those Items!","I'll get those items right away"))
if("I got those Items!")
if(goldreq > 0) {if(M.gold < goldreq) Nomoney(M)}
for(var/q = 0,q < Itemrequire.len,q++)
if(M.Countitem(Itemrequire[q]) < Reqitemamount[q]) Noitems(M)
for(var/i = 0,i < Itemrequire.len,i++) //loop through the item list and delete the items
M.Delitem(Itemrequire[i],Reqitemamount[i])
for(var/s = 0,s < Rewards.len,s++)//loop through the rewards list and reward the items
M.Getitem(Rewards[s],RewardAmount[s])
if(goldreq > 0) {if(goldreq) usr.gold -= goldreq} //take away the gold
alert(M,rewardedmes)
M.questdone += id //put the npc's id, making it so you cant do this quest over again
if(usr.gold < goldreq) Nomoney(M)
alert(M,"Alright here is your [rewardslist]","[src.name]")
if("I'll get those items right away")
alert(M,getmes,"[src.name]")
Noitems(mob/M)
alert(M,noitems)
return
Nomoney(mob/M)
alert(M,"hmmm, didn't i mention to bring [goldreq]")
return
DblClick()
src.Quest(usr)
Problem description:
A runtime error saying invaild list index or something appears. Also i dont think i did this right