I did it once in past but i cant find it but how do I code it so where say different skills have their own levels and exp to level
EX: fireball is lv1 with 20/100 to next level and lighting bolt is lv 5 with 1324/2800 to lv 6
ah ok for some reason it thought it was going to have to do with temp vars or local vars or something
|
ok im baffled here but something is wrong im trying to get it to update the info on xp per the next lv but yet it doesn't for some reason it's staying the same
var it will keep reporting the xp needed is 55 even though the level is changing whcih is weird how do i fix it? |
Why are you making
var and proc world variables and proc? Stick with the Skills datum Turbo has shown. |
In response to Mastergamerx
|
|
I did. I helped. Don't use world /var and /proc's for things that should be handled per the /datum or the skill /obj itself.
"b" will always equal 0. b = a * (reduction / 100) b = (rank + 25 * level / mod) * (0 / 100) So, let's take an example. a = rank + 25 * level / mod b = a * (reduction / 100) c = a - b a = 30 + 25 * 1 / 1 a = 55 b = 55 * (0 / 100) b = 0 c = 55 - 0 c = 55 But like I said, you should be handling it like Turboskill has shown. |
yes but the problem is the experience needed is not increasing aka the requirement var it just keeps saying 55 even though the level has increased
|
Ok so i've been kinda busy, but yeah the issue would be that rather than look to get the value of the requirement from the var directly, you'll want to instead use a 'get' proc. You see, variable a will continue to hold the value that was the result of the formula that you assigned to it, at the time that you assigned it; It won't automatically update because the value of a variable used within the formula changes**.
So what you'd want to do for your above code would be something like: proc/getRequirement() An Alternative way to do this btw, is via the use of defines: #define a (rank + 25 * level / mod) Defining those as macros rather than variables would give the desired results (without need for other changes), because of the way macros work, being that in all places where the aliases/identifiers (i.e. 'a', 'b', or 'requirement'*) occur, at run time the names are treated to mean what you defined it as on the right side of the macro. Again this is done at run time, as such it gives the same effect as fetching a value by using a proc to return the result of a formula. // | name/alias | meaning |
sigh this is just confusing me more and more i look at it so ill try to explain this best i can. I want the experience required per level to be based on "rank + 25 * level / mod" and to apply any reductions to the overall xp if there is any.
so EX:if the exp was 500 to level with 0% reductions vs say 400 xp to level with 5% reductions or w/e. so im making this quirky lil verb test to make sure everything is working accordingly |
so the problem im having atm is the getxp proc will only return the base formula and not the reduction included which i need it to do
|
It's pretty simple:
You need to set the requirement every time you level up. You're currently not doing that. All you're doing is setting a variable to a formula, which is evaluated at run-time. Variables are evaluated once, unless you set them to something else. |
Well, it seems like you're just using code without having any idea what it actually does.
Your issue stems from id:1843282. You took a piece of code Goober gave you, and just added onto it. Don't just shove it into the editor. You want a/b/c to be part of a bigger piece of code (probably part of a mob, obj, or datum) - not variables defined globally, the same with rank, level, reduction, etc. Use them in conjunction with procs and stuff. mob I'd suggest reading the guide: http://www.byond.com/docs/guide/ Here's also a really simple, but ancient, demo you can look at: http://www.byond.com/developer/Rcet/LevelDemo |
Initially i was going to go all gong ho and maybe map out a general skill system as i started doing this, but alas i'll be cutting things short here. Basically i wouldn't advise to take this code as any kind of slot in, but hopefully you can get the general idea.