Displaying variable gains

Posted by Zeno on Sat 30 Aug 2003 06:35 PM — 5 posts, 12,513 views.

USA #0
I've made a new number variable for PCs, and it can be gained sometimes while fighting, or other things. I was wondering, how would I display the increase of the value? Such as "The gods reward you with %d points". I'd have to make a function in fight.c probably, and I've been working on it, but haven't gotten far.
Australia Forum Administrator #1
Have you been reading the recent posts by David B? He is doing the same thing.
USA #2
Well, thats with MUSHclient, so its not really what I'm looking for, but I'll look it over and see if I can work it out. Still, any help I would appreciate.
Australia Forum Administrator #3
Sorry, didn't read the topic heading. :)

One approach would be to have a function to increment the variable rather than doing it directly, and whenever it is called, you could tell the player.

However if that happened too often, you could have two variables, like this:


int xxx; // the variable xxx
int xxx_reported; // what we last told him


From time to time (eg. when you check for hunger) you could compare the two, and if they differ tell the player he has received the difference, like this:


if (xxx_reported < xxx)
  {
  SendToPlayer (p, "you are rewarded with %i xxx", xxx - xxx_reported);
  xxx_reported = xxx;
  }




USA #4
Actually Nick, that post that David made helped out. I made a new function, with three variables, old and new, and had them diff. Which is what you also suggested. Worked fine. Thanks.