I think I should post this here, but im not sure. If I am wrong, please excuse me and let me know. I won't make the same mistake twice. First off, i've added in professions to my game and have given them 200 levels to be gained. I used the ROM gain_exp function and modified it to fit what I needed. It's now going into the (-) exp and not gaining levels correctly. In my score sheet I have TNL setup as: (ch->level + 1) * prof_tnl(ch) - ch->profexp. I basically want this setup to be 2000 a level, every level for the professions. Can anyone tell me where im going wrong with this?
the profession.c file looks like this:
void gain_profexp args( ( CHAR_DATA *ch, int prof_gain ) ); // Used as gain_profexp (ch,Xamount); void gain_profexptwo args( ( CHAR_DATA *ch, int prof_gain ) ); // Used as gain_profexptwo (ch, Xamount);
Just to make sure I understand what you're saying:
I'm guessing by the functions gain_profexp(…) and gain_profexptwo(…) that a player can have two professions that you have a separate function for increasing experience in each? * As an aside, if that's true, it might make a bit more sense to have one function that increases for a specified profession so as to only have to debug one function.
prof_tnl(ch) just returns the experience to the next level for the character, which in your case is always 2000, yes?
From the very top paragraph:
"(ch->level + 1) * prof_tnl(ch) - ch->profexp"
So for a character of profession level 5 (I assume that you mean the profession level there) who has exactly 10k exp, where prof_tnl(ch) is always 2000:
What exactly is being checked and assigned to the experience for the first profession?
In the code given in the post there doesn't seem to be an obvious error. Perhaps there is something wrong with the input to the function (the incoming value of prof_gain)? Assuming nothing else is going wrong, a negative experience value will never be valid in the check to see whether the experience is sufficient to gain/have gained a level.
You may want to provide example data for the exp value before going up a level (i.e. experience less than 'next level * 2000') and the exp value after going up a level. That way we can presumably see the results of the gain exp function. If you have a convenient means of debug, you might insert some output about the before and after experience values around and/or in the call to gain_profexp(…)
Sorry, I tried to edit the last post but couldn't due to it being older than one hour. Basically, to sum everything up… I want it to be 2000 per level. Level 1-100 will all cost 2000 exp to level. There are two professions,  and . Which can be any of the 6 professions available. The exp that is sending to the character is the correct amount. It's after it reaches 2000 that it goes negative for each it gives over. Say you have 100 exp tnl and it gives 1900, you will go negative 1800.
So, if the experience to the next level is greater than the current experience + gain in experience then the experience is set to 2000? In any case, prof_tnl(ch) will only ever return 2000 that I can see. Unless I miss something this would make any experience gains at level 0 that resulted in less than 2000 exp jumping you to the first level. That seems like weird behavior and it will be irrelevant check past that point, yes?
Why not just the following:
ch->profexp += prof_gain;
The pieces you post from your file 'profession.c' otherwise look fine to me. If you don't have another way to look at profession experience than 'score' (do_score(…) ?), which I take to be what you mean by "in my score sheet", maybe you should check that the calculation performed there is correct?
Yeah, I removed the UMAX long before the second response hoping to fix my problem. I made it a bit further and still couldnt get why it wasnt working after I found UMAX was show a > b etc..and the way prof_tnl(ch), etc.. was written didnt even fit that. I finally got the rest straightened out and it was literally that one line. Even after removing UMAX, I still for some reason was trying to do profexp = prof_gain + prof_exp which was giving a print of something wrong. I'm sorry I took up your time on that and thank you VERY much for helping me. What you through out with += prof_gain; worked like a charm. Thanks again Nathan.