Welcome to the Shining Force Central Forums!
SFC Forums Index Shining Forums Shining Force II
Register for your free forum account now or Login to remove this advert.

SFII Exp Tweak experience

My adventures in ASM hacking this game to tweak exp gain

Discussion about this classic Genesis/Mega Drive game.

SFII Exp Tweak experience

Postby ronnen » Wed Jan 25 2012 6:25pm

Hi. Yes, I've not been around before. Sorry if this is TL;DR ... I am verbose.

Reason I cared to get into this (and this is totally my opinion):

WARNING: SPOILER!


Since I'm fairly good with software, learned coding in ASM back in the early Zophar days (though not really genesis 68k architecture before), I figure why not fiddle diddle with this a bit this morning...

My goal for myself is to alter the game to encourage participating in killing the enemies and moving through the game rather than trying (or in some cases having) to power level / cheese.

So, not really finding a disassembled version of SFII anywhere, and being too cheap to buy IDA Pro, I picked up 68kD as well as a version of gens with tracing built in.

WARNING: SPOILER!


So I abandon'ed my effort to raise the minimum in leiu of looking around at places that memory was used, and came up with some things:

WARNING: SPOILER!


Good stuff to know if fiddling with exp routines since they are used in a few places. On to the more important things...

WARNING: SPOILER!


Interesting... What can I do with that I wonder?

WARNING: SPOILER!


Okay, lets "start over..."

WARNING: SPOILER!


Now that hits = kills for exp purposes, now all I really need to do is figure out what exactly I want to do here... Tweaking the exp scale values would be easy; Tweaking the scale itself less so depending on what was desired.

My initial thought, if I really wanted the game to have a tight "control" on leveling... is that I'd have the game reward "max" or at least "high" exp for actions up to a point, and then drop it down low.

WARNING: SPOILER!


I could also shift the scale (or just parts of it) closer to the monster's levels and tweak the max exp so I don't have a cap of 49 on the scale in order to create some other effects.

Thoughts?
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby nightshade00123 » Thu Jan 26 2012 1:07am

Wall of text below.

First of all welcome to the boards. Second, I thinks that's a very unique idea, and one that could work with a game that was being aimed for not having to focus much on leveling and rather just playing.

Although some other things might need taken into consideration, such as when accumulating these levels and power faster even with just 1 attack, this function also served to distinguish between those that were more gifted in growth due to their higher attack power or spell power and others who had to work a little harder for it.

By making it far more rewarding it could lead to no distinction in that regard and pretty much making them all easy money so to speak, but with tweaking of stats and other things I'm sure the snags could be ironed out to an extent. On the same note if this is exactly what was wanted then it's not a big deal, although that was just one example of things to consider of several. But anything different really is always a nice change, as it's rare to have people to do such things to this old game, so I say if it's your cup of tea then your welcome to it and I'm sure others will appreciate the effort as well. :)

And one last thing, good luck in your endeavours! :thumbsup:
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby Earl » Thu Jan 26 2012 6:55am

That's pretty cool. If it's easy enough for characters to reach the point of diminishing returns, that would encourage more cycling out/trying new people without making those cast off immediately beyond hope of returning to relevance.

What would be really interesting is if it were possible to give different rewards for different actions...
For example: Frontline fighters like warriors and knights should have XP determined by damage dealt. They're learning more about battle by battling. But mages should gain more XP by using higher level spells - this is mostly true already, since they do more damage - but might encourage more use of, say Muddle vs. Blaze 1. Then again, that would tie a mage's potential gains to the amount of MP they have, since higher level spells cost more... *shrug* just spitballing here.


Also, welcome to the boards. Don't hear many Zophar shout-outs these days, but I remember back when that was the big emulation site... good times. And it's nice to get some ASM insights; the guys around here who had experience in that area are busy with real life or otherwise inactive. I've been trying to figure out how the class's XP modifying code in Milestone works, but ASM is outside of my wheelhouse.
Earl

User avatar
Shining Legend
Shining Legend
 
Posts: 2928
Joined: Sat Apr 24 2004 6:39am

