|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Sun Feb 05, 2017 7:05 pm Post subject: Error: attempt to perform arithmetic on a table value |
|
|
This code: Code: | function is_intersect(pos, dir, quad)
local theta_corner, theta_min, theta_max
for i = 1, 4 do
local x, y = quad[i].x, quad[i].y
-- Find angle of line from pos to corner
theta_corner = math.atan((y - pos.y) / (x - pos.x))
-- Adjust angle to quadrant
if x < pos.x then
theta_corner = theta_corner + math.pi
elseif y < pos.y then
theta_corner = theta_corner + 2*math.pi
end
-- Keep max and min angles
if (not theta_min) or theta_corner < theta_min then
theta_min = theta_corner
end
if (not theta_max) or theta_corner > theta_max then
theta_max = theta_corner
end
end
-- Compare direction angle with max and min angles
return theta_min <= dir and dir <= theta_max
end
--process to find radians = (ytraj/xtraj) = slope then arctan(slope) = degrees
--then (degrees (simplify degrees/180 or not)* pi)/2 or /180 (if not simplified
--thus if degrees = 60 then radian format = 60pi/180 or simplified 1pi/3
pi = math.pi
rad = math.atan(ytrajectory/xtrajectory)*pi/180
angle = math.atan(xtrajectory/ytrajectory)
dir = angle <= rad and rad < 2*pi
local oldT = getTickCount() -- resolution isn't great, but good enough
local hk = createHotkey(function()
local nowT = getTickCount()
oldT = nowT
if is_intersect(pos, dir, quad)
then doKeyPress(VK_Z)
end
end, VK_E) |
Gives an error on the line of: Code: | theta_corner = math.atan((y - pos.y) / (x - pos.x)) | that I can't really understand by just looking at it and messing with it. Just want to know if anyone has a solution, also, when printing x, y it prints a blank line or when printing x, y in string it prints nil nil for x y.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Feb 05, 2017 9:55 pm Post subject: |
|
|
Sounds like you're not defining quad or pos correctly.
Probably missing a curly brace somewhere in quad. Code: | local pos = { x = 7, y = 7 }
local quad = {
{ x = 00, y = 00 },
{ x = 00, y = 10 },
{ x = 10, y = 00 },
{ x = 10, y = 10 }
} |
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Sun Feb 05, 2017 10:27 pm Post subject: |
|
|
Zanzer wrote: | Sounds like you're not defining quad or pos correctly.
Probably missing a curly brace somewhere in quad. Code: | local pos = { x = 7, y = 7 }
local quad = {
{ x = 00, y = 00 },
{ x = 00, y = 10 },
{ x = 10, y = 00 },
{ x = 10, y = 10 }
} |
|
If the spaces before the curly brace is needed, then I messed up, but the formatting you used such as the {{x, y}} is what I used as well. Also, is it required that I locally define both instead of globally? I put pos like this: Code: | pos = { x=x1, y=y1 } | and quad like this: Code: | quad = {{x=x1, y=y1}, {x=x2, y=y2}, {x=x3, y=y3}, {x=x4, y=y4}} | Now that I see it, I shouldn't have those x1, y1 things, just the x and a number probably.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Feb 05, 2017 11:50 pm Post subject: |
|
|
Spaces don't matter. Global is probably fine.
As long as x1, y1, x2, etc. were all variables you defined prior, that's fine too.
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Mon Feb 06, 2017 10:54 am Post subject: |
|
|
Zanzer wrote: | Spaces don't matter. Global is probably fine.
As long as x1, y1, x2, etc. were all variables you defined prior, that's fine too. |
Yes they were defined, the code is shown as Code: | sw_x1 = {p1x - 8388608}
sw_y1 = {p1y + 5111808}
sw_x2 = {p1x + 8388608}
sw_y2 = {p1y + 5111808}
sw_x3 = {p1x - 8388608}
sw_y3 = {p1y - 5111808}
sw_x4 = {p1x + 8388608}
sw_y4 = {p1y - 5111808}
quad = {{x=sw_x1, y=sw_y1}, {x=sw_x2, y=sw_y2}, {x=sw_x3, y=sw_y3}, {x=sw_x4, y=sw_y4}}
|
But still, it gives the error when running the function is_intersect. As it stops at Code: | theta_corner = math.atan((y - pos.y) / (x - pos.x)) | when that tries to use x.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Mon Feb 06, 2017 6:36 pm Post subject: |
|
|
Code: | sw_x1 = {p1x - 8388608} | Why did you wrap curly braces around them? That makes them a table. That's your error.
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Mon Feb 06, 2017 10:04 pm Post subject: |
|
|
Are you writing an aimbot in lua?
_________________
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Tue Feb 07, 2017 8:50 pm Post subject: |
|
|
akumakuja28 wrote: | Are you writing an aimbot in lua? |
Trying to learn more about lua by coding in a trajectory based game, yes, an aimbot, but aimbot for playing against bots, they're too hard to beat, so i'm becoming one of them. Zanzer wrote: | Code: | sw_x1 = {p1x - 8388608} | Why did you wrap curly braces around them? That makes them a table. That's your error. |
Now it gives the error of Code: | attempt to compare number with boolean | . on line 103 Code: | return theta_min <= dir and dir <= theta_max | Here's the full code: https://hastebin.com/uferubaxac.lua
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Wed Feb 08, 2017 4:37 pm Post subject: |
|
|
I fixed the error, however I have new problems. The function of is_intersect is doing nothing. Not sure if I should make a new thread for this problem.
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Wed Feb 08, 2017 5:32 pm Post subject: |
|
|
microsoftv wrote: | I fixed the error, however I have new problems. The function of is_intersect is doing nothing. Not sure if I should make a new thread for this problem. |
createThread will not give you a return to main thread.
However the moment you get everything working it would be best to execute all the code in (createThread). This code will likely tax CE pretty hard in the main thread.
Keep us posted. Im very curious how this turns out. When i was attempting this I had to some compare math(algorithm) to self adjust the mouse_event(flags, x OPTIONAL, y OPTIONAL, data OPTIONAL, extra OPTIONAL). This way the mouse snaps(moves) faster as your farther away from target and slows down as you near target. Just an observation of the snap speed when i was using CE main thread with timer.
_________________
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Thu Feb 09, 2017 11:07 am Post subject: |
|
|
akumakuja28 wrote: | microsoftv wrote: | I fixed the error, however I have new problems. The function of is_intersect is doing nothing. Not sure if I should make a new thread for this problem. |
createThread will not give you a return to main thread.
However the moment you get everything working it would be best to execute all the code in (createThread). This code will likely tax CE pretty hard in the main thread.
Keep us posted. Im very curious how this turns out. When i was attempting this I had to some compare math(algorithm) to self adjust the mouse_event(flags, x OPTIONAL, y OPTIONAL, data OPTIONAL, extra OPTIONAL). This way the mouse snaps(moves) faster as your farther away from target and slows down as you near target. Just an observation of the snap speed when i was using CE main thread with timer. |
Can you paste me the timer script?
Figured out I should probably be using timer as well for my calls for readInteger, as it's currently only being called when the function starts, and that should ultimately fix everything. I'll post again with results in 4-5 hrs.
|
|
Back to top |
|
|
microsoftv Advanced Cheater Reputation: 0
Joined: 07 Apr 2016 Posts: 82 Location: U.S
|
Posted: Fri Feb 10, 2017 12:14 am Post subject: |
|
|
Got the timer script, and everything works perfectly, except a major error is occuring, no print of an error, just what it's detecting as interesecting. If the ball is going straight up, and your character is to the right of the ball, it will automatically assume (depending on what the y value is of your character that the ball is intersecting. Not sure why it does this, but I do know that it only does it when the ytrajectory is positive/negative up or, in-game = -65565/65565. Also, no matter what the xtrajectory is, if the ytrajectory is 0 and if the xtrajectory is more than 0, then it will automatically assume the line is intersecting if the person is to the left of the ball, it also doesn't count the line as intersecting if the line is going towards you xtrajectory(-65565) and doesn't really care if the rectangle is even near the line in terms of y coordinates if it's going in that straight line, but then only cares about x coords when it's going at other trajectories. Here's the full code: Code: | setGlobalKeyPollInterval(1)
setGlobalDelayBetweenHotkeyActivation(1)
--Destroys hotkeys so they don't stay on after letting off key.
if hk then hk.destroy() end
function bally() return readInteger("[ballcoords]+1c") end
function ballx() return readInteger("[ballcoords]+18") end
function printBall()
local x = ballx()
local y = bally()
print("Ball: x: " .. x .. " y: " .. y)
end
if(t ~= nil) then -- if script is already running then
timer_setEnabled(t, false) -- stop the script
object_destroy(t)
t = nil
end
tickrate = 1 -- 50ms is every 3 frames
function main ()
ballspeed = readInteger("[ballstate]+12c")
xtrajectory = nil
if readInteger("[ballstate]+13c") > 2147483648 then
xtrajectory = (readInteger("[ballstate]+13c") - 4294967296)
else
xtrajectory = readInteger("[ballstate]+13c")
end
ytrajectory = nil
if readInteger("[ballstate]+140") > 2147483648 then
ytrajectory = (readInteger("[ballstate]+140") - 4294967296)
else
ytrajectory = readInteger("[ballstate]+140")
end
balldirection = readInteger("[ballstate]+154")
p4y = readInteger("[p4coords]+1c")
p4x = readInteger("[p4coords]+18")
p3y = readInteger("[p3coords]+1c")
p3x = readInteger("[p3coords]+18")
p2y = readInteger("[p2coords]+1c")
p2x = readInteger("[p2coords]+18")
p1y = readInteger("[p1coords]+1c")
p1x = readInteger("[p1coords]+18")
dx = readInteger("[ballcoords]+18")-readInteger("[p1coords]+18")
dy = readInteger("[p1coords]+1c")-readInteger("[ballcoords]+1c")
half_height = 5111808 -- FOR SWITCH ONLY
full_height = 9175040 -- FOR SWITCH ONLY
half_width = 8388608 -- FOR SWITCH ONLY
full_width = 16777216 -- FOR SWITCH ONLY
--sw_TopLeftPt = {p1x - 8388608, p1y + 5111808}
--sw_TopRightPt = {p1x + 8388608, p1y + 5111808}
--sw_BottLeftPt = {p1x - 8388608, p1y - 5111808}
--sw_BottRightPt = {p1x + 8388608, p1y - 5111808}
x1 = (p1x - 8388608)
y1 = (p1y + 5111808)
x2 = (p1x + 8388608)
y2 = (p1y + 5111808)
x3 = (p1x - 8388608)
y3 = (p1y - 5111808)
x4 = (p1x + 8388608)
y4 = (p1y - 5111808)
up_leftx = 6422528 -- FOR TRAIN MAP ONLY
up_lefty = 2162688 -- FOR TRAIN MAP ONLY
Rw = ballx() - up_leftx -- FOR TRAIN MAP ONLY
Rh = bally() - up_lefty -- FOR TRAIN MAP ONLY
min_slope = (bally() - Rh)/(ballx() - (Rw + full_width)) -- FOR TRAIN MAP ONLY
max_slope = (bally() - (Rh + full_height))/(ballx() - (Rw + full_width))
hitstun_countdown = readInteger(getAddress("[ballstate]+128"))/1092
if hitstun_countdown < 0 then hitstun_countdown = 0
end
bunted = readInteger(getAddress("[ballstate]+144"))
if bunted == 8 then hitstun_countdown = 0
end
if hitstun_countdown > 120 then hitstun_countdown = 0
end
--dir = {x=xtrajectory, y=ytrajectory}
--quad = {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}
quad = {{x=x1, y=y1}, {x=x2, y=y2}, {x=x3, y=y3}, {x=x4, y=y4}}
--quad = {{x = 1, y = 1}, {x = 1, y = 2}, {x = 2, y = 2}, {x = 2, y = 1}}
pos = {x=ballx(), y=bally()}
function is_intersect(pos, dir, quad)
local theta_corner, theta_min, theta_max
for i = 1, 4 do
local x, y = quad[i].x, quad[i].y
-- Find angle of line from pos to corner
theta_corner = math.atan((y - pos.y) / (x - pos.x))
-- Adjust angle to quadrant
if x < pos.x then
theta_corner = theta_corner + math.pi
elseif y < pos.y then
theta_corner = theta_corner + 2*math.pi
end
-- Keep max and min angles
if (not theta_min) or theta_corner < theta_min then
theta_min = theta_corner
end
if (not theta_max) or theta_corner > theta_max then
theta_max = theta_corner
end
end
-- Compare direction angle with max and min angles
return theta_min <= dir and dir <= theta_max
end
--process to find radians = (ytraj/xtraj) = slope then arctan(slope) = degrees
--then (degrees (simplify degrees/180 or not)* pi)/2 or /180 (if not simplified
--thus if degrees = 60 then radian format = 60pi/180 or simplified 1pi/3
--rad = angle <= rad and rad < 2*pi
pi = math.pi
dir = ((math.atan(ytrajectory/xtrajectory)*pi)/180)+3*pi/2
--angle = math.atan(xtrajectory/ytrajectory)
angle = math.atan(ytrajectory/xtrajectory)
end
t = createTimer(nil, false) -- create a Timer object and assign it to variable t
timer_onTimer(t, main) -- When the timer ticks, call the function main
timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on -- Lua code here
local oldT = getTickCount() -- resolution isn't great, but good enough
local hk = createHotkey(function()
local nowT = getTickCount()
oldT = nowT
--if is_intersect_gene(pos1, {x=2.01, y=1}, quad)
if is_intersect(pos, dir, quad)
then
printBall() print(dir)
else
print("Not intersecting")
end
--print("False Ball: " .. ballx .. ", " .. bally)
end, VK_E)
-- if you don't want to affect all other hotkeys, just change this hotkey:
--hk.DelayBetweenActivate = 1
|
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Fri Feb 10, 2017 2:44 pm Post subject: |
|
|
OK so this is a pass bot, cool. SImple fix for math on 0 is to force a low value of your own. Or you can create argument's to just handle 0. However in the code u stated your resolution was low but worked. ANd depending on how loosely the game calculates a completed pass forcing a ZERO value OUT prolly hurt anything.
This is pretty cool tho.
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|