FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Zero-K/scripts/cremcom.lua at master · ZeroK-RTS/Zero-K · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ZeroK-RTS
/
Zero-K
Public
Notifications
You must be signed in to change notification settings
Fork
251
Star
824
Code
Issues
1.2k
Pull requests
49
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Zero-K
/
scripts
/
cremcom.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
316 lines (281 loc) · 8.62 KB
Breadcrumbs
Zero-K
/
scripts
/
cremcom.lua
Copy path
File metadata and controls
316 lines (281 loc) · 8.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
include
"
constants.lua
"
----
----------------------------------------------------------------------------
--
pieces
----
----------------------------------------------------------------------------
local
base
=
piece
'
base
'
local
torso
=
piece
'
torso
'
local
uparmR
=
piece
'
upperarmr
'
local
uparmL
=
piece
'
upperarml
'
local
flareR
=
piece
'
flarer
'
local
snout
=
piece
'
snout
'
local
pelvis
=
piece
'
pelvis
'
local
flareL
=
piece
'
flarel
'
local
thighL
=
piece
'
thighl
'
local
thighR
=
piece
'
thighr
'
local
forearmL
=
piece
'
forearml
'
local
forearmR
=
piece
'
forearmr
'
local
shinR
=
piece
'
shinr
'
local
shinL
=
piece
'
shinl
'
local
shieldEmit
=
piece
'
shieldemit
'
local
smokePiece
=
{
torso
}
local
nanoPieces
=
{
snout
}
local
jets
=
{
piece
'
jet1
'
,
piece
'
jet2
'
,
piece
'
jet3
'
,
piece
'
jet4
'
}
local
flares
=
{[
0
]
=
flareL
, [
1
]
=
flareR
}
----
----------------------------------------------------------------------------
--
constants
----
----------------------------------------------------------------------------
--
Signal definitions
local
SIG_WALK
=
1
local
SIG_RESTORE
=
8
local
SIG_AIM
=
2
local
SIG_DGUN
=
4
local
TORSO_SPEED_YAW
=
math.rad
(
300
)
local
ARM_SPEED_PITCH
=
math.rad
(
180
)
local
FOREARM_SPEED_PITCH
=
math.rad
(
240
)
local
PACE
=
1.75
local
BASE_VELOCITY
=
UnitDefNames
.
cremcom1
.
speed
or
1.375
*
30
local
VELOCITY
=
UnitDefs
[
unitDefID
].
speed
or
BASE_VELOCITY
PACE
=
PACE
*
VELOCITY
/
BASE_VELOCITY
--[[
local baseHeight = UnitDefNames.armcom1.modelHeight
local height = UnitDefs[unitDefID].modelHeight
if height and baseHeight then
PACE = PACE * baseHeight/height
Spring.Echo("Stride length compensation")
end
]]
--
local
THIGH_FRONT_ANGLE
=
math.rad
(
-
50
)
local
THIGH_FRONT_SPEED
=
math.rad
(
60
)
*
PACE
local
THIGH_BACK_ANGLE
=
math.rad
(
30
)
local
THIGH_BACK_SPEED
=
math.rad
(
60
)
*
PACE
local
SHIN_FRONT_ANGLE
=
math.rad
(
45
)
local
SHIN_FRONT_SPEED
=
math.rad
(
90
)
*
PACE
local
SHIN_BACK_ANGLE
=
math.rad
(
10
)
local
SHIN_BACK_SPEED
=
math.rad
(
90
)
*
PACE
local
ARM_FRONT_ANGLE
=
math.rad
(
-
20
)
local
ARM_FRONT_SPEED
=
math.rad
(
22.5
)
*
PACE
local
ARM_BACK_ANGLE
=
math.rad
(
10
)
local
ARM_BACK_SPEED
=
math.rad
(
22.5
)
*
PACE
local
ARM_PERPENDICULAR
=
math.rad
(
90
)
local
FOREARM_FRONT_ANGLE
=
math.rad
(
-
40
)
local
FOREARM_FRONT_SPEED
=
math.rad
(
45
)
*
PACE
local
FOREARM_BACK_ANGLE
=
math.rad
(
10
)
local
FOREARM_BACK_SPEED
=
math.rad
(
45
)
*
PACE
--[[
local FOREARM_FRONT_ANGLE = math.rad(-15)
local FOREARM_FRONT_SPEED = math.rad(40) * PACE
local FOREARM_BACK_ANGLE = math.rad(-10)
local FOREARM_BACK_SPEED = math.rad(40) * PACE
]]
--
local
TORSO_ANGLE_MOTION
=
math.rad
(
10
)
local
TORSO_SPEED_MOTION
=
math.rad
(
15
)
*
PACE
local
RESTORE_DELAY
=
4000
local
rightAngle
=
math.rad
(
90
)
--[[
local doubleWep = true
local udef = UnitDefs[unitDefID]
local wepdef = udef.weapons[3].weaponDef
if WeaponDefs[wepdef].name == "noweapon" then
doubleWep = false
end
]]
----
----------------------------------------------------------------------------
--
vars
----
----------------------------------------------------------------------------
local
armsFree
,
shieldOn
=
true
,
true
local
restoreHeading
=
0
local
starBLaunchers
=
{}
local
wepTable
=
UnitDefs
[
unitDefID
].
weapons
wepTable
.
n
=
nil
for
index
,
weapon
in
pairs
(
wepTable
)
do
local
weaponDef
=
WeaponDefs
[
weapon
.
weaponDef
]
if
weaponDef
.
type
==
"
StarburstLauncher
"
then
starBLaunchers
[
index
]
=
true
end
end
----
----------------------------------------------------------------------------
--
funcs
----
----------------------------------------------------------------------------
local
function
Walk
()
Signal
(
SIG_WALK
)
SetSignalMask
(
SIG_WALK
)
while
true
do
--
left leg up, right leg back
Turn
(
thighL
,
x_axis
,
THIGH_FRONT_ANGLE
,
THIGH_FRONT_SPEED
)
Turn
(
shinL
,
x_axis
,
SHIN_FRONT_ANGLE
,
SHIN_FRONT_SPEED
)
Turn
(
thighR
,
x_axis
,
THIGH_BACK_ANGLE
,
THIGH_BACK_SPEED
)
Turn
(
shinR
,
x_axis
,
SHIN_BACK_ANGLE
,
SHIN_BACK_SPEED
)
if
armsFree
then
--
left arm back, right arm front
Turn
(
torso
,
y_axis
,
TORSO_ANGLE_MOTION
,
TORSO_SPEED_MOTION
)
Turn
(
uparmL
,
x_axis
,
ARM_BACK_ANGLE
,
ARM_BACK_SPEED
)
Turn
(
uparmR
,
x_axis
,
ARM_FRONT_ANGLE
,
ARM_FRONT_SPEED
)
Turn
(
forearmL
,
x_axis
,
FOREARM_BACK_ANGLE
,
FOREARM_BACK_SPEED
)
Turn
(
forearmR
,
x_axis
,
FOREARM_FRONT_ANGLE
,
FOREARM_FRONT_SPEED
)
end
WaitForTurn
(
thighL
,
x_axis
)
Sleep
(
0
)
--
right leg up, left leg back
Turn
(
thighL
,
x_axis
,
THIGH_BACK_ANGLE
,
THIGH_BACK_SPEED
)
Turn
(
shinL
,
x_axis
,
SHIN_BACK_ANGLE
,
SHIN_BACK_SPEED
)
Turn
(
thighR
,
x_axis
,
THIGH_FRONT_ANGLE
,
THIGH_FRONT_SPEED
)
Turn
(
shinR
,
x_axis
,
SHIN_FRONT_ANGLE
,
SHIN_FRONT_SPEED
)
if
armsFree
then
--
left arm front, right arm back
Turn
(
torso
,
y_axis
,
-
TORSO_ANGLE_MOTION
,
TORSO_SPEED_MOTION
)
Turn
(
uparmL
,
x_axis
,
ARM_FRONT_ANGLE
,
ARM_FRONT_SPEED
)
Turn
(
uparmR
,
x_axis
,
ARM_BACK_ANGLE
,
ARM_BACK_SPEED
)
Turn
(
forearmL
,
x_axis
,
FOREARM_FRONT_ANGLE
,
FOREARM_FRONT_SPEED
)
Turn
(
forearmR
,
x_axis
,
FOREARM_BACK_ANGLE
,
FOREARM_BACK_SPEED
)
end
WaitForTurn
(
thighR
,
x_axis
)
Sleep
(
0
)
end
end
local
function
RestorePose
()
Signal
(
SIG_WALK
)
SetSignalMask
(
SIG_WALK
)
Move
(
pelvis
,
y_axis
,
0
,
1
)
Turn
(
thighR
,
x_axis
,
0
,
math.rad
(
200
))
Turn
(
shinR
,
x_axis
,
0
,
math.rad
(
200
))
Turn
(
thighL
,
x_axis
,
0
,
math.rad
(
200
))
Turn
(
shinL
,
x_axis
,
0
,
math.rad
(
200
))
Turn
(
uparmL
,
x_axis
,
0
,
math.rad
(
120
))
Turn
(
uparmR
,
x_axis
,
0
,
math.rad
(
120
))
end
function
script
.
Create
()
Move
(
flareL
,
y_axis
,
-
2
)
Move
(
flareR
,
y_axis
,
-
2
)
Turn
(
flareL
,
x_axis
,
rightAngle
)
Turn
(
flareR
,
x_axis
,
rightAngle
)
StartThread
(
GG
.
Script
.
SmokeUnit
,
unitID
,
smokePiece
)
Spring
.
SetUnitNanoPieces
(
unitID
,
nanoPieces
)
end
function
script
.
StartMoving
()
StartThread
(
Walk
)
end
function
script
.
StopMoving
()
StartThread
(
RestorePose
)
end
function
beginJump
()
script
.
StopMoving
()
GG
.
PokeDecloakUnit
(
unitID
,
unitDefID
)
end
function
jumping
()
GG
.
PokeDecloakUnit
(
unitID
,
unitDefID
)
for
i
=
1
,
4
do
EmitSfx
(
jets
[
i
],
1028
)
end
end
function
endJump
()
script
.
StopMoving
()
EmitSfx
(
base
,
1029
)
end
function
script
.
AimFromWeapon
(
num
)
return
torso
end
function
script
.
QueryWeapon
(
num
)
if
num
==
3
then
return
flareR
elseif
num
==
2
or
num
==
4
then
return
shieldEmit
end
return
flareL
end
local
function
RestoreAfterDelay
()
Signal
(
SIG_RESTORE
)
SetSignalMask
(
SIG_RESTORE
)
Sleep
(
RESTORE_DELAY
)
Turn
(
uparmL
,
x_axis
,
0
,
ARM_SPEED_PITCH
/
2
)
Turn
(
uparmR
,
x_axis
,
0
,
ARM_SPEED_PITCH
/
2
)
Turn
(
forearmL
,
x_axis
,
0
,
FOREARM_SPEED_PITCH
/
2
)
Turn
(
forearmR
,
x_axis
,
0
,
FOREARM_SPEED_PITCH
/
2
)
Turn
(
torso
,
y_axis
,
restoreHeading
,
TORSO_SPEED_YAW
/
2
)
WaitForTurn
(
torso
,
y_axis
)
armsFree
=
true
end
function
script
.
AimWeapon
(
num
,
heading
,
pitch
)
if
starBLaunchers
[
num
]
then
pitch
=
ARM_PERPENDICULAR
end
if
num
>=
5
then
Signal
(
SIG_AIM
)
SetSignalMask
(
SIG_AIM
)
armsFree
=
false
Turn
(
torso
,
y_axis
,
heading
,
TORSO_SPEED_YAW
)
Turn
(
uparmL
,
x_axis
,
-
pitch
,
ARM_SPEED_PITCH
)
Turn
(
forearmL
,
x_axis
,
-
rightAngle
,
FOREARM_SPEED_PITCH
)
WaitForTurn
(
torso
,
y_axis
)
WaitForTurn
(
uparmL
,
x_axis
)
StartThread
(
RestoreAfterDelay
)
return
true
elseif
num
==
3
then
Signal
(
SIG_DGUN
)
SetSignalMask
(
SIG_DGUN
)
armsFree
=
false
Turn
(
torso
,
y_axis
,
heading
,
TORSO_SPEED_YAW
)
Turn
(
uparmR
,
x_axis
,
-
pitch
,
ARM_SPEED_PITCH
)
Turn
(
forearmR
,
x_axis
,
-
rightAngle
,
FOREARM_SPEED_PITCH
)
WaitForTurn
(
torso
,
y_axis
)
WaitForTurn
(
uparmR
,
x_axis
)
WaitForTurn
(
forearmR
,
x_axis
)
StartThread
(
RestoreAfterDelay
)
return
true
elseif
num
==
2
or
num
==
4
then
Sleep
(
100
)
return
(
shieldOn
)
end
return
false
end
function
script
.
Shot
(
num
)
if
num
==
5
then
EmitSfx
(
flareL
,
1025
)
elseif
num
==
3
then
EmitSfx
(
flareR
,
1027
)
end
end
function
script
.
FireWeapon
(
num
)
if
num
==
5
then
EmitSfx
(
flareL
,
1024
)
elseif
num
==
3
then
EmitSfx
(
flareR
,
1026
)
end
end
function
script
.
StopBuilding
()
SetUnitValue
(
COB
.
INBUILDSTANCE
,
0
)
restoreHeading
=
0
StartThread
(
RestoreAfterDelay
)
end
function
script
.
StartBuilding
(
heading
,
pitch
)
restoreHeading
=
heading
Turn
(
torso
,
y_axis
,
heading
,
ARM_SPEED_PITCH
)
SetUnitValue
(
COB
.
INBUILDSTANCE
,
1
)
end
function
script
.
Killed
(
recentDamage
,
maxHealth
)
local
severity
=
recentDamage
/
maxHealth
if
severity
<
0.5
then
Explode
(
torso
,
SFX
.
NONE
)
Explode
(
uparmL
,
SFX
.
NONE
)
Explode
(
uparmR
,
SFX
.
NONE
)
Explode
(
pelvis
,
SFX
.
NONE
)
Explode
(
thighL
,
SFX
.
NONE
)
Explode
(
thighR
,
SFX
.
NONE
)
Explode
(
forearmL
,
SFX
.
NONE
)
Explode
(
forearmR
,
SFX
.
NONE
)
Explode
(
shinR
,
SFX
.
NONE
)
Explode
(
shinL
,
SFX
.
NONE
)
return
1
else
Explode
(
torso
,
SFX
.
SHATTER
)
Explode
(
uparmL
,
SFX
.
SMOKE
+
SFX
.
FIRE
+
SFX
.
EXPLODE
)
Explode
(
uparmR
,
SFX
.
SMOKE
+
SFX
.
FIRE
+
SFX
.
EXPLODE
)
Explode
(
pelvis
,
SFX
.
SHATTER
)
Explode
(
thighL
,
SFX
.
SHATTER
)
Explode
(
thighR
,
SFX
.
SHATTER
)
Explode
(
forearmL
,
SFX
.
SMOKE
+
SFX
.
FIRE
+
SFX
.
EXPLODE
)
Explode
(
forearmR
,
SFX
.
SMOKE
+
SFX
.
FIRE
+
SFX
.
EXPLODE
)
Explode
(
shinR
,
SFX
.
SHATTER
)
Explode
(
shinL
,
SFX
.
SHATTER
)
return
2
end
end
Back
|
FazBrowse Home
|
New Git URL