Math is scary, hard, messy. Basically magic.
Dr. Willy in first Mega Man shoots bullets at you that will always hit. Obvious cheater. There is no report option in Mega Man...
It's not straight shot like in Contra, it's parabolic LIKE IN REAL LIFE.
Do you know any article/tutorial about that kind of magic?
How do I aimbot?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How do I aimbot?
Well, you know you want a parabola, and you also probably want its highest point to be right in the center, so given your source $$s = (s_x, s_y)$$ and your target $$t = (t_x, t_y)$$. The center is then obviously at $$c = (\frac{s_x+t_x}{2}, h)$$, where h is the height of the apex.
So we want a parabola with center c that goes through s and t, which means that with y = 0 it's at s and t. We also know that x^2 reaches y=0 with x=0, so we need to "raise" it by adding h at the center, so the formula becomes:
$$y = (x-c_x)^2 + h$$
Now we need to "squash" it horizontally so it goes through s and t, that are at equal distances from that center point in the x axis. So with x being sx, we want y to be 0, so..
$$a(s_x - c_x)^2 = h$$
So now we can now find a using
$$a = \frac{h}{(s_x - c_x)^2}$$
And our final formula for the parabola becomes
$$y = a(x-c_x)^2 + h$$
Now you just need to tweak h until it looks right. I hope I didn't confuse you too much, and good luck! (This is the point where someone else comes in and gives you a solution that's easier to calculate and/or program.)
EDIT: I should probably mention the derivative of this will give you the "velocities" you probably want for your calculation.
So we want a parabola with center c that goes through s and t, which means that with y = 0 it's at s and t. We also know that x^2 reaches y=0 with x=0, so we need to "raise" it by adding h at the center, so the formula becomes:
$$y = (x-c_x)^2 + h$$
Now we need to "squash" it horizontally so it goes through s and t, that are at equal distances from that center point in the x axis. So with x being sx, we want y to be 0, so..
$$a(s_x - c_x)^2 = h$$
So now we can now find a using
$$a = \frac{h}{(s_x - c_x)^2}$$
And our final formula for the parabola becomes
$$y = a(x-c_x)^2 + h$$
Now you just need to tweak h until it looks right. I hope I didn't confuse you too much, and good luck! (This is the point where someone else comes in and gives you a solution that's easier to calculate and/or program.)
EDIT: I should probably mention the derivative of this will give you the "velocities" you probably want for your calculation.
Re: How do I aimbot?
Very interesting set of runes!
I will sit with pen and paper and try to visualise this concept
I will sit with pen and paper and try to visualise this concept
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How do I aimbot?
Oh, I forgot to mention, this is the easy part, it gets tricky when the y positions are different.
Re: How do I aimbot?
I guess my whole game will be flat T_T
Re: How do I aimbot?
Well, let's explain it this way:
With the aforementioned y = a(x - cx)^2 + h, you know...
y is where the parabola's height will be, given all of the other information.
a is the amount the parabola is scaled by.
x is where it will be, horizontally.
cx is the amount the parabola is offset by on the x-axis (where the vertex x is). Note that it is being subtracted. That means that if you want a negative offset, you will actually be adding (or subtracting a negative, same thing).
h is the amount it's being moved up or down. Also where vertex y is.
Keep in mind, the equation for a quadratic (what makes a parabola) can also be modeled by ax^2 + bx + c = y.
The vertex (highest/lowest point on the parabola) can be gotten by:
Note that y also represents the height of the vertex.
You can get the roots of the parabola with:
The vertex will always be halfway between the two, so now we have three main points: x1, x2, and vx (Vertex x )
x1 is where the boss is (x position).
x2 is where the player will be (player.x + player.velocity * TIME).
vx is the center of the parabola.
vx will be ( x1 + x2 ) / 2.
vy is vx + Height.
y = a * ( vx - x1 ) * ( vx - x2 ), therefore:
a = ( vy ) / ( ( vx - x1 ) * ( vx - x2 ) )
b = a * ( x1 + x2 )
c = a * x1 * x2
and y = ax^2 + bx + c
EDIT: And yes, having different y positions makes this formula a bit more complicated. Lemme see if I can figure that out.
With the aforementioned y = a(x - cx)^2 + h, you know...
y is where the parabola's height will be, given all of the other information.
a is the amount the parabola is scaled by.
x is where it will be, horizontally.
cx is the amount the parabola is offset by on the x-axis (where the vertex x is). Note that it is being subtracted. That means that if you want a negative offset, you will actually be adding (or subtracting a negative, same thing).
h is the amount it's being moved up or down. Also where vertex y is.
Keep in mind, the equation for a quadratic (what makes a parabola) can also be modeled by ax^2 + bx + c = y.
The vertex (highest/lowest point on the parabola) can be gotten by:
Code: Select all
function GetVertex( a, b, c )
local x = ( -b ) / ( 2 * a )
local y = c - ( ( b ^ 2 ) / ( 4 * a ) )
return x, y
end
You can get the roots of the parabola with:
Code: Select all
function GetRoots( a, b, c )
local Discriminate = b^2 - 4 * a * c
if Discriminate < 0 then return nil end -- If it's negative, it doesn't intersect.
local x1 = ( -b + math.sqrt( Discriminate ) ) / ( 2 * a )
local x2 = ( -b - math.sqrt( Discriminate ) ) / ( 2 * a )
return x1, x2
end
x1 is where the boss is (x position).
x2 is where the player will be (player.x + player.velocity * TIME).
vx is the center of the parabola.
vx will be ( x1 + x2 ) / 2.
vy is vx + Height.
y = a * ( vx - x1 ) * ( vx - x2 ), therefore:
a = ( vy ) / ( ( vx - x1 ) * ( vx - x2 ) )
b = a * ( x1 + x2 )
c = a * x1 * x2
and y = ax^2 + bx + c
Not sure explaining yours a bit more and giving other options counts as a better solution or not...bartbes wrote:(This is the point where someone else comes in and gives you a solution that's easier to calculate and/or program.)
EDIT: And yes, having different y positions makes this formula a bit more complicated. Lemme see if I can figure that out.
Last edited by davisdude on Sat Apr 19, 2014 4:52 pm, edited 1 time in total.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How do I aimbot?
Oh, and perhaps an easier to visualise way of obtaining the same results I got above would perhaps be this:
We start of with a parabola that has its peak at 1 (which will be the apex) and its roots at -1 and 1. That is:
$$y = -x^2+1$$
Next, we multiply it by the height h, to make sure our apex is where we want it:
$$y = h\left(-x^2+1\right) = -hx^2+h$$
Now, we still have the roots at -1 and 1, but what if our points are not '2' apart, but d. Well, then we need to divide the x coordinate by d, but since x is squared, we have to square d too.
$$y = -h\left(\frac{x}{d}\right)^2+h = -\frac{h}{d^2}x^2+h $$
Personally I think the last one is easier to read, but they're of course equivalent.
Now, we can easily see what a must be to get the same formula as above (though now that I think of it, I probably missed some negations there).
EDIT: And for the arbitrary positions one, you can define the apex as a point, then find a formula for a parabola through those three points, as seen here.
We start of with a parabola that has its peak at 1 (which will be the apex) and its roots at -1 and 1. That is:
$$y = -x^2+1$$
Next, we multiply it by the height h, to make sure our apex is where we want it:
$$y = h\left(-x^2+1\right) = -hx^2+h$$
Now, we still have the roots at -1 and 1, but what if our points are not '2' apart, but d. Well, then we need to divide the x coordinate by d, but since x is squared, we have to square d too.
$$y = -h\left(\frac{x}{d}\right)^2+h = -\frac{h}{d^2}x^2+h $$
Personally I think the last one is easier to read, but they're of course equivalent.
Now, we can easily see what a must be to get the same formula as above (though now that I think of it, I probably missed some negations there).
EDIT: And for the arbitrary positions one, you can define the apex as a point, then find a formula for a parabola through those three points, as seen here.
Re: How do I aimbot?
Okay, here's how you get the parabola given the vertex, a point, and a root:
Recall that the vertex x is 1/2 way between the player and the boss, and the vertex y is the boss' position + the height of the vertex each time.
Also:
$$y = a( x - cx ) ^ 2 + h$$.
cx is the vertex x, and h is the vertex y, so
$$y = a( x - vx ) ^ 2 + vy$$
If the parabola passes through a certain point, that means that the y and x are the given point (the player's position). So
$$py = a( px - vx ) ^ 2 + vy$$
Get a by doing some math
$$py - vy = a( px - vx ) ^ 2$$
$$\frac{py - vy}{( px - vx ) ^ 2} = a$$
Recall that the vertex x is 1/2 way between the player and the boss, and the vertex y is the boss' position + the height of the vertex each time.
Also:
$$y = a( x - cx ) ^ 2 + h$$.
cx is the vertex x, and h is the vertex y, so
$$y = a( x - vx ) ^ 2 + vy$$
If the parabola passes through a certain point, that means that the y and x are the given point (the player's position). So
$$py = a( px - vx ) ^ 2 + vy$$
Get a by doing some math
$$py - vy = a( px - vx ) ^ 2$$
$$\frac{py - vy}{( px - vx ) ^ 2} = a$$
Last edited by bartbes on Sun Apr 20, 2014 7:02 pm, edited 1 time in total.
Reason: Used fancy formulas.
Reason: Used fancy formulas.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: How do I aimbot?
Okay, so I tried to became the one with projectile. Think like projectile.
Then I thought... okay so what this f(x) has to do with velocities and gravity.
No idea, so I come up with another idea.
Spawned projectile will know the distance betwen enemy and player.
Then I can move him in x-axis and count y-position for every x.
Like that:
Would it work?
Then I thought... okay so what this f(x) has to do with velocities and gravity.
No idea, so I come up with another idea.
Spawned projectile will know the distance betwen enemy and player.
Then I can move him in x-axis and count y-position for every x.
Like that:
Would it work?
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests