-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevMode.lua
478 lines (413 loc) · 19.1 KB
/
DevMode.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
--System:ExecuteCommand("load_game"); -- note: for executing this script as a console command (e.g. edit script, then re-load game to test script)
cl_display_hud = 1
cl_drunken_cam = 0
ThirdPersonView = 0
Input:BindCommandToKey("#GotoNextSpawnpoint()","f2",1);
Input:BindCommandToKey("#ToggleFastFlyMode()","f3",1);
Input:BindCommandToKey("#ToggleNoClipFlyMode()","f4",1);
--Input:BindCommandToKey("\\save_game","f5",""); -- How to key-bind a console command
--Input:BindCommandToKey("\\load_game","f8",""); -- How to key-bind a console command
Input:BindCommandToKey("#QuickSave()","f5",1);
Input:BindCommandToKey("#QuickLoad()","f8",1);
Input:BindCommandToKey("#BlindDeafEnemies()","f9",1);
Input:BindCommandToKey("#ToggleGod()","backspace",1);
Input:BindCommandToKey("#AllGrenades()","9",1);
Input:BindCommandToKey("#AllGear()","0",1);
Input:BindCommandToKey("#MoreAmmo()","o",1);
Input:BindCommandToKey("#AllWeapons()","p",1);
--- temp variables for functions below ---
prev_speed_walk=p_speed_walk;
prev_speed_run=p_speed_run;
prev_speed_walk2=p_speed_walk;
prev_speed_run2=p_speed_run;
default_speed_walk=p_speed_walk;
default_speed_run=p_speed_run;
screenshotmode=0;
fastfly=0; -- for functions that toggle states
noclipfly=0;
blind_deaf_enemies=0;
function QuickSave()
if _localplayer then
Game:Save('Quicksave');
Hud:AddMessage("[CHEAT]: Quick-saved the game.");
System:LogToConsole("\001CHEAT: Quick-saved the game.");
else
Hud:AddMessage("[CHEAT]: Cannot quick-save the game.");
end
end
function QuickLoad()
Game:Load('Quicksave'); -- also allowed when no game is yet loaded
Hud:AddMessage("[CHEAT]: Quick-loaded the game.");
System:LogToConsole("\001CHEAT: Quick-loaded the game.");
end
function BlindDeafEnemies()
if _localplayer then
if (blind_deaf_enemies==1) then
ai_ignoreplayer=0;
ai_soundperception=1;
Hud:AddMessage("[CHEAT]: Enemies CAN see/hear you.");
System:LogToConsole("\001CHEAT: Enemies CAN see/hear you.");
else
ai_ignoreplayer=1;
ai_soundperception=0;
Hud:AddMessage("[CHEAT]: Enemies CANNOT see/hear you.");
System:LogToConsole("\001CHEAT: Enemies CANNOT see/hear you.");
end
blind_deaf_enemies=1-blind_deaf_enemies;
else
Hud:AddMessage("[CHEAT]: No hiding from enemies.");
end
end
function ToggleAIInfo()
if (not aiinfo) then
aiinfo=1;
else
aiinfo=1-aiinfo;
end
if (aiinfo==1) then
ai_debugdraw=1;
ai_drawplayernode=1;
ai_area_info=1;
else
ai_debugdraw=0;
ai_drawplayernode=0;
ai_area_info=0;
end
end
function GotoNextSpawnpoint()
if _localplayer then
local pt;
pt=Server:GetNextRespawnPoint();
if(not pt)then -- last respawn point or there are no respawn points
pt=Server:GetFirstRespawnPoint(); -- try to get the first one
end
if(pt)then -- if there is one
Game:ForceEntitiesToSleep();
_localplayer:SetPos(pt);
_localplayer:SetAngles({ x = pt.xA, y = pt.yA, z = pt.zA });
end
Hud:AddMessage("[CHEAT]: Jumped to next checkpoint.");
System:LogToConsole("\001CHEAT: Jumped to next checkpoint.");
else
Hud:AddMessage("[CHEAT]: Cannot jump to next checkpoint.");
end
end
function SetPlayerPos()
local p=_localplayer
p:SetPos({x=100,y=100,z=300});
end
function ToggleFastFlyMode()
if _localplayer then
ToggleNewDesignerMode(40,120,1);
if (fastfly==1) then
Hud:AddMessage("[CHEAT]: Fast Fly Mode OFF");
System:LogToConsole("\001CHEAT: Fast Fly Mode OFF.");
fastfly=0;
else
if (noclipfly==1) then
Hud:AddMessage("[CHEAT]: No-Clip Fly Mode OFF");
System:LogToConsole("\001CHEAT: No-Clip Fly Mode OFF.");
noclipfly=0;
else
Hud:AddMessage("[CHEAT]: Fast Fly Mode ON");
System:LogToConsole("\001CHEAT: Fast Fly Mode ON.");
fastfly=1;
end
end
else
Hud:AddMessage("[CHEAT]: Cannot set fly mode.");
end
end
function ToggleNoClipFlyMode()
if _localplayer then
ToggleNewDesignerMode(10,15,0);
if (noclipfly==1) then
Hud:AddMessage("[CHEAT]: No-Clip Fly Mode OFF");
System:LogToConsole("\001CHEAT: No-Clip Fly Mode OFF.");
noclipfly=0;
else
if (fastfly==1) then
Hud:AddMessage("[CHEAT]: Fast Fly Mode OFF");
System:LogToConsole("\001CHEAT: Fast Fly Mode OFF.");
fastfly=0;
else
Hud:AddMessage("[CHEAT]: No-Clip Fly Mode ON");
System:LogToConsole("\001CHEAT: No-Clip Fly Mode ON.");
noclipfly=1;
end
end
else
Hud:AddMessage("[CHEAT]: Cannot set fly mode.");
end
end
-- replacement for ToggleSuperDesignerMode() and ToggleDesignerMode()
--
-- USAGE:
-- deactivate designer mode: (nil,nil,0)
-- old super designer mode (with collision): (40,120,1)
-- old designer mode (without collision): (10,15,0)
-- change values: call with (nil,nil,0) then with the new values (0.., 0.., 0/1)
--
function ToggleNewDesignerMode( speedwalk, speedrun, withcollide )
if(SuperDesignerMode_Save1~=nil or speedwalk==nil) then
--Hud:AddMessage("[CHEAT]: Fly mode OFF");
p_speed_walk = SuperDesignerMode_Save1;
p_speed_run = SuperDesignerMode_Save2;
_localplayer.DynProp.gravity = SuperDesignerMode_Save3;
_localplayer.DynProp.inertia = SuperDesignerMode_Save4;
_localplayer.DynProp.swimming_gravity = SuperDesignerMode_Save5;
_localplayer.DynProp.swimming_inertia = SuperDesignerMode_Save6;
_localplayer.DynProp.air_control = SuperDesignerMode_Save7;
_localplayer.cnt:SetDynamicsProperties( _localplayer.DynProp );
SuperDesignerMode_Save1=nil;
-- activate collision, parameter is 0 or 1
_localplayer:ActivatePhysics(1);
else
--Hud:AddMessage("[CHEAT]: Fly mode ON");
SuperDesignerMode_Save1 = p_speed_walk;
SuperDesignerMode_Save2 = p_speed_run;
SuperDesignerMode_Save3 = _localplayer.DynProp.gravity;
SuperDesignerMode_Save4 = _localplayer.DynProp.inertia;
SuperDesignerMode_Save5 = _localplayer.DynProp.swimming_gravity;
SuperDesignerMode_Save6 = _localplayer.DynProp.swimming_inertia;
SuperDesignerMode_Save7 = _localplayer.DynProp.air_control;
p_speed_walk = speedwalk;
p_speed_run = speedrun;
_localplayer.DynProp.gravity=0.0;
_localplayer.DynProp.inertia=0.0;
_localplayer.DynProp.swimming_gravity=0.0;
_localplayer.DynProp.swimming_inertia=0.0;
_localplayer.DynProp.air_control=1.0;
_localplayer.cnt:SetDynamicsProperties( _localplayer.DynProp );
-- deactivate collision, parameter is 0 or 1
_localplayer:ActivatePhysics(withcollide);
end
end
function ToggleScreenshotMode()
if(screenshotmode~=0) then
System:LogToConsole("SCREENSHOTMODE OFF-->SWITCH TO NORMAL");
screenshotmode=0;
hud_crosshair = "1"
cl_display_hud = "1"
r_NoDrawNear = "0"
ai_ignoreplayer = "0"
ai_soundperception = "1"
r_DisplayInfo = "1"
else
System:LogToConsole("SCREENSHOTMODE ON");
screenshotmode=1;
hud_crosshair = "0"
cl_display_hud = "0"
r_NoDrawNear = "1"
ai_ignoreplayer = "1"
ai_soundperception = "0"
r_DisplayInfo = "0"
end
end
function DecreaseSpeed()
if tonumber(p_speed_walk)>5 then
p_speed_walk=p_speed_walk-5;
p_speed_run=p_speed_run-5;
System:LogToConsole("Decreased player speed by 5");
else
System:LogToConsole("You can not go any slower!");
end
end
function IncreaseSpeed()
if tonumber(p_speed_walk)<500 then
p_speed_walk=p_speed_walk+5;
p_speed_run=p_speed_run+5;
System:LogToConsole("Increased player speed by 5");
else
System:LogToConsole("You can not go any faster!");
end
end
function DefaultSpeed()
p_speed_walk=default_speed_walk;
p_speed_run=default_speed_run;
System:LogToConsole("Player speed reset");
end
function TeleportToSpawn(n)
local player = _localplayer;
local pos = Server:GetRespawnPoint("Respawn"..n);
if pos then
player:SetPos(pos);
player:SetAngles({ x = pos.xA, y = pos.yA, z = pos.zA });
end
end
-- Give the player the passed weapon, load it if neccesary
function AddWeapon(Name)
Game:AddWeapon(Name)
for i, CurWeapon in WeaponClassesEx do
if (i == Name) then
_localplayer.cnt:MakeWeaponAvailable(CurWeapon.id);
end
end
end
--_localplayer.cnt.ammo=999; -- Reserve ammo -- Relevant to ammo manipulations
--_localplayer.cnt.ammo_in_clip=999; -- Clip ammo
function MoreAmmo()
if _localplayer then
local weapon = _localplayer.cnt.weapon;
local name = "";
local nAmmo = 0;
local nFireMode = 0;
if (weapon) then
name = weapon.name;
nFireMode = _localplayer.cnt.firemode; -- .firemode exists even for single firemode cases.
if (name=="AG36") then
if (nFireMode == 0) then
nAmmo = 300;
else
nAmmo = 10;
nFireMode = 2; -- Flag an alt-ammo add, for displayed message.
end
_localplayer.cnt.ammo = nAmmo;
end
if (name=="Falcon") then
nAmmo = 150;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="SniperRifle") then
nAmmo = 30;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="MP5") then
nAmmo = 300;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="RL") then
nAmmo = 10;
_localplayer.cnt.ammo = nAmmo;
name = "Rocket Launcher";
end
if (name=="Shotgun") then
nAmmo = 50;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="OICW") then
if (nFireMode == 0) then
nAmmo = 300;
else
nAmmo = 10;
nFireMode = 2; -- Flag an alt-ammo add, for displayed message.
end
_localplayer.cnt.ammo = nAmmo;
end
if (name=="P90") then
nAmmo = 300;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="M4") then
nAmmo = 300;
_localplayer.cnt.ammo = nAmmo;
end
if (name=="M249") then
nAmmo = 300;
_localplayer.cnt.ammo = nAmmo;
end
local sFireMode = "";
if (nFireMode==2) then sFireMode="(alt fire-mode) "; end;
Hud:AddMessage("[CHEAT]: Set the ammo reserve for weapon '" ..name.."' "..sFireMode.."to
"..nAmmo..".");
System:LogToConsole("\001CHEAT: Set the ammo reserve for weapon '" ..name.."' "..sFireMode.."to
"..nAmmo..".");
else
Hud:AddMessage("[CHEAT]: No ammo added. Try arming a gun first.");
end
else
Hud:AddMessage("[CHEAT]: Cannot give ammo.");
end
end
-- These script commands can set the ammo reserve of the player for some types of ammo.
-- (The ammo is not loaded, just in reserve.)
-- _localplayer.Ammo.Pistol = 150;
-- _localplayer.Ammo.Assault = 300;
-- _localplayer.Ammo.Sniper = 30;
-- _localplayer.Ammo.SMG = 350;
-- _localplayer.Ammo.Shotgun = 50;
-- --_localplayer.Ammo.MortarShells = 10; -- This one doesn't seem to work.
-- _localplayer.Ammo.SmokeGrenade = 6;
-- _localplayer.Ammo.FlashbangGrenade = 6;
-- --_localplayer.Ammo.HandGrenade = 6; -- This one doesn't seem to work.
-- _localplayer.Ammo.Rocket = 10;
function AllWeapons()
if _localplayer then
AddWeapon("AG36");
AddWeapon("Falcon");
AddWeapon("SniperRifle");
AddWeapon("MP5");
AddWeapon("RL");
AddWeapon("Shotgun");
AddWeapon("OICW");
AddWeapon("P90");
--AddWeapon("M4"); -- Maximum of 9 weapons can be carried (all accessed by mouse-wheel)
AddWeapon("M249");
Hud:AddMessage("[CHEAT]: Give 9 weapons. (Drop unwanted weapons. Access all weapons by mouse-wheel.)");
System:LogToConsole("\001CHEAT: Give 9 weapons. (Drop unwanted weapons. Access all weapons by mouse-
wheel.)");
else
Hud:AddMessage("[CHEAT]: Cannot give weapons.");
end
end
function AllGrenades()
if _localplayer then
local nHG = _localplayer:GetAmmoAmount("HandGrenade");
local nSG = _localplayer:GetAmmoAmount("SmokeGrenade");
local nFG = _localplayer:GetAmmoAmount("FlashbangGrenade");
_localplayer:AddAmmo("FlashbangGrenade",6-nFG);
_localplayer:AddAmmo("SmokeGrenade",6-nSG);
_localplayer:AddAmmo("HandGrenade",6-nHG);
--_localplayer.Ammo.SmokeGrenade = 6; -- Set exact amount, no worries to exceed normal
maximum.
--_localplayer.Ammo.FlashbangGrenade = 6;
--_localplayer.Ammo.HandGrenade = 6; -- Doesn't work unfortunately
--_localplayer.cnt.grenadetype = 2; -- HUD selects hand grenade.
--_localplayer.cnt.numofgrenades = 6; -- Set selected grenade's amount.
-- Set .grenadetype is annoyingly asynchronous, but
one use is fine.
Hud:AddMessage("[CHEAT]: Give all grenades.");
System:LogToConsole("\001CHEAT: Give all grenades.");
else
Hud:AddMessage("[CHEAT]: Cannot give grenades.");
end
end
function AllGear()
if _localplayer then
_localplayer.cnt:GiveBinoculars(1);
_localplayer.cnt:GiveFlashLight(1);
_localplayer.items.heatvisiongoggles=1;
Hud:AddMessage("[CHEAT]: Give binoculars, flashlight, and heat-vision goggles.");
System:LogToConsole("\001CHEAT: Give binoculars, flashlight, and heat-vision goggles.")
else
Hud:AddMessage("[CHEAT]: Cannot give gear.");
end
end
function ToggleGod()
if _localplayer then
if (not god) then
god=1;
else
god=1-god;
end
-- Check if we are going to set or remove god mode now.
if (god==1) then
GodMode_Save1 = _localplayer.cnt.health;
GodMode_Save2 = _localplayer.cnt.armor;
_localplayer.cnt.health = 99999;
_localplayer.cnt.armor = 99999;
Hud:AddMessage("[CHEAT]: God Mode ON. Set health and armor to 99999.");
System.LogToConsole("\001CHEAT: God Mode ON. Set health and armor to 99999.");
else
_localplayer.cnt.health = GodMode_Save1;
_localplayer.cnt.armor = GodMode_Save2;
Hud:AddMessage("[CHEAT]: God Mode OFF. Restored health ("..GodMode_Save1..") and armor
("..GodMode_Save2..").");
System:LogToConsole("\001CHEAT: God Mode OFF. Restored health ("..GodMode_Save1..") and armor
("..GodMode_Save2..").");
end
else
Hud:AddMessage("[CHEAT]: Cannot set god mode.");
end
end
--Hud:AddMessage("Loaded script: DevMode.lua"); -- debugging feedback