-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathshipassault.lua
More file actions
159 lines (141 loc) · 3.93 KB
/
Copy pathshipassault.lua
File metadata and controls
159 lines (141 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
include "constants.lua"
local base, turret, sleeves = piece("base", "turret", "sleeves")
local wake1, wake2, wake3, wake4 = piece("wake1", "wake2", "wake3", "wake4")
local barrel1, barrel2, flare1, flare2 = piece("barrel1", "barrel2", "flare1", "flare2")
local gunPieces = {
[0] = {barrel = barrel1, flare = flare1},
[1] = {barrel = barrel2, flare = flare2},
}
local missiles = { piece("missile1", "missile2", "missile3", "missile4") }
local smokePiece = {base, turret}
----------------------------------------------------------
----------------------------------------------------------
local gun_1 = 0
local missileNum = 1
local SIG_MOVE = 1
local SIG_AIM = 2
local SIG_RESTORE = 4
----------------------------------------------------------
----------------------------------------------------------
local function Wake()
Signal(SIG_MOVE)
SetSignalMask(SIG_MOVE)
while true do
if not Spring.GetUnitIsCloaked(unitID) then
EmitSfx(wake1, 2)
EmitSfx(wake2, 2)
EmitSfx(wake3, 2)
EmitSfx(wake4, 2)
end
Sleep(200)
end
end
function script.StartMoving()
StartThread(Wake)
end
function script.StopMoving()
Signal(SIG_MOVE)
end
function script.Create()
StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
for i = 1, #missiles do
Turn(missiles[i], x_axis, math.rad(-90))
end
Move(flare1, z_axis, -8)
Move(flare2, z_axis, -8)
end
function script.QueryWeapon(num)
if num == 1 then
return gunPieces[gun_1].flare
else
return missiles[missileNum]
end
end
function script.AimFromWeapon(num)
if num == 1 then
return turret
end
return missiles[missileNum]
end
function script.BlockShot(num, targetID)
if num == 2 and GG.OverkillPrevention_CheckBlock(unitID, targetID, 400.1, 90, false, false, true) then
return true
end
if num == 2 then
local reloadState = Spring.GetUnitWeaponState(unitID, 3, 'reloadState')
return not (reloadState and (reloadState < 0 or reloadState < Spring.GetGameFrame()))
end
return false
end
local function RestoreAfterDelay()
Signal(SIG_RESTORE)
SetSignalMask(SIG_RESTORE)
Sleep(6000)
Turn(turret, y_axis, 0, math.rad(120))
Turn(sleeves, x_axis, 0, math.rad(60))
end
function script.AimWeapon(num, heading, pitch)
if num == 1 then
Signal(SIG_AIM)
SetSignalMask(SIG_AIM)
Turn(turret, y_axis, heading, math.rad(270))
Turn(sleeves, x_axis, -pitch, math.rad(120))
WaitForTurn(turret, y_axis)
WaitForTurn(sleeves, x_axis)
StartThread(RestoreAfterDelay)
return true
elseif num == 2 or num == 3 then
return true
end
end
local function Recoil(piece)
Sleep(33)
Move(piece, z_axis, -8)
Sleep(400)
Move(piece, z_axis, 0, 6)
gun_1 = 1 - gun_1 --this updates the turret's aim at a resonable time
end
function script.Shot(num)
if num == 1 then
Move(gunPieces[gun_1].flare, z_axis, 5)
EmitSfx(gunPieces[gun_1].flare, 1024)
Move(gunPieces[gun_1].flare, z_axis, 0)
StartThread(Recoil, gunPieces[gun_1].barrel)
elseif num == 2 or num == 3 then
missileNum = missileNum + 1
if missileNum > 4 then missileNum = 1 end
EmitSfx(missiles[missileNum], 1025)
end
end
function script.Killed(recentDamage, maxHealth)
local severity = recentDamage / maxHealth
if (severity <= .25) then
Explode(base, SFX.NONE)
Explode(turret, SFX.NONE)
Explode(sleeves, SFX.NONE)
Explode(barrel1, SFX.FALL)
Explode(barrel2, SFX.FALL)
return 1 -- corpsetype
elseif (severity <= .5) then
Explode(base, SFX.NONE)
Explode(turret, SFX.NONE)
Explode(sleeves, SFX.SHATTER)
Explode(barrel1, SFX.SMOKE)
Explode(barrel2, SFX.SMOKE)
return 1 -- corpsetype
elseif (severity <= 1) then
Explode(base, SFX.SHATTER)
Explode(turret, SFX.SHATTER)
Explode(sleeves, SFX.SHATTER)
Explode(barrel1, SFX.SMOKE + SFX.FIRE)
Explode(barrel2, SFX.SMOKE + SFX.FIRE)
return 2 -- corpsetype
else
Explode(base, SFX.SHATTER)
Explode(turret, SFX.SHATTER)
Explode(sleeves, SFX.SHATTER)
Explode(barrel1, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
Explode(barrel2, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE)
return 2 -- corpsetype
end
end