Jump to content
IGNORED

Damage...


Opry99er

Recommended Posts

Greetings...

 

 

 

Tonight, I want to discuss damage... How is damage calculated?

 

 

 

Let's talk about a real life example... tank warfare!!!

 

 

 

If we were thinking about reality, an abstract equation I believe that would fit (while VERY simplistic and stripped down) is listed below:

 

DAMAGE=(ATK+ATKMOD)-DEF-DEFMOD

 

In this case, to equate damage, we first add the values of ATK and ATKMOD... These would be the basic "attack" value and the modifier of that value. In the tank example...

 

The tank shoots 88mm shells. These shells are modified by the fact that they create a minor explosion on impact. (attack and attack modifier)

 

Let's keep the values abstract for now...

 

Let's say that tank is firing on another tank in another army. That tank has a 3" thick steel hull... The tank is also protected by sand bags that are piled up around it, softening the impact even more. (defense" and "defense modifier)

 

 

Now of course, in real life, it is difficult to determine the precise damage that will be done to the receiving tank, but as a programmer, I must find a way to calculate damage, and this is the simplest, most stripped-down method I can think of.

 

DAMAGE=(ATK+ATKMOD)-DEF-DEFMOD

 

 

Let's put real numbers in here, since I'm the pupper master and can set values for this kind of thing.

 

*Let's say the standard ATK of the first tank is a value of 10... meaning it will do 10 damage to whatever it hits.

*Next, let's say that the exploding factor of the shells adds an additional "5" points to the value. Now we have a base-line.

 

(15)-DEF-DEFMOD (This would mean that if no defense exists, "15" damage points would be inflicted on impact)

 

*Now, let's say that the 3 inch thick hull of the tank provides "5" points of defense. This would mean that each time the tank is hit, it would take "10" hit points of damage.

 

(15)-5=10

 

*We also have "DEFMOD" here though... the sand bags. In this case, let's say that the sand bags offer an additional defense value of "3".

 

Our equation is now set.

 

DAMAGE=(15)-5-3 ***(or "7" for a total)***

 

Each time the tank is hit, 7 "hit points" are removed from it's total structural integrity.

 

If the tank can sustain "25" damage before it is completely destroyed, then it would take 4 hits to completely destroy the defending tank.

 

25 HP

**1st hit**

18 HP

**2nd hit**

11 HP

**3rd hit**

4 HP

**4th hit**

-3 HP (or 0, since zero is "dead")

 

 

The key to doing this in a program is to make sure the initial values are "balanced." We do not want it to take 700 hits from an exploding 88mm shell to destroy a tank... it is unrealistic! We also don't want the attacking tank to be able to wipe out the entire planet with one cannon blast! Finding the "natural" values for use with our damage formula is key to making this work.

 

Now... of COURSE this is completely stripped down and extremely basic, but if I were putting together a damage algorithm, does this seem like a reasonable place to start?

 

 

 

Link to comment
Share on other sites

That is a good way to calculate your base--but it is incomplete. Both the attack and the defense are inherently imperfect, so the inflicted damage will be variable. If you take your ATK factor and turn it into a random integer between one and your expected maximum value and then add your ATKMOD to it, that will allow for sufficiently variable damage from the attacker's standpoint. Do the same with DEF to make it a random value between one and the maximum value, add the DEFMOD to it, and then subtract the resulting number from the modified ATK factor. Note that you have to handle edge cases too--as otherwise you could get weird stuff like an attack ADDING hit points to the target, something you generally do not want to do. All you have to do to avoid that is to treat negative ATK numbers as zero--and even with your non-random system, you'll need to add this particular edge-case modification. Dungeons and Dragons (or pretty much any of the old-school pencil and paper role-playing games) does similar things to ensure that the randomness of the real world is mirrored in the game. Now that little guy can take out the honking big monster of an opponent that would usually obliterate them--if the random luck of the draw favors them that day.

  • Like 2
Link to comment
Share on other sites

Yes, I definitely see the need for a random element, and have been working on a way to put it in to my test code.

 

One thing though, I am not wanting it to be so random that there is a potential for a fatal blow to be dealt to a high level opponent by tossing a rock at him.

 

In reality, a guy swinging a tree branch at a tank has ZERO chance of destroying the tank in one blow. :) just in keeping with the tank theme.

 

Your points are very good, and I appreciate your input...

 

Perhaps the random element could be something like +/-3 of the base attack value and +/-3 of the base defense value. This would allow a "tank" the potential for a fairly wide range of point deductions. (1-13 if I am not mistaken)

 

Setting the negative integers to zero is certainly necessary for the reasons you described. LOL!!

 

Something like:

 

IF DAMAGE<0 THEN DAMAGE=0

Edited by Opry99er
Link to comment
Share on other sites

