ID:266052
 
I'm on the verge of changing the way my game handles whether a player has a certain skill or not.
Currently they learn a skill and get a verb accordingly. And @ logout their verbs are saved and restored.

The new system Im supposing will give players actual objs when they get a new skill.

Within that: I was wondering what people generally accepted as the best method:
1) attaching the verb to the object itself
2) keeping the verb system the same but adding an if() check to see if the related obj is ion contents
3) something else/better?
Personally, when I have verbs that need to be added/removed from a client at runtime, I have a few lists;
mob/var/verbList = new/list()
mob/var/verbsActive = new/list()


I populate this list with keywords for the verbs;

mob/verb/Learn_Punch()
src.verbList += "Punch"
src.verbPopulate()


verbPopulate() will then handling adding the verbs as accordingly;

mob/proc/verbPopulate()
for(var/varbs in verbList)
if(varbs in verbsActive)continue //We don't need to add a verb that's already been added
src.verbs += text2path("/mob/runtimeVerbs/verb/[varbs]")
src.verbsActive += varbs


Then I just save the verbList var, and run verbPopulate() on Login.
In response to El Wookie
The interface should be:

mob
verb/LearnPunch()
addVerb("Punch")
verb/UnlearnPunch()
removeVerb("Punch")


(I'd prefer <code>addVerb(PUNCH)</code> where PUNCH = macro for the path to the verb, myself)

The activeVerbs list should also be replaced by checking mob.verbs directly, I'd say.
In response to Toadfish
This is redundant as you would need to list them anyway to save them, meaning either way it's the same amount of programming with no different outcome...
In response to El Wookie
Sorry, I'm not sure what you're talking about. What I meant is the proc would work like this:

mob/proc/addVerb(verb1)
if (verb1 in mob.verbs) return
mob.verbs += verb1
verbList.Add(verb1)

</dm>
In response to Toadfish
That's identical to my proc...
In response to El Wookie
Hence "interface" and not "algorithm" or "implementation": the point is it's better practice to set it up like that. Otherwise your verbList and actual verbs are not dependent on each other which can cause errors where you accidentally add or remove one to the latter and not the former, for example.
In response to Toadfish
No, seriously, in every way, aside from the fact you have lines in a different order to me which makes no difference, our procs are identical.
In response to El Wookie
mob/proc/verbPopulate()
for(var/varbs in verbList)
if(varbs in verbsActive)continue //We don't need to add a verb that's already been added
src.verbs += text2path("/mob/runtimeVerbs/verb/[varbs]")
src.verbsActive += varbs


Is not identical to

mob/proc/addVerb(verb1)
if (verb1 in mob.verbs) return
mob.verbs += verb1
verbList.Add(verb1)


Because one controls the added verb and the other updates the verb list according to preset data. Neither are the lines the same. I'm really not sure what you're on about.
In response to Toadfish
If you can't tell that those are practically identical then you shouldn't be giving advice.
In response to El Wookie
What he's trying to point out is that he thinks that supplementing the type path rather than a name of a verb would avoid too much dependency. Hence, dropping the text2path proc and directly supplementing the type path itself.

If you'll be too worked up about your code being "identical" to others, then you shouldn't be giving advice.
Don't worry, I don't mean it. I'm not that rude.
Your description is not very clear.

What are these "actual" objs that you are speaking of?

The easiest way it to place the verb in an obj and let the verb have set src in usr. Then place it in the mob's contents.
In response to Jemai1
I'd set src = usr.contents, myself.

The difference is inputting "punch name-of-punch-skill-card target" vs. "punch target".
In response to El Wookie
El Wookie wrote:
Personally, when I have verbs that need to be added/removed from a client at runtime, I have a few lists;
> mob/var/verbList = new/list()
> mob/var/verbsActive = new/list()
>

I populate this list with keywords for the verbs;

> mob/verb/Learn_Punch()
> src.verbList += "Punch"
> src.verbPopulate()
>


What happens when you add something to verbList but forget to call verbPopulate?

It'd be better to have it like this:

mob
proc
learn_punch()
add_verb("punch")

add_verb(v)
if(v in verbList) return
verbList += v
verbPopulate()


It's harder for the developer to screw that up because add_verb handles all of the details, you don't have to handle the details (calling verbPopulate) every time you add a verb.