Re: SFII Exp Tweak experience

Postby Hirsute » Thu Jan 26 2012 8:32am

First, welcome.
Second, extremely good write-up. I know next to nothing about ASM or code in general and I was able to follow everything you wrote there with perfect clarity.
Third, this is fascinating! My mind is already buzzing with the possibilities of such a hack.
"...the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Bill Watterson, Calvin & Hobbes

Aldur wrote:Oh my god Hirsute, you're a sadistic bastard.

Hirsute's Shining Force 2 Mod
Every battle redesigned. Characters rebalanced. Fun increased. Try it now!
"...the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Bill Watterson, Calvin & Hobbes

Aldur wrote:Oh my god Hirsute, you're a sadistic bastard.

Hirsute's Shining Force 2 Mod
Every battle redesigned. Characters rebalanced. Fun increased. Try it now!
Hirsute

User avatar
Emperor of Canada
Shining Legend
 
Posts: 6830
Joined: Tue Feb 24 2009 5:44pm
Location: Ankara, Turkey

Re: SFII Exp Tweak experience

Postby ronnen » Thu Jan 26 2012 6:44pm

nightshade00123 wrote: By making it far more rewarding it could lead to no distinction in that regard and pretty much making them all easy money so to speak, but with tweaking of stats and other things I'm sure the snags could be ironed out to an extent. On the same note if this is exactly what was wanted then it's not a big deal, although that was just one example of things to consider of several.


Good points.

It just strikes me as "unfair" to doubly punish the use of a "slow growth" character. First, you have a weaker character to begin with... and now they also level more slowly?

WARNING: SPOILER!


But you are quite right, there are some things that need to be considered to make this not trivialize the leveling experience at the very least.
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby nightshade00123 » Thu Jan 26 2012 7:12pm

Beware the wall below.

Well another thing that I thought of was the fact that on certain maps there are certain amounts of enemies, for instance in the beginning there are fewer enemies and towards the middle/end of the game that amount increases.

I believe the creators chose the scale they used with that in mind along with other criteria, raising that value could drastically lower the difficulty on longer maps because in vanilla the amount of Exp was given out in amounts that would yield a certain amount of levels whilst doing the map.

If that amount were to yield more then when 1-2 levels were to be gained by the early part of the battle and a few levels around the middle and some towards the end, you now have several levels more gained in the beginning, followed by even more in the middle, and finishing with a higher amount overall and effecting future battles as well.

That doesn't go without saying if you were to tweak some things such as enemy stats it could be overcome, although that might effectively make it like it was before without exp changes.

And I agree about the slow growths, what a drag to know you picked somebody that isn't going to be good until after a good portion of the game is done and much grind was needed to make that possible. I believe better things can be done about this too, I also believe there to be more than 1 approach to doing so.

Either way creativity/balance is a must if you want to make a better experience for yourself when creating your hack, and I believe with enough effort a person could make just about anything work given enough thought, time, and effort. I'm sure these changes will prove quite interesting. :)
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby ronnen » Thu Jan 26 2012 7:56pm

earl wrote:What would be really interesting is if it were possible to give different rewards for different actions...
For example: Frontline fighters like warriors and knights should have XP determined by damage dealt. They're learning more about battle by battling. But mages should gain more XP by using higher level spells - this is mostly true already, since they do more damage - but might encourage more use of, say Muddle vs. Blaze 1. Then again, that would tie a mage's potential gains to the amount of MP they have, since higher level spells cost more... *shrug* just spitballing here.


This is an excellent idea.

WARNING: SPOILER!


I looked into that and figured out how to determine what kind of attack is being done:
Memory location ($B62E) seems to hold this value.
If attack it = 00
If magic it = 01
(there are more, but I'm not sure what the rest are. I'm sure one is healing, I think 02 but again... not sure)

As part of that I identified the routines that calculate damage for both magic and attack, and that both access the "exp gain" code at 0xACEA (healing does not access this code, it uses a separate routine).

So let's talk about "fighter" exp. How would you convert damage done to exp?

