Total noob, (function quirks) - what am I doing wrong here?

CHANGE:

my original question was about increasing int lvl by 1 for every 10 increases of int exp.

the integers lvl and exp have been temporarily removed. I will be doing those a bit differently than I had initially planned. Instead of just leveling up once every 10 exp points, I'm going to use constant ints to determine current exp and exp required to hit the next level. level exp will be unique for each level.

My most recent post in this topic describes my current situation.
Last edited on
You have to check all those yourself...however, why are these all static?
Last edited on
I'm guessing you have a loop of sorts in your program?

The simplest solution is to set maxhp to 10 + exp/10 every time you gain experience. It's not the most efficient solution, but hey... premature optimization's evil. :)

For the second problem, what you could do is use an if statement at every point where currenthp could be raised above maxhp, and check if as a result of the raise currenthp is greater than maxhp. If it is, set it to maxhp. Also not the most efficient solution, but in theory it works. :)

http://cplusplus.com/doc/tutorial/control/#if <- Just in case.

Happy codin- by the way, why are you using static?

-Albatross
Last edited on
From what I read (and based on what I'm trying to do), all I need are static counters.

And when you say check them all myself, I'm not 100% sure what you're talking about. I have some code written that I haven't compiled yet (I'm at work so if I post it and its full of errors then you know why), but I don't have a loop (most ideal code block?) written for what I'm trying to do, as I don't really know how to structure the syntax for it.
Basically do what Albatross says:

Everytime you gain exp, you would set your maxhp to (base_maxhp + exp/10).
and everytime you gain curhp, you'd need to check to make sure it isn't above maxhp and if so, lower it.
etc.
Bleh. I will take a look at that when I get home.

I was using Code::Blocks to write my mini command prompt programs before, but I just set up a new computer in my room which came with Visual.

I have a loop for killing zombies, which already grants exp, but it's static. I just used ++exp; every time you hit the "Z" button in command prompt to kill a zombie. It's guaranteed auto-kill, and your character doesn't actually deal damage as of yet (zombies don't have a hp value and player doesn't have a damage value). It just says you do. Lol.

I also already have a function that exits the program and makes fun of you if you happen to die from a zombie.

Anyway, I will do some more research with that link and logic that you gave me and post some results when I make some progress. Hopefully I can get the healing potions working the way they should! (H key)

Thanks =)
Last edited on
removed; code no longer even remotely the same
Last edited on
Topic archived. No new replies allowed.