Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Damage calculation in modern game engines?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Nihilihihak   Members   -  Reputation: 103

Like
0Likes
Like

Posted 30 August 2013 - 01:53 PM

(I am not sure where to post this so sorry if i made a mistake)

 

I am currently learning basic computer science in school and this year we need to make a project that needs to be completed by the end of the year, the students can choose what they want to make and i would like to make a game(nothing elaborate but i'd like to have atleast a basic combat system)

 

I am trying to understand why certain games are "balanced"(mathematicly speaking) ,the first game i started with was team fortress2 because it has different classes and quite a lot of different weapons.

 

In the tf2 wiki they explain how damage is calculated but i had a lot of trouble in understanding how this works in the game engine itself.

and the numbers of each weapon(in the wiki) seem quite meaningless for DPS calculations.sad.png

 

1)Are there certain tools that i can use to take a look at for instance the TF2 engine(source code) and look how they calculate damage, it must be a script of some sorts?

(Is there something that makes elaborate source code managable for a beginner to understand ?)

 

2)How can a beginner learn from games that have already fully been made without stepping in to illegal territory?

 

ANY help will be appreciated, thanks in advance smile.png



Sponsor:

#2 Khatharr   Crossbones+   -  Reputation: 3031

Like
0Likes
Like

Posted 30 August 2013 - 03:18 PM

I am trying to understand why certain games are "balanced"(mathematicly speaking) ,the first game i started with was team fortress2 because it has different classes and quite a lot of different weapons.

 

In the tf2 wiki they explain how damage is calculated but i had a lot of trouble in understanding how this works in the game engine itself.

and the numbers of each weapon(in the wiki) seem quite meaningless for DPS calculations.sad.png

 

1)Are there certain tools that i can use to take a look at for instance the TF2 engine(source code) and look how they calculate damage, it must be a script of some sorts?

(Is there something that makes elaborate source code managable for a beginner to understand ?)

 

It sounds like you're nowhere near ready to implement a game of this type. Implementing basic mathematical algorithms is ground-level programming. More importantly, TF2, despite what you may believe, is an extremely complex game. Typical solo beginner projects start with things like tic-tac-toe and increase in complexity, through pong and breakout and up until things like Tetris clones. Beyond that level of complexity you're looking at putting in a significant amount of time and energy. What are the requirements for this project that you have to complete?

 

 


2)How can a beginner learn from games that have already fully been made without stepping in to illegal territory?

 

 

The same way a budding writer watches movies and reads books. Don't violate the rights of other copyright holders in your work.


void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#3 Nihilihihak   Members   -  Reputation: 103

Like
0Likes
Like

Posted 30 August 2013 - 03:50 PM

The idea is that within 10 months i have something fairly decent to show to the judges (the teacher will tell us if our project is complex enough).

 I would want to keep tweaking and adding stuff year after year until i feel that it is done. 

 

We are allowed to use tools to make our game (unity 3D) so we don't have to start from scratch.

I see this as a very very long project to learn my ways in game development and programming.

 

I am allowed to start from scratch but that would involve working with VERY abstract ideas (pure code) and they have not taught us that much programming yet, that's why i would prefer using something like unity.

 

(I am NOT making a TF2 clone, the end result will look and probably feel nothing like it, i just gave that game as an example of "inspiration" for my game and i'd like to figure out how they did things.)



#4 Paradigm Shifter   Crossbones+   -  Reputation: 5412

Like
0Likes
Like

Posted 30 August 2013 - 04:18 PM

For balancing you want to run simulations of various scenarios (with AI or player v player) and tweak until the win-loss ratio approaches 50%. Although you may want to implement something like a rock paper scissors system too.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#5 cardinal   Members   -  Reputation: 899

Like
0Likes
Like

Posted 02 September 2013 - 10:55 AM

Could you link the wiki page you are describing? Perhaps someone here can explain it to you.

 

Damage calculation is a bit high level. Are you sure you should be worrying about it at this point in the project? I would think you should first worry about things such as being able to damage other players in the first place. Later on you can plug in better logic that allows you to balance the game once you actually have a game to speak of.

 

In general I would imagine as a very simple example, damage calculation in an FPS would be based around each projectile having a base damage value that gets modified based on which body part it hits. You can modify it by more complex things such as the character type and armor if needed. There are other things to consider in a full fledged FPS game, such as explosions, in which case it would probably be related to distance from the explosion's point of origin, with some sort of fall-off the farther away you are.

 

Damage calculation would be game code rather than engine code as it would be specific to each game based on its design.



#6 Nihilihihak   Members   -  Reputation: 103

Like
0Likes
Like

Posted 02 September 2013 - 11:15 AM

http://wiki.teamfortress.com/wiki/Damage

 

i'm not really making an FPS in a classical sense but it does contain quite a lot of FPS elements.

I wonder if i can balance a game purely in a mathematical sense like each class(weapon) is capable of the same amount of DPS but in different ways (or in shooters TTK time to kill).

 

And make something like a slider wich gives you a certain level of mobility for a certain amount of health (and getting rid of "classes" but certain weapons will be suited for a certain playstyle).

 

I'm interested in the TF2 way of calculating damage because of the different weapons (like flamethrowers and shotguns).

I imagine it's some kind of script or function.



#7 cardinal   Members   -  Reputation: 899

Like
1Likes
Like

Posted 02 September 2013 - 04:16 PM

Looking at that wiki page, they definitely calculate damage similar to how I described it:

 

From the wiki:

(Base Damage) × (Distance and Randomness Modifier) × (Resistance/Vulnerability Modifiers) × (Splash Modifier) 

 

They do a good job explaining what the different modifiers are on the wiki, but:

 

Base Damage: This is the damage a specific projectile causes. Generally when talking DPS it would be this number multiplied by the rate of fire of the projectile. This would be tied generally to the type of bullet rather than the gun (as the wiki states), since in some games weapons would have multiple firing modes (like a sub machine gun with a grenade launcher attached).

 

Distance + Randomness: This is a multiplier used to reduce damage as the projectile collision occurs further away from the bullet's point of origin. I didn't read about the randomness aspect, but I imagine a slight randomness is applied to this multiplier.

 

Resistance/Weakness: This is a multiplier that would be used to reduce/improve effectiveness of a weapon against specific characters (i.e. a fire dragon is strong against fire magic, but weak against ice), or for example power up bonuses (i.e. armor or ammo upgrade).

 

Splash Modifier: This is for explosions, it is as I described in my original reply.

 

 

 

These would most likely all be tuned separately, but yes, the designers probably had the engineers build sliders (or some tool) to adjust all of these values. Lots of playtesting would have been done to get the numbers just right, and often values are adjusted post-ship if balancing issues are discovered.

 

 

An example of the calculation described above would be, assuming you are 15 feet away and the opponent has picked up body armor:

 

Shotgun:

 

Base Damage: 100

Distance Modifier: 1.0 (0.5 at 25 feet, 1.5 at 10 feet --> 1.0 at 15 feet)

Resistance Modifier: 0.5 (due to body armor)

Splash Modifier: 1.0 (since it's not an explosive weapon there should be no splash damage adjustment).

 

Result: 100 x 1 x 0.5 x 1 = 50 damage

 

But if you were 5 feet away and he had no armor:

 

Base Damage: 100

Distance Modifier: 1.5 (0.5 at 25 feet, 1.5 at 10 feet --> 1.5 at 5 feet)

Resistance Modifier: 1.0 (due to no armor)

Splash Modifier: 1.0 (since it's not an explosive weapon there should be no splash damage adjustment).

 

Result: 100 x 1.5 x 1 x 1 = 150 damage

 

 

 

 

I would create sliders to tune rate of fire for each weapon, and the base damage for each weapon (you can always add as many modifiers as you need after the fact). Then to increase an individual weapon's damage per second, you would tune either the rate of fire of the weapon and/or the base damage. You would then need to tune things like clip capacity to balance things such as reloading.

 

It's very hard to mathematically balance a game, but it is a good tool to start with.



#8 Satharis   Members   -  Reputation: 1060

Like
1Likes
Like

Posted 02 September 2013 - 07:02 PM

To be honest dealing with the numbers in a game is basically straight up math, the code for handling it is very basic and often not much more than basic arithmetic or possibly some algebra from the.. well, billion math libraries available, usually built into the standard library for a language as well.

At the very simple level you're just trying to invent some kind of formula for calculating the numbers, a few posters above have given example of the typical one line statement you can decompose it into.

Balance on the other hand is a different topic entirely, if you're talking about something like an fps they often do a mix of mathematical guessing like statistics and just a lot of tweaking numbers and testing the game until it "feels right."

For something like an RPG or an MMO you get into territory of where they really do use statistics and graphing to plan out number for items.

If you're making something simple you really don't need to get too worked up about it.. just invent some numbers. Maybe decide if you want to have a certain number of health and whether the game has armor or resistance or elemental attacks or who the heck knows, it really depends a lot on what is in the game.

In general terms even a game like breakout could have "health and damage" if the blocks take more than one hit to destroy.

Edited by Satharis, 02 September 2013 - 07:03 PM.


#9 Krohm   Crossbones+   -  Reputation: 3190

Like
0Likes
Like

Posted 05 September 2013 - 01:18 AM


1)Are there certain tools that i can use to take a look at for instance the TF2 engine(source code) and look how they calculate damage, it must be a script of some sorts?
Maybe you could hack something together with Garry's mod? I'm afraid there's going to be quite some trial and error. An Halo designer wrote a full article about the process of fine tuning their sniper rifle. It turns out it must "feel" right so... I guess there's experience more than method.

 
2)How can a beginner learn from games that have already fully been made without stepping in to illegal territory?
Modding is legal, even when you pull out crucial data.

#10 ShadowFlar3   Members   -  Reputation: 1258

Like
1Likes
Like

Posted 05 September 2013 - 01:59 AM

So how familiar are you with programming and game development?

 

I think regardless you can probably pull off some kind of Unity FPS game for your project. Unity is pretty well documented and plenty of tutorials on Youtube. But sure it will be a lot of work and I hope you are interested in game development (even after the year) :)

 

I don't think you should worry about TF2 mechanics that much at this point. You should come up with a simple damage system first (like damage = 15) and start refining little by little if you want to. Damage balance will not be an issue in the same way as TF2 since you aren't making a multiplayer game if you aren't already very experienced in programming. Just don't make the computer controlled bad guys too powerful, that's all the balance there is.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS