-
Автор темы
- #1
что это делает и можно ли на нл такое??
Код:
local target_angles = {0, 0} -- initialize target angles to zero
-- this function takes in an opponent's position and calculates the target angles
function calculate_target_angles(opponent_x, opponent_y, opponent_z)
local my_x, my_y, my_z = get_my_position() -- get the player's own position
local dx = opponent_x - my_x -- calculate difference in x coordinates
local dy = opponent_y - my_y -- calculate difference in y coordinates
local dz = opponent_z - my_z -- calculate difference in z coordinates
-- use atan2 function to calculate pitch and yaw angles
target_angles[1] = math.atan2(dz, math.sqrt(dx^2 + dy^2))
target_angles[2] = math.atan2(dy, dx)
end
-- this function sends the target angles to GameSense
function send_angles_to_gamesense()
local pitch_degrees = math.deg(target_angles[1])
local yaw_degrees = math.deg(target_angles[2])
gamesense.set_event_data("pitch", pitch_degrees)
gamesense.set_event_data("yaw", yaw_degrees)
gamesense.send_event("aim_angles", {pitch = pitch_degrees, yaw = yaw_degrees})
end
-- main function that gets called every frame
function main()
local opponent_x, opponent_y, opponent_z = get_opponent_position() -- get opponent's position
calculate_target_angles(opponent_x, opponent_y, opponent_z) -- calculate target angles
send_angles_to_gamesense() -- send target angles to GameSense
end