Forged Alliance Forever Forged Alliance Forever Forums 2014-09-12T20:14:09+02:00 /feed.php?f=41&t=8445 2014-09-12T20:14:09+02:00 2014-09-12T20:14:09+02:00 /viewtopic.php?t=8445&p=80527#p80527 <![CDATA[Re: Flak with maximum number of units hit]]>
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.

Statistics: Posted by Domino — 12 Sep 2014, 20:14


]]>
2014-09-09T20:08:40+02:00 2014-09-09T20:08:40+02:00 /viewtopic.php?t=8445&p=80317#p80317 <![CDATA[Re: Flak with maximum number of units hit]]>
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:
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.

Statistics: Posted by A_vehicle — 09 Sep 2014, 20:08


]]>
2014-08-31T00:36:48+02:00 2014-08-31T00:36:48+02:00 /viewtopic.php?t=8445&p=79830#p79830 <![CDATA[Flak with maximum number of units hit]]>

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)?

Statistics: Posted by maov — 31 Aug 2014, 00:36


]]>