Skip to content

Commit

Permalink
Guardian Torso to Restore Thread
Browse files Browse the repository at this point in the history
Reduce performance hit when Guardian commander is firing
  • Loading branch information
Porkch0p committed Jan 22, 2025
1 parent 5cf87d6 commit 39c2747
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions scripts/dynassault.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ local ARM_SPEED_PITCH = math.rad(180)
local ARM_PERPENDICULAR = math.rad(90)

local RESTORE_DELAY = 2500
local resetRestoreTorso = false

--------------------------------------------------------------------------------
-- vars
Expand Down Expand Up @@ -170,20 +171,6 @@ local function RestoreLegs()
end


function script.Create()
dyncomm.Create()
Hide(rcannon_flare)
Hide(lnanoflare)

-- Turn(larm, x_axis, math.rad(30))
-- Turn(rarm, x_axis, math.rad(-10))
-- Turn(rhand, x_axis, math.rad(41))
-- Turn(lnanohand, x_axis, math.rad(36))

StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
Spring.SetUnitNanoPieces(unitID, nanoPieces)
end

function script.StartMoving()
StartThread(Walk)
end
Expand All @@ -197,14 +184,28 @@ end
--------------------------------------------------------------------------------

local function RestoreTorsoAim()
Signal(SIG_RESTORE_TORSO)
SetSignalMask(SIG_RESTORE_TORSO)
Sleep(RESTORE_DELAY)
Turn(torso, y_axis, restoreHeading, TORSO_SPEED_YAW)
end

local function RestoreTorsoAfterDelay(sleepTime)
local counter = (sleepTime or RESTORE_DELAY)
while true do
if counter > 0 then
counter = counter - 100
end
if resetRestoreTorso then
resetRestoreTorso = false
counter = RESTORE_DELAY
end
if counter <= 0 then
RestoreTorsoAim()
end
Sleep(100)
end
end

local function RestoreLaser()
StartThread(RestoreTorsoAim)
resetRestoreTorso = true
Signal(SIG_RESTORE_LASER)

This comment has been minimized.

Copy link
@Porkch0p

Porkch0p Jan 22, 2025

Author Contributor

Guardian primary weapon changes aim point after D-Gun is installed, a restore thread may require additional changes

SetSignalMask(SIG_RESTORE_LASER)
Sleep(RESTORE_DELAY)
Expand All @@ -220,7 +221,7 @@ local function RestoreLaser()
end

local function RestoreDGun()
StartThread(RestoreTorsoAim)
resetRestoreTorso = true
Signal(SIG_RESTORE_DGUN)
SetSignalMask(SIG_RESTORE_DGUN)
Sleep(RESTORE_DELAY)
Expand Down Expand Up @@ -327,6 +328,21 @@ function script.StartBuilding(heading, pitch)
SetUnitValue(COB.INBUILDSTANCE, 1)
end

function script.Create()
dyncomm.Create()
Hide(rcannon_flare)
Hide(lnanoflare)

-- Turn(larm, x_axis, math.rad(30))
-- Turn(rarm, x_axis, math.rad(-10))
-- Turn(rhand, x_axis, math.rad(41))
-- Turn(lnanohand, x_axis, math.rad(36))

StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
StartThread(RestoreTorsoAfterDelay)
Spring.SetUnitNanoPieces(unitID, nanoPieces)
end

function script.Killed(recentDamage, maxHealth)
local severity = recentDamage/maxHealth
if severity < 0.5 then
Expand Down

0 comments on commit 39c2747

Please sign in to comment.