ID:156046
 
Greetings,

I'm pretty new to BYOND programming, but I have lots of experience with other languages. But now I stumbled onto a problem, which I can't really solve by using the search or blue book.

Let's say I have the following code:

mob var HP = 250 fighting_knowledge = 10 verb punch(mob/M as mob in oview(1)) var damage = rand(1,3)*fighting_knowledge M.HP -= damage world << "Punch:[usr] hit [M] for [damage] HP" usr.fighting_knowledge += rand(0,1) verb double_punch(mob/M as mob in oview(1)) var damage = 2*rand(1,3)*fighting_knowledge M.HP -= damage world << "Double Punch:[usr] hits [M] for [damage] HP"

How could I unlock the "double_punch" verb for a user once he reached a certain amount of "fighting_knowledge" ?

I know it "works" with set invisibility = (number) but I wouldn't know how to continue with that.

Thank you,
JackSmoke
You could use something like this. Although it may not be the best way.

mob
skills //not a var, a mob called skills.
verb
double_punch()
//your double punch code
proc/CheckFightingSkills()
if(src.fighting_knowledge > /* insert number here */)
src.verbs += /mob/skills/verb/double_punch


Then you would call that proc everytime the user's fighting_knowledge increased. You may want some sort of identifier to the player, like usr << "You learned double punch!"
In response to Darkoro
Say, I have another question.
Let's say I'd add it like this:

<code> proc CheckFightingSkills() if(src.fighting_knowledge > 20) src.verbs += /mob/skills/verb/double_punch usr << "You learned Double Punch" </code>

and I don't want that message to appear every single time (that he learned the punch). Do I need a help-variable or is there an internal function to check if a user already has the verb?

'cause right now I'd need a variable like "dp_learned" and add that in so it'd be:

<code> proc CheckFightingSkills() if(src.fighting_knowledge > 20 && dp_learned == 0) src.verbs += /mob/skills/verb/double_punch usr << "You learned Double Punch" dp_learned = 1 </code>
In response to JackSmoke
I think there is a way to check if the verb is in a user's verb list, but i wouldn't know about that. It may have something to do with looping through the player's "verbs" list and checking if it matches the verb, or it may not.
In response to Darkoro
Hmm, then I'll leave that open for now.
Thanks alot tho', I think I just have to think outside the box for once :)

In response to JackSmoke
You'd use locate(/mob/skills/verb/double_punch) in src.verbs
In response to JackSmoke
Garthor gave you the answer. Use the locate() proc the way he suggested.