ID:162531
 
Well for my game i want to have quests so that you can speak to npc and he will check if you have the item. And if you do have the item he gives you a reward, and if you dont he says go get them.

And well i need help making the part about the npc checking for the number of the item and taking the item if you have it. If anyone knows how i could do this please help it would be much apreciated.

ps
The item i want him to check for is: obj/DemonWings
And the number they need is: 10

thanks for reading this,
Setox
You just need to check how many instances of [type] are in a given source. Here:

proc/NumberOfType(source,type)
for(var/O in source)
if(istype(O,type)) ++ .


You can use this proc to do this, where 'source' is the location you're seeking [type] in. E.g.

mob/king
verb/finish_quest()
if(NumberOfType(usr,/obj/goblin_head) > 8)
usr << "The kingdom and I are in your debt, [usr.name]."
In response to DivineO'peanut
Thanks alot ^^ my quest is done now.
In response to Setox
The item checking is working, but i dont know how to make it take the items away. By the way what are the dm tags soi can so you what i have done and show you what errors i have
In response to Setox
proc/getOfType(var/source, var/type)
if(isatom(source) || islist(source))
. = list()
for(var/datum/D in source)
if(istype(D, type))
. += type


Then, to delete them:

var/list/L = getOfType(src, /obj/item/batwing)
if(L.len >= 10)
for(var/obj/batwing/B in L)
del(B)
In response to Garthor
I now have 2 errors
proc/getOfType(var/source, var/type)
if(isatom(source) || islist(source))
. = list()
for(var/datum/D in source)
if(istype(D, type))
. += type


the errors i know have are:

error:isatom:undefined proc
error:islist:undefined proc

please help.
In response to Setox
I think those are just shortcuts Garthor used to check if <code>source</code> is an atom or a list.
In response to DivineO'peanut
So i can get rid of it?. By the way thanks for replying. ^^
In response to DivineO'peanut
I'd guess #defines he's been using so long he forgot they aren't part of the software :)

#define islist(l) istype(l, /list)
#define isatom(a) istype(a, /atom)


Put that at the top of your .dm file and it should work.
In response to Flick
Thanks i know have no errors but he dosnt take the wings this is what i have done.

mob/wingermerchant
wingmerchant
name = "Wing Merchant"
icon = 'wing merchant.dmi'
health = 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
maxhealth = 20000
Mtai = 15000
Mnin = 15000
Mgen = 15000
tai = 15000
nin = 15000
gen = 15000
verb
Talk()
set src in oview(2)
set category = "Wing Merchant"
switch(input("Help please", text) in list ("Yes","No"))
if("Yes")
usr<<"My son gets wings for me and then i sell them. But he was injured badly from from a battle with a ravenger. Know i need money for a medical ninja to heal him. But ofcource i am old and weak, so please go bring me 10 demon wings ravengers drop them then bring them back to me."
if("No")
usr<<"Oh ok :( if you ever change you're mine please come back."

proc/NumberOfType(source,type)
for(var/O in source)
if(istype(O,type)) ++ .


mob/wingermerchant
verb/finish_quest()
set src in oview(2)
set category = "Wing Merchant"
if(NumberOfType(usr,/obj/DemonWings) > 10)
usr << "thank you thank you so much, [usr.name]."
var/list/L = getOfType(src, /obj/DemonWings)
if(L.len >= 10)
for(var/obj/DemonWings/B in L)
del(B)
if(NumberOfType(usr,/obj/DemonWings) < 10)
usr << "go get more please i need 10, [usr.name]."






proc/getOfType(var/source, var/type)
if(isatom(source) || islist(source))
. = list()
for(var/datum/D in source)
if(istype(D, type))
. += type


That is what i have done for for the npc quest guy code no errors but for some wierd reason he dont take the demon wings.
In response to Setox
In your finish_quest verb, you call the 'getOfType' verb with an argument of 'src'. The src in this case is the wingermerchant since the verb finish_quest actually belongs to him. The person using the verb would be the person you want to get the wings from. That would be 'usr'.
In response to Flick
I changes src to usr i still seem to have the same problem. This is what i now done. I have no errors though

mob/wingermerchant
verb/finish_quest()
set src in oview(2)
set category = "Wing Merchant"
if(NumberOfType(usr, /obj/DemonWings) > 10)
usr << "thank you thank you so much, [usr.name]."
var/list/L = getOfType(usr, /obj/DemonWings)
if(L.len >= 10)
for(var/obj/DemonWings/B in L)
del(B)
if(NumberOfType(usr,/obj/DemonWings) < 10)
usr << "go get more please i need 10, [usr.name]."


What do? i apreciate what you have told me so far.^.^
In response to Flick
Actually, I just made them up and forgot to look up if they were actually one of the istype()s. Strangely enough, islist() was used in the reference (under IsBanned()) but wasn't actually listed as a proc. The 4.0 reference changed it to istype(., /list) though.
In response to Garthor
Oh lol. Anyway how do i change

for(var/obj/DemonWings/w in usr.contents)
del(w)


So that it only deleted 10 of them?

Thanks for reading this
In response to Setox
for(var/v = 1 to 10)
del(locate(/obj/DemonWings/) in usr)
In response to Garthor
Yay! Thanks everyone my quest is now done.
B