ID:1642349
 
Keywords: help, how, howto, howtomake, make, npc, to, verb, verbs
(See the best response by Pirion.)
Code:


Problem description:

How would i make a NPC(Non playing character(Game mob)) use a verb?
Best response
A verb is a proc that has been been made accessible to a client to call directly. Therefore, you would call it just like you would call any other proc.

mob/verb/say(t as text)
view(6) << "[src.name]: [t]"

mob/shopkeeper/ai_loop()
while(src)
say("Boy, sure is hot today!")
sleep(6000)
In response to Pirion
obj
skill
clones//this is the line the must only contain one verb after it untill the next jutsu
verb
Clones()
set category = "Skills"
set name = "Clone jutsu"
if(src.cooldown)
usr<<"You must wait [src.cooldown] seconds before you can use this again."
return
if(usr.handseal(50,3))
src.cooldown=15
spawn(1)
while(src.cooldown)
if(src)
src.cooldown-=1
sleep(10)
var/mob/npc/Bunshin/A=new()
if(A)
A.name="[src]";A.density=0;A.owner=usr;A.icon=usr.icon;A.overlays+=usr.overlays;A.loc=locate(usr.x+1,usr.y,usr.z)
var/obj/smoke/B=new()
B.loc=locate(A.x,A.y,A.z)
view(A)<< sound('Smoke.wav',0,0,1)
else
usr<<"You failed the jutsu."



mob
proc
usejutsu(mob/M)
if(src.ko)
return
var/jutsu=pick(src.jutsus)
if(jutsu=="missles")
src.auramissles()
if(jutsu=="missle")
src.auramissle()
if(jutsu=="push")
src.push1()
if(jutsu=="pull")
src.pull1()
if(jutsu=="crows")
src.crowg()
if(jutsu=="finishstart")
src.finishstart(M)
if(jutsu=="clone")
src.Clones()// here i where i need it

So how would I do this one?
As the verb uses usr, you need to first resolve that issue. For tips, check out "Dream Tutor: usr Unfriendly".

Once you've done that, you'll want to determine how /mob will access the path /obj/skill/clones/verb/Clones.

1: You can add the verb to the verbs list, this will not preserve the meaning of src. (src becomes /mob rather than /obj/skill/clones)

2: You can create an instance of the object and call object.Clones() (src is an object, though it doesn't have access to Clones(), so src.Clones is not correct here). This will preserve the meaning of src.