mirror of
https://github.com/wiremod/advdupe2.git
synced 2025-03-04 03:03:05 -05:00
Fixed: Last YAW value being reset when user requests a small change (#425)
* Fixed: Last YAW value being reset when user requests a small change Fixed: Progress bar pixel-perfect aliment Fixed: Tool screen HUD use boolean state instead of a number Updated: Pitch-roll dupe control via MouseMiddle Updated: Tool screen shows P,Y,R and height Added: E+Shift+MouseMiddle resets offsets Removed: Heuristics for proper angle handling Optimized: Tool screen avoid creating color objects every frame * Added: Local variable for player and fail-save conversion values * Fixed: P/R offests relative to player's aim vector * Fixed: Sign of P/R usage according to the axis used * Removed Base world angle * Account for YAW value when calculation P/R
This commit is contained in:
parent
2618c37624
commit
8b30c2bc5e
@ -827,73 +827,63 @@ if(CLIENT)then
|
|||||||
GAMEMODE:PlayerBindPress(ply, bind, pressed)
|
GAMEMODE:PlayerBindPress(ply, bind, pressed)
|
||||||
end
|
end
|
||||||
|
|
||||||
local XTotal = 0
|
local YawTo = 0
|
||||||
local YTotal = 0
|
local BsAng = Angle()
|
||||||
local LastXDegree = 0
|
|
||||||
local function MouseControl( cmd )
|
|
||||||
local X = -cmd:GetMouseX()/-20
|
|
||||||
local Y = cmd:GetMouseY()/-20
|
|
||||||
|
|
||||||
local X2 = 0
|
local function GetRotationSign(ply)
|
||||||
local Y2 = 0
|
local VY = tonumber(ply:GetInfo("advdupe2_offset_yaw")) or 0
|
||||||
|
BsAng:Zero(); BsAng:RotateAroundAxis(BsAng:Up(), VY)
|
||||||
if(X~=0)then
|
local PR = ply:GetRight()
|
||||||
X2 = tonumber(LocalPlayer():GetInfo("advdupe2_offset_yaw"))
|
local DP = BsAng:Right():Dot(PR)
|
||||||
|
local DR = BsAng:Forward():Dot(PR)
|
||||||
if(LocalPlayer():KeyDown(IN_SPEED))then
|
if(math.abs(DR) > math.abs(DP)) then -- Roll priority
|
||||||
XTotal = XTotal + X
|
if(DR >= 0) then return -1, 1 else return 1, -1 end
|
||||||
local temp = XTotal + X2
|
else -- Pitch axis takes priority. Normal X-Y map
|
||||||
|
if(DP >= 0) then return 1, 1 else return -1, -1 end
|
||||||
local degree = math.Round(temp/45)*45
|
|
||||||
if(degree>=225)then
|
|
||||||
degree = -135
|
|
||||||
elseif(degree<=-225)then
|
|
||||||
degree = 135
|
|
||||||
end
|
|
||||||
if(degree~=LastXDegree)then
|
|
||||||
XTotal = 0
|
|
||||||
LastXDegree = degree
|
|
||||||
end
|
|
||||||
|
|
||||||
X2 = degree
|
|
||||||
else
|
|
||||||
X2 = X2 + X
|
|
||||||
if(X2<-180)then
|
|
||||||
X2 = X2+360
|
|
||||||
elseif(X2>180)then
|
|
||||||
X2 = X2-360
|
|
||||||
end
|
|
||||||
end
|
|
||||||
RunConsoleCommand("advdupe2_offset_yaw", X2)
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
/*if(Y~=0)then
|
local function MouseControl( cmd )
|
||||||
local modyaw = LocalPlayer():GetAngles().y
|
local ply = LocalPlayer()
|
||||||
local modyaw2 = tonumber(LocalPlayer():GetInfo("advdupe2_offset_yaw"))
|
local X = cmd:GetMouseX() / 20
|
||||||
|
local Y = -cmd:GetMouseY() / 20
|
||||||
|
local ru = ply:KeyDown(IN_SPEED)
|
||||||
|
local mm = input.IsMouseDown(MOUSE_MIDDLE)
|
||||||
|
|
||||||
if(modyaw<0)then modyaw = modyaw + 360 else modyaw = modyaw + 180 end
|
if(mm) then
|
||||||
if(modyaw2<0)then modyaw2 = modyaw2 + 360 else modyaw2 = modyaw2 + 180 end
|
if(ru) then
|
||||||
|
YawTo = 0 -- Reset total integrated yaw
|
||||||
modyaw = modyaw - modyaw2
|
RunConsoleCommand("advdupe2_offset_pitch", 0)
|
||||||
local modyaw3 = modyaw
|
RunConsoleCommand("advdupe2_offset_yaw" , 0)
|
||||||
if(modyaw3<0)then
|
RunConsoleCommand("advdupe2_offset_roll" , 0)
|
||||||
modyaw3 = modyaw3 * -1
|
else
|
||||||
|
if(Y ~= 0) then
|
||||||
|
local VR = tonumber(ply:GetInfo("advdupe2_offset_roll")) or 0
|
||||||
|
local VP = tonumber(ply:GetInfo("advdupe2_offset_pitch")) or 0
|
||||||
|
local SP, SR, P, R = GetRotationSign(ply)
|
||||||
|
if(SP ~= SR) then
|
||||||
|
P = math.NormalizeAngle(VP + X * SR)
|
||||||
|
R = math.NormalizeAngle(VR + Y * SP)
|
||||||
|
else
|
||||||
|
P = math.NormalizeAngle(VP + Y * SP)
|
||||||
|
R = math.NormalizeAngle(VR + X * SR)
|
||||||
|
end
|
||||||
|
RunConsoleCommand("advdupe2_offset_pitch", P)
|
||||||
|
RunConsoleCommand("advdupe2_offset_roll" , R)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
local pitch = tonumber(LocalPlayer():GetInfo("advdupe2_offset_pitch"))
|
if(X ~= 0)then
|
||||||
local roll = tonumber(LocalPlayer():GetInfo("advdupe2_offset_roll"))
|
VY = tonumber(ply:GetInfo("advdupe2_offset_yaw")) or 0
|
||||||
|
if(ru)then
|
||||||
--print(modyaw3)
|
YawTo = YawTo + X -- Integrate the mouse on the X value from the mouse
|
||||||
if(modyaw3 <= 90)then
|
RunConsoleCommand("advdupe2_offset_yaw", math.SnapTo(math.NormalizeAngle(YawTo), 45))
|
||||||
pitch = pitch + (Y - Y * (modyaw3/90))
|
else
|
||||||
roll = roll - (Y*(modyaw3/90))
|
YawTo = VY + X -- Update the last yaw with the current value from the mouse
|
||||||
|
RunConsoleCommand("advdupe2_offset_yaw", math.NormalizeAngle(YawTo))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
--if(pitch>180)then pitch = -180
|
|
||||||
|
|
||||||
RunConsoleCommand("advdupe2_offset_pitch",pitch)
|
|
||||||
RunConsoleCommand("advdupe2_offset_roll",roll)
|
|
||||||
end*/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--Checks binds to modify dupes position and angles
|
--Checks binds to modify dupes position and angles
|
||||||
@ -915,12 +905,6 @@ if(CLIENT)then
|
|||||||
hook.Remove("PlayerBindPress", "AdvDupe2_BindPress")
|
hook.Remove("PlayerBindPress", "AdvDupe2_BindPress")
|
||||||
hook.Remove("CreateMove", "AdvDupe2_MouseControl")
|
hook.Remove("CreateMove", "AdvDupe2_MouseControl")
|
||||||
end
|
end
|
||||||
|
|
||||||
XTotal = 0
|
|
||||||
YTotal = 0
|
|
||||||
LastXDegree = 0
|
|
||||||
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1564,22 +1548,25 @@ if(CLIENT)then
|
|||||||
tryToBuild()
|
tryToBuild()
|
||||||
end
|
end
|
||||||
|
|
||||||
local state = 0
|
local StColor = {r=130, g=25, b=40, a=255}
|
||||||
local ToColor = {r=25, g=100, b=40, a=255}
|
local NoColor = {r=25, g=100, b=40, a=255}
|
||||||
local CurColor = {r=25, g=100, b=40, a=255}
|
local CurColor = {r=25, g=100, b=40, a=255}
|
||||||
local rate
|
local CWhite = Color(255,255,255,255)
|
||||||
surface.CreateFont ("AD2Font", {font="Arial", size=40, weight=1000}) ---Remember to use gm_clearfonts
|
surface.CreateFont ("AD2Font", {font="Arial", size=40, weight=1000}) ---Remember to use gm_clearfonts
|
||||||
surface.CreateFont ("AD2TitleFont", {font="Arial", size=24, weight=1000})
|
surface.CreateFont ("AD2TitleFont", {font="Arial", size=24, weight=1000})
|
||||||
|
|
||||||
function TOOL:DrawToolScreen()
|
function TOOL:DrawToolScreen()
|
||||||
if(not AdvDupe2)then return true end
|
if(not AdvDupe2)then return true end
|
||||||
|
|
||||||
local text = "Ready"
|
local text = "Ready"
|
||||||
|
local state, co = false
|
||||||
|
local ply = LocalPlayer()
|
||||||
|
|
||||||
if(AdvDupe2.Preview)then
|
if(AdvDupe2.Preview)then
|
||||||
text = "Preview"
|
text = "Preview"
|
||||||
end
|
end
|
||||||
local state=0
|
|
||||||
if(AdvDupe2.ProgressBar.Text)then
|
if(AdvDupe2.ProgressBar.Text)then
|
||||||
state=1
|
state = true
|
||||||
text = AdvDupe2.ProgressBar.Text
|
text = AdvDupe2.ProgressBar.Text
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1588,30 +1575,32 @@ if(CLIENT)then
|
|||||||
surface.SetDrawColor(32, 32, 32, 255)
|
surface.SetDrawColor(32, 32, 32, 255)
|
||||||
surface.DrawRect(0, 0, 256, 256)
|
surface.DrawRect(0, 0, 256, 256)
|
||||||
|
|
||||||
if(state==0)then
|
if(state)then
|
||||||
ToColor = {r=25, g=100, b=40, a=255}
|
co = StColor
|
||||||
else
|
else
|
||||||
ToColor = {r=130, g=25, b=40, a=255}
|
co = NoColor
|
||||||
end
|
end
|
||||||
|
|
||||||
rate = FrameTime()*160
|
local rate = FrameTime() * 160
|
||||||
CurColor.r = math.Approach( CurColor.r, ToColor.r, rate )
|
CurColor.r = math.Approach( CurColor.r, co.r, rate )
|
||||||
CurColor.g = math.Approach( CurColor.g, ToColor.g, rate )
|
CurColor.g = math.Approach( CurColor.g, co.g, rate )
|
||||||
|
|
||||||
surface.SetDrawColor(CurColor)
|
surface.SetDrawColor(CurColor)
|
||||||
surface.DrawRect(13, 13, 230, 230)
|
surface.DrawRect(13, 13, 230, 230)
|
||||||
|
|
||||||
surface.SetTextColor( 255, 255, 255, 255 )
|
surface.SetTextColor( 255, 255, 255, 255 )
|
||||||
|
|
||||||
draw.SimpleText("Advanced Duplicator 2", "AD2TitleFont", 128, 50, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
|
draw.SimpleText("Advanced Duplicator 2", "AD2TitleFont", 128, 50, CWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
|
||||||
draw.SimpleText(text, "AD2Font", 128, 128, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
draw.SimpleText(text, "AD2Font", 128, 128, CWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||||
if(state~=0)then
|
if(state)then
|
||||||
draw.RoundedBox( 6, 32, 178, 192, 28, Color( 255, 255, 255, 150 ) )
|
draw.RoundedBox( 6, 32, 178, 192, 28, Color( 255, 255, 255, 150 ) )
|
||||||
draw.RoundedBox( 6, 36, 182, 188*(AdvDupe2.ProgressBar.Percent/100), 24, Color( 0, 255, 0, 255 ) )
|
draw.RoundedBox( 6, 34, 180, 188*(AdvDupe2.ProgressBar.Percent / 100), 24, Color( 0, 255, 0, 255 ) )
|
||||||
elseif(LocalPlayer():KeyDown(IN_USE))then
|
elseif(ply:KeyDown(IN_USE))then
|
||||||
draw.SimpleText("Height: "..LocalPlayer():GetInfo("advdupe2_offset_z"), "AD2TitleFont", 25, 160, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
|
local font, align = "AD2TitleFont", TEXT_ALIGN_BOTTOM
|
||||||
draw.SimpleText("Pitch: "..LocalPlayer():GetInfo("advdupe2_offset_pitch"), "AD2TitleFont", 25, 190, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
|
draw.SimpleText("H: "..ply:GetInfo("advdupe2_offset_z") , font, 20, 210, CWhite, TEXT_ALIGN_LEFT , align)
|
||||||
draw.SimpleText("Yaw: "..LocalPlayer():GetInfo("advdupe2_offset_yaw"), "AD2TitleFont", 25, 220, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
|
draw.SimpleText("P: "..ply:GetInfo("advdupe2_offset_pitch"), font, 236, 210, CWhite, TEXT_ALIGN_RIGHT, align)
|
||||||
|
draw.SimpleText("Y: "..ply:GetInfo("advdupe2_offset_yaw") , font, 20 , 240, CWhite, TEXT_ALIGN_LEFT , align)
|
||||||
|
draw.SimpleText("R: "..ply:GetInfo("advdupe2_offset_roll") , font, 236, 240, CWhite, TEXT_ALIGN_RIGHT, align)
|
||||||
end
|
end
|
||||||
|
|
||||||
cam.End2D()
|
cam.End2D()
|
||||||
|
Loading…
Reference in New Issue
Block a user