Repository navigation
Expand file tree
/
Copy pathdefault.lua
More file actions
464 lines (366 loc) · 11.1 KB
/
Copy pathdefault.lua
File metadata and controls
464 lines (366 loc) · 11.1 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
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
DisableFog = false
LastFog = true
NormalFOV = 85
LastZoomed = false
Zoom = 1
-------------------------------------------------------------------------------
function KeyEvent(Key, Action, Value)
--Make sure we have a player, the console is closed, and
--the game menu is closed.
if (PC.Player == nill) or PC.Player.Console.bTyping or
PC.Player.GUIController.bVisible then
return false
end
--Letter 'O' key toggles fog
if Key == 0x4F then
if Action == 1 then
DisableFog = not DisableFog
end
return true
end
--MouseWheelUp zooms in
if Key == 0xEC then
if Action == 1 then
Zoom = Zoom / 2
if Zoom < 0.01 then
Zoom = Zoom * 2
end
end
return true
end
--MouseWheelDown zooms out
if Key == 0xED then
if Action == 1 then
Zoom = Zoom * 2
if Zoom > 1 then
Zoom = 1
end
end
return true
end
return false
end
-------------------------------------------------------------------------------
function PostRender(Canvas)
--Make sure we are playing
LocalPRI = PC.PlayerReplicationInfo
if LocalPRI == nill then
return
end
--Get the base weapon attachments
BWAData = {}
local Index = 1
local BWA = Engine.FindFirstAActor(CBWA)
while BWA do
BWAData[Index] = BWA
Index = Index + 1
BWA = Engine.FindNextAActor(BWA, CBWA)
end
--Draw Aiming Dot
Canvas.SetDrawColor(255, 255, 0, 255)
Canvas.SetPos((Canvas.SizeX / 2) - 1, (Canvas.SizeY / 2) - 1)
Canvas.DrawTile(TWhite, 2, 2, 0, 0, 2, 2, Canvas.DrawColor)
--Draw Pickup ESP
local Pickup = Engine.FindFirstAActor(CPickup)
while Pickup do
DrawPickupESP(Canvas, Pickup)
Pickup = Engine.FindNextAActor(Pickup, CPickup)
end
--Draw Player ESP
local PRI = Engine.FindFirst(LocalPRI)
while PRI do
if #PRI ~= #LocalPRI then
DrawPlayerESP(Canvas, PRI)
end
PRI = Engine.FindNext(PRI)
end
--Restore Visuals
PC.Region.Zone.bDistanceFog = LastFog
PC.Region.Zone.bClearToFogColor = LastFog
end
-------------------------------------------------------------------------------
function PreRender(Canvas)
--Get the view angles.
local Vec = Engine.New(FVector)
local Rot = Engine.New(FRotator)
ViewVec, ViewRot = Canvas.GetCameraLocation(Vec, Rot)
ViewAxesX, ViewAxesY, ViewAxesZ = Canvas.GetAxes(ViewRot,
Vec, Vec, Vec)
--Set the new FOV
if PC.Pawn and PC.Pawn.bPawnZoomed then
if LastZoomed then
if NormalFOV == PC.DefaultFOV then
NormalFOV = PC.DesiredFOV
Zoom = NormalFOV / PC.DefaultFOV
else
PC.DesiredFOV = PC.DefaultFOV * Zoom
end
else
LastZoomed = true
NormalFOV = PC.DefaultFOV
PC.DesiredFOV = NormalFOV
PC.FovAngle = NormalFOV
end
else
if LastZoomed then
LastZoomed = false
Zoom = 1
end
NormalFOV = PC.DefaultFOV
PC.DesiredFOV = NormalFOV * Zoom
PC.FovAngle = PC.DesiredFOV
end
--Modify Visuals
LastFog = PC.Region.Zone.bDistanceFog
if DisableFog then
PC.Region.Zone.bDistanceFog = false
PC.Region.Zone.bClearToFogColor = false
end
end
-------------------------------------------------------------------------------
function Tick(DeltaTime, ViewPort)
--Save the PlayerController
PC = ViewPort.Actor
--Check for a new level.
if LevelName ~= PC.Level.sLevelName then
LevelName = PC.Level.sLevelName
print('New level: '..LevelName)
FRotator = Engine.UObjects['Struct Object.Rotator']
FVector = Engine.UObjects['Struct Object.Vector']
CBWA = Engine.UObjects['Class AGP.BaseWeaponAttachment']
CPickup = Engine.UObjects['Class Engine.Pickup']
CThrowPickup = Engine.UObjects['Class AGP.ThrowWeaponPickup']
TWhite = Engine.UObjects['Texture Engine.WhiteSquareTexture']
--Perfect Aim
Fire = Engine.UObjects['Function AGP_Weapon.Fire']
--Fire[0x15D] = 0x27
--Fire[0x184] = 0x27
end
end
-------------------------------------------------------------------------------
function DrawPickupESP(Canvas, Pickup)
LastPickup = Pickup
--Calc the pickup's screen position
local Vec = Engine.New(FVector)
Vec.X = Pickup.Location.X
Vec.Y = Pickup.Location.Y
Vec.Z = Pickup.Location.Z
local Screen = Canvas.WorldToScreen(Vec)
if Screen.Z >= 1 then
return
end
--Set the pickup's color
local Size = 20
if Engine.IsA(Pickup, CThrowPickup) then
Size = 10
Canvas.SetDrawColor(0, 255, 255, 255)
else
Canvas.SetDrawColor(0, 0, 255, 255)
end
--Calc the pickup's distance.
local Delta = Canvas.Subtract_VectorVector(Vec, ViewVec)
local Dist = Canvas.VSize(Delta)
--Calc the pickup's screen size.
Vec.X = ViewVec.X + (Dist * ViewAxesX.X)
Vec.Y = ViewVec.Y + (Dist * ViewAxesX.Y)
Vec.Z = ViewVec.Z + (Dist * ViewAxesX.Z)
local Box = Canvas.WorldToScreen(Vec)
Vec.X = Vec.X + (Size * ViewAxesZ.X)
Vec.Y = Vec.Y + (Size * ViewAxesZ.Y)
Vec.Z = Vec.Z + (Size * ViewAxesZ.Z)
local Box2 = Canvas.WorldToScreen(Vec)
local H
local W
H = (Box.Y - Box2.Y) / 2
W = H
--Create a good name.
local Name
if LocalPRI.Team and (Pickup.idTeamOwner ~= 255) and
(Pickup.idTeamOwner ~= LocalPRI.Team.TeamIndex) then
Name = Engine.FNames[Pickup.EnemyPickupClass.Name];
else
Name = Engine.FNames[Pickup.Name];
end
Name = string.sub(Name, 9)
Name = string.sub(Name, 1, string.find(Name, '_') - 1)
--Draw the ESP box
if PC.LineOfSightTo(Pickup) then
DrawRect(Canvas, Screen.X - W, Screen.Y - H, W*2, H*2)
else
DrawCorners(Canvas, Screen.X - W, Screen.Y - H, W*2, H*2)
end
Canvas.Font = Canvas.TinyFont
Canvas.SetPos(Screen.X + W + 5, Screen.Y - H)
Canvas.DrawTextClipped(Name)
end
-------------------------------------------------------------------------------
function DrawPlayerESP(Canvas, PRI)
--Skip players without names
if (PRI.PlayerName == nil) or PRI.bDead or PRI.bIsSpectator or
PRI.bOnlySpectator or PRI.bWaitingPlayer then
return
end
--Calc the player's screen position
local bIsProne = false
local bIsCrouched = false
local BleedHealth = 0
local Health = ' '
local Vec = Engine.New(FVector)
local Pawn = PRI.myPawn
if Pawn then
Vec.X = Pawn.Location.X
Vec.Y = Pawn.Location.Y
Vec.Z = Pawn.Location.Z
bIsProne = Pawn.bIsProne
bIsCrouched = Pawn.bIsCrouched
BleedHealth = Pawn.BleedHealth
if BleedHealth > 0 then
Health = string.format('[%d-%d]', Pawn.Health, BleedHealth)
else
Health = string.format('[%d]', Pawn.Health)
end
else
Vec.X = PRI.LocationX
Vec.Y = PRI.LocationY
Vec.Z = PRI.LocationZ
end
local Screen = Canvas.WorldToScreen(Vec)
if Screen.Z >= 1 then
return
end
--Calc the player's color
local Enemy = true
if PRI.Team and LocalPRI.Team and (#PRI.Team == #LocalPRI.Team) then
Enemy = false
if BleedHealth > 0 then
--Yellow
Canvas.SetDrawColor(255, 255, 0, 255)
else
--Green
Canvas.SetDrawColor(0, 255, 0, 255)
end
else
--Red
Canvas.SetDrawColor(255, 0, 0, 255)
end
--Calc the player's distance.
local Delta = Canvas.Subtract_VectorVector(Vec, ViewVec)
local Dist = Canvas.VSize(Delta)
--Calc the player's screen size.
Vec.X = ViewVec.X + (Dist * ViewAxesX.X)
Vec.Y = ViewVec.Y + (Dist * ViewAxesX.Y)
Vec.Z = ViewVec.Z + (Dist * ViewAxesX.Z)
local Box = Canvas.WorldToScreen(Vec)
Vec.X = Vec.X + (50 * ViewAxesZ.X)
Vec.Y = Vec.Y + (50 * ViewAxesZ.Y)
Vec.Z = Vec.Z + (50 * ViewAxesZ.Z)
local Box2 = Canvas.WorldToScreen(Vec)
local H
local W
if bIsProne then
W = Box.Y - Box2.Y
H = W / 2
elseif bIsCrouched then
H = (Box.Y - Box2.Y) / 2
W = H
else
H = Box.Y - Box2.Y
W = H / 2
end
--Draw the ESP box
if Pawn and PC.LineOfSightTo(Pawn) then
DrawRect(Canvas, Screen.X - W, Screen.Y - H, W*2, H*2)
else
DrawCorners(Canvas, Screen.X - W, Screen.Y - H, W*2, H*2)
end
Canvas.Font = Canvas.TinyFont
Canvas.SetPos(Screen.X + W + 5, Screen.Y - H)
Canvas.DrawTextClipped(string.format(
'%s %s',
PRI.PlayerName,
Health))
--Draw armed and slung weapon names
if Pawn then
local Attachments
local BWA
local Index
local Name
for Index=1, #BWAData do
BWA = BWAData[Index]
if BWA.Owner then
--print(Index, #BWAData, #BWA.Owner, #Pawn, Engine.FNames[BWA.Name])
if BWA.bCurrentlySelectedAttachment and (#BWA.Owner == #Pawn) then
if Enemy and (BWA.bDontSwapMeshes == false) then
Name = Engine.FNames[BWA.EnemyAttachmentClass.Name]
else
Name = Engine.FNames[BWA.Name]
end
Name = string.sub(Name, 9)
Name = string.sub(Name, 1, string.find(Name, '_') - 1)
Attachments = Name
end
end
end
for Index=1, #BWAData do
BWA = BWAData[Index]
if BWA.Owner then
if (BWA.bCurrentlySelectedAttachment == false) and (#BWA.Owner == #Pawn) then
if Enemy and (BWA.bDontSwapMeshes == false) then
Name = Engine.FNames[BWA.EnemyAttachmentClass.Name]
else
Name = Engine.FNames[BWA.Name]
end
Name = string.sub(Name, 9)
Name = string.sub(Name, 1, string.find(Name, '_') - 1)
if Attachments then
Attachments = Attachments .. ' (' .. Name .. ')'
else
Attachments = '(' .. Name .. ')'
end
end
end
end
if Attachments then
Canvas.SetPos(Screen.X + W + 5, Screen.Y - H + 10)
Canvas.DrawTextClipped(Attachments);
end
end
end
-------------------------------------------------------------------------------
function DrawCorners(Canvas, X, Y, W, H)
local DH = H / 4
local DW = W / 4
if DW < 1 then
DW = 1
end
--Draw the horizontals.
Canvas.SetPos(X, Y)
Canvas.DrawTile(TWhite, DW, 1, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X + W - DW + 1, Y)
Canvas.DrawTile(TWhite, DW, 1, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X, Y + H)
Canvas.DrawTile(TWhite, DW, 1, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X + W - DW + 1, Y + H)
Canvas.DrawTile(TWhite, DW, 1, 0, 0, 2, 2, Canvas.DrawColor)
--Draw the verticals.
if DH > 0 then
Canvas.SetPos(X, Y + 1)
Canvas.DrawTile(TWhite, 1, DH, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X + W, Y + 1)
Canvas.DrawTile(TWhite, 1, DH, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X, Y + H - DH)
Canvas.DrawTile(TWhite, 1, DH, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X + W, Y + H - DH)
Canvas.DrawTile(TWhite, 1, DH, 0, 0, 2, 2, Canvas.DrawColor)
end
end
-------------------------------------------------------------------------------
function DrawRect(Canvas, X, Y, W, H)
Canvas.SetPos(X, Y)
Canvas.DrawTile(TWhite, 1, H, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.DrawTile(TWhite, W, 1, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X, Y+H)
Canvas.DrawTile(TWhite, W+1, 1, 0, 0, 2, 2, Canvas.DrawColor)
Canvas.SetPos(X+W, Y+1)
Canvas.DrawTile(TWhite, 1, H-1, 0, 0, 2, 2, Canvas.DrawColor)
end