Directional Damage

Post here if you want to help developing something for FAF.

Directional Damage

Postby Resin_Smoker » 24 Jan 2015, 12:11

I've been thinking how to best come up with a functional process for this mod considering how using a projectiles / units vector is far from ideal. Then it hit me...

Location, location, location!

Use the projectiles point of impact relative to the offset position of the unit.

What the hell does this mean you say?

Obviously we'll use the point of impact of the projectile in comparison to the units position. However the units position should be offset by (a negative) amount of the size of the units hit box. Should the projectile impact within 1/2 the width of the units hitbox we can say that the projectile impacted the rear of the unit.

This process would be very quick and thus only requires major modifications to projectile.lua to ensure that the projectiles point of impact is passed the he unit. The unit would make the determination / comparison via its default units.lua \ OnDamage event.

Best of all this would work with splash damage too!

Reisn
Last edited by Resin_Smoker on 24 Jan 2015, 16:20, edited 1 time in total.
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: Directional Damage

Postby nine2 » 24 Jan 2015, 14:52

What exactly is the projectiles point of impact relative to at the moment? Like is it in map coords, or unit coords?
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Directional Damage

Postby Resin_Smoker » 24 Jan 2015, 16:21

Map
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: Directional Damage

Postby Sheeo » 24 Jan 2015, 17:07

Resin_Smoker wrote:I've been thinking how to best come up with a functional process for this mod considering how using a projectiles / units vector is far from ideal. Then it hit me...

Location, location, location!


What do you mean using a projectiles / units vector? Of course given the projectile impact position and the unit position, it's trivial to compute the orientation of the impact.

What you need to do is modify projectile#DoDamage to pass the position of the projectile to the various damage functions -- but then you run into the issue that Damage, DamageArea and DamageRing are engine functions, so you need to reimplement those in lua.

This isn't impossible and it would help us alleviate the problems with splash damage as well, but we may run into problems with sim speed, since lua isn't an optimal language for matrix multiplication.

Then again we may potentially just skip some hurdles with the reimplementation and get a fast enough result. We can't really profile it though.
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Re: Directional Damage

Postby Resin_Smoker » 25 Jan 2015, 12:12

Sheeo wrote:
Resin_Smoker wrote:I've been thinking how to best come up with a functional process for this mod considering how using a projectiles / units vector is far from ideal. Then it hit me...

Location, location, location!


What do you mean using a projectiles / units vector? Of course given the projectile impact position and the unit position, it's trivial to compute the orientation of the impact.

What you need to do is modify projectile#DoDamage to pass the position of the projectile to the various damage functions -- but then you run into the issue that Damage, DamageArea and DamageRing are engine functions, so you need to reimplement those in lua.

This isn't impossible and it would help us alleviate the problems with splash damage as well, but we may run into problems with sim speed, since lua isn't an optimal language for matrix multiplication.

Then again we may potentially just skip some hurdles with the reimplementation and get a fast enough result. We can't really profile it though.



Rotational vector...

However there are ways to express the projectiles impact location to the unit or during the damage area operation. Both require that a table in the unit be used to store the location for later comparison once our unit's damage event is triggered.

As for reimplementation, I'm requesting the following be added to Damage:

    Location (impact)
    Complete damage data spec
    Velocity
    Vector (last known direction of movement and facing)
    Game time of launch / impact
    Launching units ID

With that, anything needed can be created or derived. Keep in mind that I had a method to pass all of this from the launcher to the projectile to the impacted unit via a series of table. This was going to be part of the WOF v0.8 that I was never able to finish.

Resin
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: Directional Damage

Postby Resin_Smoker » 25 Jan 2015, 14:11

Best way to carry all of the extra data is to utilize a preexisting table such as damageData. This is ideal as it is created as part of the projectile and can carry most all of what's needed for later on. Beyond the projectile's damageData, passing this info to the unit can be done by pushing the damageData table just prior to the damage or area damage functions. This way the unit in question has the required info for anything a potential mod or function could ever desire.

Resin
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: Directional Damage

Postby ckitching » 25 Jan 2015, 18:43

I think the important point from Sheeo's post that you may have missed is the performance issue. If you start doing vector calculations in Lua whenever there's a damage event you're going to absolutely obliterate performance.

It's unclear that there is a good solution to this problem available from Lua.
User avatar
ckitching
Avatar-of-War
 
Posts: 229
Joined: 03 Jan 2015, 12:51
Has liked: 2 times
Been liked: 69 times
FAF User Name: ckitching

Re: Directional Damage

Postby zeroAPM » 25 Jan 2015, 19:28

Could be possible to have Lua call a program in another language to calculate it?

Because AFAIK, the engine is in c++ but everything else is done via Lua, could be possible to make another "jump"?
zeroAPM
Priest
 
Posts: 452
Joined: 21 May 2014, 20:39
Has liked: 3 times
Been liked: 52 times
FAF User Name: Impressingbutton

Re: Directional Damage

Postby Resin_Smoker » 25 Jan 2015, 19:32

ckitching wrote:I think the important point from Sheeo's post that you may have missed is the performance issue. If you start doing vector calculations in Lua whenever there's a damage event you're going to absolutely obliterate performance.

It's unclear that there is a good solution to this problem available from Lua.


That's just it, you don't... This would be called on as needed. All I am saying is the carry the needed info via the projectile's damage table and later pass it to the unit (s).
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times


Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest