-
Notifications
You must be signed in to change notification settings - Fork 200
/
engine_compat.lua
616 lines (529 loc) · 18.6 KB
/
engine_compat.lua
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
local RET_FALSE = function() return false end
local RET_TRUE = function() return true end
local RET_NONE = function() end
local RET_TABLE = function() return {} end
local RET_ZERO = function() return 0 end
local RET_ONE = function() return 1 end
local RET_STRING = function() return "" end
if not Script then
Script = { IsEngineMinVersion = RET_FALSE }
elseif not Script.IsEngineMinVersion(1, 0, 0) then
-- For some reason IsEngineMinVersion breaks on tags where the minor is not 0 (X.1.Y-...),
-- though this can only happen for random people's forks since regular BAR & Spring build
-- systems both hardcode the minor to 0. Assume we're on bleeding edge in that case.
Script.IsEngineMinVersion = RET_TRUE
end
-- Parser envs don't have it; some are actually "synced",
-- such as modrules, but we cannot tell from here
Script.GetSynced = Script.GetSynced or RET_FALSE
if Script.IsEngineMinVersion(104, 0, 50) then
local origGetGroundInfo = Spring.GetGroundInfo
Spring.GetGroundInfo = function (x, z)
local r1, r2, r3, r4, r5, r6, r7, r8, r9 = origGetGroundInfo(x, z)
return r2, r3, r4, r5, r6, r7, r8, r9, r1
end
local origGetTerrainTypeData = Spring.GetTerrainTypeData
Spring.GetTerrainTypeData = function (index)
local r1, r2, r3, r4, r5, r6, r7, r8 = origGetTerrainTypeData(index)
return r2, r3, r4, r5, r6, r7, r8, r1
end
end
Game = Game or {} -- 104-331 for defs; still missing from some like modrules
Game.gameSpeed = Game.gameSpeed or 30 -- 104-331
if not Script.IsEngineMinVersion(104, 0, 503) then
local tableCache = {123}
local function MakeWrappedSingleParamFunc(originalFunc)
return function (unitID, cmdID, cmdParam, cmdOpts)
-- unitID can actually be a table thereof, but we don't mind
if type (cmdParam) ~= "table" then
tableCache[1] = cmdParam
return originalFunc(unitID, cmdID, tableCache, cmdOpts)
else
return originalFunc(unitID, cmdID, cmdParam, cmdOpts)
end
end
end
local function MakeWrappedArrayParamFunc(originalFunc)
return function (units, orders)
for i = 1, #orders do
local order = orders[i]
local param = order[2]
if type(param) ~= "table" then
order[2] = {param}
end
end
return originalFunc(units, orders)
end
end
local originalGiveOrder = Spring.GiveOrder
Spring.GiveOrder = function(cmdID, cmdParam, cmdOpts)
if type (cmdParam) ~= "table" then
tableCache[1] = cmdParam
return originalGiveOrder(cmdID, tableCache, cmdOpts)
else
return originalGiveOrder(cmdID, cmdParam, cmdOpts)
end
end
Spring.GiveOrderToUnit = MakeWrappedSingleParamFunc(Spring.GiveOrderToUnit )
Spring.GiveOrderToUnitMap = MakeWrappedSingleParamFunc(Spring.GiveOrderToUnitMap )
Spring.GiveOrderToUnitArray = MakeWrappedSingleParamFunc(Spring.GiveOrderToUnitArray)
Spring.GiveOrderArrayToUnitMap = MakeWrappedArrayParamFunc(Spring.GiveOrderArrayToUnitMap )
Spring.GiveOrderArrayToUnitArray = MakeWrappedArrayParamFunc(Spring.GiveOrderArrayToUnitArray)
end
if Script.IsEngineMinVersion(104, 0, 536) then
local origGetPlayerInfo = Spring.GetPlayerInfo
Spring.GetPlayerInfo = function (playerID)
if not playerID then
return
end
local r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12 = origGetPlayerInfo(playerID)
return r1, r2, r3, r4, r5, r6, r7, r8, r9, r11, r10, r12
end
end
if Game.paralyzeOnMaxHealth == nil then -- 104-585
Game.paralyzeOnMaxHealth = true
Game.paralyzeDeclineRate = 40
end
Game.speedModClasses = Game.speedModClasses or -- 104-756
{ Tank = 0
, KBot = 1
, Hover = 2
, Boat = 3
, Ship = 3
}
if not Spring.GetTidal then -- 104-804
Spring.GetTidal = function()
return Game.tidal or 0
end
if Script.GetSynced() then
Spring.SetTidal = RET_NONE
Spring.SetWind = RET_NONE
end
end
if not Spring.PreloadSoundItem then -- 104-994
Spring.PreloadSoundItem = RET_FALSE
end
if not Script.IsEngineMinVersion(104, 0, 1100) then
Script.SetWatchProjectile = Script.SetWatchWeapon
Script.SetWatchExplosion = Script.SetWatchWeapon
Script.SetWatchAllowTarget = Script.SetWatchWeapon
end
if not Script.IsEngineMinVersion(104, 0, 1143) then
local spGetCommandQueue = Spring.GetCommandQueue
local unpacc = unpack
Spring.GetUnitCurrentCommand = function (unitID, index)
index = index or 1
local queue = spGetCommandQueue(unitID, index)
if not queue then
return
end
local command = queue[index]
if not command then
return
end
return command.id, command.options.coded, command.tag, unpacc(command.params)
end
end
if Script.IsEngineMinVersion(104, 0, 1166) then
local origGetTeamInfo = Spring.GetTeamInfo
Spring.GetTeamInfo = function (p1, p2)
local r1, r2, r3, r4, r5, r6, r7, r8 = origGetTeamInfo(p1, p2)
return r1, r2, r3, r4, r5, r6, r8, r7
end
end
if not math.tau then -- 104-1421 AFAICT
math.tau = 2 * math.pi
end
if not Spring.SetUnitBuildParams and Script.GetSynced() then -- BAR 105-552
Spring.SetUnitBuildParams = RET_NONE
end
if not Spring.GetUnitBuildParams then -- BAR 105-552
Spring.GetUnitBuildParams = function(unitID, param)
local unitDef = UnitDefs[Spring.GetUnitDefID(unitID)]
if param == "buildRange3D" then
return unitDef.buildRange3D
else
return unitDef.buildDistance
end
end
end
if not Spring.GetUnitsInScreenRectangle and not Script.GetSynced() then -- BAR 105-637
Spring.GetUnitsInScreenRectangle = RET_TABLE
end
if not Spring.SetUnitNoEngineDraw then -- BAR 105-653
Spring.SetUnitNoEngineDraw = RET_NONE
Spring.SetFeatureNoEngineDraw = RET_NONE
end
if not Spring.GetUnitNoEngineDraw and not Script.GetSynced() then -- BAR 105-653
Spring.GetUnitNoEngineDraw = RET_FALSE
Spring.GetFeatureNoEngineDraw = RET_FALSE
end
if not Spring.GetUnitInBuildStance then -- BAR 105-665
Spring.GetUnitInBuildStance = RET_FALSE
end
if not Spring.ForceTesselationUpdate then -- BAR 105-710
--[[ This is just here so gadget code can avoid
a nil check. The workaround was to apply
ground detail changes to force an update,
but that requires a timed delay (since else
the change isn't noticed) which I am not
going to reimplement here. ]]
Spring.ForceTesselationUpdate = RET_FALSE
end
if not Spring.SetWindowGeometry then -- BAR 105-733
Spring.SetWindowGeometry = RET_NONE
end
if not Spring.UnitIconGetDraw and not Script.GetSynced() then -- BAR 105-800
Spring.UnitIconGetDraw = RET_FALSE
end
if not Spring.UnitIconSetDraw then -- BAR 105-800
Spring.UnitIconSetDraw = RET_NONE
end
if not Spring.GetTimerMicros and not Script.GetSynced() then -- BAR 105-916
Spring.GetTimerMicros = RET_ZERO
end
if not Spring.LevelOriginalHeightMap and Script.GetSynced() then -- BAR 105-946
-- NB: no Get here
Spring.LevelOriginalHeightMap = RET_NONE
Spring.AdjustOriginalHeightMap = RET_NONE
Spring.RevertOriginalHeightMap = RET_NONE
Spring.AddOriginalHeightMap = RET_ZERO
Spring.SetOriginalHeightMap = RET_ZERO
Spring.SetOriginalHeightMapFunc = RET_ZERO
end
if not Spring.AddUnitExperience and Script.GetSynced() then -- BAR 105-961
local spGetUnitExperience = Spring.GetUnitExperience
local spSetUnitExperience = Spring.SetUnitExperience
Spring.AddUnitExperience = function (unitID, deltaXP)
spSetUnitExperience(unitID, spGetUnitExperience(unitID) + deltaXP)
end
end
if not Spring.SetBoxSelectionByEngine then -- BAR 105-980
Spring.SetBoxSelectionByEngine = RET_NONE
Spring.GetBoxSelectionByEngine = RET_FALSE
end
if not Spring.SetFactoryBuggerOff and Script.GetSynced() then -- BAR 105-1029
Spring.SetFactoryBuggerOff = RET_FALSE
end
if not Spring.BuggerOff and Script.GetSynced() then -- BAR 105-1029
Spring.BuggerOff = RET_NONE
end
if not Spring.GetFactoryBuggerOff then -- BAR 105-1029
Spring.GetFactoryBuggerOff = function()
return false, 0, 1, 0, false, false, false
end
end
if not Spring.GetSyncedGCInfo and not Script.GetSynced() then -- BAR 105-1131
Spring.GetSyncedGCInfo = RET_ZERO
end
if not Spring.GetKeyFromScanSymbol and not Script.GetSynced() then -- BAR 105-1169
Spring.GetKeyFromScanSymbol = RET_STRING
end
if not Spring.GetSelectionBox and not Script.GetSynced() then -- BAR 105-1193
Spring.GetSelectionBox = RET_NONE
end
if not Spring.GetPressedScans and not Script.GetSynced() then -- BAR 105-1199
Spring.GetPressedScans = RET_TABLE
end
if not Spring.GetCameraRotation and not Script.GetSynced() then -- BAR 105-1242
local spGetCameraDirection = Spring.GetCameraDirection
local acos = math.acos
local atan2 = math.atan2
local sqrt = math.sqrt
Spring.GetCameraRotation = function()
local x, y, z = spGetCameraDirection()
local len = sqrt(x^2 + y^2 + z^2)
return acos(y / len), atan2(x / len, -z / len), 0
end
end
if not Spring.GetMiniMapRotation and not Script.GetSynced() then -- BAR 105-1242
Spring.GetMiniMapRotation = RET_ZERO
end
if not Spring.LoadModelTextures then -- BAR 105-1244
Spring.LoadModelTextures = RET_FALSE
end
if not Spring.SetWindowMinimized then -- BAR 105-1245
Spring.SetWindowMinimized = RET_FALSE
Spring.SetWindowMaximized = RET_FALSE
end
if not Spring.GetTeamAllyTeamID then -- BAR 105-1300
Spring.GetTeamAllyTeamID = function(teamID)
local _, _, _, allyTeamID = Spring.GetTeamInfo(teamID)
return allyTeamID
end
end
if not Spring.GetProjectileAllyTeamID then -- BAR 105-1300
Spring.GetProjectileAllyTeamID = function(proID)
return Spring.GetTeamAllyTeamID(Spring.GetProjectileTeamID(proID))
end
end
if not Spring.GiveOrderArrayToUnit then -- BAR 105-1492
local spGiveOrderArrayToUnitArray = Spring.GiveOrderArrayToUnitArray
local staticTable = {123}
Spring.GiveOrderArrayToUnit = function (unitID, orderArray)
staticTable[1] = unitID
return spGiveOrderArrayToUnitArray(staticTable, orderArray)
end
end
Game.metalMapSquareSize = Game.metalMapSquareSize or 16 -- BAR 105-1505
if not Spring.SetUnitHeadingAndUpDir and Script.GetSynced() then -- BAR 105-1611
Spring.SetUnitHeadingAndUpDir = RET_NONE
Spring.SetFeatureHeadingAndUpDir = RET_NONE
end
if not Script.GetSynced() and not Script.IsEngineMinVersion(105, 0, 1621) then
local originalGetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted
Spring.GetSelectedUnitsSorted = function()
local units = originalGetSelectedUnitsSorted()
local n = units.n
units.n = nil
return units, n
end
local originalGetSelectedUnitsCounts = Spring.GetSelectedUnitsCounts
Spring.GetSelectedUnitsCounts = function()
local units = originalGetSelectedUnitsCounts()
local n = units.n
units.n = nil
return units, n
end
end
if not Spring.GetFeaturesInScreenRectangle and not Script.GetSynced() then -- BAR 105-1649
Spring.GetFeaturesInScreenRectangle = RET_TABLE
end
if Script.GetSynced() and not Script.IsEngineMinVersion(105, 0, 1706) then
local inTransfer = false
local originalTransferUnit = Spring.TransferUnit
Spring.TransferUnit = function(unitID, teamID, captured)
if inTransfer then
return
end
inTransfer = true
originalTransferUnit(unitID, teamID, captured)
inTransfer = false
end
end
if not Script.IsEngineMinVersion(105, 0, 1719) then
local originalSetActiveCommand = Spring.SetActiveCommand
Spring.SetActiveCommand = function(...)
if not select(1, ...) then
return originalSetActiveCommand(-1)
else
return originalSetActiveCommand(...)
end
end
end
Game.footprintScale = Game.footprintScale or 2 -- BAR 105-1725
Game.buildSquareSize = Game.buildSquareSize or 16 -- BAR 105-1725
if not Script.IsEngineMinVersion(105, 0, 1776) then
local originalSetSunDirection = Spring.SetSunDirection
Spring.SetSunDirection = function (x, y, z, a)
local n = math.diag(x, y, z)
return originalSetSunDirection(x / n, y / n, z / n, a)
end
end
if not Spring.SetUnitSeismicSignature and Script.GetSynced() then -- BAR 105-1777
Spring.SetUnitSeismicSignature = RET_NONE
end
if not Spring.GetUnitSeismicSignature then -- BAR 105-1777
Spring.GetUnitSeismicSignature = RET_ZERO
end
if not Spring.SelectUnit then -- BAR 105-1790
local spSelectUnitArray = Spring.SelectUnitArray
Spring.SelectUnit = function (unitID, append)
return spSelectUnitArray({unitID}, append)
end
local spGetSelectedUnits = Spring.GetSelectedUnits
Spring.DeselectUnit = Script.GetSynced() and RET_NONE or function (unitID)
local selected = spGetSelectedUnits()
for i = 1, #selected do
if selected[i] == unitID then
selected[i] = selected[#selected]
selected[#selected] = nil
spSelectUnitArray(selected)
return
end
end
end
end
if not Spring.GetUnitWorkerTask then -- BAR 105-1793
local spGetUnitCurrentCommand = Spring.GetUnitCurrentCommand
Spring.GetUnitWorkerTask = function(unitID)
local cmdID, _, _, targetID = spGetUnitCurrentCommand(unitID)
return cmdID, targetID
end
end
if not Spring.SetUnitShieldRechargeDelay and Script.GetSynced() then -- BAR 105-1799
Spring.SetUnitShieldRechargeDelay = RET_NONE
end
if UnitDefs then -- BAR 105-1801
local keys = { -- old, new
"tooltip" , "description",
"wreckName" , "corpse",
"buildpicname" , "buildPic",
"canSelfD" , "canSelfDestruct",
"selfDCountdown", "selfDestructCountdown",
"losRadius" , "sightDistance",
"losHeight" , "sightEmitHeight",
"airLosRadius" , "airSightDistance",
"radarRadius" , "radarDistance",
"jammerRadius" , "radarDistanceJam",
"sonarRadius" , "sonarDistance",
"sonarJamRadius", "sonarDistanceJam",
"seismicRadius" , "seismicDistance",
"kamikazeDist" , "kamikazeDistance",
"targfac" , "isTargetingUpgrade",
"wantedHeight" , "cruiseAltitude",
}
for _, unitDef in pairs (UnitDefs) do
for i = 1, #keys, 2 do
local oldKey = keys[i]
local newKey = keys[i+1]
-- Spring recoils in horror if you try to assign existing
-- keys, so it MUST be done under a nil check (also remember
-- that some are bools so it can't be just "if not x")
if unitDef[newKey] == nil then
unitDef[newKey] = unitDef[oldKey]
end
end
if unitDef.radarEmitHeight == nil then
unitDef.radarEmitHeight = unitDef.sightEmitHeight or 20
end
end
end
if not Spring.GetUnitIsBeingBuilt then -- BAR 105-1806
local spGetUnitHealth = Spring.GetUnitHealth
local spGetUnitIsStunned = Spring.GetUnitIsStunned
Spring.GetUnitIsBeingBuilt = function(unitID)
local _, _, inBuild = spGetUnitIsStunned(unitID)
local _, _, _, _, buildProgress = spGetUnitHealth(unitID)
return inBuild, buildProgress
end
end
if not Spring.GetPlayerRulesParam then -- BAR 105-1823
local spGetGameRulesParam = Spring.GetGameRulesParam
Spring.GetPlayerRulesParam = function (playerID, key)
return spGetGameRulesParam("playerRulesParam_" .. playerID .. "_" .. key)
end
Spring.GetPlayerRulesParams = RET_TABLE
-- Set technically added in BAR 105-1803, but useless without the matching Get
if Script.GetSynced() then
local spSetGameRulesParam = Spring.SetGameRulesParam
Spring.SetPlayerRulesParam = function (playerID, key, value)
return spSetGameRulesParam("playerRulesParam_" .. playerID .. "_" .. key, value)
end
end
end
if not Script.IsEngineMinVersion(105, 0, 1873) then
local vfsDirList = VFS.DirList
local vfsSubDirs = VFS.SubDirs
local function recursiveSearch(results, dir, pattern, modes)
local files = vfsDirList(dir, pattern, modes)
for i = 1, #files do
results[#results + 1] = files[i]
end
local subfolders = vfsSubDirs(dir, "*", modes)
for i = 1, #subfolders do
recursiveSearch(results, subfolders[i], pattern, modes)
end
end
VFS.DirList = function(dir, pattern, modes, recursive)
if not recursive then
return vfsDirList(dir, pattern, modes)
else
local results = {}
recursiveSearch(results, dir, pattern, modes)
return results
end
end
end
if not Spring.GetUnitEffectiveBuildRange then -- BAR 105-1882
local spGetUnitBuildParams = Spring.GetUnitBuildParams
Spring.GetUnitEffectiveBuildRange = function(unitID, unitDefID)
-- don't add the unitDefID radius, that's how it worked back then
return spGetUnitBuildParams(unitID, "buildRange")
end
end
if not Script.IsEngineMinVersion(105, 0, 1900) then
local originalGetUnitEffectiveBuildRange = Spring.GetUnitEffectiveBuildRange
local spGetUnitBuildParams = Spring.GetUnitBuildParams
Spring.GetUnitEffectiveBuildRange = function(unitID, unitDefID)
if not unitDefID then
return spGetUnitBuildParams(unitID, "buildRange")
else
return originalGetUnitEffectiveBuildRange(unitID, unitDefID)
end
end
end
if not Spring.GetFacingFromHeading then -- BAR 105-1921
Spring.GetFacingFromHeading = function (heading)
return math.floor((heading / 16384 + 0.5) % 4)
end
Spring.GetHeadingFromFacing = function (facing)
return facing == 1 and 16384
or facing == 2 and 32767
or facing == 3 and -16384
or 0
end
end
if not Spring.GetModelRootPiece then -- BAR 105-1924
Spring.GetModelRootPiece = RET_ONE
Spring.GetUnitRootPiece = RET_ONE
Spring.GetFeatureRootPiece = RET_ONE
end
if not Spring.DeselectUnitArray then -- BAR 105-1976
Spring.DeselectUnitArray = function(units)
for _, unitID in pairs(units) do
Spring.DeselectUnit(unitID)
end
end
end
if not Spring.DeselectUnitMap then -- BAR 105-1976
Spring.DeselectUnitMap = function(units)
for unitID in pairs(units) do
Spring.DeselectUnit(unitID)
end
end
end
Game.textColorCodes = Game.textColorCodes or -- BAR 105-1983
{ Color = '\255'
, ColorAndOutline = '\254'
, Reset = '\008'
}
if GL then -- BAR 105-1988
GL.FUNC_ADD = GL.FUNC_ADD or 32774
GL.FUNC_SUBTRACT = GL.FUNC_SUBTRACT or 32778
GL.FUNC_REVERSE_SUBTRACT = GL.FUNC_REVERSE_SUBTRACT or 32779
GL.MIN = GL.MIN or 32775
GL.MAX = GL.MAX or 32776
end
if not Spring.IsPosInMap then -- BAR 105-1989
Spring.IsPosInMap = function (x, z)
local inMap = x >= 0 and z >= 0 and x <= Game.mapSizeX and z <= Game.mapSizeZ
local inPlayableArea = inMap
return inPlayableArea, inMap
end
end
if not Script.IsEngineMinVersion(105, 0, 2182) then
Spring.SetUnitBuildeeRadius = Script.GetSynced() and RET_NONE
Spring.GetUnitBuildeeRadius = Spring.GetUnitRadius
if UnitDefs then
for _, unitDef in pairs (UnitDefs) do
unitDef.buildeeBuildRadius = 64 -- arbitrary
end
end
end
if not Script.IsEngineMinVersion(105, 0, 2346) and not Script.GetSynced() then
local spGetGameFrame = Spring.GetGameFrame
local spGetFrameTimeOffset = Spring.GetFrameTimeOffset
local gameSpeed = Game.gameSpeed
Spring.GetGameSecondsInterpolated = function()
return (spGetFrameTimeOffset() + spGetGameFrame()) / gameSpeed
end
end
if true then -- No engine has this yet
local origAddUnitDamage = Spring.AddUnitDamage
function Spring.AddUnitDamageByTeam(unitID, damage, paralyze, attackerID, weaponID, teamID)
gadgetHandler.GG._AddUnitDamage_teamID = teamID
origAddUnitDamage(unitID, damage, paralyze, attackerID, weaponID)
gadgetHandler.GG._AddUnitDamage_teamID = nil -- TODO: deal with recursion by saving old value. But this needs testing.
end
end