WARNING: SPOILER!


Then let's consider Mages. Gaining more exp for using higher level spells is interesting but has some problems.

WARNING: SPOILER!


Perhaps spell level isn't what we really care about, but rather how much mana is consumed by the action?

WARNING: SPOILER!


And then there is the matter of Kiwi, who does both attacks and magic randomly... any of those solutions might have some funny consequences.

I touched on healers in my hack already. Or rather, I touched on how healing works with respect to exp. But since only healers get any amount of exp for healing...

WARNING: SPOILER!


Technically Earl's suggestion would be considerably harder than my initial efforts / plan, but possibly more rewarding if someone can figure out an equitable way to do it.
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby nightshade00123 » Fri Jan 27 2012 3:50am

That would be a pretty neat addition to SF gaining exp in that manner. And those are definitely some considerations to think about as well, with mages and their mp and slow growth/weak fighters would definitely pose a challenge to balance.

That being said I still think the original exp idea is probably a whole lot easier to manage balance wise, good luck.
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby Earl » Fri Jan 27 2012 5:33am

Honestly, I'm not much of a battle mechanics guy; hacks like Obob's and Milestone do amazing things with challenge and balance, but I generally don't think in those terms. I'm not surprised that anything I might suggest would be impractical.


But how do you *not* punish characters who are weaker/late bloomers? Isn't it sort of the point that such characters are millstones you have to carry until so far in?

Although... What if 'fighter' type attacks were given more XP for doing less damage? That sounds counter-intuitive, so follow me... weaker characters are discouraged from picking on all but the most depleted of mobs because killing them is the only way for them to get decent XP. But if they could get that XP just from participating normally, there's less need to baby them.

At the same time, on the face of it, it looks like powerhouses would be punished because their high damage is no longer weighing XP gains in their favor. This would be offset because the power hitters are more likely to kill mobs (that have been softened up by the weaker characters), and so they'd still be getting the 'kill' bonus more often.

There would have to be some thresholds for that, though (as in, diminishing returns for doing truly trivial 1 point damage)... otherwise high defense enemies would be swarmed by weaklings and milked for XP. But it has a kind of logic to it -- learning more from engaging tougher units...
Earl

User avatar
Shining Legend
Shining Legend
 
Posts: 2928
Joined: Sat Apr 24 2004 6:39am

Re: SFII Exp Tweak experience

Postby ronnen » Fri Jan 27 2012 9:01pm

Earl wrote:But how do you *not* punish characters who are weaker/late bloomers? Isn't it sort of the point that such characters are millstones you have to carry until so far in?


Yes but, as I said before, they are doubly punished (a. they suck until late game, b. they gain less exp because they suck) which is :(

Earl wrote:Although... What if 'fighter' type attacks were given more XP for doing less damage? That sounds counter-intuitive, so follow me... weaker characters are discouraged from picking on all but the most depleted of mobs because killing them is the only way for them to get decent XP. But if they could get that XP just from participating normally, there's less need to baby them.


Hmmm...that makes sense. I'll have to think of some elegant mathematics that I can actually fit in the space provided by them which supports that.

------

On another note, I was thinking about my original approach. It is totally something that could be in SpaceKing's SF2Edit.

I'll probably try and get in touch with him, but for now I don't have access to that, so I just whipped something together in VS.

Image

The results of which can be found here for now: SF2ExpEdit

Feel free to give me feedback.

*edit* Oh right, and yes, there is a README in there that hopefully does a decent job of describing what stuff does :) :shifty:

*edit* updated file link per night's comments the first one wasn't working
Last edited by ronnen on Fri Jan 27 2012 10:41pm, edited 1 time in total.
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby nightshade00123 » Fri Jan 27 2012 10:18pm

Awesome Ronnen, not to mention very fast work as well.

I'll try this out as soon as I get a free moment.

EDIT

The contents of the download are empty................
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby ronnen » Fri Jan 27 2012 10:42pm

'Corrected' link in my preceding post to a different provider. Hopefully that works better.
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby Earl » Sat Jan 28 2012 6:58am

