Author Topic: Damage calculator  (Read 22826 times)

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #10 on: March 29, 2013, 04:08:41 pm »
I've had some ideas about how to implement this stuff. The ATK/DEF bit would be pretty straight forward to do. But I am not sure it is even necessary to...

At first I thought the model could be done by adjusting the monsters' attack/defense whenever the player changes equipment, but I quickly realized that that would not cut it.

But it made me hopeful to keep thinking. I think what should be able to work is to simply precompute the results for all of the attacks/defense pairings whenever the player changes equipment. Same thing pretty much.

Except never really letting SOM do anything. So just do something like zero out the stats for the monsters, and just put the resulting damage in the first affinity and have it deal direct damage to the player. And more or less the same for defense, though its more complicated.

But I realize just now that the trouble with this is monsters can hit other monsters, or at least their magic can. So I think the only way this problem can possibly be approached assuming SOM does the hit detection, is to just try to find the bits of the game that identifies the attacking/defending parties and scoop it out, or if it goes through a subroutine, send it to one of our subroutines instead. And if it doesn't well then fill the scooped out bit with a subroutine call that does.

So more or less the way I probably would've opted to implement the formula calculator. Just at a higher level (assuming that's even possible)

I try not to go about reprogramming SOM this way if I can help it. But I am damned near convinced this is the only way in this case. I did a job similar to this for the first time a little while back in order to decouple the look axes so turning could be faster during fast turns without also speeding up the vertical axis.

That is enabled by extension. The only difference in this case is rerouting or injecting a call jump. It will be new territory. But I intend to look into equipping items here in a bit, and I assume that is done as a subroutine because it just isn't the kind of thing that is done in a main loop. It feels like the time is right to bump things up to this level of tampering even though I am pretty sure the EULA expressly forbids disassembly :sweatdrop:
« Last Edit: March 29, 2013, 04:13:40 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #11 on: March 31, 2013, 10:12:08 pm »
So I double checked everything, and this ((1+(ATK+DEF)/DEF-DEF*2/ATK)*ATK/2) simplification does look right. Don't know that it matches SOM's output, but it matches the formula above.

Here is a plot. You (HwitVlf) have probably done this already. But just if anyone wants to see what it looks like. Here is a plot with 40 defense (there are also 3D plotters available if you search for it and don't mind using Java plugins)

http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIoMSsoeCs0MCkvNDAtNDAqMi94KSp4LzIiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyItMTE4LjQyOTcwOTkwMTMzNDQ5IiwiMTkxLjUxNDQ0MjkzMDY5NDkiLCItNzguNjY5MDI3NDU3Mjk2MDciLCIxMTIuMDY1ODM1ODIzOTUyNjQiXX1d

I can see how this works. But I am pretty sure I would (or will) never be able to figure out this function even if I had the patience to stare down the numbers. I don't know if its an awful formula, but it does rather lend itself to Final Fantasy like games where levels are very stratified and the numbers become very unwieldy when outclassed (though I'd expect that at least one of the KF games probably works this way)

What worries me is the player doesn't know if their weapon is having any effect. But I guess you'd give up after hacking away for too long. But suddenly a monster that seemed insurmountable might become a pushover if you can get a stat up 10 more points (if defense is 40 as in the plot)

Ultimately I agree though. I think KF is better suited to slow (or no) progression. Lord knows a game doesn't really take long enough to make any real kind of progression in real life anyway. And if it did it probably wouldn't be fun to play. Not to mention that Damage=Attack-Defense would probably be easier for authors to wrap their head around. I like to feel like I've made some progress by the end of the game, but I don't need to feel like a superman. 

The real problem I see here is one affinity would dominate. In other words unless the affinities are very close together, the lower ones will either have no effect, or the higher ones will be overkill. Of course if a monster has a immunity to an affinity or two, having extras doesn't hurt.


PS: I can see now how Magic could drive damage bonuses for the magical affinities. I kind of always assumed that Strength would be multiplied by the affinity rather than added on top of of it. I mean if you have 0 Strength how can you hit for any damage right??

