On Wed, 6 May 1998, Owen Brodal-Robertson wrote:
[...]
>
> now it compiles, but I have this REALLY bad feeling that I've gone and
> done something really dumb...
>
> What I want, is to make it so that every level's exp is determined as a
> percentage of the previous level (i.e. level 20 would require 120% of the
> exp level 19 required. I hope that makes sense).
I'm not sure how curr_exp gets set above, but if its set to the
player's current exp, he will never level as he will always need 120%
more than what he currently has. <G> But we can make the function you
want with recursion:
int prev_exp; /* put this with variable declarations above ofcourse */
case CLASS_WARRIOR:
switch (level) {
case 0:
return 0;
break;
case 1:
return 1;
break;
case 2:
return 2000;
break;
default:
prev_exp=level_exp(class, level-1);
return ((prev_exp - level_exp(class, level-2))*level)/100+prev_exp;
break;
}
This function will take the amount of exp it took to get to the previous
level from the level before that, multiply it by a percentage equal to
the level, to find the exp needed from the previous level to the new level.
Ofcourse it is a bit CPU intensive with all the recursion, if the call
level_exp(class, level-2) can somehow be avoided it will save alot.
>
> If I've done something wrong, can someone stamp me with a 'STUPID NEWBIE'
> stamp, and help me out?
Sorry, I'm all out of ink. :)
I hope this helped,
-Hans
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST