ID:1661026
 
(See the best response by Halloween14.)
Code:


Problem description:
I have a slight problem controlling verb accessibility. I know how to do so to a degree, but can't manage to do so in a way that would allow me to implement a class system in a game. I've noticed, primarily in Naruto games, that certain techniques are only usable in certain clans. I've managed to make it so certain verbs are only viewable by those with a specific variable associated with their mob, but not limiting the ability to use those verbs by simply typing that in. I've read the guide multiple times, and while I'll admit it's possible I've simply missed a section, that doesn't really solve my problem. Any help would be appreciated.
Best response
Ok, gonna try this out but let me state I know nothing about Naruto. For this example I will just refer to elements as these abilities (earth, wind, fire, & water). It is a good idea to have one verb that branches off to whatever element that player uses...

mob/var/element=0 //1=earth 2=wind 3=fire 4=water let users select their element when creating character
mob/var/hp=100//just a default health variable :P

mob/verb/elemental()//defines the universal verb (will not cause inaccessible verb when used by any player since all will have it and it will branch off depending on their element
if(usr.element==1)
usr.earthattack()//calls the earthattack process... the following 3 are the same just directing to their processes instead
if(usr.element==2)
usr.windattack()
if(usr.element==3)
usr.fireattack()
if(usr.element==4)
usr.waterattack()

mob/process/earthattack()//these are the actual attacks being called from the initial verb
for(var/mob/M in range(1,usr)//does an aoe for range of one
new/obj/attack/earth/E=new()//this creates a new earth object under the attack obj. (good idea to group similar items - ie obj/weapons/"then specific weapon" or obj/food/"specific food" this way you can make a verb like equip() that applies to only weapons but all weapons ^-^
E.loc=M.loc//apply the effect object to where the user is attacking
spawn(10)//continues with the code below then executes the indented code below this line after the ticks in the arguement field pass - in this case 10 ticks
del(E)//get rid of the element object so it doesn't stay forever
M.hp-=usr.elementaldamage//subtract the users elemental damage from the source hp and if you like you can change it from an exact number like this - src.hp-=rand(usr.elementaldamage,usr.elementaldamage+10) - that means the damage could be from the elemental damage to +10 elemental and anywhere in between
M.deathcheck()//now of course run a death check on the enemy to see if it died

mob/process/windattack()//this is just to show how similar these would be and the others would work the same as well
for(var/mob/M in range(1,usr)
new/obj/attack/wind/W=new()
W.loc=M.loc
spawn(10)
del(W)
M.hp-=usr.elementaldamage
M.deathcheck()

obj/attack/earth//this is the object that pops up to show the element attack
icon='elements.dmi'//defines the dmi file
icon_state="earth"//uses the earth icon for the object

obj/attack/wind//same as before but slightly altered
icon='elements.dmi'
icon_state="wind"


I hope this helps you out, I know this is the way I would handle it plus some extra stuff to flesh it out but this should be a decent reference.

Also, heres another way to code it a little lighter...

mob/var/element=0
mob/var/hp=100

mob/verb/elemental()
for(var/mob/M in range(1,usr)
var/obj/attack/A
A.icon_state="[usr.element]"//this would make the icon state "1" if it is earth so the icons would be named 1, 2, 3, and 4 instead of the actual earth, wind, etc. (less code to go through)
A.loc=M.loc
spawn(10)
del(A)
M.hp-=usr.elementaldamage
M.deathcheck()
//now you dont need those processes since this takes their place :)

obj/attack
icon='elements.dmi'//you dont need to define a state since the process takes care of that

^this is a much easier way to go through it but I thought I would show both since the first may make more sense :/
I like that idea, and it does answer part of my question. What I want to know now is how to remove a verb from certain player's verb list completely. For example, say I have two classes: Swordsman, Archer. Two skills: Slash, Shoot. Now, I know I could make it so that the verbs are derived from the particular classes weapon, but what I want to know is how I could derive the verb from the player, but only give the Slash verb to the Swordsman, and the Shoot verb to the Archer. The Swordsman can't see or use the Shoot verb, and vice versa. Any tips on doing something like that?
Here is that specifically. Instead of removing verbs just add them depending on class.
mob/player//default user mob

mob/player/swordsman//these are the defined classes where you add their verbs
verb
slash()//this just states the verb and so far does nothing, refer to the previous post to see how to finish these

mob/player/archer
verb
shoot()

mob/proc/chooseclass()//process for selecting/changing class
switch(alert("What class do you choose?",,"Archer","Swordsman","Cancel"))
if("Archer")
usr.verbs+=typesof(/mob/archer/verb)//give the usr archer verbs
usr.verbs-=typesof(/mob/swordsman/verb)//remove the swordsman verbs if they have them
if("Swordsman")
usr.verbs-=typesof(/mob/archer/verb)
usr.verbs+=typesof(/mob/swordsman/verb)


This makes it so you can choose a class and it will remove accessible verbs and give you the correct ones.
I'd thought about trying something somewhat similar, but wasn't sure how to go about making it work. Thanks for taking the time to answer my questions, it's definitely appreciated.
Not a problem, both examples shouldn't be too hard and there is plenty that can be done with them.