Note that the fully randomized ATK and DEF values still won't let Gorfus the Barbarian take out that tank in a single blow with his trusty rock. On the other hand, if he gets really lucky and keeps whacking the tank with it while not being hurt too badly by the tank, he might just succeed in beating it to submission with a succession of lucky blows. The chances of that happening are very low (he'd have to RND to his max attack value every time--while the tank's defense would have ro RND to the minimum every time, without being flattened by the tank, as he'd have to be in exactly the reverse situation when it comes to his own defenses (he'd have to RND high on defense and the tank would have to RND low on its attack).

 

Using an interesting incident from 1895: the Italians (armed with riflles, machine guns, and artillery) fought with the local African tribes in Eritrea/Ethiopia. They attacked the Ethiopian army (they had rifles and a bit of artillery, but a large portion of their troops were cavalry armed with lances). The Ethiopians slaughered them. . .

Link to comment
Share on other sites

Here would be the randomized version of the equation: ATK=((INT(RND*10))+(ATKMOD=5))-(DEF2=((INT(RND*5))+(DEFMOD=3)). This gives you an attack value against that target of (6 to 15)-(4 to 9). As this is a linear randomization, each value is equally probable, but as only three of the ten attack values could EVER result in no damage, your tank would have a high likelihood of grinding any opponent into the dust. You could make it into a bell curve by changing the tank's attack number into two randomized fives (which also increases the minimum random number to two), further skewing the results into the tank's favor.

Edited by Ksarul
Link to comment
Share on other sites

Actually, a better way to show this is:

 

100 ATK1=10

110 ATKMOD=5

120 DEF1=5

130 DEFMOD=3

140 ATK=(INT(RND*ATK1)+ATKMOD)-(INT(RND*DEF1)+DEFMOD)

 

Note that you still have another edge case in this--the randomized part can still end up as a zero, so you actually may want to input a check to increase the zero value to one.

Edited by Ksarul
  • Like 2
Link to comment
Share on other sites

Okay... I took an ambien a few minutes ago, and your equation is sort of ripping my face off right now. :)

 

I'll try and decipher it for a few, before I cannot type any longer. :)

 

 

ahhh, hilarity.

 

***Words of wisdom folks... don't take your prescription ambien while still trying to code and do math. I've had to rewrite this line 4 times.

Link to comment
Share on other sites

Actually, a better way to show this is:

 

100 ATK1=10

110 ATKMOD=5

120 DEF1=5

130 DEFMOD=3

140 ATK=(INT(RND*ATK1)+ATKMOD)-(INT(RND*DEF1)+DEFMOD)

 

 

Okay, that makes a bit more sense. :)

 

Just to be sure here... in 140, your leading ATK... shouldn't that be "DAM" or DAMAGE?

Link to comment
Share on other sites

In this sense, the leading ATK is the damage it does to the target, yes. It is the result of all of the modifiers, plus and minus, to that half of the combat exchange.

 

Actually, thinking about the INT function, it would give you a value between zero and n-1, so all you have to do to remove the zero edge case is to add one

 

((INT(RND*ATK1)+1)+ATKMOD)-((INT(RND*DEF1)+1)+DEFMOD)

Edited by Ksarul
Link to comment
Share on other sites

BTW, thanks for making me think about programming again. I did a lot of this kind of stuff until about 20 years ago programming an AD&D character generation program, a bowling league program, and a stock market simulation game--but I've gotten a bit rusty at it. This type of numerical manipulation was in all three of them. . .

Edited by Ksarul
Link to comment
Share on other sites

Hi,

 

If this relates to the fantasy RPG you are creating I have a few thoughts:

 

If I were to make a computerized combat system, I think perhaps the easiest model to 'borrow' would be from dungeons and dragons. More specifically from D&D 3.0 or 3.5 rules. The second edition rules use a mechanic called THAC0 or To Hit Armor Class Zero which is somewhat confusing and uses a lot of double negatives. However when WOTC bought out TSR they changed the mechanic to use mostly positive numbers and I think simplified it in the process. I can try to explain how this 'newer' system works:

 

You have a character, that character has a Base Attack Bonus or BAB. Lets say at level one for a fighter that is 1 and increases by 1 per level. So at level 10 your fighter has a BAB of 10. Now we look at weapons. Each weapon has a random damage value minimum and maximum generated by a dice roll. For example a dagger would be 1d4 damage or 1 four sided dice rolled or 1-4 damage randomly generated. The first number 1 is the number of dice, the second number is the sides of the dice. So 2d8 would be two eight sided dice or 2-16 damage randomly generated. In addition to the damage values each weapon is allowed an enhancement or weapon bonus that increased it's attack bonus. So if I have a dagger +2, that is +2 to your BAB and then 1d4+2 damage or 3-7 damage. D&D also uses the mechanic of just adding to damage and not the attack bonus. This is simply called a damage bonus and not an enhancement bonus on the weapon.

 