That's awesome, and the readme makes stuff very clear.

On a somewhat exp-related note, would it also be possible to set effective levels for the various classes and/or set classes as being unpromoted? This is something Nightshade and I bumped up against in our hacks; there are plenty of classes to work with, but post-promotion status has several associated effects (different music, extra spell damage, spell progression issues)... and in the original game set a character's level for exp purposes to 20 (there's code in Milestone that eliminates the exp issue [no idea how], but the others still stand). There's probably a reason BNC left it the way he did, but I figure it doesn't hurt to ask.
Earl

User avatar
Shining Legend
Shining Legend
 
Posts: 2928
Joined: Sat Apr 24 2004 6:39am

Re: SFII Exp Tweak experience

Postby nightshade00123 » Sat Jan 28 2012 7:34am

Earl wrote:On a somewhat exp-related note, would it also be possible to set effective levels for the various classes and/or set classes as being unpromoted? This is something Nightshade and I bumped up against in our hacks; there are plenty of classes to work with, but post-promotion status has several associated effects (different music, extra spell damage, spell progression issues)... and in the original game set a character's level for exp purposes to 20 (there's code in Milestone that eliminates the exp issue [no idea how], but the others still stand). There's probably a reason BNC left it the way he did, but I figure it doesn't hurt to ask.


Not to mention the max level caps are thrown off as well, ie. making a promoted class unpromoted then setting the max level for unpromoted classes to 20 and the promoted classes to 30 will unfortunately still make that promoted you set as unpromoted level to 30!

But yeah I looked through vanilla, for the exp problem, a few more times and couldn't figure it out. Would be nice to know.
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby ronnen » Sun Jan 29 2012 12:11am

First, I'm not sure I could have answered this with as much certainty if not for some notes BNC made that Earl shared with me; so thank you Earl (and ultimately BNC)!

The short answer is this: The game hard codes which classes are promoted and which classes are not by using inline (i.e not in a centralized location like a data-table) comparisons.

The long answer follows below:

Earl wrote:but post-promotion status has several associated effects (different music, extra spell damage, spell progression issues)... and in the original game set a character's level for exp purposes to 20....


WARNING: SPOILER!


nightshade00123 wrote: Not to mention the max level caps are thrown off as well...


WARNING: SPOILER!


---

As an aside, Earl mentioned that the Caravan does ROM expansions... According to my understanding of my read of the Caravan documentation, it does not expand areas i'd generally describe as subroutines / functions, though it does much of the work that would be needed in order to start on expanding subroutines.

I think I have a better disassembler now, so I'll see if I can find an assembler which will get the job done... then maybe I can think about that.
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby Earl » Sun Jan 29 2012 9:09am

