ID:167203
 
In my current project, I want to have some fairly specific control of when certain verbs are accessible for the skill system, but I can't seem to get my head around how I'm going to do it.

The way I'd like to set things up is so that verbs can be accessible from objs (via setting the src), but only by certain people. So, for instance, someone has the 'cut down tree' skill, and the trees have the 'cut down' verb. People with the skill can access the verb, but no one else can.

Hopefully I'm explaining this in a decypherable manner. Thinking about this has been giving me a head ache.
Hmmm...

mob/var/list/skills = list()
obj
tree
if(get_dist(usr,src) > 1) //if the distance b/w the usr and tree is greater than one, stop the proc
usr.verbs -= /mob/verb/cut_down_tree //subtract the verb just in case
return
if(locate("cut_down_tree")in usr.skills)) //if "cut down tree" is in the list of skills
usr.verbs += /mob/verb/cut_down_tree //add the verb
else //if not
return


I suppose something like that, but I'm not so sure. Never really tried it. Yeah, I know, no put usr in proc, ungh, but it I'm just trying it, don't yell please.
In response to Pyro_dragons
no put usr in proc

No offense meant, but what process?

The way I'd like to set things up is so that verbs can be accessible from objs (via setting the src), but only by certain people. So, for instance, someone has the 'cut down tree' skill, and the trees have the 'cut down' verb. People with the skill can access the verb, but no one else can.

Well, the easiest way then would probably be to give them a skill object in their contents, and then use "set src in usr" in the verb. That way, only players with that object can use the verb.
In response to DarkCampainger
But when the verb's src is another object entirely. I'm starting to think that there's no particularly simple way to do this, and I'll just need to get over the fact and actually do some programming. I'd love to be informed that I'm wrong, though.
In response to Gathin
Just make the verb take an argument, which is the tree.

obj/skill/Cut_down_trees
verb/cut_tree(turf/tree/T as turf in oview(1))
set src in usr
// Give wood
usr << "You cut down [T] and receive 1 piece of lumber."
new /obj/lumber(usr)
// Replace tree with stump
new /turf/treestump(T)


Then anyone with an /obj/skill/Cut_down_trees object in their inventory will be able to use the cut_tree verb on nearby trees.

There is one small issue with this method; namely, if there are multiple trees in oview(1) and the player clicks the cut_tree verb in their verb panel (as opposed to right-clicking or using a macro), a popup will appear asking them which tree to cut down. That can be annoying, but the only way to fix it is to make the verb belong to the tree, which means that everyone will be able to see it.

If that's a problem for you, then you might want to consider other methods of control, such as clicking trees or bumping into them to cut them down.
In response to Crispy

If that's a problem for you, then you might want to consider other methods of control, such as clicking trees or bumping into them to cut them down.

Oi, good point. Command panels are silly things, anyway. Thanks.