ID:156177
 
I've been looking at various tutorials or guides, and google, and experimenting myself, but I can't seem to get my hands on this right.

I've seen many games have it so I know its possible, and I thought I'd maybe try my luck here, so here's my problem:

I want players to have spells, but to be able to use the spell, they have to have learned it ( makes sense ).

I'm assuming spells will be verbs that can be used, but here's the thing, I can't seem to find how to make the verb appear ONLY if the person has learned that certain spell, and how to make it unusable, even by the command, to use if you haven't learned it. Could anyone maybe give me a helping hand, or point me out to a reference that could help me get it?

Thanks in advance, will
Well you can simply use something like this:
spells_of_awesomeness/verb/ //this groups the verbs, making them unavailable until enabled
Poof()
usr << "Poof!"
mob/proc/Condition()//checks for the condition to be fufilled
if(yourcondition==1)//if your condition is fufilled
src.verbs += typesof(/spell_of_awesomeness/verb)//makes the verbs available to that player

That should be it.
In response to Govilku
I added it to my code, but it doesn't really seem to work, i know the varaible spell_telepathy really equals to one during the test, is there some sort of place where I should actually run the proc? I'm kinda new to DM, so it still confuses me.

proc
Condition()
if ( spell_telepathy == 1 )
{
src.verbs += typesof(/spells/verb/telepathy)
}

In response to Anchar
You can run the proc anywhere as it runs constantly as a check for the condition. It looks like you have done some sort of C programming, which I heard was acceptable in DM to a point. A proc typically runs in this form.
mob
proc()
if(blahblah==1)
...

Hope this works for you.
In response to Govilku
Yeah I know, but those brackets help me read the code clearer, since i'm used to C and PHP.

I've narrowed down the problem to that line you gave me

usr.verbs += typesof(/spells/verb/telepathy)

It seems thats the line thats not doing anything, since the if statement itself reveals true and the proc actually executes and sends me back a message. Any idea of what I could have done wrong here?


spells

verb
telepathy(D as text, M as text)
set src in usr
D << "[usr] says: [M]"

This is the actual verb, thanks a lot by the way.

PS: how do you do that quote thing with the codes?
In response to Anchar
Well the main problem is that you included the name of the actual verb. You only need to name the group or "list". So:

usr.verbs += typesof(/spells/verb)//that's it


You insert code snippets by using <"DM"> and closing it with </"DM"> (without the quotes and no spaces)
In response to Govilku
I see, but if I don't use the actual name of the verb, won't that just add all the spells in the actual group? That's gonna be a problem if I have to create a separate group for each individual spell....
In response to Anchar
I put it into a group because it wouldn't be readily available, i was showing you different ways to do it
spells
do_stuff()
blahblahblah
mob/proc/remove()
if(condition=0)
src.verbs -= /spells/do_stuff//do not use the "()" in this situation
I suggest giving the verb to an obj, set its src setting to "set src = usr", and then just place the obj in the player's contents when they have access to it.