ID:1417033
 
(See the best response by MDC.)
I wanna make a system where I can give all my techniques a few stats like maybe level, xp to next level, or number of uses, etc. but I realllly don't wanna be like var/fireballevel,iceballlevel,etc for each skill how do I make a system to apply basic stat sI guess to a skill but save em individually liek if i opened fireball itd say im lv 5 and got 56 uses and got 200 xp to go and then if i open ice storm its completely different based on what I levled and used
Best response
You don't need a variable for each. This is one way to do it:

skills
var
level=1
current_exp = 10
exp_to_next_level = 100
skill_1
skill_2
skill_3


This way skills 1, 2, and 3 each have the same variables "level", "current_exp", and "exp_to_next_level".
what exactly are skill 1-3 supose to be cause im wondering how they would be referenced in regards to they information i would need
skill_1 could be fireball
skill_2 could be iceball
skill_3 could be whatever and you just keep going with how many skills you want. As long as they're under their parent "skills" like up there, they'll each have the variables you see up there.
i mean in a basic sense how would i display each skills variables in a seeable fashion like how would i be bale to see fireballs exp vs ice balls etc
you'd check skill_1.level
skill_1.current_exp
etc
skills
var
Uses=9

mob
verb


Fireball()
src.icon_state="spew"
usr<<"uses is at[Fireball.Uses]"

how am I supose to place this for verbs it just gives me a error saying fireball.uses is undefined
You missed a part. You have to list the fireball and every other similar skill under "skills"

skills
var
Uses=0
Fireball
icon = 'blah.dmi'
icon_state = "wahtever"

mob
verb
Fireball()
create your fireball
do stuff
src.icon_state="spew"
make Fireball.Uses++ so it adds another use to the variable
display Fireball.Uses(watch your usr and src usage)
You should probably be showing him how to actually create the fireball and access the variable from it, instead of assuming he knows what your pseudo-code is supposed to be doing.

mob/verb/Fireball()
var/skills/Fireball/fireball = new() // Create the fireball
fireball.Uses++
// Do other stuff with the fireball here.


This, of course isn't going to keep track of anything since you're creating the fireball locally and it gets deleted, so you're gonna want to do something a bit more permanent.

mob/var/list/my_skills = list()

mob/verb/LearnFireball()
var/skill/Fireball/found = locate() in usr.my_skills
if(found)
usr << "You already have that skill!"
return
found = new() // Create the skill if it isn't known yet.
usr.my_skills += found

mob/verb/Fireball()
var/skill/Fireball/found = locate() in usr.my_skill
if(!found)
usr << "You don't know fireball!"
else
found.Uses++
// Create a projectile or whatever here.


Now, you'd probably want to make things a lot more generic, so you'd want the action of each skill contained in a /skill/proc called Action() or whatever you want, then calling that proc would do things like create the projectile and handle the variable changes needed.

As for viewing which skills you have and whatnot,

mob/verb/ViewSkills()
for(var/skill/S in usr.my_skill)
usr << "[S] ([S.Uses])"


These are just examples though, you're expected to expand on them yourself and make them work how you need them to work. Good luck :)
awesome this work great for how i think im going to use it
Yeah, sorry about that gamer. It was really late last night and I wanted you to figure out the rest on your own. Glad you got it working.