Rear or flank attacks

Everything about mods can be found here.

Moderator: Morax

Rear or flank attacks

Postby Franck83 » 01 Jul 2017, 21:26

Hi all dear faf modders,


I would like to do different damage amount depending off the target impact area (front, rear, left, right of the unit). This can add very cool game mechanisms ;) (strenghening parts of the armor, bonus when flank or rear attacks, projectile dispersion at some angles...)

I tried several solutions but one is partialy fonctional.


The following code detects the projectile orientation and the target orientation at the impact. It calculates the difference between the two.

If the difference is near to 0, the unit and the projectile are sharing the same direction. It means that the projectile hit the target from rear.
When the difference is near 180°, it means that the projectile hit the target from front.

But, when the target is hit from flank, i got near switching 90° or 270° random results. So i don't know if the projectile hit from left or right flank.

My skills in mathematics are not good enough to correct my code. Is somebody is enough skilled in math to help me :!: ?


Code: Select all
local oldprojectile = Projectile
Projectile = Class(oldprojectile) {
   
   oldOnImpact = Projectile.OnImpact,
   OnImpact = function(self, targetType, targetEntity)
      if targetEntity and self then
         local qx, qy, qz, qw = unpack(targetEntity:GetOrientation())
         local a = math.atan2(2.0*(qx*qz + qw*qy), qw*qw + qx*qx - qz*qz - qy*qy)
         local current_yaw = math.floor(a * (180 / math.pi) + 0.5) + 180
         -- LOG('Target orientation : '..current_yaw)
            
         qx, qy, qz, qw = unpack(self:GetOrientation())
         a = math.atan2(2.0*(qx*qz + qw*qy), qw*qw + qx*qx - qz*qz - qy*qy)
         current_yaw2 = math.floor(a * (180 / math.pi) + 0.5) + 180
         -- LOG('Projectile orientation : '..current_yaw2)   
            
         LOG('Difference : '..math.abs(current_yaw2 - current_yaw))   
      end
      Projectile.oldOnImpact(self, targetType, targetEntity)
   end,
}

Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Rear or flank attacks

Postby JoonasTo » 02 Jul 2017, 01:09

Does it matter if it's the left or the right flank? Generally speaking vehicles tend to be similarly armoured on both sides, perhaps it's a reason for bots with a single arm mounted cannon? Still, shouldn't be difference enough to simulate in practice.

Also, aside from the extreme 0,90,180 degree angle cases the projectile can always hit two(three if you count the top and bottom) sides of the unit. Even a projectile coming in at a 5 degree angle, could hit one side or the rear. Similarly one at 185 degrees could hit the other side or the front.

Of course those would be glancing blows in most cases, so utilising that information could be interesting indeed...
User avatar
JoonasTo
Priest
 
Posts: 498
Joined: 08 Feb 2015, 01:11
Has liked: 18 times
Been liked: 81 times
FAF User Name: JoonasTo

Re: Rear or flank attacks

Postby Franck83 » 02 Jul 2017, 09:57

You're right. we can do front / right / side parts of the armor. It is a less good but still good solution.

On the other side, i would like better damage localization accuracy. That's why i'm trying to go deeper in searching. This open solutions.
For example, some functions like Entity:GetCollisionExtents() give us the mini / maxi collision box. It will be cool to be able to know where the unit is hit : head, chest, arm, rear...
I'm ok with projectile impact coord but i didn't succeed in localizing the damage impact on the unit by using collision system. So i'm using a unit/projectile direction system.

This features can bring us very cool epic game mechanics. Imagine we can add head, arm, legs, chest armor parts to bots. This may open fantastic micro solutions during battles.

Image
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Rear or flank attacks

Postby RocketRooster » 02 Jul 2017, 10:03

The trigonometric functions operate using degrees and not radians? Interesting. I suppose it allows the use of lookup tables for speed.
RocketRooster
Avatar-of-War
 
Posts: 294
Joined: 08 Apr 2016, 11:29
Has liked: 29 times
Been liked: 52 times
FAF User Name: RocketRooster

Re: Rear or flank attacks

Postby Franck83 » 02 Jul 2017, 10:11

RocketRooster wrote:The trigonometric functions operate using degrees and not radians? Interesting. I suppose it allows the use of lookup tables for speed.


There is a conversion from radian

Code: Select all
math.floor(a * (180 / math.pi) + 0.5) + 180
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Rear or flank attacks

Postby biass » 02 Jul 2017, 10:19

Make a reverse move 1st ;)
Map thread: https://bit.ly/2PBsa5H

Petricpwnz wrote:biass on his campaign to cleanse and remake every single map of FAF because he is an untolerating reincarnation of mapping hitler
User avatar
biass
Contributor
 
Posts: 2239
Joined: 03 Dec 2015, 07:54
Has liked: 598 times
Been liked: 662 times
FAF User Name: biass

Re: Rear or flank attacks

Postby EcoNoob » 02 Jul 2017, 11:33

That mod looks very interesting though, what are ya making? :D
EcoNoob
Avatar-of-War
 
Posts: 238
Joined: 20 Nov 2015, 22:05
Has liked: 155 times
Been liked: 70 times
FAF User Name: EcoNoob

Re: Rear or flank attacks

Postby JoonasTo » 02 Jul 2017, 12:28

Franck83 wrote:You're right. we can do front / right / side parts of the armor. It is a less good but still good solution.

On the other side, i would like better damage localization accuracy. That's why i'm trying to go deeper in searching. This open solutions.
For example, some functions like Entity:GetCollisionExtents() give us the mini / maxi collision box. It will be cool to be able to know where the unit is hit : head, chest, arm, rear...
I'm ok with projectile impact coord but i didn't succeed in localizing the damage impact on the unit by using collision system. So i'm using a unit/projectile direction system.

This features can bring us very cool epic game mechanics. Imagine we can add head, arm, legs, chest armor parts to bots. This may open fantastic micro solutions during battles.

There might be some problems with the targeting system then as not all units 'aimpoint' is at the center of mass, it is the head for some units, top or bottom floor for some buildings, etc.
This isn't a problem if you don't have too many units ofc. You can just mod that but if you have to mod it for every unit, it's a pain.

EcoNoob wrote:That mod looks very interesting though, what are ya making? :D

BattleTech? :P

biass wrote:Make a reverse move 1st ;)

Hmph, clearly a false believer, repent and experience enlightenment with the glorious Aurora, always facing it's opponent head on as the righteous knight of our faith!

No really though, we shouldn't get a reverse move, we should have unit AI that always retreats with the front facing the enemy as long as there's an enemy in scanning range or you give a move order close enough.
User avatar
JoonasTo
Priest
 
Posts: 498
Joined: 08 Feb 2015, 01:11
Has liked: 18 times
Been liked: 81 times
FAF User Name: JoonasTo

Re: Rear or flank attacks

Postby Franck83 » 02 Jul 2017, 13:16

There might be some problems with the targeting system then as not all units 'aimpoint' is at the center of mass, it is the head for some units, top or bottom floor for some buildings, etc.
This isn't a problem if you don't have too many units ofc. You can just mod that but if you have to mod it for every unit, it's a pain


The option i tried to do is to calculate the middle x, y, z of the collision box (il may be circle collision in some cases). Since i got the projectile coordonates at the impact, it seems possible to locate impact without editing any unit. You can call the collision box coordonates at any time in the sim side. That's very cool, but i got some incoherent results. May be i will try again later. But i fell stucked at this time.


That mod looks very interesting though, what are ya making? :D


Said simple, it allows upgrading, training and promoting for any kind of unit in the game. You want to protect and level up your little tech 1 bot ? It s possible, not easy, but with time, micro and mass you can. Choosing class grants skills. Skills grants powers (in current dev). Powers and skills can be trained at the player choice.
So you can craft any kind of unit you want. for example, you can make some tech 3 bot with anti experimental armor capabilities. A specialized unit is stronger against some and weaker against others. Or you can get high dodging aircrafts or high damage bombers. You can train your eegineers for combat, building or large passive repairing.

For now, the mod is working fine with some mechanics and some formulas (defense rating (chance to negate damage), attack rating (chance to hit), building skill...

It take me more 1 year and a half and 3 complete reboot coding to find the right flexible architecture. Now any upgrade, any power is a callback script file that can be coded for any kind of result. You can create a armor that grants % damage converting in energy without touching the mod engine. So it's very easy to long term mod maintenance.

There is some work to do, i'm not focused on upgrades or balancing now, but i'm trying to integrate any kind of cool game mechanic possible.

Theses are screenshots from the mod.

Image

Image

Image

Image
Last edited by Franck83 on 02 Jul 2017, 13:35, edited 1 time in total.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Rear or flank attacks

Postby Franck83 » 02 Jul 2017, 13:17

EcoNoob wrote:That mod looks very interesting though, what are ya making? :D

BattleTech? :P


don't know battle tech, maybe there are some similitaries :) ?

I take a look at battle tech, and right, you can control upgrades with slots...

In battle tech you control 1 unit, but with forged alliance, you can do it for all units ;) !
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest