ShellShock Live

ShellShock Live

316 ratings
Perfect accuracy with CALCULATIONS
By ilyaki
To find the power of a shot, multiply negative two by the square root of { the negative gravity constant (which is -379.106 pixels per second squared) by the distance in x in pixels to your target squared, divided by { two multiplied by the cosine of the angle of your choice squared multiplied by { the tangent of the same angle multiplied by the distance in x subtract the distance in y } } } , Then divide all that by { the gravity constant multiplied by the relationship between the power of a shot and the time for it to hit the ground when shot straight upwards(which is 0.0518918)
13
5
4
9
7
3
4
2
2
2
   
Award
Favorite
Favorited
Unfavorite
Introduction
In 2D projectile motion, the velocity in the x-direction is constant, whilst the velocity in the y-direction is changing solely due to gravity.

Our goal is to find the power needed for a shot when given the coordinates of both tanks, and an angle of your choice.

To do this we must:
  • Calculate the time for the shot to move the correct distance in x, given an initial velocity
  • Use motion equations to calculate the initial velocity
  • Calculate the gravity constant in pixel per second squared
  • Find the relationship between initial velocity and power of a shot



The Model
  • The distance in x from our tank to the enemy's is s_x(pixels)
  • The distance in y from our tank to theirs is s_y(pixels)
  • The acceleration due to gravity is g(pixels per second squared)
  • The initial velocity of the shot, as a vector, is u(pixels per second)
    - The x-component will be u*cos(θ)
    - The y-component will be u*sin(θ)
Calculating the initial speed of a shot
To find the time to move s_x in the x-direction:


We can now use this in one of the Equations of motion:

Where s is distance, u is initial velocity, a is acceleration and t is time. If you want the proof for this equation, Google it.

Plugging in our vertical components:


We are looking for the equation of initial velocity(u), so simplify and rearrange u as the subject


Using this equation, we can calculate the initial velocity required for a shot to hit a given coordinate using a given angle.
However, there are two issues:
1: We still don’t know the value of g
2: Shellshock doesn’t accept initial velocity in pixels per second as an input, so we need to convert it to power
Calculating the acceleration due to gravity(g) in pixels per second squared
To calculate the gravity constant, we will shoot a shot with standard projectile motion once at a given power level and angle on a (mostly)flat plain. Shoot an explosive weapon first to make sure the final y-coordinate of the shot is less than your tank.

I chose 100 Power and 80 degrees angle.
^ Notice the tracer line

Since the x-velocity(v_x) is constant, I will calculate it first.
We need to measure the coordinates of our tank and the coordinates of the shot when it lands and the time to reach the position where it lands

Take a screenshot of the game, with the tracer line, and open it in an advanced photo editing tool, such as MS Paint. MS Paint displays the exact pixel coordinates of the mouse cursor in the bottom left corner of the window.
Calculate the change in x by subtracting the x-coordinate of the tank from the x-coordinate of the landing spot. I measured 861 pixels.


Next step: measuring the time to land
We need to take a recording of the shot firing. I will use OBS[www.obsproject.com]. Then, open up the recording in VLC[www.videolan.org]. To measure the timings of each frame in milliseconds, install the Jump to time (Previous frame)[www.addons.videolan.org] plugin. Keep incrementing or decrementing the frame time until you find the exact time of firing the shot and it landing. Calculate the difference, change in time: Δt. I measured 5.093 seconds.

Calculating the x-velocity
v_x is simply change in x divided by change in time:


Alternatively, x as a function of time:

^We will use this form later


Plotting a graph of the tracer line
[Note that in MS Paint, the origin (0,0) is in the top left corner. However, I assume in these calculations that (0,0) is the bottom left corner. To convert the MS Paint coordinates, the corrected y-coordinate is equal to the MS y-coordinate subtracted from the resolution height of your monitor(mine is 1080). We must do this for all readings.]

Take many repeated measurements of points on the tracer line. Calculate the distance in x and y to the tank. Plot the x,y distances as a table on Desmos[www.desmos.com]
For example, using the same tracer line as above (100 power, 80 degrees angle):

We can now use Desmos’s regressions calculator to plot y as a function of x through the points. This is the syntax for a quadratic plot:
a,b and c are constants that will be calculated by Desmos


Calculating gravity
The definition of acceleration is the rate of change of velocity. The definition of velocity is the rate of change of displacement(y in this case). Hence, we need to find the rate of change of y with respect to x to find the rate of change of y with respect to time(VELOCITY) to find the rate of change of velocity with respect to time(ACCELERATION = g)

Firstly, the rate of change of y with respect to x, using basic calculus:



We can use this in combination with the rate of change of x with respect to time(which is the same thing as x-velocity):

^Notice how in step 4 I replaced x with its function for time: vx*t


Now we have an equation for y-velocity as a function of time. Taking the derivative again with respect to time will give us acceleration:


Hence the acceleration in the y-direction due to gravity is -379.106 pixels per second squared. Write it in Desmos for future use:


g is constant and will be the same on every shot, not just with 100 power, 80 angle


Now that we have calculated the gravity constant, all we need to do is find the relationship between initial velocity and shot power

Converting initial speed to power
The method I will be using to find the relationship:
  1. Fire shots directly upwards(90 degrees) and measure the time for the shot to come back down and hit us (total y displacement = 0). This way we don’t need to do any pixel measurements
  2. Create a table of power to time. Work out the relationship
  3. Use the movement equation to work out a formula that calculates shot power from initial velocity

Here is the data I collected. x_2 is the shot power and y_2 is the time


When plotted, the points look like this:


This looks like a direct proportionality through the origin. Let’s plot a straight line regression in the form y=mx :


As you can see, the relationship is perfect


Working out the relationship formula
The regression shows that:


Filling in the equation of motion:



And rearranging:


Plug in the formula t=q*power:


Make power the subject:


We now have all the formulae and calculations we need: onto the final step
Final Formula
Combining
and



Forms the MAGIC FORMULA



You could plot this in Desmos to create a graph:
^ The y-axis would show power, and the x-axis would show s_x . Use a slider to set s_y
NOTE: Desmos uses radians by default. Click the spanner/wrench icon in the top-right corner and select degrees
How to use the formula
  1. Take a screenshot of the game
  2. Open screenshots folder
  3. Measure s_x and s_y with MS Paint
  4. Use the formula or graph
  5. Shoot at the power level calculated


Tips and Tricks
  • Save the Desmos project
  • Shellshock only accepts integers(whole numbers) as inputs for power, meaning you have to round up or down. If you calculate a power level that is far from an integer (e.g. 64.5), try changing your angle until you are closer to an integer (e.g. 64.9). This is important for being accurate at long range with precise weapons
  • Most weapons will have the same trajectory, so they will work with the formula. However, some exceptions are: Hover ball, Moons, etc
  • The formula is designed to hit the target exactly. Some weapons like Bolt will bounce off.
  • The constants used is my calculations were done on a 1920x1080 resolution monitor. You will have to scale the numbers if you are using a different resolution(e.g. g on a 4k monitor should be doubled)
Conclusion
Thanks for reading.
This guide took a long time to create, so likes and favourites are greatly appreciated :)

This is technically cheating, so don’t abuse it: only use it as a joke against friends, etc.
(Also please don’t sue me, etc)
156 Comments
luke.liede Feb 14 @ 11:27pm 
hmmmm good job you must have liked math allot
KADremorriaU Aug 14, 2024 @ 3:06am 
what the fuck
Welshking May 27, 2024 @ 11:37am 
teacher the test isnt THAT confusing the test /\ and no:GDNormal:
doge May 9, 2024 @ 1:37pm 
me: *wind: low*
Ctrekoz Apr 22, 2024 @ 7:16am 
What the hell
WHAT THE
KАМ КillJоy Apr 12, 2024 @ 4:52am 
Ok, i see. Vo = ((q*g)/2)*Pow where q = 0.0518718 and g = 379.106
KАМ КillJоy Apr 12, 2024 @ 1:28am 
Amazing work. Can you help me with x(t) and y(t) functions?
x(t) = v0 * cos(a) * t
y(t) = v0 * sin (a) * t - (g/2)*t^2
I need to convert v0 into power somehow.
Frupert the nude apricot Jan 5, 2024 @ 1:39pm 
Wow this just makes it more impressive that I can wing it and usually get direct hits :/
Devil✰Down May 21, 2023 @ 3:54am 
now good luck doing this in 30sec
ablluu May 14, 2023 @ 9:54am 
Nice work, but two questions: Do you be chance also know the impact of wind on the x velocity? and as you can only enter natural numbers as an angle would it be better to round the angle before inserting it into the formular or after?