2010/09/03

Experience and Leveling Up

I’m on a code spree; v0.09 might come soon.

The major addition I wanted to do for v0.09 is XP and Levels. I plan to use a very simple system to start: xp granted by killing a creature equals the creature’s level. So a level 5 creature gives 5 xp. This is reasonable; creature difficulty also scales linearly.

Then comes the philosophical question: how much XP to gain levels? I think I found the correct answer: “Depends on how much content there is”. Basically I’m going to playtest the game, and when it feels like I should be gaining a level I’ll find a nearby XP cutoff point. This point will change as I add more of the game world to explore.

The important code for XP will be on the Character menu. Each level gained (2 through 9) the player can increase one core attribute (physical, magical, offense, defense). Anytime the character menu is open and not all points have been spent I need to display [+] buttons for spending those points.

I’ve decided to not bother adding a respec/reset button. It’s easy enough to do out of game: edit the save game file and set build=1,1,1,1. Then when you load your game you can reassign your points.

Finally I need to enforce requirements checks when equipping items. This should be easy, as I think MenuInventory already has a reference to the player’s StatBlock.

[–update–]
XP, leveling, attribute upgrading, and item requirements checks added. Please let me know on the forums if you test this.

Here’s what I did for now, for the XP requirements. I want the number of creatures to be killed (thus, time spent at each level) to increase logarithmically (20,50,100,200,500,1000,2000,5000). So the scale looks like this:

  • 20 lvl 1 kills to 2: 20 xp
  • 50 lvl 2 kills to 3: 100 xp (120 total)
  • 100 lvl 3 kills to 4: 300 xp (420 total)
  • 200 lvl 4 kills to 5: 800 xp (1220 total)
  • 500 lvl 5 kills to 6: 2500 xp (3720 total)
  • 1000 lvl 6 kills to 7: 6000 xp (9720 total)
  • 2000 lvl 7 kills to 8: 14000 xp (23720 total)
  • 5000 lvl 8 kills to 9: 40000 xp (63720 total)

How long does it take in a hack & slash to kill 10,000 creatures? I have no clue, really. Sounds like hours of gameplay though. I timed myself getting to level 4:

  • 3 minutes to reach level 2
  • 6 minutes to reach level 3
  • 15 minutes to reach level 4

The number of kills required approximately doubles each level, and as expected the grinding time doubles also. Projecting the rest of the levels:

  • 30 minutes to reach level 5
  • 1 hour to reach level 6
  • 2 hours to reach level 7
  • 4 hours to reach level 8
  • 8 hours to reach level 9

Total 16 hours of gameplay (not counting quests, trips to town, etc). That’s a pretty solid number. I’d need a good collection of maps to make 16 hours work.

2010/09/02

Gold Coins

The latest check-in has gold coins dropping from creatures/containers. Warning: if you get over 2 billion gold you might end up with negative 2 billion 🙂

Respawning

The latest Google Code check-in allows respawning. Grab this updated code if you like collecting epic magic items!

Save Game Files

This makes me start to think about Save Game files. I plan on using plaintext save files. This might entice some people to cheat, but how rewarding is it for some young person to edit their own save games and experiment!

What needs to be stored in the save game file:

  • Name
  • Experience
  • Skill points spent (PMOD)
  • Equipped and Carried items (68 slots total plus gold)
  • Action Bar customization (12 slots total)
  • Respawn point (map name and coordinates)
  • Campaign Flags and Quest data
  • Achievement Statistics

Of those, the only implemented features are the items and respawn point. I will be working on gold, experience, leveling, and action bar stuff for 0.09 and at that point a save file makes a lot of sense (and should be easy to do).

I’ve added simple save same support added in the latest check-in. The game is saved to saves/save1.txt. Edit the file if you want to change your hero name (or cheat by giving yourself uber gear). Delete or rename the file if you want to start a new character.

2010/09/01

OSARE v0.08 “Loot” Released

The newest OSARE release is focused on loot. Over 500 items are in the game, dropped from enemies or found in treasure chests. I also added the starting logic for the Log Menu (and a heads-up log display). Finally, there is a new starting area called “Goblin Warrens” where you can fight low-level creatures to scavenge for beginner equipment.