I'm not sure if there's room to expand the class data (haven't looked at it in a while), but I *think* there's some empty space. Whether there is or not, it would probably be easy to shuffle the existing classes around to get the desired effect. Adding classes would be obviously be pretty awesome too, but that's a whole other kettle of fish; they'd need graphics, animation data, and other stuff that's not jumping to mind right now...

In any case, thanks for checking that out and explaining what's going on.
Hope that didn't derail you too much.
Earl

User avatar
Shining Legend
Shining Legend
 
Posts: 2928
Joined: Sat Apr 24 2004 6:39am

Re: SFII Exp Tweak experience

Postby nightshade00123 » Sun Jan 29 2012 4:13pm

Earl wrote:In any case, thanks for checking that out and explaining what's going on.
Hope that didn't derail you too much.


Same here, I appreciate what you have done in the short time you have been here already. You wade through that code like it's water LOL. For people like me and Earl we have to go through and poke at things and 'hope' we find something useful, and it doesn't always turn up anything useful.

Also I plan on using the tools and some of the other things you have shown already, haven't had time to sit and really play with things yet, so thanks again for these things. :)
nightshade00123

Shining Hero
Shining Hero
 
Posts: 539
Joined: Tue Mar 15 2011 2:40am

Re: SFII Exp Tweak experience

Postby ronnen » Sun Jan 29 2012 4:49pm

UPDATE

I stumbled across some stuff in BNC's notes that got me looking at an area of the ROM @ 0x0000853A. His notes refer to it as "classTypes" and it contains 30 entries of 0 (unpromoted), 1 (promoted), or 2 (special item promoted).

WARNING: SPOILER!


And just above it at 0x0000851A is a function his notes refer to as "GetSomethingClassType" (seriously) which for player controlled characters returns a some value less than 0x0C if the class is unpromoted, and some larger value is if it is promoted (though I'm not 100% sure what either of those exact values are, its not overly pertinent for our purposes).

So, it seems the original developers did what I suggested, and made a centralized function for determining if a class was promoted based on a data table. However, it seems they only use this method in one place normally... at 0x0000E90A when doing some enemyAI stuff (GetSomethingClassType returns the enemy "class" if it isn't a player controlled characters).

BUT

This means that in the examples I cited whereby it is doing hard coded comparisons to 0x0C (the HERO class), we can just replace the function call to 0x00008306 (BNC calls this function GetClass) with a function call to 0x0000851A (without having to change the 0x0C comparison) and it will work perfectly for all values 0, 1, and 2 in the classType table.

So, to make the "set promoted class base level to 20 for exp" use the table you can change
Code: Select all
0x0000A978: 0x4EB9 0x0000 0x8306                JSR      0x8306

to
Code: Select all
0x0000A978: 0x4EB9 0x0000 0x851A                JSR      0x851A


I tested this for a variety of class values and this worked perfectly!

I'm confident this same technique of swapping the JSR call as outlined above would worked in all of the "check is promoted" locations.
WARNING: SPOILER!


I'll look more into the ones I'm not sure on yet... Especially the church promotion one, as that would be a non-starter if your hack thinks Xxxx class is non-promoted but won't let you promote it :)

Altering the church actions to promote based on the "promoted" table is unnecessary as long as the "promotion data" is set up correctly. The church guy doesn't care if a class is promoted, he can still promote it.

BNC's notes aren't exactly crystal clear to cross reference with what I'm seeing in the code sometimes ^_^
They are great if I'm already looking at an area, but finding out I should look at that area is sometimes a bit of luck :p

So thank BNC!

Hopefully that gives Earl and Night the information they need to tackle the issues they mentioned successfully!
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Re: SFII Exp Tweak experience

Postby Earl » Mon Jan 30 2012 8:54am

Huh. So all that 4EB9 stuff is part of the ASM code. I keep seeing different strings containing it peppered around the mapsetup data, and was only able to nail down what it was doing in a few easy cases (like calling priest/shop/caravan menus).

And thanks again, that sounds like exactly what I was looking for.
Earl

User avatar
Shining Legend
Shining Legend
 
Posts: 2928
Joined: Sat Apr 24 2004 6:39am

Re: SFII Exp Tweak experience

Postby ronnen » Tue Jan 31 2012 6:05pm

As an aside, I'm trying to see if I can get Space King's permission to update SF2Edit with my exp utility (with a couple more stuffs along those lines that I've "found"... like buff / debuff exp).

I'd like to add handling of the promotion class issues we discussed in this thread that aren't handled by SF2Edit to it as well (modifiying the "is promotion class" bits and how different places make use of them so that they aren't simple > 0x0C comparisons)

If I don't hear back from him in a "timely manner" though (i.e a few weeks / a month / I get tired of waiting), I'll probably just update the utility I made.

But obviously I'd rather not do that:
A) Having separate editors is sub-par in general
B) SF2Edit allows for reallocating the data tables (which SF2ExpEdit doesn't) and that'd be good to have for the promotion class toolset so that I can match it up to the new size of the other promotion table, but since I don't know how/where it reallocates the data tables exactly... it'd be hard for me to appropriately handle that as part of a second exe (SF2ExpEdit)/
ronnen

Shining Member
Shining Member
 
Posts: 162
Joined: Fri Jan 20 2012 9:01pm

Next

Return to Shining Force II

Who is online

Users viewing this topic: No registered users and 1 guest