I think I still prefer (myself) the notion that the magic is just a quality of the weapon, so swinging it harder just hits harder. IOW the Magic stat should be limited to spells only (if it isn't; I should probably do an experiment to see for myself)


EDITED: By the way, it will be interesting to find out what this looks like in SOM's program. Kudos if its identical.
« Last Edit: March 31, 2013, 10:19:19 pm by Holy Diver »

Offline Verdite

  • VIP
  • Dark Slayer Destroyer
  • *****
  • Posts: 1624
Re: Damage calculator
« Reply #12 on: April 01, 2013, 10:33:55 am »
Dont mean to derail things but some input is better than none.

"What worries me is the player doesn't know if their weapon is having any effect."

Usually a monsters hit animation indicates this, you could have 3 animations depending on how you hit... First one would be a short wince, second would be a wince with a step back, third would be as devastating as you want and could stagger the opponent back thus giving you the option of rushing or retreating.

THEN you could remove all the damage numbers from the players view in the inventory  :eek: and replace the damage numbers with 'sharp' to 'dull' for blades and 'solid' or 'rickety' for maces. Examples.

For a decent cutting sword it could read
Slash :  Good - depending on metal and craftsmanship
Stab: Poor - depending on sword class, rapiers would be different
Smash : Average - depending on weight and swing type, swords can break bones with impact on armour
Durability : Broken through to excellent.
Then you could have the same for armour defences. Remove the numbers and replace it with something slightly more mysterious.

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #13 on: April 01, 2013, 05:16:22 pm »
Dont mean to derail things but some input is better than none.

"What worries me is the player doesn't know if their weapon is having any effect."

Usually a monsters hit animation indicates this, you could have 3 animations depending on how you hit... First one would be a short wince, second would be a wince with a step back, third would be as devastating as you want and could stagger the opponent back thus giving you the option of rushing or retreating.

Well I am not referring to hypotheticals here--I try to make that clear if that is the case. I meant with plain vanilla SOM you always stun the monster. And with this damage formula, there are good odds you'll be hitting for 0 if your attack power is below the damage window. But with SOM the damage is always rounded up to 1 if it isn't exactly 0. I think actually that all of the affinities are summed together before that rounding happens.

I actually don't think KF2 works this way. Because there would be a lot of stories of people trying to kill the Giant Kraken but not succeeding if so. Unless that is its HP is actually low enough that each hit is taking off exactly 1 hp regardless before it goes down (which is very possible too)

Anyway I basically agree that this is probably not an ideal formula for most games going forward.


PS: I honestly didn't mean for this thread to turn this way. Or I didn't want it to go beyond sussing out the damage formula itself. If you want to recommend anything here, I would just like to ask what variables should be provided to the formula? I will probably call this Attack variable HP and the armor variable AP. I can see the sum of all of the affinities being useful (both divided by category and altogether) and having access to the counters is a no brainer...

Strength and Magic bonuses will be separate formulas. And I am pretty sure if the affinity is 0 it won't be considered for bonuses or damage.

And before I call it quits. Per that Void system. I have the sneaking feeling that instead of the physical affinities being presented to the player as percentiles, if any it will be the magical affinities that will be so. The system still works the same, but this is because I reckon the magical affinities won't change. But I can easily see the physical affinities changing based on the swing ID. So you'd have to present a range like 0-10, and that wouldn't work well with percentiles. Plus there are likely to be fewer physical affinities, so players can more easily appraise the weapon if the raw power is a function of those affinities...

Another consideration is if we chose to represent one of the affinities as percentiles (you don't have to do this but it seems likely as it saves the player from doing a lot of work in their head) then the affinity group that is not percentiles almost definitely has to have its Void affinity visible. My guess is that usually the aVoid affinity would be called Magic and it would represent a magical component of a weapon's attack that cannot normally be defended against. You'd probably want it to be boosted by the Magic stat somehow (whereas the other physicals would be boosted by Strength)

I think it will still be hidden by default though, as many games would probably opt to just not use the aVoid affinity.
« Last Edit: April 01, 2013, 05:21:14 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #14 on: April 01, 2013, 05:27:18 pm »
THEN you could remove all the damage numbers from the players view in the inventory  :eek: and replace the damage numbers with 'sharp' to 'dull' for blades and 'solid' or 'rickety' for maces. Examples.

For a decent cutting sword it could read
Slash :  Good - depending on metal and craftsmanship
Stab: Poor - depending on sword class, rapiers would be different
Smash : Average - depending on weight and swing type, swords can break bones with impact on armour
Durability : Broken through to excellent.
Then you could have the same for armour defences. Remove the numbers and replace it with something slightly more mysterious.

I see what you are doing here. Basically you want a way to translate stats into grades. I think this has merit myself, just because you might want to convert 100 to 10 to make it less intimidating, assuming there is some reason to not just use 10. And like I've said I do think a fuzzy stat presentation might be an improvement (even though most RPG nerds would probably protest)

Anyway. This seems like it would naturally be part of the Script since its simply translating in game text (my idea was to just use ABCDEFS as From' games have a history of doing that... but Armored Core games also often include a wordier grading system for appraising the AC; Poor, Fine, Good, Excellent spring to mind)
« Last Edit: April 01, 2013, 05:30:20 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #15 on: April 01, 2013, 07:17:49 pm »
Assuming "Excellent" will fit in the space allocated,

A=Fine
B=Good
C=Average
D=Fair
E=Poor
F=whatever

If you used this for affinities, I am not sure what you'd do about ranges... eg. Poor-Fine doesn't really make sense. So I think numbers are still best here. Likewise, just because a spear is not made for smashing, doesn't make it a Poor weapon.

Anyway, Excellent is for S. Which means Fine condition with mastery. I included Average (as suggested) because it looks weird if all of the grades are four letter words (and C had to be something)

I don't think weapons (or spells) should level up more than once. But I do think having mastery of similar weapons could accelerate the mastery of similar weapons, and that would not be difficult to implement (fyi: something like the Excellector is not the same as mastery)
« Last Edit: April 01, 2013, 07:21:10 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #16 on: April 10, 2013, 11:15:33 pm »
I noticed with all zero on a weapon it still deals 1 damage. That suggests that SOM just adds 1 after all the damage is added up. Will probably find out soon enough.

I did confirm for myself that Strength gives damage bonuses to magic. I suppose that makes sense if you literally throw the fireball or whatever, but I don't know if the analogy can apply to other kinds of magic attacks. It could be used exclusively with bullets attacks I suppose.

One thing I totally don't understand is if you leave a monsters defenses at all 0 you deal attack+strength/5. But if they have defense I am able to deal wild amounts of damage. If this represents a simplified system when all defenses are at 0 that's fine. But if this rule applies to individual affinities then that would be a bug wouldn't it?

Or does the monster defense settings represent weakness? I totally don't get it. I also wonder what happens if a monster's defense are negative. You can't see that in the graph in SOM_PRM. But would that give them an acute weakness to the affinity?

PS: I assumed before that an attack can never deal more damage than its damage rating. But this wasn't based on looking at the formula as much much as the if defense is 0 condition. But without taking the time to analyze. This is simply not what I am seeing. If I give a skeleton a small amount of defense I can deal massive damage. I just tested this and it is per affinity...

So the only way this isn't a bug is if the numbers in SOM_PRM are inverted, so that -2 is defense and +2 is weakness. And that isn't the case either! So is this a bug or what? I don't get it.

Basically it seems like if you leave any ratings set to 0 that affinity plays by totally different rules. If its a small number versus the damage devastating damage is dealt. But if its 0 then just the damage itself is dealt. Which at most can be 255 according to SOM_PRM. What say you. Is this a bug?

Negative defense BTW receives more damage than 0, but nothing astronomical like a small amount of defense will. In fact full negative defense (-128) yields 189 damage instead of 100. Where as 1 yields 5119.

Clearly 0 and less defense doesn't use this formula. It seems like a bug, or SOM is offering two different damage systems. But if you mix the systems then the result is clearly a bug...

So if you don't set all defenses to greater than 0, or all defenses to 0 or less, then you end up with a game that appears to be buggy :movingeyes:


I really like SOM. But if me or someone like me didn't exist to rehabilitate it it would be a straight up lost cause.


« Last Edit: April 10, 2013, 11:28:01 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #17 on: April 10, 2013, 11:30:49 pm »
EDITED: This seems like a bug to me. Because the negative number system looks much more friendly if you were to make a game where everything is tweaked by hand. But its pretty much useless because it can't represent defense. It can only represent weakness. And if you do give the monster some defense, more than likely you are just opening it up to astronomically damaging attacks (ironically) so its really baffling how this is supposed to work.

I guess you could represent defense purely by HP if you use only 0 or less defenses. The problem though is you can't do the same with armor, not using SOM_PRM anyway (if at all) so that the damage system would not be symmetrical. Looks like lose lose. If you are making a game without Ex (after I can add some extensions for damage here in a bit) just don't forget to set all defenses to at least 1 :doh:


PS: The behavior at and below 0 defense is baffling to me. I don't know whether it should be removed as a bug or what. The only place I can see it being useful is in a game where there is no armor. So that you just have the starting armor to determine the player's defense ratings. Or a variation would be having the armor approximate the negative damage formula behavior as well as you could. I think it would be possible if all armor has around the same defense in every slot with slight deviations up to 189%. In fact that would probably be the best way to make your game if you can figure out how to do that.


EDITED: Actually using the negative numbers, the weaker the weapon the more damage it deals in relative terms. It doesn't seem to be using the damage formula (with negative numbers plugged in) above at all. So I am unsure if it should be discounted as a bug or what. Well actually with a 255 weapon it literally deals less damage than a 100 weapon. So yeah, seems like a bug to me.

At 50 damage you deal 169. At 100 189. At 255 you deal 139.
« Last Edit: April 10, 2013, 11:46:24 pm by Holy Diver »

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Damage calculator
« Reply #18 on: June 13, 2013, 09:15:49 am »
MAG would be substituted for ATK for Magic damage types. Now aren't you glad you asked? Personally, I wouldn't "bake in" any damage formula. I would set up a simple default formula which is loaded from an external configuration text document. Thus letting users insert their own formula if they want.

Here is your formula system. I've been working on it for nearly a month, it will probably be another week before there is anything to demo. So I thought I'd give anyone who wants to a chance to study up on it in advance. Maybe sink some time into what you'd like to do with it.

http://en.swordofmoonlight.org/wiki/Sword_of_Moonlight_Extension_Library/list_of_numbers

Not everything is covered yet, but I've finally settled on a terminology for communicating these concepts. Everything has been covered here (http://www.swordofmoonlight.net/bbs2/index.php?topic=142)


EDITED: The Preface in the wiki covers the non-technical terminology. However the rest of the document doesn't yet reflect it. I've struggled in terms of how to explain things with it for some time.

The analogs for SOM's counters are: a counter is a "sum". Its number is a "subscript". All of the counters together is a "Number". Specifically a variable. With 1024 sums denoted by 1024 subscripts.
« Last Edit: June 13, 2013, 05:56:54 pm by Holy Diver »

Offline HwitVlf

  • Dark Slayer Destroyer
  • ****
  • Posts: 1667
Re: Damage calculator
« Reply #19 on: June 13, 2013, 02:54:58 pm »
Sounds neat.  Wouldn't  it work just as well to use simple math tags like:
Damage=(Attack1-Defense1)+(Attack2-Defense2)... etc

I can see how such labels could fall short for advanced stuff, but it would be quite simple for beginners to pick up.