Now lets talk defense. This works similarly in which each armor has a value assigned to it. So your plate armor might have a value of 8 and your helmet has a value of 2, so your total AC or Armor Class would be 10. You can have enhancement bonuses to these items as well so if you had some leather armor AC value 6, but you had Dan's Leather Armor +3, the AC value would be 9.

 

So how do we hit something? D&D uses the 20 sided dice as its base dice. So our level 10 fighter has a BAB of 10, so when he takes a swing he rolls 1d20 and adds +10 to it, this is his attack. So lets say we roll a 13+10 = 23. We simply compare this to the armor that we are attacking against and if the attack number is higher, the attack is successful! Does this all make sense? This is a very simplistic view of the D&D system, there are tons of other rules like damage types, dexterity bonuses, dodging, etc etc etc. (which I would be happy to explain if interested), but I thought for a simply attack/damage/defense model this works very well. Lets do one more example:

 

level X thief has a base attack bonus BAB of +4. Thief has equipped a +2 assassins dagger 1d4. So when the thief attack he will roll 1d20 +4(BAB) +2(weapon bonus) for his total attack vs. AC(armor class) roll. If he rolls higher than the monsters AC, then it is a hit and damage is rolled 1d4+2.

 

Does this help? If this is something that is interesting or helpful I am happy to help with any questions. I played D&D quite a bit over the years :)

Link to comment
Share on other sites

Gosh, can't a guy just build a tank game without everyone bringing RPGs into it?!?!?! :lol:

 

Yea, I am doing preliminary testing for my RPG battle engine. :)

 

Your D&D conventions sound an awful lot like the battle engine in FFMysticQuest... Which is a good thing!

 

I have several components to add, but in this thread I wanted to start with the simplest possible algorithm and build.from there...

 

Eventually there will be elemental modifiers for weapons that are associated with an element, armor the same. There will be a random "critical" element, doubling the damage to the opponent. There will be magic attack and magic defense to calculate when that type of attack is used.

 

But basically, right now... I want to.be able to whack a skeleton with a stick and see if I can.do damage. :)

 

Thanks for posting... I may have some questions for you going forward. :)

Link to comment
Share on other sites

Actually, a better way to show this is:

 

100 ATK1=10

110 ATKMOD=5

120 DEF1=5

130 DEFMOD=3

140 ATK=(INT(RND*ATK1)+ATKMOD)-(INT(RND*DEF1)+DEFMOD)

 

Note that you still have another edge case in this--the randomized part can still end up as a zero, so you actually may want to input a check to increase the zero value to one.

 

Okay, that makes a bit more sense. :)

 

Just to be sure here... in 140, your leading ATK... shouldn't that be "DAM" or DAMAGE?

 

 

I don't know how important your timing is through the game loop; but, every call to RND in XB takes roughly 72ms, whereas, in TIB it takes 1/4 of that time (18ms). Both routines are operating on an 8-byte, radix-100, floating-point number. TIB makes 7 calls to the GPL RAND function, once for each of the 7 radix-100 digits. XB does its own thing with a more involved (probably more nearly random) routine.

 

This subject has already been beat to death in a couple of other threads here. I just bring it up to point out that you have faster alternatives if speed becomes an issue:

  1. Load ALC to do it the TIB way (plenty of help on this forum! :) ),
  2. If the number to be randomized is less than 100, load ALC to replicate the GPL RAND function and do it for only one radix-100 byte instead of seven or
  3. If the number to be randomized is less than 256, use the VDP interrupt timer byte (>8379), which ticks 60 times a second (0 – 255), adjusting to the proper range.

I should think (3) would be the fastest, though least nearly random, method.

 

Just tryin to stir up trouble. :grin:

 

...lee

  • Like 1
Link to comment
Share on other sites

 

But basically, right now... I want to.be able to whack a skeleton with a stick and see if I can.do damage. :)

 

 

 

Awesome. Ha this made me laugh, so true though.

 

I have no idea how to program, but 20 years ago I made a couple simple games in Qbasic for DOS and so it would go something like this... you would have to translate in the programming language of choice but maybe it will get some ideas going.

 

START

set variable p1bab$ = p1level$ +2

randomize timer d20 + p1bab$

IF randomize timer > mob1AC$ THEN goto HIT

IF randomize timer < mob1AC$ THEN goto START

HIT

blahblahblahblbhablah

Link to comment
Share on other sites

