Skip to content

Commit dfeee14

Browse files
committed
Thresher no longer gets stuck on itself.
* Reigned in colvol. * Moved aim positions down the barrel except when firing. This stops it from switching targets when it decides it can shoot around corners. * Moved aim position to the centre when undeployed, just for safety. The collision volume also moves up and down. Fixes #5785. Fixes #5772.
1 parent fc180ab commit dfeee14

4 files changed

Lines changed: 54 additions & 13 deletions

File tree

Objects3d/corflak.s3o

0 Bytes
Binary file not shown.

scripts/aimPosTerraform.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ local function DoUpdate(unitID)
1414
local data = unitData[unitID]
1515
local nearbyHeight = data.baseHeight
1616
local nearbyLowHeight = data.baseHeight
17+
if not nearbyHeight then
18+
data.defaultAim[2] = data.aimOffetOverride
19+
GG.OverrideMidAndAimPos(unitID, data.defaultMid, data.defaultAim)
20+
return
21+
end
22+
1723
for i = -1, 1, 1 do
1824
for j = -1, 1, 1 do
1925
if i ~= 0 or j ~= 0 then
@@ -23,6 +29,7 @@ local function DoUpdate(unitID)
2329
end
2430
end
2531
end
32+
2633
local newAimHeight = nearbyHeight - data.baseHeight + data.cliffPeek
2734
if data.aimOffetOverride then
2835
data.defaultAim[2] = data.aimOffetOverride
@@ -74,6 +81,17 @@ function GG.Script_SetupAimPosTerraform(unitID, floatOnWater, defaultMid, defaul
7481
StartThread(UpdateAimPos, unitID)
7582
end
7683

84+
function GG.Script_SetupOffsetData(unitID, unitDefID)
85+
local ud = UnitDefs[unitDefID]
86+
local midTable = ud.model
87+
local data = {
88+
defaultAim = {midTable.midx, midTable.midy + (aimOff or 0), midTable.midz},
89+
defaultMid = {midTable.midx, midTable.midy + (midOff or 0), midTable.midz},
90+
}
91+
unitData[unitID] = data
92+
return data.defaultAim[2]
93+
end
94+
7795
function GG.Script_OffsetAimAndColVol(unitID, newAimOffetOverride, colVolOffset)
7896
unitData[unitID].aimOffetOverride = newAimOffetOverride
7997
GG.OffsetColVol(unitID, colVolOffset)

scripts/turretaaflak.lua

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ include "pieceControl.lua"
1616

1717
local stuns = {false, false, false}
1818
local disarmed = false
19+
local deployed = false
20+
local FLARE_OFFSET = -32
21+
local DEPLOY_OFFSET = 18
22+
local BASE_OFFSET = -4
23+
local BASE_AIM = 32
1924

2025
local StopTurn = GG.PieceControl.StopTurn
2126

2227
function script.Create()
28+
GG.Script_SetupOffsetData(unitID, unitDefID, 50)
2329
if not GG.Script.onWater(unitID) then
2430
Hide(floatbase)
2531
end
2632
StartThread(GG.Script.SmokeUnit, unitID, {guns})
33+
Move(flare[1], z_axis, FLARE_OFFSET)
34+
Move(flare[2], z_axis, FLARE_OFFSET)
2735
end
2836

2937
local function RestoreAfterDelay()
@@ -33,9 +41,14 @@ local function RestoreAfterDelay()
3341
Turn (a2, x_axis, 0, math.rad(60))
3442
Turn (a3, x_axis, 0, math.rad(50))
3543
Turn (a4, x_axis, 0, math.rad(10))
44+
Sleep(1500)
45+
if deployed then
46+
deployed = false
47+
GG.Script_OffsetAimAndColVol(unitID, BASE_AIM, BASE_OFFSET)
48+
end
3649
end
3750

38-
local function StunThread ()
51+
local function StunThread()
3952
Signal (SIG_AIM)
4053
SetSignalMask(SIG_AIM)
4154
disarmed = true
@@ -48,31 +61,28 @@ local function StunThread ()
4861
StopTurn (a4, x_axis)
4962
end
5063

51-
local function UnstunThread ()
64+
local function UnstunThread()
5265
disarmed = false
5366
RestoreAfterDelay()
5467
end
5568

56-
function Stunned (stun_type)
69+
function Stunned(stun_type)
5770
stuns[stun_type] = true
5871
StartThread (StunThread)
5972
end
60-
function Unstunned (stun_type)
73+
function Unstunned(stun_type)
6174
stuns[stun_type] = false
6275
if not stuns[1] and not stuns[2] and not stuns[3] then
6376
StartThread (UnstunThread)
6477
end
6578
end
6679

6780
function script.AimWeapon(num, heading, pitch)
68-
6981
Signal (SIG_AIM)
7082
SetSignalMask (SIG_AIM)
71-
7283
while disarmed do
7384
Sleep(34)
7485
end
75-
7686
local slowMult = (Spring.GetUnitRulesParam(unitID,"baseSpeedMult") or 1)
7787

7888
Turn (a1, x_axis, math.rad(-45), math.rad(200)*slowMult)
@@ -85,7 +95,10 @@ function script.AimWeapon(num, heading, pitch)
8595

8696
WaitForTurn (turret, y_axis)
8797
WaitForTurn (guns, x_axis)
88-
98+
if not deployed then
99+
deployed = true
100+
GG.Script_OffsetAimAndColVol(unitID, BASE_AIM + DEPLOY_OFFSET*0.8, BASE_OFFSET + DEPLOY_OFFSET)
101+
end
89102
StartThread(RestoreAfterDelay)
90103
return true
91104
end
@@ -94,19 +107,28 @@ function script.AimFromWeapon()
94107
return trueaim
95108
end
96109

110+
function script.BlockShot(num)
111+
Move(flare[gun_to_use], z_axis, 0)
112+
return false
113+
end
114+
97115
function script.QueryWeapon()
116+
if not deployed then
117+
return trueaim
118+
end
98119
return flare[gun_to_use]
99120
end
100121

101122
function script.FireWeapon()
102123
Move(barrel[gun_to_use], z_axis, -15)
103124
EmitSfx(flare[gun_to_use], 1024)
104125
Move(barrel[gun_to_use], z_axis, 0, 40)
126+
Move(flare[gun_to_use], z_axis, FLARE_OFFSET)
105127
gun_to_use = 3 - gun_to_use
106128
end
107129

108130
local explodables = {barrel[1], barrel[2], a2, a4, turret}
109-
function script.Killed (recentDamage, maxHealth)
131+
function script.Killed(recentDamage, maxHealth)
110132
local severity = recentDamage / maxHealth
111133
local brutal = (severity > 0.5)
112134
local effect = SFX.FALL + (brutal and (SFX.SMOKE + SFX.FIRE) or 0)

units/turretaaflak.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ return { turretaaflak = {
88
buildingGroundDecalType = [[turretaaflak_aoplane.dds]],
99
buildPic = [[turretaaflak.png]],
1010
category = [[FLOAT]],
11-
collisionVolumeOffsets = [[0 11 -4]],
12-
collisionVolumeScales = [[50 86 50]],
13-
collisionVolumeType = [[CylY]],
11+
collisionVolumeOffsets = [[0 -4 0]],
12+
collisionVolumeScales = [[50 80 50]],
13+
collisionVolumeType = [[ellipsoid]],
1414
corpse = [[DEAD]],
1515

1616
customParams = {
1717
aim_lookahead = 120,
18-
aimposoffset = [[0 16 0]],
18+
aimposoffset = [[0 12 0]],
1919
bait_level_default = 0,
20+
dynamic_colvol = [[1]],
2021
},
2122

2223
explodeAs = [[MEDIUM_BUILDINGEX]],

0 commit comments

Comments
 (0)