Downloads

  • Download (v0.08)
  • 2010/08/29

    Item Database

    All of the coding is done for the v0.08 loot update. Woot!

    What remains is adding all the starting game items to items.txt. This is impractical to create or maintain by hand. What I’m going to do is put all the item data into a MySQL database and use PHP to create the items.txt from that data.

    Once the data is online, I can easily create a webpage to search/browse items.

    2010/08/26

    Loot Stats

    Finally got all the starting loot animations done. As far as I know, this means I’m completely done with art assets for v0.08. More will be added in later releases but this is plenty for now. I checked those animations into the OSARE svn, so you can see them in action if you don’t mind compiling.

    Next up is adding all the item stats. I have plenty of starting stats worked out, though I need to work on item names for bows and armors. This is all stored in the /resources/items/items.txt file. I will probably create a mysql database of the items and some php to create the items.txt. Then I could make a real item database/lookup section of the OSARE website. Sounds win-win to me.

    I have two major code pushes left for v0.08. First is loot from containers. This shouldn’t be too bad. In the map files I assign a level to each container event (default: level 1). When a container is opened, use a similar chain of events as killing a creature to produce loot.

    The second major feature, and of course the whole point, is picking up loot. Right now when the menus are closed, mouse clicks are assumed to be basic attack actions aimed at the cursor. Loot will have a rectangular click region to be picked up. When someone clicks on the playing field, I have to check all the loot to make sure the mouse click isn’t aiming for loot pickup before assigning it as an attack action. Similar code will be added for the action bar (don’t know if that will be added in this release).

    Then it’s a few tiny bits of cleanup code. I need to add % chance of dropping loot to creature definitions. Bosses will drop loot 100% of the time, weak zombies maybe 5%. This is a pretty minor update; I’ll add it right before releasing v0.08 though, because testing loot is easier when every kill basically drops something.

    2010/08/18

    Loot Animation

    Making a list of the loot animations I need. Just to keep track. Essentially every item type has a unique icon and loot animation, and possibly a character layer if it is a main/off/body item.

    0.08 will contain at least these loot animations:

    • Dagger
    • Shortsword
    • Longsword
    • Greatsword
    • Wand
    • Rod
    • Staff
    • Greatstaff
    • Slingshot
    • Shortbow
    • Longbow
    • Greatbow
    • Clothes
    • Leather Armor
    • Buckler
    • Steel Armor
    • Shield
    • Health Potion
    • Mana Potion
    • Ring
    • Boots
    • Belt
    • Generic Gem (white and shiny)

    It feels like I’m putting a lot of effort into content and not into the engine itself. But, a long loot list will give me enough variables to play with to see if my implementation is flexible enough for real game needs.

    2010/08/08

    Loot

    Lots of real life events have been overshadowing my OSARE time. Thanks to all of you who still have interest in the project.

    I’m only 2-3 coding sessions (and an art/data session) away from being done with loot. Currently in svn I have a good dagger and shortsword “flying loot” animation done, and I have those dropping off creatures. The coming data push will add a couple dozen more loot animations and a few hundred items.

    I still have to add the “click to pickup” mechanism for loot. It’s not a particularly interesting set of code, but once that’s done I should be able to use similar routines for other items. At this point I’m considering a ClickRegion struct (similar to the current Renderable struct) that can be generated by dropped loot, containers, switches, etc.

    Finally I need to add support for loot to be generated from containers. I’ll probably assign a loot container a level and % chance to drop an item, much like I do with monsters.

    2010/07/08

    Unicode

    Unicode is slightly intimidating, but I think I’ve found the most useful way to tackle it in my game.

    GNU Unifont is a GPL-licensed bitmapped font that I can work with. It is fixed height (16 pixels tall) and fixed width (8 or 16 pixels wide) so coding for the font should be easy. In C++ I could use double-width chars (wchar_t) and I should be able to find matching string functions.

    Working with OpenGameArt means I’m working with artists from all over the world, and plain ASCII won’t cut it for most of the people who already have direct interest in the game. If I support Unicode, at least someone could modify all my game data files to make a native translation.

    Of course, just supporting a Unicode font isn’t enough. I need to add RTL text support and possibly modify some menus for those languages. I need to macro lines like “Increases accuracy by 5” so the sentence can be reworked and rearranged for the target language. I need to isolate the displayed text as much as possible so that translators don’t have to hunt for changes. Finally, ideally, I need to support choosing language at runtime or at least in a config file.

    Language translations isn’t the exciting part of making a game. My development model for OSARE has been to make the fun parts first, then make it work properly/flexibly later. Unicode/translation support might actually come once I have most everything else in place… perhaps around that phase where most of OSARE’s features are complete and I need to start generating tons of game assets (more monsters/tilesets).

    If I use the GNU Unifont format directly, I might not even need a bitmap version of the font. I could write out the pixels just as described in the text format. Don’t know what kind of performance concerns that would create with SDL.