Jump to content
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


So I implemented item usage in (and out of) battles yesterday. There's a potion in the tavern (bottom floor of the inn) sitting on the small table in the front of the room which you can use to gain about 15HP from. You can use it from the inventory menu, or with the 'use item' command in battles.

Today I wrote up the code for experience tables, gaining experience from battles, levelling up, etc. I think the hardest part was figuring out the overly complex system for stat gains. lolol complications.

Basically, when you level up you're given access to the stat allocation page. You can difer the allocation indefinitely - if you level up multiple times without allocating stats it'll recognize that and let you allocate multiple times etc etc.

You choose 3 of the 6 stats to increase; you can choose any stat any number of times, it doesn't care (though its not really advantageous to do so due to a couple ceils, but I haven't really looked into that).

Basically, you're guarenteed that 7 stat points will be allocated between the 3 categories you select. The ternary stat will always get less than or equal to the secondary, which always is less than or equal to the primary.

$statinc3 = rand( 1, 2 );
$statinc2 = rand( $statinc3, 4 - $statinc3 );
$statinc1 = 7 - $statinc2 - $statinc3;

Makes a nice distribution, I think.

Anyway, there are 3 main secondary stats: maximum HP, maximum MP and dexterity. Each of the 6 core stats is combined with multipliers then summed to get the raw secondary stat gain, which is then scaled by a somewhat random factor. Each primary stat has weights that make logical sense with the different weapon classes, so a dagger-user ends up with the most dexterity, and the magic-user gets the highest max MP. That was a nightmare working out...

Anyway, that leaves us with luck, which is... randomly gained :3

$rawluk = rand(0,1)*rand(0,1) + rand(0,1)*rand(0,1) + rand(0,1)*rand(0,1);

And so on. This presents us with a nice little screen (using the stat choices from the above screen) like this -


I'm going to finish up the weapon/armor code tommorrow, which involves the stats and such to determine overall power/defense/evasion/accuracy and such. Basically, the transformation between the numbers and the actual gameplay mechanic. Its all starting to come together...
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!