-
Notifications
You must be signed in to change notification settings - Fork 200
/
dbg_dev_commands.lua
967 lines (884 loc) · 25.3 KB
/
dbg_dev_commands.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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
function gadget:GetInfo()
return {
name = "Dev Commands",
desc = "Adds useful commands.",
author = "Google Frog",
date = "12 Sep 2011",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true, -- loaded by default?
handler = true,
}
end
local syncedGadgetList = {
"Ceasefires2",
"Perks",
"UnitMorph",
"DroppedStartPos",
"Dont fire at radar",
"Disable Buildoptions",
"Teleporter",
"Grey Goo",
"No Self-D",
"Attributes",
"Fall Damage",
"Transport Speed",
"MarketPlace",
"Refuel Pad Handler",
"Windmill Control",
"Weapon Timed Replace",
"Mod statistics",
"Unit Explosion Spawner",
"astar.lua",
"Tactical Unit AI",
"Repair Speed Changer",
"Terrain Texture Handler",
"Spherical LOS",
"Target Priority",
"TransportAIbuttons",
--"Dev Commands",
"ranks api",
"Nano Frame Death Handeling",
"Terraformers",
"Mex Placement",
"AutoReadyStartpos",
"Lups Cloak FX",
"Test",
"api_subdir_gadgets.lua",
"NoAirNuke",
"Lag Monitor",
"Animator",
"Control gunship strafe range",
"Awards",
"Carrier Drones",
"Bounties",
"Aircraft Command",
"Boolean Disable",
"DoLine",
"Instant Self Destruct",
"Missile Silo Controller",
"Factory Anti Slacker",
"Time slow v2",
"Gunship Strafe Control",
"Aircraft Crashing",
"Game Over",
"UnitStealth",
"Noexplode Stopper",
"Puppy Handler",
"Blocking Tag Implementation",
"Area Denial",
"Water Effects",
"UnitPriority",
"Rezz Hp changer + effect",
"Units on fire",
"Metalspot Finder Gadget",
"Allow Builder Hold Fire",
"Target on the move",
"Unit E-Stall Disable",
"Stockpile",
"Impulse Float Toggle",
"Retreat Command",
"LUS",
--"Profiler",
"Decloak when damaged",
"ShareControl",
"Center Offset",
"Shield Link",
"Set Nano Piece",
"Self destruct blocker",
"LockOptions",
"AirTransport_SeaPickup",
"Area Guard",
"Reclaim HP changer",
"Weapon Impulse ",
"Bomber Dive",
"Solar Force Closed",
"Vertical Swarm",
"Prevent Lab Hax",
"lups_wrapper.lua",
"Jumpjets",
"One Click Weapon",
"Paralysis",
"Thrusters",
"No Friendly Fire",
"AirPlantParents",
"UnitCloakShield",
"StartSetup",
"Save/Load",
"Mex Control with energy link",
"Capture",
"Single-Hit Weapon",
"IconGenerator",
"Orbital Drop",
"D-Gun Aim Fix",
"lavarise",
"Resign Gadget",
"CMD_RAW_MOVE",
"CEG Spawner",
"LupsNanoSpray",
"CustomUnitShaders",
"Hide Autorepairlevel Command",
}
local unsyncedGadgetList = {
"Ceasefires2",
"LockOptions",
"Awards",
"Noexplode Stopper",
"Perks",
"Control gunship strafe range",
"Area Denial",
"Bounties",
"Aircraft Command",
"DoLine",
"CAI",
"Lups",
"Dont fire at radar",
"Teleporter",
"Rezz Hp changer + effect",
"Factory Anti Slacker",
"Bomber Dive",
"Attributes",
"Thrusters",
"Planet Wars Structures",
"Fall Damage",
"DroppedStartPos",
"BOXXY R1 w volume type",
"Transport Speed",
"Aircraft Crashing",
"Game Over",
"Terraformers",
"UnitStealth",
"Windmill Control",
"Target on the move",
"Spherical LOS",
"Chicken Spawner",
"Animator",
"Shield Link",
"Self destruct blocker",
"Units on fire",
"Metalspot Finder Gadget",
"Allow Builder Hold Fire",
"UnitPriority",
"Prevent Lab Hax",
"One Click Weapon",
"Impulse Float Toggle",
"Old Jugglenaut Juggle",
"Retreat Command",
"Unit Explosion Spawner",
"UnitMorph",
"Chicken control",
"ShareControl",
"Area Guard",
"astar.lua",
"unit_missilesilo.lua",
"MarketPlace",
"IconGenerator",
"AirTransport_SeaPickup",
"lavarise",
"Unit E-Stall Disable",
"Disable Features",
"Weapon Impulse ",
"Water Effects",
"Resign Gadget",
"Solar Force Closed",
"Center Offset",
"Target Priority",
"Capture",
"TransportAIbuttons",
--"Dev Commands",
"unit_carrier_drones.lua",
"Lag Monitor",
"AirPlantParents",
"ranks api",
"UnitCloakShield",
"StartSetup",
"Save/Load",
"Mex Control with energy link",
"LupsNanoSpray",
"Mex Placement",
"Single-Hit Weapon",
"CMD_RAW_MOVE",
"Zombies!",
"CustomUnitShaders",
"Lups Cloak FX",
"Test",
"Hide Autorepairlevel Command",
"CEG Spawner",
"api_subdir_gadgets.lua",
}
local gadgetList = {
"Ceasefires2",
"Perks",
"UnitMorph",
"DroppedStartPos",
"Dont fire at radar",
"Disable Buildoptions",
"Teleporter",
"Grey Goo",
"No Self-D",
"Attributes",
"Fall Damage",
"Transport Speed",
"MarketPlace",
"Refuel Pad Handler",
"Windmill Control",
"Weapon Timed Replace",
"Mod statistics",
"Unit Explosion Spawner",
"astar.lua",
"Tactical Unit AI",
"Repair Speed Changer",
"Terrain Texture Handler",
"Spherical LOS",
"Target Priority",
"TransportAIbuttons",
"ranks api",
"Nano Frame Death Handeling",
"Terraformers",
"Mex Placement",
"AutoReadyStartpos",
"Lups Cloak FX",
"Test",
"api_subdir_gadgets.lua",
"NoAirNuke",
"Lag Monitor",
"Animator",
"Control gunship strafe range",
"Awards",
"Carrier Drones",
"Bounties",
"Aircraft Command",
"Boolean Disable",
"DoLine",
"Instant Self Destruct",
"Missile Silo Controller",
"Factory Anti Slacker",
"Time slow v2",
"Gunship Strafe Control",
"Aircraft Crashing",
"Game Over",
"UnitStealth",
"Noexplode Stopper",
"Puppy Handler",
"Blocking Tag Implementation",
"Area Denial",
"Water Effects",
"UnitPriority",
"Rezz Hp changer + effect",
"Units on fire",
"Metalspot Finder Gadget",
"Allow Builder Hold Fire",
"Target on the move",
"Unit E-Stall Disable",
"Stockpile",
"Impulse Float Toggle",
"Retreat Command",
"LUS",
"Decloak when damaged",
"ShareControl",
"Center Offset",
"Shield Link",
"Set Nano Piece",
"Self destruct blocker",
"LockOptions",
"AirTransport_SeaPickup",
"Area Guard",
"Reclaim HP changer",
"Weapon Impulse ",
"Bomber Dive",
"Solar Force Closed",
"Vertical Swarm",
"Prevent Lab Hax",
"lups_wrapper.lua",
"Jumpjets",
"One Click Weapon",
"Paralysis",
"Thrusters",
"No Friendly Fire",
"AirPlantParents",
"UnitCloakShield",
"StartSetup",
"Save/Load",
"Mex Control with energy link",
"Capture",
"Single-Hit Weapon",
"IconGenerator",
"Orbital Drop",
"D-Gun Aim Fix",
"lavarise",
"Resign Gadget",
"CMD_RAW_MOVE",
"CEG Spawner",
"LupsNanoSpray",
--"CustomUnitShaders",
"Hide Autorepairlevel Command",
"CAI",
"Lups",
"Planet Wars Structures",
"BOXXY R1 w volume type",
"Chicken Spawner",
"Old Jugglenaut Juggle",
"Chicken control",
"unit_missilesilo.lua",
"Disable Features",
"unit_carrier_drones.lua",
"Zombies!",
}
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
local spIsCheatingEnabled = Spring.IsCheatingEnabled
local creationUnitList, creationIndex
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
if (gadgetHandler:IsSyncedCode()) then
-- '/luarules circle'
-- '/luarules give'
-- '/luarules gk'
-- '/luarules clear'
-- '/luarules restart'
local ORDERS_PASSIVE = {
{
CMD.FIRE_STATE,
0,
0,
},
{
CMD.MOVE_STATE,
0,
0,
},
}
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-- UnitName TeamID Number Radius [Xpos Zpos]
-- For example '/luarules circle turretlaser 1 60 420 3200 3200'
local function circleGive(cmd, line, words, player)
if not (spIsCheatingEnabled() and #words >= 4) then
return
end
local unitName = words[1]
local team = math.abs(tonumber(words[2]) or 0)
local count = math.floor(tonumber(words[3]) or 0)
local radius = math.abs(tonumber(words[4]) or 0)
local ox = tonumber(words[5]) or Game.mapSizeX/2
local oz = tonumber(words[6]) or Game.mapSizeZ/2
if not (type(unitName) == "string" and UnitDefNames[unitName] and team >= 0 and count > 0 and radius > 0) then
return
end
local unitDefID = UnitDefNames[unitName].id
local increment = 2*math.pi/count
for i = 1, count do
local angle = i*increment
local x = ox + math.cos(angle)*radius
local z = oz + math.sin(angle)*radius
local y = Spring.GetGroundHeight(x,z)
Spring.CreateUnit(unitDefID, x, y, z, 0, team, false)
end
end
local function MoveUnit(cmd, line, words, player)
if not (spIsCheatingEnabled() and #words >= 3) then
return
end
local unitID = tonumber(words[1])
local x = tonumber(words[2])
local z = tonumber(words[3])
if not (unitID and x and z) then
return
end
Spring.SetUnitPosition(unitID, x, z)
end
local function DestroyUnit(cmd, line, words, player)
if not (spIsCheatingEnabled() and #words >= 1) then
return
end
local unitID = tonumber(words[1])
if unitID then
Spring.DestroyUnit(unitID, false, true)
end
end
local function RotateUnit(cmd, line, words, player)
if not (spIsCheatingEnabled() and #words >= 2) then
return
end
local unitID = tonumber(words[1])
local facing = tonumber(words[2])
if not (unitID and facing and Spring.ValidUnitID(unitID)) or Spring.GetUnitIsDead(unitID) then
return
end
local teamID = Spring.GetUnitTeam(unitID)
local unitDefID = Spring.GetUnitDefID(unitID)
local x,y,z = Spring.GetUnitPosition(unitID)
local ud = unitDefID and UnitDefs[unitDefID]
if ud.isImmobile then
x, y, z = Spring.Pos2BuildPos(unitDefID, x, y, z, facing)
end
Spring.DestroyUnit(unitID, false, true)
Spring.CreateUnit(unitDefID, x, y, z, facing, teamID)
end
local function SetupNanoUnit(unitID, nanoAmount)
local _, maxHealth = Spring.GetUnitHealth(unitID)
Spring.SetUnitHealth(unitID, {build = nanoAmount, health = maxHealth})
end
local function give(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local nanoAmount = math.max(0.01, math.min(1, tonumber(words[1] or "1") or 1))
local build = (nanoAmount < 1)
local buildlist = UnitDefNames["armcom1"].buildOptions
local INCREMENT = 128
local orderUnit = {}
local zOffset = 0
for i = 1, #buildlist do
local udid = buildlist[i]
local ud = UnitDefs[udid]
if not ud.customParams.child_of_factory then
zOffset = zOffset + 1
local x, z = INCREMENT, zOffset*INCREMENT
local y = Spring.GetGroundHeight(x,z)
local unitID = Spring.CreateUnit(udid, x, y, z, 0, 0, build)
if build then
SetupNanoUnit(unitID, nanoAmount)
end
if ud.buildOptions and #ud.buildOptions > 0 then
local sublist = ud.buildOptions
local offset = 1
if ud.customParams.parent_of_plate then
local subUdid = UnitDefNames[ud.customParams.parent_of_plate].id
local x2, z2 = (1 + offset)*INCREMENT, zOffset*INCREMENT
local y2 = Spring.GetGroundHeight(x2,z2)
local subUnitID = Spring.CreateUnit(subUdid, x2, y2, z2, 0, 0, build)
if build then
SetupNanoUnit(subUnitID, nanoAmount)
end
orderUnit[#orderUnit + 1] = subUnitID
offset = offset + 1
end
for j = 1, #sublist do
local subUdid = sublist[j]
local x2, z2 = (j+offset)*INCREMENT, zOffset*INCREMENT
local y2 = Spring.GetGroundHeight(x2,z2)
local subUnitID = Spring.CreateUnit(subUdid, x2, y2, z2+32, 0, 0, build)
--local ud = UnitDefs[subUdid]
--Spring.Echo(ud.humanName .. "\t" .. ud.speed .. "\t" .. ud.maxWeaponRange .. "\t" .. (ud.health / ud.buildTime))
if build then
SetupNanoUnit(subUnitID, nanoAmount)
end
orderUnit[#orderUnit + 1] = subUnitID
--Spring.CreateUnit(subUdid, x2+32, y2, z2, 1, 0, false)
--Spring.CreateUnit(subUdid, x2, y2, z2-32, 2, 0, false)
--Spring.CreateUnit(subUdid, x2-32, y2, z2, 3, 0, false)
end
end
end
end
--Spring.GiveOrderArrayToUnitArray(orderUnit, ORDERS_PASSIVE)
end
local function SortUnits(a, b)
return UnitDefs[a].metalCost < UnitDefs[b].metalCost
end
local function givesort(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local nanoAmount = math.max(0.01, math.min(1, tonumber(words[1] or "1") or 1))
local build = (nanoAmount < 1)
local buildlist = UnitDefNames["armcom1"].buildOptions
local units = {}
for i = 1, #buildlist do
local udid = buildlist[i]
local ud = UnitDefs[udid]
if ud.buildOptions and #ud.buildOptions > 0 then
local sublist = ud.buildOptions
for j = 1, #sublist do
local subUdid = sublist[j]
if Spring.Utilities.getMovetype(UnitDefs[subUdid]) == 2 then -- Land or sea
units[#units + 1] = subUdid
end
end
end
end
table.sort(units, SortUnits)
local increment = 6100/#units
local zPos = 4000
local orderUnit = {}
for i = 1, #units do
Spring.Echo(UnitDefs[units[i]].humanName, UnitDefs[units[i]].metalCost)
local height = Spring.GetGroundHeight(increment*i, zPos)
local unitID = Spring.CreateUnit(units[i], increment*i, height, zPos, 0, 0, false)
orderUnit[#orderUnit + 1] = unitID
end
Spring.GiveOrderArrayToUnitArray(orderUnit, ORDERS_PASSIVE)
end
local function PlanetwarsGive(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local INCREMENT = 128
local index = 1
for unitDefID = 1, #UnitDefs do
local ud = UnitDefs[unitDefID]
if ud and string.find(ud.name, "pw_") then
local x, z = INCREMENT, index*INCREMENT
local y = Spring.GetGroundHeight(x,z)
local unitID = Spring.CreateUnit(unitDefID, x, y, z, 0, 0, build)
index = index + 1
end
end
end
local function ColorTest(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local displayDefID = UnitDefNames["energysolar"].id
local displayDefID2 = UnitDefNames["dyntrainer_assault_base"].id
local jumbleDefID = UnitDefNames["cloakraid"].id
local INCREMENT = 96
local orderUnit = {}
local allyTeamList = Spring.GetAllyTeamList()
for i = 1, #allyTeamList do
local teamList = Spring.GetTeamList(allyTeamList[i])
for j = 1, #teamList do
local teamID = teamList[j]
local x, z = j*INCREMENT, i*INCREMENT
local y = Spring.GetGroundHeight(x,z)
orderUnit[#orderUnit + 1] = Spring.CreateUnit(displayDefID, x, y, z, 0, teamID, false)
orderUnit[#orderUnit + 1] = Spring.CreateUnit(displayDefID2, x, y, 800 + z, 0, teamID, false)
for k = 1, 15 do
local rx, rz = 2600 + math.random()*1000, 3000 + math.random()*1000
local ry = Spring.GetGroundHeight(rx, rz)
orderUnit[#orderUnit + 1] = Spring.CreateUnit(jumbleDefID, rx, ry, rz, 0, teamID, false)
end
end
end
Spring.GiveOrderArrayToUnitArray(orderUnit, ORDERS_PASSIVE)
end
local function gentleKill(cmd,line,words,player)
if spIsCheatingEnabled() then
local units = Spring.GetAllUnits()
for i=1, #units do
local unitID = units[i]
Spring.SetUnitHealth(unitID,0.1)
Spring.AddUnitDamage(unitID,1, 0, nil, -7)
end
end
end
local function nanoFrame(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local nanoAmount = math.max(0.01, math.min(1, tonumber(words[1] or "0.99") or 0.99))
local units = Spring.GetAllUnits()
for i=1, #units do
local unitID = units[i]
Spring.SetUnitHealth(unitID, {build = nanoAmount})
end
end
local function rezAll(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local features = Spring.GetAllFeatures()
for i = 1, #features do
local featureID = features[i]
local defName, facing = Spring.GetFeatureResurrect(featureID)
if defName ~= "" then
local x, y, z = Spring.GetFeaturePosition(featureID)
local teamID = Spring.GetFeatureTeam(featureID)
if teamID == -1 then
teamID = Spring.GetGaiaTeamID()
end
Spring.DestroyFeature(featureID)
Spring.CreateUnit(defName, x, y, z, facing, teamID)
end
end
end
local function damage(cmd,line,words,player)
if spIsCheatingEnabled() then
local units = Spring.GetAllUnits()
for i=1, #units do
local unitID = units[i]
Spring.SetUnitHealth(unitID,1)
end
end
end
local function clear(cmd,line,words,player)
if spIsCheatingEnabled() then
local units = Spring.GetAllUnits()
for i=1, #units do
local unitID = units[i]
Spring.DestroyUnit(unitID, false, true)
end
local features = Spring.GetAllFeatures()
for i=1, #features do
local featureID = features[i]
Spring.DestroyFeature(featureID)
end
end
end
local function uclear(cmd,line,words,player)
if spIsCheatingEnabled() then
local units = Spring.GetAllUnits()
for i=1, #units do
local unitID = units[i]
Spring.DestroyUnit(unitID, false, true)
end
end
end
local function restart(cmd,line,words,player)
if spIsCheatingEnabled() then
local units = Spring.GetAllUnits()
local teams = Spring.GetTeamList()
for i=1,#teams do
local teamID = teams[i]
if GG.startUnits[teamID] and GG.CommanderSpawnLocation[teamID] then
local spawn = GG.CommanderSpawnLocation[teamID]
local unitID = GG.DropUnit(GG.startUnits[teamID], spawn.x, spawn.y, spawn.z, spawn.facing, teamID, nil, 0)
Spring.SetUnitRulesParam(unitID, "facplop", 1, {inlos = true})
end
end
for i=1, #units do
local unitID = units[i]
Spring.DestroyUnit(unitID, false, true)
end
local features = Spring.GetAllFeatures()
for i=1, #features do
local featureID = features[i]
Spring.DestroyFeature(featureID)
end
end
end
local function serial(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local buildlist = UnitDefNames["armcom1"].buildOptions
local unitList = {}
for i = 1, #buildlist do
local udid = buildlist[i]
local ud = UnitDefs[udid]
unitList[#unitList + 1] = udid
if ud.buildOptions and #ud.buildOptions > 0 then
local sublist = ud.buildOptions
for j = 1, #sublist do
unitList[#unitList + 1] = sublist[j]
end
end
end
creationIndex = tonumber(words[1]) or 1
creationUnitList = unitList
gadgetHandler:UpdateGadgetCallIn('GameFrame', gadget)
end
local function EchoCrush()
if not spIsCheatingEnabled() then
return
end
local features = Spring.GetAllFeatures()
for i = 1, #features do
local featureID = features[i]
local fdid = Spring.GetFeatureDefID(featureID)
local mass = fdid and FeatureDefs[fdid] and FeatureDefs[fdid].mass
if mass then
local crush = 1
if mass < 50 then
crush = 2
elseif mass < 150 then
crush = 3
elseif mass < 500 then
crush = 4
else
crush = "x"
end
Spring.Utilities.FeatureEcho(featureID, crush)
end
end
end
local function bisect(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local increment = math.abs(tonumber(words[1]) or 1)
local offset = math.floor(tonumber(words[2]) or 0)
local invert = (math.abs(tonumber(words[3]) or 0) == 1) or false
--[[
local occured = {}
for i = 1, #syncedGadgetList do
occured[syncedGadgetList[i] ] = true
end
for i = 1, #unsyncedGadgetList do
if not occured[unsyncedGadgetList[i] ] then
syncedGadgetList[#syncedGadgetList+1] = unsyncedGadgetList[i]
end
end
for i = 1, #syncedGadgetList do
Spring.Echo("\"" .. syncedGadgetList[i] .. "\",")
end
--]]
for i = 1, #gadgetList do
if i >= offset and (offset-i)%increment == 0 then
if not invert then
gadgetHandler:GotChatMsg("disablegadget " .. gadgetList[i], 0)
end
elseif invert then
gadgetHandler:GotChatMsg("disablegadget " .. gadgetList[i], 0)
end
end
end
local function nocost(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local enabled = not (tonumber(words[1]) == 0)
GG.SetFreeStockpile(enabled)
Spring.Echo("Free stockpile " .. ((enabled and "enabled") or "disabled") .. ".")
GG.SetFreeMorph(enabled)
Spring.Echo("Free morph " .. ((enabled and "enabled") or "disabled") .. ".")
GG.Terraform.SetFreeTerraform(enabled)
Spring.Echo("Free terraform " .. ((enabled and "enabled") or "disabled") .. ".")
GG.Overdrive.SetNoGridRequirement(enabled)
Spring.Echo("No grid requirement " .. ((enabled and "enabled") or "disabled") .. ".")
end
local function power(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local enabled = not (tonumber(words[1]) == 0)
GG.Overdrive.SetNoGridRequirement(enabled)
Spring.Echo("No grid requirement " .. ((enabled and "enabled") or "disabled") .. ".")
end
local function EmpiricalDps(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local enabled = not (tonumber(words[1]) == 0)
if enabled then
gadgetHandler:GotChatMsg("enablegadget Empirical DPS", 0)
else
gadgetHandler:GotChatMsg("disablegadget Empirical DPS", 0)
end
Spring.SetGameRulesParam("enable_EmpiricalDPS", enabled and 1 or 0)
end
local function PrintUnits(cmd, line, words, player)
if not Spring.IsCheatingEnabled() then
return
end
local unitList = Spring.GetAllUnits()
for i = 1, #unitList do
Spring.Utilities.UnitEcho(unitList[i])
end
end
local function GiveMexes(cmd, line, words, player)
if not Spring.IsCheatingEnabled() then
return
end
local spots = GG.metalSpots
if not spots then
return
end
for i = 1, #spots do
local spot = spots[i]
Spring.CreateUnit("staticmex", spot.x, 0, spot.z, 0, 0)
end
end
local function PlaceBattle(cmd, line, words, player)
if not Spring.IsCheatingEnabled() then
return
end
GG.load_galaxy_mission_handler = true
gadgetHandler:GotChatMsg("disablegadget " .. "Galaxy Campaign Battle Handler", 0)
gadgetHandler:GotChatMsg("enablegadget " .. "Galaxy Campaign Battle Handler", 0)
local battleName = words[1] or "cc"
local unitList, featureList = VFS.Include("LuaRules/Configs/battles/" .. battleName .. ".lua")
if featureList then
GG.mission_PlaceFeatures(featureList, 0)
end
if unitList then
GG.mission_PlaceTeamUnits(unitList)
end
end
function gadget:GameFrame(n)
if not spIsCheatingEnabled() then
return
end
if n%120 == 0 then
if not creationUnitList[creationIndex] then
creationIndex, creationUnitList = nil, nil
gadgetHandler:RemoveGadgetCallIn('GameFrame', gadget)
return
end
local INCREMENT = 128
local unitDefID = creationUnitList[creationIndex]
for i = 1, 25 do
for j = 1, 25 do
local x, z = 1000 + i*INCREMENT, 1000 + j*INCREMENT
local y = Spring.GetGroundHeight(x,z)
Spring.CreateUnit(unitDefID, x, y, z, 0, 0, false)
end
end
Spring.Echo(UnitDefs[unitDefID].humanName, creationIndex)
creationIndex = creationIndex + 1
elseif n%120 == 100 then
clear()
end
end
function gadget:Initialize()
if Spring.GetGameRulesParam("enable_EmpiricalDPS") == 1 then
gadgetHandler:GotChatMsg("enablegadget Empirical DPS", 0)
end
gadgetHandler.actionHandler.AddChatAction(self, "bisect", bisect, "Bisect gadget disables.")
gadgetHandler.actionHandler.AddChatAction(self, "emd", EmpiricalDps, "Toggle empirical DPS.")
gadgetHandler.actionHandler.AddChatAction(self, "ecrush", EchoCrush, "Echos all crushabilities.")
gadgetHandler.actionHandler.AddChatAction(self, "circle", circleGive, "Gives a bunch of units in a circle.")
gadgetHandler.actionHandler.AddChatAction(self, "moveunit", MoveUnit, "Moves a unit.")
gadgetHandler.actionHandler.AddChatAction(self, "destroyunit", DestroyUnit, "Destroys a unit.")
gadgetHandler.actionHandler.AddChatAction(self, "rotateunit", RotateUnit, "Rotates a unit.")
gadgetHandler.actionHandler.AddChatAction(self, "give", give, "Like give all but without all the crap.")
gadgetHandler.actionHandler.AddChatAction(self, "givesort", givesort, "Gives mobiles sorted by cost.")
gadgetHandler.actionHandler.AddChatAction(self, "pw", PlanetwarsGive, "Spawns all planetwars structures.")
gadgetHandler.actionHandler.AddChatAction(self, "gk", gentleKill, "Gently kills everything.")
gadgetHandler.actionHandler.AddChatAction(self, "nf", nanoFrame, "Sets nanoframe values.")
gadgetHandler.actionHandler.AddChatAction(self, "rez", rezAll, "Resurrects wrecks for former owners.")
gadgetHandler.actionHandler.AddChatAction(self, "damage", damage, "Damages everything.")
gadgetHandler.actionHandler.AddChatAction(self, "color", ColorTest, "Spawns units for color test.")
gadgetHandler.actionHandler.AddChatAction(self, "clear", clear, "Clears all units and wreckage.")
gadgetHandler.actionHandler.AddChatAction(self, "uclear", uclear, "Clears all units.")
gadgetHandler.actionHandler.AddChatAction(self, "serial", serial, "Gives all units in succession.")
gadgetHandler.actionHandler.AddChatAction(self, "restart", restart, "Gives some commanders and clears everything else.")
gadgetHandler.actionHandler.AddChatAction(self, "nocost", nocost, "Makes everything gadget-implemented free.")
gadgetHandler.actionHandler.AddChatAction(self, "power", power, "Remove grid power limit.")
gadgetHandler.actionHandler.AddChatAction(self, "printunits", PrintUnits, "")
gadgetHandler.actionHandler.AddChatAction(self, "battle", PlaceBattle, "")
gadgetHandler.actionHandler.AddChatAction(self, "mexes", GiveMexes, "")
gadgetHandler:RemoveGadgetCallIn('GameFrame', gadget)
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
else -- UNSYNCED
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
local function bisect(cmd,line,words,player)
if not spIsCheatingEnabled() then
return
end
local increment = math.abs(tonumber(words[1]) or 1)
local offset = math.floor(tonumber(words[2]) or 0)
local invert = (math.abs(tonumber(words[3]) or 0) == 1) or false
for i = 1, #gadgetList do
if i >= offset and (offset-i)%increment == 0 then
if not invert then
gadgetHandler:GotChatMsg("disablegadget " .. gadgetList[i], 0)
end
elseif invert then
gadgetHandler:GotChatMsg("disablegadget " .. gadgetList[i], 0)
end
end
collectgarbage("collect")
end
local function gc()
collectgarbage("collect")
end
function gadget:Initialize()
gadgetHandler.actionHandler.AddChatAction(self,"bisect",bisect,"Bisect gadget disables.")
gadgetHandler.actionHandler.AddChatAction(self,"gc",gc,"Garbage collect.")
end
end