Experience Points and Leveling Up

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Ice Cream Jonsey
Posts: 28877
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Experience Points and Leveling Up

Post by Ice Cream Jonsey »

The code I am working on right now for Cyberganked is the one that check to see if a character gained a level.

I am going to think about what method would be most elegant in this thread, and maybe it will be an interesting discussion.

Here are the requirements and limitations:

- A character can have a maximum of 32,000 experience points. (Roody, I got your code about getting around Hugo's int limitation and I may go that route for this. Actually I almost definitely will.)

- A character gains levels based on tables for their class. A class is something like Commando, Magician, Mechanic, etc. So I can't just say if a player is at 22,222 experience points then their level is definitely 12 or whatever - it would depend on class.
the dark and gritty...Ice Cream Jonsey!

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Re: Experience Points and Leveling Up

Post by Tdarcos »

Ice Cream Jonsey wrote:- A character can have a maximum of 32,000 experience points.
- A character gains levels based on tables for their class. A class is something like Commando, Magician, Mechanic, etc.
It sounds like you have plenty of room there. But, the question is, why do you need to do this? Do the attributes for a player class constitute separate attribute-type values for the class such that if you change enough of one attribute alone it changes the condition of the class or does it require more than one attribute to change, and if so, is the change cumulative for all of them or certain groups of attributes together are what determines what the change is? I'm not sure if I am clear but let me give an example.

In Free Pascal / Delphi, you can have an element on a form which is a button you can click on to do something, and you can also have an image; a picture, an icon, whatever. Image class objects don't have a click event but they do have a mousedown and a mouseup event. The mousedown event, if you enable it, fires when the user presses down on one of the buttons of the mouse - left, scroll wheel, or right - within the image. The mouseup event fires when the user releases that mouse button, whether the release is inside or outside of the image.

The mouseup event tells you which button was released and the x,y position relative to the top left corner of the image where the mouse is when the button is released. If either is negative or above the size of the image in that direction, it's out of range and outside the image, and in that case you can do nothing. But if you use the values when in range to do something when the mouse button used is the left button (as opposed to the scroll wheel button or the right button) and the left button release is within the image, well, you've just converted the element from an image into an image button.

Putting in code in the mouseup event of an image to act if the left mouse button release is within the image changes the class of the object from an image to an image button even if it's not in the button class explicitly.

So in your case, do raising or lowering certain properties of the character then change its class, and if so, what properties? If there is a property 'magic,' and 90-100 means a wizard, at what point is it not a wizard, e.g. if a warrior gets some potion and raises his magic from 10 to 90 is he now a wizard, or is he simply a warrior with high magic ability? I would think that certainly, if he reaches 90 he changes from class warrior to class wizard. But what about a wizard whose magic drops to 89, does this degrade a wizard to, say, sorcerer or mage or whatever the next level below wizard is, or does it just mean his magic is unreliabkle vis a vis Aunt Harriet in the TV show Bewitched?

If advancing above or dropping below a specific attribute automatically changes you to a new class is the case, then you'd need some sort of table to say that certain values automatically put someone in a particular class.

Otherwise you'd need some sort of code algorithm to say that, e.g. if you're above this attribute that puts you in one class, or if you're above attribute "a" to this amount and attribute "b" to this amount makes you this class, otherwise you're that class. Or it could be that all the attributes represent a certain value and the combined total determines your class.

What do you think? Does this help clarify your thoughts as to what you want to try to accomplish?
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Jizaboz
Posts: 4811
Joined: Tue Jan 31, 2012 2:00 pm
Location: USA
Contact:

Re: Experience Points and Leveling Up

Post by Jizaboz »

Ice Cream Jonsey wrote:The code I am working on right now for Cyberganked is the one that check to see if a character gained a level.

- A character can have a maximum of 32,000 experience points. (Roody, I got your code about getting around Hugo's int limitation and I may go that route for this. Actually I almost definitely will.)

- A character gains levels based on tables for their class. A class is something like Commando, Magician, Mechanic, etc. So I can't just say if a player is at 22,222 experience points then their level is definitely 12 or whatever - it would depend on class.
I'd be interested to know how this would work in Hugo. Planning-wise though I think it would be a good idea to make an excel sheet that you can then spit graphs out of to visualize this.

|Class| |LVL1XPReq| |LVL2XPReq|
rogue 10 20

You've mentioned an xp cap, but not a level cap. Let's say that the level cap is 12. First, divide the xp cap by the level cap. Then use those #s to get an idea of how you can start plugging your values into each "LVLXPReq" now that the XP and level cap have been determined. I'd start at the bottom and top then work my way to the middle to eventually distribute the math depending on higher XP requirements for higher levels. In this process you also factor in which classes will be gaining higher. Classes with more skills or "multiclasses" of course always gain levels slower than their barbarian counterparts.

Then you'd have all the text you need for somehow throwing these tables into the Cyberganked code.. which I'm too much of a Hugo noob to speculate on at the moment.

User avatar
Ice Cream Jonsey
Posts: 28877
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

OK, having digested these two posts and what Roody said in chat, I think I am going to go this route:

The game keeps track of the character's level.

You need a certain number of experience points to get to a new level.

New levels are always something the character asks for. (In fact, Jason Scott has agreed to play the NPC that acts as the "review board" or the person you "radio in to" for a new level, in Bard's Tale and Wasteland respectively.

When a character asks for a new level, I check to see if they acquired enough for the next level. If they did, then I zero out their experience points and change their level to the next one.

This lets me set up a thing where at max you need 32,000 experience points for each new level once you get up there.

HOWEVER, if I zero it, it also means that a player can only add one level at a time, which probably violates game/player trust.

Hmm.

I think I'm ready for Hugo 4 that supports 64 bit numbers. :)
the dark and gritty...Ice Cream Jonsey!

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

I personally have not played many crpgs where it's possible to go up multiple levels from one battle. Just the same, yeah, if your design depends upon handling 33,000+ numbers, there's always that object-based thing you can do.

For those that haven't seen it, you split your numbers up to objects, like this:

Code: Select all

property million alias n_to
property hundthou alias ne_to
property tenthou alias e_to
property thou alias se_to
property hundred alias s_to
property tens alias sw_to
property single alias w_to
property change alias noun

object gamescore
{
	million 0
	hundthou 0
	tenthou 0
	thou 0
	hundred 0
	tens 0
	single 0
	change 0
}
Then, your code can add to the digits of your choice, and another routine can print the result as one pretty number.

Post Reply