Forged Alliance Forever Forged Alliance Forever Forums 2016-09-23T14:12:27+02:00 /feed.php?f=41&t=13162 2016-09-23T14:12:27+02:00 2016-09-23T14:12:27+02:00 /viewtopic.php?t=13162&p=136087#p136087 <![CDATA[Re: multiple bomb drop code shenanigans]]>

Statistics: Posted by Heaven — 23 Sep 2016, 14:12


]]>
2016-09-18T11:57:26+02:00 2016-09-18T11:57:26+02:00 /viewtopic.php?t=13162&p=135637#p135637 <![CDATA[Re: multiple bomb drop code shenanigans]]> Its based on the position of the target and not on where you want your bomb to drop.
Time between these two positions can be quite substantial so thats why you see such a big effect.

So to properly fix it you probably have to calculate time differently. My solution was a mere patch job so to speak.

Statistics: Posted by KeyBlue — 18 Sep 2016, 11:57


]]>
2016-09-18T01:41:22+02:00 2016-09-18T01:41:22+02:00 /viewtopic.php?t=13162&p=135623#p135623 <![CDATA[Re: multiple bomb drop code shenanigans]]> After some coding and testing, i have found the solution to your problem!

The issue was with:
Code:
local velocitychange = VMult(displacement, 1/time)

Due to time changing, this value also changes. But that is ofcourse not what you want. You want the same displacement each time.
So you only need to calculate this value once for each line. And then reuse it for later bombs.

Hope thats what you wanted.

I put my changes into the spoiler tag.
Spoiler: show
Code:
    --add this line at the start somewhere
    --needed because somewhere bomb_data[id] gets set to nil before it reaches your code.
    local current_bd = bomb_data[id]

Spoiler: show
Code:
   
    if bp.BombLineSpread and bp.BombingLines then
        if not current_bd.velocitychange then
            current_bd.velocitychange = {}
        end
        .
        .
        local adjvelocity = DisplaceTarget(proj.vel, (bp.BombLineSpread*i)-offset, time, current_bd, i)
        .

Spoiler: show
Code:
DisplaceTarget = function(vel, disp, time, bomb_d, i)
    --here we will be adding a 2d displacement to our target position, for lots of interesting things.
    --we will be working in 2d, but our vector will be 3d so we can add it easily later.
    --for that we just set y to 0 and call it a day.
   
   
    local velocitychange
    if bomb_d.velocitychange[i] then
        velocitychange = bomb_d.velocitychange[i]
    else
        --local direction = Vector(vel[1], 0, vel[3])
        --[x][z] goes to [-z][x] for right hand and [z][-x] for left hand
        local perpendicular = Vector(vel[3], 0, -vel[1]) --we want to displace perpendicular to the direction our bomb is going in
        local dist = math.sqrt(perpendicular[1]*perpendicular[1] + perpendicular[3]*perpendicular[3]) --the length of our vector
       
        displacement = VMult(perpendicular, (disp/dist)) --obtain unit vector AND scale it in the same line! efficiency!
        --1/dist would be the unit vector, then we just multiply that by disp but we are being cool here.
        velocitychange = VMult(displacement, 1/time) --get the velocity we need to add so we get into the right place. probably.
        --since we are going perpendicular to the bomb path, this doesnt affect CalculateBallisticAcceleration and so we dont need to change the target position.
        bomb_d.velocitychange[i] = velocitychange
    end
   
    local velocity = VAdd(vel, velocitychange) --add our adjusted speed to our projectile speed.
   
    return velocity
end



I just thought about just giving you the file. So i'll add that aswell.

Statistics: Posted by KeyBlue — 18 Sep 2016, 01:41


]]>
2016-09-17T23:56:54+02:00 2016-09-17T23:56:54+02:00 /viewtopic.php?t=13162&p=135617#p135617 <![CDATA[Re: multiple bomb drop code shenanigans]]>
KeyBlue wrote:
Question: If the bombs spread out, why would the napalm lines, be parallel?
Don't the napalm lines just folow the direction the bombs are going?

I guess you should let the dispersion of the bombs on each line be along the original direction and not along your adjusted direction?

PS: looks nice. And liked your efficiency ;)


This could be the result of the bombs being fired rather then dropped. Now as the bombs that are created are launched in the direction of the weapons "bone" (part of the unit model) they apear to be thrown / ejected from the bomber rather then simply falling to the ground. Hence why they are spread out but remain roughly parallel. The problem will be known once i'm able to read the unit blueprint /script as well as any other modifications he's made. Also be aware that dropped bombs assume the forward momentum of the bomber dropping them. The spread is caused by motion along another vector in combination with the bombers flight motion. (both motion vectors are added together)

Now if i had made this script I'd of opt'd to edit the unit script instead of the blueprint. Thus i'd have the bomber drop extra bombs and offset their initial position and velocity to have more control over the effect.

Resin

Statistics: Posted by Resin_Smoker — 17 Sep 2016, 23:56


]]>
2016-09-17T23:49:25+02:00 2016-09-17T23:49:25+02:00 /viewtopic.php?t=13162&p=135615#p135615 <![CDATA[Re: multiple bomb drop code shenanigans]]> Don't the napalm lines just folow the direction the bombs are going?

I guess you should let the dispersion of the bombs on each line be along the original direction and not along your adjusted direction?

PS: looks nice. And liked your efficiency ;)

Statistics: Posted by KeyBlue — 17 Sep 2016, 23:49


]]>
2016-09-17T23:34:22+02:00 2016-09-17T23:34:22+02:00 /viewtopic.php?t=13162&p=135614#p135614 <![CDATA[Re: multiple bomb drop code shenanigans]]>
Resin

Statistics: Posted by Resin_Smoker — 17 Sep 2016, 23:34


]]>
2016-09-17T23:30:45+02:00 2016-09-17T23:30:45+02:00 /viewtopic.php?t=13162&p=135613#p135613 <![CDATA[Re: multiple bomb drop code shenanigans]]>
Resin

Statistics: Posted by Resin_Smoker — 17 Sep 2016, 23:30


]]>
2016-09-17T19:48:55+02:00 2016-09-17T19:48:55+02:00 /viewtopic.php?t=13162&p=135589#p135589 <![CDATA[multiple bomb drop code shenanigans]]> Image
the code is even configurable from the unit blueprint so no messy script editing if its not needed
Image
however as you can see in the second picture, the bomb runs spread out. this means my code isnt working properly (


i would like to have some help with working out why this is the case. i suspect its something to do with sideways acceleration on the projectile somewhere but i dont know where that comes from, either that or my physics is failing me now (
https://github.com/FAForever/fa/pull/1513
you can view the code here, all for the glory of equilibrium of course.

i thought it might be useful to post this so that if and when this is fixed it should be flexible enough to use for a variety of bombing run weapons and whatnot. enjoy.

balance terrorists strike again!

Statistics: Posted by Exotic_Retard — 17 Sep 2016, 19:48


]]>