Help - Search - Members - Calendar
Full Version: How damage is modeled in AS
ALTAR games official forum > UFO: Aftershock > UFO:AS Modding
ShadoWarrior
Grendel sent me a PM asking some questions whose answers I felt should be seen by everyone. I hope he won't mind my replying here. (Hopefully, this might save me the hassle of explaining this again in the future.)

QUOTE
Can one incorporate multiple existing damage types into a 'new' round?  For example, when round hits, AP damage is applied to the target (Tungsten penetrator accelerated to 4000 fps by the RDX charge), HE damage appied to all within a small radius (jacket spall and fragmentation), and maybe even a smaller incindiary effect (zirconium carbide particles)...

Another possible approach would be to "spawn" the two (HE & Incind.)ammo types on the target when the original round hits if the engine can be coaxed to do this...if this were OFP, I could script this in about 30 minutes, but I have no idea how AS is configured yet...

It's more complicated than applying more than one damage type. The short answer is no. For two reasons. First, you cannot apply two damage types simultaneously. Second, because of the underlying mechanics of how targetting works. (However, you can create a new damage type that is a hybrid. More on this later.) But before I go further, I think I need to explain a bit about the damage mechanism in AS, as gleaned from studying the equipment file.

First, I'll give a brief explanation of damage types. Damage types key into a 13-element array of values defined for each armor representing the percentage penetration (ie: inverse of resistance) to that type of damage. So a value of "1.0" means 100% of the damage gets through, while "0.2" means that 20% of the damage is applied (80% resistance). That's all damage types are: a means to determine resistance to the attack.

For example, if you want to model API ('Hard' and 'Burn' damage types), you could devise a new damage type that uses the lowest resistances of 'Hard' and "Burn'. Then you have to go through the massive effort of adding the new damage type to every single armor of every single actor (friend and enemy) in the game, since you're expanding the damage type array. That's edits to many hundreds of text files. Say that you manage to accomplish this monumental task. So far so good, you think? But wait, we're not done. We haven't really modelled the API round, which not only does AP ('Hard') penetration damage, but also has WP that continues to burn in the wound after the round has expended its kinetic energy. That's two effects: impact, and burning. (If it's a Raufoss round, there are 3 effects: impact, explosion, and burning.) We'll now look at how these seperate effects are treated by AS.

The other thing you must know about damage is something called the Influencer. It's how damage is applied to target(s) before damage type (resistance) is considered. There are 9 types of 'influences'. Each type defines a method for affecting (influencing) a target. I'll discuss the three most commonly associated with weapons: 'Target', 'Fragment', and 'Constant'.

Target: applies an effect (may be damage, may be healing, or something else) to a designated target (and only that target). The target may or may not be at range. All projectile and laser weapons, for example, use 'Target', and have a 'Time' value of 0 (meaning the effect, damage, is applied in full instantly).

Fragment: applies an effect in a range (radius) around the target location. The effect's strength decreases as distance increases from the center of effect.

Constant: applies an effect in a range (radius) around the target location. The effect's strength remains the same regardless of distance from the center of effect.

'Fragment' is used in the game to represent explosions. (There's a seperate value called 'Pellets' that represents the actual frags.) Real explosions, as well as those in the game, have decreasing concussion the further you are from the center of a blast. Fragment models this well. If you wanted to model a small nuke, you'd also use 'Fragment' as radiation intensity also decreases with distance. Most explosions in the game also have 'Time' of zero, since a blast is an instantaneous event.

'Constant' is used in the game to model such things as an area covered in flames. The effects of the fire will be (generally) the same regardless of where in the flames you are unfortunate enough to be standing in. Most Constant effects have a non-zero 'Time' value as the effects last for a while.

The point of all this? You may only specify ONE influence for an attack, and you may only specify ONE damage type for the influence.

So, for API, you cannot specify 'Hard' for 'Target' with 'Time' of zero, and 'Burn' also for 'Target' with non-zero 'Time'. (ie: instantaneous impact of AP, plus prolonged burning due to WP) The best you can do in modelling API is using 'Hard' or 'Burn' and specifying a non-zero 'Time', or creating a new damage type, either of which will apply the combined/hybrid damage over time. You cannot apply the damages seperately, one as an instant, the other over time.

It's far worse for Raufoss ammo, which has explosive effects as well as API. To properly do Raufoss, you'd need to be able to do 'Target' and 'Fragment' influences at the same time, which is impossible in AS.
Grendel
Thanks for taking the time to explain this thouroughly, ShadoWarrior.
ShadoWarrior
Addendum I:

As Caelum discovered when he was working on testing the new flamethrowers in my mod, in order for area-effect damage-over-time to correctly be applied you must specify the Ranged type as "Rocket" or "Grenade", not "Gun".

Example -
CODE
     Ranged Ranged RECORD
       range FLT 40
       accuracy FLT 20
       time FLT 0.2
       recoil FLT -1
       type STR "Grenade"
ShadoWarrior
Addendum II:

Most players do not understand the mechanics of shotguns in the game. All ammo in the game has a value called "pellets" which indicates how many sub-pieces there are to the ammo. All regular guns have exactly one pellet (the ammo is a single slug). Grenades have many pellets (aka frags, up to 16). Each such piece has its own individual to-hit roll (equal to the hit % number you see displayed in tactical combat) and small amount of damage that it inflicts. The listed base damage of a pelleted weapon in the game is the total base damage for all pellets assuming that they all hit. In the case of normal shotgun shells, there are 12 pellets, and for the SPAS 12, the damage per pellet is 120. 12x120=1440 (which is the number you see in the info window in inventory). The actual damage you will get in the tactical game will vary based on how many pellets hit, the soldier's enemy skill, and whether they achieve a critical hit. (It seems that if a critical hit is achieved then ALL the pellets that hit do extra damage; it appears that one master check is made for critical damage, not one per pellet. I may be wrong, but that's been my observation.)
Cathexis
That's really elegant. I'd figured it was something like that but I wasn't sure. I presume it does an attack roll for each pellet at the percentage displayed when targetting?

As for the critical hit being a single check, that makes a degree of sense, because assuming the spread on the shotgun isn't terribly high, where you point the weapon is where the majority of the shot is going to end up, and critically hitting is a case of the operator picking (either on purpose or by accedent) a "good" spot to hit, which is where most of the shots are going to end up (also I'd imagine that if critical hits were determined per pellet, shotguns would knock people over all the time but wouldn't do appricably more damage per shot).
ShadoWarrior
QUOTE (Cathexis @ Dec 23 2005, 02:27 PM)
I presume it does an attack roll for each pellet at the percentage displayed when targetting?

Yes. I said as much: "equal to the hit % number you see displayed in tactical combat". wink.gif
Cathexis
Yup, you sure did. I'm having one of those days I guess :)
Space Voyager
ohmy.gif You sure dug yourself into Aftershock, ShadoW!
Joe!
i asked my roommate to work on the game code itself so he can add my custom damage codes into it... maybe i can ask him to re code it in a way that the function will call the data from the editable txt files rather than from whithin the code. hope this works tongue.gif
ShadoWarrior
In case you aren't aware of it, changing the game code in any way whatsoever is illegal in almost every country on Earth. Furthermore, I'll warn you that discussing it on these forums is likely to get you banned.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.