Flak with maximum number of units hit

Everything about mods can be found here.

Moderator: Morax

Flak with maximum number of units hit

Postby maov » 31 Aug 2014, 00:36

I am trying to make a flak projectile that when it explodes/dies creates the flak cloud and creates a entity that does close to instant damage to the x nearest targets within a certain range. Ala an AOE Flak that can hit a maximum number of units.


My idea is to spawn a unit on the death of the projectile, that unit should do x fast shots reload and die before reload finishes. Then i need a function which returns all the units within range, where i take k nearest neighbour and attack each once.


Is the idea possible or is there a better way?

Furthermore what is the name of the function that returns all targets within range (I assume one such exists and that its highly optimized)?
maov
Crusader
 
Posts: 20
Joined: 31 Aug 2014, 00:06
Has liked: 2 times
Been liked: 1 time

Re: Flak with maximum number of units hit

Postby A_vehicle » 09 Sep 2014, 20:08

Spoiler: show
I am assuming the reason you are even considering this mod is because of the problem with fast units outrunning explosion damage from regular flak?

If so, I can tell you that while I don't know exactly why this happens, I believe it is because there is a delay in the engine function DamageArea and DamageRing between the time the engine checks the explosion area for all units present and applying the damage. This is an engine problem that can't really be modded. If the engine has a delay in dealing area damage, I doubt a script could remove it (although I could be wrong!). You would most likely find this delay in the time it takes for your script to find all units in the area of effect of your unit/weapon.

However I can tell you that there is a(n approximate) formula (depending on physical in game factors) to determine if a unit will outrun the engine-driven explosion damage:
if DamageRadius/2 >= UnitSpeedAtInstantofExplosion/10 then damage will be dealt, otherwise the unit will outrun the damage.

This is why SAMs were given a damage radius of 1.5 by FAF, because spy planes have a max speed of 30 units. Therefore:
1.5*2==30/10.
Before this was figured out, FA made SAMs have no damage radius because weapons with no damage radius deal damage the same tick that Damage is called.

You or others on this forum may already know this, but I figured it was appropriate to post here so new modders could see how it worked.


Edit: It appears I misunderstood you, you meant you wanted a unit that only hit the x closest units in range, even if more units were in range of the explosion. That wouldn't be difficult. You could probably create a custom function in defaultprojectile.lua and do something like this:

Code: Select all
function LimitedChainExplosionDamage(<parameters>)
    for i,j in units do
        <damage code>
        if i == x then break
    end
end,

That isn't exactly what you'd paste, or where you'd paste it, but that is the essence of what you are looking for. It would deal damage to the first x number of units in the area then stop. To do that based on distance would be more complicated but obviously still possible.
Typical Voodoo Edition Map Dialog:
Master_lee wrote:Varaxis ist loser vote all my maps 1 !!! he cant make maps noob go home !!!!!!

Padfoot141 wrote:Terrible map. Spawn with 6 commanders and there are civillians with fatboys.

Master_lee wrote:Padfoot141 go home loser ! go play thermo !
A_vehicle
Avatar-of-War
 
Posts: 55
Joined: 31 Jul 2012, 03:20
Has liked: 1 time
Been liked: 2 times
FAF User Name: A_vehicle

Re: Flak with maximum number of units hit

Postby Domino » 12 Sep 2014, 20:14

Hey this is easy,

you dont need to create units on projectile death, just create the effects... then as you loop though the units around position
enter them into a table.. loop the table of units getting the distance from the projectile impact position (flack death)
then have something like 3 different damage amounts based on distance from impact..

<= 3 = 50% dmg
>=4 and <= 5 = 15% dmg
> 5 and <= maxrange = 3% dmg

it can all be done from one function on projectile death.
do the effects in another function call that function after getting the units but before iterating for dmg.
this way dmg is dealt at the same time the effect trigegrs.

2 functions max depending on how fancy you want the effects.
Domino
Priest
 
Posts: 315
Joined: 14 Mar 2012, 21:07
Has liked: 3 times
Been liked: 75 times


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest