Damage calculator - Printable Version +- Sword of Moonlight Forums (https://forum.swordofmoonlight.com) +-- Forum: Sword of Moonlight (https://forum.swordofmoonlight.com/Forum-Sword-of-Moonlight) +--- Forum: SOM Addons (https://forum.swordofmoonlight.com/Forum-SOM-Addons) +--- Thread: Damage calculator (/Thread-Damage-calculator) |
Re: Damage calculator - HwitVlf - 2013-07-05 Well yeah, single thread processors run one op at a time, but the code is still just going to reflect the sequence the programmers set up. Even if they ran a subroutine like "trigger Hit animation" between damage calculation and HP reduction, you should still be able to skip past that subroutine and get the damage calculation section without much searching. Anyways, it's pointless to discuss. It takes what it takes based on your skill level and game.exe's stupidliness. A quick look shows around 400 sub routines in game.exe; most of them quite short. Have you charted any of their functions? Re: Damage calculator - Holy_Diver - 2013-07-06 (2013-07-05, 10:11 PM)HwitVlf link Wrote:Well yeah, single thread processors run one op at a time, but the code is still just going to reflect the sequence the programmers set up. Even if they ran a subroutine like "trigger Hit animation" between damage calculation and HP reduction, you should still be able to skip past that subroutine and get the damage calculation section without much searching. Anyways, it's pointless to discuss. It takes what it takes based on your skill level and game.exe's stupidliness. See you seem to be basing your conception here on having some code injected somewhere. If that's the case you may as well inject the code anywhere; edited: as in, the best place possible. If there is no code injected however, it just runs where it runs. I wonder too if you realize that the HP loss is just the final result of attack and defense with respect to eight variables, so you can't extract all of that from the HP loss. It's like being handed a 4 and being asked whether its 1+3 or 2+2. You can't say. Quote:A quick look shows around 400 sub routines in game.exe; most of them quite short. Have you charted any of their functions? After this next release SomEx.dll is going to standardize around som_db.exe, specifically the final patched version. Other exe files are no longer going to be supported. So if someone wanted to they could start documenting the subroutines of that image. I think it would be useful to have a big graph of the EXE with curved lines linking call jumps that you can zoom in and out of in order to help visualize it. But I looked for a product like that yesterday and didn't find anything. I could probably make such a graph myself with a graphing library. I don't know if there would be too much program for it to be practical or not. I know it pretty well instinctively. It just takes a few afternoons to do whatever I want to do with it when something needs to be done. EDITED: Also just for the record. Even in multi thread applications, or a massively parallel architecture, things are happening at the rate of nanoseconds, so you just can't presume concurrency. Everything must be run in sequence. If two execution threads must interact that's an interlock point which can bring everything to a grinding stop. It's a miracle just to keep the concurrent tasks from clobbering one another at the speed of light. Re: Damage calculator - Holy_Diver - 2013-07-06 Quote:To be honest I'm more interested in blurring the line between NPC and enemy. It might make sense for authors to just setup their damage formulas to not harm individuals. On the other hand, do_not_harm_defenseless_characters would be easy enough to setup. EDITED: I did just remember that there is a box you can check to make NPCs invincible in the parameter editor. Still do_not_harm_defenseless_characters would let the player harm these NPCs while forbidding other NPCs from doing the same. It probably wouldn't hurt to add a confirmation dialogue extension to let the player confirm their decision to harm the NPC so that they can't do that on accident. It seems like such a dialog should be the in-game variety. So you'd have to mimic that, and also there needs to be an extension to keep players from accidentally advancing / cancelling dialogs too. So such a dialog may be a ways away. Re: Damage calculator - Holy_Diver - 2013-07-06 Here is reproduction of the damage formula with the ASM in /*comments*/ Code: /* Re: Damage calculator - Holy_Diver - 2013-07-06 I think the "mystery" bit (in the code above) is probably the monsters' evade maneuver defense bonus come to think of it just now. The Strength and Magic bonuses are added to the player's defense as well as attack. The formula is simpler than ((1+(ATK+DEF)/DEF-DEF*2/ATK)*ATK/2). It's simply ATK-DEF+ATK*ATK/(DEF*2) where ATK and DEF are positive numbers. EDITED: Actually with further testing it turns out it is max(0,ATK-DEF)+ATK*ATK/(DEF*2). In other words if DEF is greater than ATK the first term is 0. Why? Who can say. If DEF*2 is 0 then the second additive term becomes infinity, which is undefined behavior when converted to an integer. But the 0044F938 subroutine produces 0 for infinity. I think the subroutine just does floating point to integer conversion. There are at least 3 separate subroutines that do that in this chunk of code. And they are inline subroutines. So the 400 subroutine figure quoted above probably includes a lot of junk subroutines like these. Anyway, since the ASM loads the result of the undefined operation into a register, it gets added to the total as 0. To my mind I don't see the logic in this method of calculating damage. Why two different damage terms, one linear, one exponential, the exponential one collapsing to 0 on infinity damage, none of it makes sense to me, but I wouldn't be surprised if its the same formula used in the King's Field games, however the undefined bits might have played out differently on the PS1. I think probably the thing to do in terms of looking at this as a bug, would be to take the linear term out. And treat 0 defense against nonzero attack as infinity damage. Whatever is done, clamping to 0 seems like a good place to begin. PS: @HwitVlf: neither am I convinced that just doing ATK-DEF would work so well in terms of game play. I don't think players would like it so much unless it was coupled with a way to chip away at the opponents' defenses (that doesn't involve leveling up.) EDITED: Also, the last bit is if there was no damage, then the damage is 1. This subroutine also does bad status infliction as a result of an attack, but I've not included that part above. Re: Damage calculator - Holy_Diver - 2013-07-06 EDITED: I think something that could capture the spirit of this formula would be ATK-DEF where DEF can be chipped away at by ATK*ATK/(DEF*2). In other words, the DEF stat would be brought down with every swing according to an exponential function. The remainder could then be applied to ATK-DEF. And then instead of 0 DEF being infinity damage, it would just be no defense. Re: Damage calculator - Holy_Diver - 2013-07-06 (2013-07-05, 02:05 PM)Holy Diver link Wrote:For the physical affinities using grades it would still appear powerless. No Slash/Smash/Stab or whatever, but the Raw power would be the sum of the magical or material affinities, so you could conclude that the power does not take the form of one of the physical affinities, which would actually be the case. In other words it would be a "vorpal" sword of some kind, or more likely a magic spell... I think one approach to dealing with this could be to just not award mastery for the Void physical affinity. Since it would be an innate power in the weapon. No amount of swinging practice would make a difference. And since how you apply the weapon would have no relation to the stat then it wouldn't be clear how each swing relates to the effectiveness of the damage output. Could make these kinds of weapons popular with wizard players because they would be just as effective with or without mastery. I reckon magic spells could work the same way too. So that if they don't have any physical affinities, then there is no benefit from mastery. Actually the power of the spell should probably just be a function of the Magic stat. Where mastery only awards modest benefits. Probably you would want to go up to 150%, so that anything over 100% is S. That way if the weapon/swing is a 50% F with complete mastery of the swing you could get a 100% A hit. Re: Damage calculator - HwitVlf - 2013-07-06 I expected the actual damage formula would look different than what I used in the excel, but it worked, and no one ever used the Excel anyways so it didn't really matter. Still, comparing the two, I can't easily see how they came to the same conclusion. Not worth the brain power to figure out. I believe the KF damage formula was designed to be a limiter to exploration. If an enemies stats are significantly unbalanced from the player's, it results in giving/receiving massive damage. In an open world game, that works to keep the player out of advanced areas until they're at the proper level. The down side to the KF formula is: it's not user friendly when making up a game, and it completely takes the challenge out of defeating enemies who are at a lower level. People should be able to customize their damage formula with your plugin, but I like "damage=atk-def" for the default setting because it's simple for new developers to understand and use. As long as they have the option to change it, starting with the simplest formula makes sense to me. Re: Damage calculator - Holy_Diver - 2013-07-07 (2013-07-06, 09:50 PM)HwitVlf link Wrote:People should be able to customize their damage formula with your plugin, but I like "damage=atk-def" for the default setting because it's simple for new developers to understand and use. As long as they have the option to change it, starting with the simplest formula makes sense to me. When it comes to defaults I don't deviate from SOM if there is not a technical reason to do so. I don't want to usurp its identity. Besides _1-_2 is easy enough to write into a text file. Still I think that formula could present problems. I wonder if there is a website that documents popular damage formulas. If not we should make one. I reckon once the people have a tool to experiment with a standard formula will emerge. I for one wish game play was more standardized. Every game working differently, detracts from the story telling potential in games I think. It's hard to consume games like books and movies when every one is different. That's not to say that experimentation should not occur. It should just occur behind the scenes IMO. After 30yrs of gaming some standards should have emerged by now. EDITED: IMO the game mechanics should not detract or add to the experience. They should only exist to make the experience more visceral. Since that is the strength of the medium. EDITED: I think one formula that might work as a default could be ATK-max(0,DEF-ATK*ATK/(DEF*2)) This says that the exponential formula negates the DEF and then what remains goes through the defenses. It's as if the armor regenerates after each hit. I think armor could be an interesting concept. It would certainly take the all powerfulness away from healing magic in video games, since the healing would heal the body but not the armor. So you might be full HP but standing naked. A game could have living armor that could be healed, lessening the effect of the heal on HP in the process, but I doubt that would fit into many games. Though it might become a popular trope. Like in King's Field probably only the Dark Armor would have that property. Anyway, the damage formula is pretty buggy. So changing it to some degree is a necessity. Using that formula would at least look similar to the original formula. I want to keep the exponential curve regardless. And I'd like for the results to be similar. I think that formula would basically reduce down to the linear component. But the exponential curve means that it is more forgiving than atk-def would be. Re: Damage calculator - Holy_Diver - 2013-07-07 I've taken a look at ATK-max(0,DEF-ATK*ATK/(DEF*2)). I am a little hesitant about using a completely different damage formula by default. But it has some nice properties. For one. You can obviously never do more damage than the weapon+bonus itself. Which I think is very intuitive. It isn't as unforgiving as ATK-DEF would be. Specifically I think you can start doing damage if your rating is within square root of 0.5 or 70.71% of the defense rating. That's a fairly auspicious number. It shows up in circles. For instance it's how far you can move diagonally when pressing the movement buttons. Whereas with ATK-DEF you would have to be at 100% of the defense rating before you can deal damage. Which seems unrealistic, though I've no doubt games use this. It's reasonable to suspect that a weapon with a rating just below the armor can do more than 0 damage. When the weapon and armor are equally matched you deal 55.90% of the weapon's damage. I am not sure if this number is significant (it almost definitely is) but it is the same number that SOM's classical formula yields. So that seems good (edited: I have a feeling this may be 50%. Could be rounding and stat bonuses were making the difference. Still seems like an awful big difference. May be worth revisiting sometime) I expect when the weapon is 141.42% over the armor you will deal the weapon's maximum damage. This is square root of 2. Or the length of the diagonal of a square enclosing a unit circle. Whereas square root of 0.5 is the width of the square formed by that diagonal clipped at the edge of the circle. Anyway at this point the armor is no longer effective (edited: for the record, this hunch seems to checkout) It would be easy to draw a diagram of these relationships. It would be a circle in a square with another square just inside one of the quadrants of the circle. I mean. Considering the limited range of the stats. I think this is about as good as anything you could come up with. It's intuitive. And based on literally round numbers. And uses the two terms of the original formula exclusively. EDITED: I like this formula I think. If this is what the bugfix does. Because there must be a fix. Then to get the original formula minus its bugs I guess you'd just have to manually use that formula itself. It seems unlikely that anyone would want to. And I kind of feel like weapons doing more damage than their ratings is a bug in and of itself. Plus I don't have the reservations for this formula that I have for ATK-DEF. |