As a side note, the method I was giving you was also derived from Dungeons and Dragons--the 1974 original edition that came before any of the Advanced Dungeons and Dragons variants (I personally am a First Edition player, primarily, although I've played everything up to the current editions). I used the earliest incarnation of the game it because it was in the spirit of the request--simple, yet balanced. I figured that would be better than going to an Empire of the Petal Throne format (d100), Pure D&D and any of its derivatives (d20), Traveller (Hexadecimal modified 2d6), or GURPS, Guardians of Order, or any of the multitude of additional d6-based games. I have several floor-to-ceiling bookcases full of role-playing game materials in the house. . .

  • Like 1
Link to comment
Share on other sites

As a side note, the method I was giving you was also derived from Dungeons and Dragons--the 1974 original edition that came before any of the Advanced Dungeons and Dragons variants (I personally am a First Edition player, primarily, although I've played everything up to the current editions). I used the earliest incarnation of the game it because it was in the spirit of the request--simple, yet balanced. I figured that would be better than going to an Empire of the Petal Throne format (d100), Pure D&D and any of its derivatives (d20), Traveller (Hexadecimal modified 2d6), or GURPS, Guardians of Order, or any of the multitude of additional d6-based games. I have several floor-to-ceiling bookcases full of role-playing game materials in the house. . .

 

Why reinvent the wheel right? I don't have any original D&D stuff, but I have maybe 30-40 AD&D 2nd edition books from the 80's-90's in a trunk in the basement that I am sure my wife would LOVE to get rid of :)

Link to comment
Share on other sites

To be completely honest, I have never played a single game of D&D, advanced or otherwise. I have spent some time today studying the history, conventions, and incarnations of the game and it sounds pretty amazing.

 

As a kid, I played Tunnels of Doom... by myself... very few friends, and the ones I DID have were into video games too. :) Went from ToD to FFI, Faxanadu, Willow, Ultima, AD&D Pool of Radiance, Bard's Tale, etc etc etc...

 

Always loved RPGs... and then the SNES came out.

 

I have to tell you that the combination of FF Mystic Quest and FF2 (IV) changed the way I viewed gaming forever. It ceased to be about winning a game or getting a high score... for me, it was like reading a book... An interactive book where you take control of the lead character and interact with the world as that character.

 

I came late to Ultima IV, which I found as an adult... The Ultima games on the NES were okay, but I never quite felt like I was a "part" of the game.

 

Grandia II followed in the series of my RPG playing career, which changed the way I wanted to see the combat sequences occur in my turn-based RPGs.

 

Most recently, Morrowind (Elder Scrolls 3) took me into several hundred hours of abyss. I went in as one person and came out as another. That's what a game should do to you, if it is of quality and you are in the proper mindset to appreciate it.

 

I played dozens more computer and console RPGs over the years... But the list of the ones that impacted the way I game are as follows (from a kid, to an adult)

 

*Tunnels of Doom

*Faxanadu

*Final Fantasy Mystic Quest

*Final Fantasy 2 (IV)

*Grandia II

*Morrowind (Elder Scrolls 3)

 

 

Without these 6 games, I don't know who I would be as a human. :)

Edited by Opry99er
Link to comment
Share on other sites

So, I would like to present a different way of calculating defense.

 

Rather than absolute, think of defenses in terms of effectiveness.

 

So, an effective defense could block 75% of damage, so it'd be equitable regardless of attack type, and every attack would generate some damage (although potentially tiny), which is a more realistic approach.

 

An attack with a feather would have a very low attack score, and a defense of paper mache shield would have a very low effectiveness.

 

An attack with a missile would have a higher score and armor plate would have a higher effectiveness.

Link to comment
Share on other sites

Most recently, Morrowind (Elder Scrolls 3) took me into several hundred hours of abyss. I went in as one person and came out as another. That's what a game should do to you, if it is of quality and you are in the proper mindset to appreciate it.

 

While I finished Oblivion (TES4) in the meantime, I picked up Morrowind again which I left some time ago because it was so tedious to improve the character from the start. Also, my fault was to use a setting where I did not have magicka refilling overnight...

 

I finished Morrowind (TES3) just a few months ago, after about 2 years. :) The worst problem was that I somehow got lost in the quests: There was no real progress, until I had a look at some guides and noticed that Caius Cosades kept waiting for me for some months.

 

Currently losing myself in the world of Skyrim (TES5). If your PC is sufficiently powerful, a game you should definitely go for. Moreover, you can spend days while figuring out the best mods.

Edited by mizapf
Link to comment
Share on other sites

Morrowind.... The game that made my wife a widow and my kids fatherless...

 

If you are not careful and dont keep track of your progress log, it is easy to get lost in the world...

 

I have now played all the way through the game twice... Both times as a dark elf. I will tell you that developing my flight spell, enchanting my armor and robes with near-invisibility, and getting the highest quality glass helm (which I enchanted as well) were the keys to the game for.me.

 

I also became a master alchemist and would walk all the way across Morrowind for a single element to use with my alchemy set.

 

I took over a house and made it mine... Became a collector of rare items and displayed them beautifully all through the house...

 

 

I was truly obsessed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...