-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas.cpp
394 lines (375 loc) · 13.1 KB
/
canvas.cpp
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
#include "canvas.h"
extern SDK* sdk;
void DrawFilledRect(int x, int y, int width, int height, D3DCOLOR color) {
D3DRECT rect = {
x,
y,
x + width,
y + height
};
pDevice->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
}
void DrawLine(int src_x, int src_y, int dst_x, int dst_y, int thickness, D3DCOLOR color) {
if (!sdk->LineL) D3DXCreateLine(pDevice, &sdk->LineL);
D3DXVECTOR2 Line[2];
Line[0] = D3DXVECTOR2(src_x, src_y);
Line[1] = D3DXVECTOR2(dst_x, dst_y);
sdk->LineL->SetWidth(thickness);
sdk->LineL->Draw(Line, 2, color);
}
void DrawLine(Vec2 src, Vec2 dst, int thickness, D3DCOLOR color) {
DrawLine(src.x, src.y, dst.x, dst.y, thickness, color);
}
void DrawBoneLine(Ent* ent, int from_bone, int to_bone) {
D3DCOLOR color = sdk->colors.color_bones;
// if (ent->is_c4_owner) color = D3DCOLOR_ARGB(255, 135, 98, 208);
if (ent->m_flFlashDuration > 0) color = sdk->colors.color_white;
Vec3 from_bone_pos_3d = sdk->get_bone_pos(ent, from_bone);
Vec3 to_bone_pos_3d = sdk->get_bone_pos(ent, to_bone);
Vec2 from_bone_pos_2d, to_bone_pos_2d;
if (W2S(from_bone_pos_3d, from_bone_pos_2d) && W2S(to_bone_pos_3d, to_bone_pos_2d)) {
//DrawLine(from_bone_pos_2d.x, from_bone_pos_2d.y, to_bone_pos_2d.x, to_bone_pos_2d.y, 2, color);
DrawLine(from_bone_pos_2d, to_bone_pos_2d, 2, color);
}
}
void DrawBoneIDs(Ent* ent) {
for (int i = 0; i < 128; i++) {
Vec2 bone_pos_2d;
if (W2S(sdk->get_bone_pos(ent, i), bone_pos_2d)) {
DrawText(std::to_string(i).c_str(), bone_pos_2d.x, bone_pos_2d.y, sdk->colors.color_white);
}
}
}
void DrawBoneEsp(Ent* ent) {
//char name[128];
//strcpy_s(name, (char*) (*(uintptr_t*) ((uintptr_t) ent + 0x6C) + 0x04));
//char* model_name = &name[35];
char* model_name = &((char*) (*(uintptr_t*) ((uintptr_t) ent + 0x6c) + 0x4))[35];
/********** Special Models **********/
if (strstr(model_name, "ctm_st6_variante")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 0, 69);
DrawBoneLine(ent, 69, 70);
DrawBoneLine(ent, 0, 76);
DrawBoneLine(ent, 76, 77);
}
/************************************/
else if (strstr(model_name, "ctm_idf")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 7, 41);
DrawBoneLine(ent, 41, 42);
DrawBoneLine(ent, 42, 43);
DrawBoneLine(ent, 0, 71);
DrawBoneLine(ent, 71, 72);
DrawBoneLine(ent, 0, 78);
DrawBoneLine(ent, 78, 79);
} else if (strstr(model_name, "tm_leet")) {
sdk->colors.color_bones = sdk->colors.color_t;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 7, 39);
DrawBoneLine(ent, 39, 65);
DrawBoneLine(ent, 65, 41);
DrawBoneLine(ent, 0, 79);
DrawBoneLine(ent, 79, 75);
DrawBoneLine(ent, 0, 72);
DrawBoneLine(ent, 72, 68);
} else if (strstr(model_name, "ctm_sas")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 40);
DrawBoneLine(ent, 40, 41);
DrawBoneLine(ent, 41, 42);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 0, 82);
DrawBoneLine(ent, 82, 83);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
} else if (strstr(model_name, "tm_separatist")) {
sdk->colors.color_bones = sdk->colors.color_t;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
DrawBoneLine(ent, 0, 66);
DrawBoneLine(ent, 66, 67);
} else if (strstr(model_name, "tm_professional")) {
sdk->colors.color_bones = sdk->colors.color_t;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 40, 41);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 0, 78);
DrawBoneLine(ent, 78, 79);
DrawBoneLine(ent, 0, 71);
DrawBoneLine(ent, 71, 72);
} else if (strstr(model_name, "ctm_fbi")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 40, 41);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 0, 72);
DrawBoneLine(ent, 72, 73);
DrawBoneLine(ent, 0, 81);
DrawBoneLine(ent, 81, 82);
} else if (strstr(model_name, "ctm_st6")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
DrawBoneLine(ent, 0, 66);
DrawBoneLine(ent, 66, 67);
} else if (strstr(model_name, "ctm_swat")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 13, 14);
DrawBoneLine(ent, 7, 40);
DrawBoneLine(ent, 40, 41);
DrawBoneLine(ent, 41, 42);
DrawBoneLine(ent, 0, 68);
DrawBoneLine(ent, 68, 69);
DrawBoneLine(ent, 0, 75);
DrawBoneLine(ent, 75, 76);
} else if (strstr(model_name, "tm_phoenix")) {
sdk->colors.color_bones = sdk->colors.color_t;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
DrawBoneLine(ent, 0, 66);
DrawBoneLine(ent, 66, 67);
} else if (strstr(model_name, "ctm_gign")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 12, 13);
DrawBoneLine(ent, 7, 40);
DrawBoneLine(ent, 40, 41);
DrawBoneLine(ent, 41, 42);
DrawBoneLine(ent, 0, 77);
DrawBoneLine(ent, 77, 78);
DrawBoneLine(ent, 0, 70);
DrawBoneLine(ent, 70, 71);
} else if (strstr(model_name, "tm_balkan")) {
sdk->colors.color_bones = sdk->colors.color_t;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
DrawBoneLine(ent, 0, 66);
DrawBoneLine(ent, 66, 67);
} else if (strstr(model_name, "ctm_gsg9")) {
sdk->colors.color_bones = sdk->colors.color_ct;
DrawBoneLine(ent, 8, 7);
DrawBoneLine(ent, 7, 0);
DrawBoneLine(ent, 7, 10);
DrawBoneLine(ent, 10, 11);
DrawBoneLine(ent, 11, 12);
DrawBoneLine(ent, 7, 38);
DrawBoneLine(ent, 38, 39);
DrawBoneLine(ent, 39, 40);
DrawBoneLine(ent, 0, 73);
DrawBoneLine(ent, 73, 74);
DrawBoneLine(ent, 0, 66);
DrawBoneLine(ent, 66, 67);
}
}
void DrawMenuText(const char* text, float x, float y, int height, D3DCOLOR color, DWORD format) {
RECT rect;
SetRect(&rect, x, y, x, y);
//D3DXCreateFontW(
// LPDIRECT3DDEVICE9 pDevice,
// INT Height,
// UINT Width,
// UINT Weight,
// UINT MipLevels,
// BOOL Italic,
// DWORD CharSet,
// DWORD OutputPrecision,
// DWORD Quality,
// DWORD PitchAndFamily,
// LPCWSTR pFaceName,
// LPD3DXFONT * ppFont);
if (!sdk->FontF)
D3DXCreateFont(pDevice, height, 0,
FW_MEDIUM, 1, false,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
MONO_FONT | FF_DONTCARE, L"Fira Code", &sdk->FontF);
//STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
sdk->FontF->DrawTextA(NULL, text, -1, &rect, format | DT_NOCLIP, color);
}
void DrawText(const char* text, float x, float y, D3DCOLOR color, bool contrast) {
RECT rect;
//D3DXCreateFontW(
// LPDIRECT3DDEVICE9 pDevice,
// INT Height,
// UINT Width,
// UINT Weight,
// UINT MipLevels,
// BOOL Italic,
// DWORD CharSet,
// DWORD OutputPrecision,
// DWORD Quality,
// DWORD PitchAndFamily,
// LPCWSTR pFaceName,
// LPD3DXFONT * ppFont);
if (!sdk->FontF)
D3DXCreateFont(pDevice, 14, 0, FW_MEDIUM, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, MONO_FONT | FF_DONTCARE, L"Fira Code", &sdk->FontF);
if (contrast) {
SetRect(&rect, x + 1, y + 1, x + 1, y + 1);
sdk->FontF->DrawTextA(NULL, text, -1, &rect, DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 0, 0, 0));
}
SetRect(&rect, x, y, x, y);
sdk->FontF->DrawTextA(NULL, text, -1, &rect, DT_CENTER | DT_NOCLIP, color);
}
void DrawText(const char* prefix, int text, float x, float y, D3DCOLOR color, bool contrast) {
std::stringstream ss_text;
ss_text << text;
std::string s_text = prefix + ss_text.str();
char* msg_text = (char*) s_text.c_str();
RECT rect;
if (!sdk->FontF)
D3DXCreateFont(pDevice, 14, 0, FW_MEDIUM, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, MONO_FONT | FF_DONTCARE, L"Fira Code", &sdk->FontF);
if (contrast) {
SetRect(&rect, x + 1, y + 1, x + 1, y + 1);
sdk->FontF->DrawTextA(NULL, msg_text, -1, &rect, DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 0, 0, 0));
}
SetRect(&rect, x, y, x, y);
sdk->FontF->DrawTextA(NULL, msg_text, -1, &rect, DT_CENTER | DT_NOCLIP, color);
}
void DrawText(const char* prefix, float text, float x, float y, D3DCOLOR color, bool contrast) {
std::stringstream ss_text;
ss_text << text;
std::string s_text = prefix + ss_text.str();
char* msg_text = (char*) s_text.c_str();
RECT rect;
if (!sdk->FontF)
D3DXCreateFont(pDevice, 14, 0, FW_MEDIUM, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, MONO_FONT | FF_DONTCARE, L"Fira Code", &sdk->FontF);
if (contrast) {
SetRect(&rect, x + 1, y + 1, x + 1, y + 1);
sdk->FontF->DrawTextA(NULL, msg_text, -1, &rect, DT_CENTER | DT_NOCLIP, D3DCOLOR_ARGB(255, 0, 0, 0));
}
SetRect(&rect, x, y, x, y);
sdk->FontF->DrawTextA(NULL, msg_text, -1, &rect, DT_CENTER | DT_NOCLIP, color);
}
void DrawHeadBox2D(const Vec2& ent_head, Vec2 top, Vec2 bottom, int thickness, D3DCOLOR color) {
int height = static_cast<int>(std::abs(top.y - bottom.y));
Vec2 top_left, top_right;
Vec2 bottom_left, bottom_right;
top_left.x = top.x - static_cast<float>(height);
top_left.y = top.y;
top_right.x = top.x + static_cast<float>(height);
top_right.y = top.y;
bottom_left.x = bottom.x - static_cast<float>(height);
bottom_left.y = bottom.y;
bottom_right.x = bottom.x + static_cast<float>(height);
bottom_right.y = bottom.y;
DrawLine(top_left, top_right, thickness, color);
DrawLine(top_right, bottom_right, thickness, color);
DrawLine(bottom_right, bottom_left, thickness, color);
DrawLine(bottom_left, top_left, thickness, color);
}
void DrawHeadBox3D(Vec3 top, Vec3 bottom, float angle, int width, int thickness, D3DCOLOR color) {
int height3D = std::abs(top.z - bottom.z);
Vec3 b1, b2, b3, b4, t1, t2, t3, t4;
b1.x = bottom.x + (cos(TORAD(angle + 45)) * width / 2);
b1.y = bottom.y + (sin(TORAD(angle + 45)) * width / 2);
b1.z = bottom.z;
b2.x = bottom.x + (cos(TORAD(angle + 135)) * width / 2);
b2.y = bottom.y + (sin(TORAD(angle + 135)) * width / 2);
b2.z = bottom.z;
b3.x = bottom.x + (cos(TORAD(angle + 225)) * width / 2);
b3.y = bottom.y + (sin(TORAD(angle + 225)) * width / 2);
b3.z = bottom.z;
b4.x = bottom.x + (cos(TORAD(angle + 315)) * width / 2);
b4.y = bottom.y + (sin(TORAD(angle + 315)) * width / 2);
b4.z = bottom.z;
t1.x = b1.x;
t1.y = b1.y;
t1.z = b1.z + height3D;
t2.x = b2.x;
t2.y = b2.y;
t2.z = b2.z + height3D;
t3.x = b3.x;
t3.y = b3.y;
t3.z = b3.z + height3D;
t4.x = b4.x;
t4.y = b4.y;
t4.z = b4.z + height3D;
Vec2 b1_2, b2_2, b3_2, b4_2, t1_2, t2_2, t3_2, t4_2;
if (W2S(b1, b1_2) && W2S(b2, b2_2) && W2S(b3, b3_2) && W2S(b4, b4_2) && W2S(t1, t1_2) && W2S(t2, t2_2) && W2S(t3, t3_2) && W2S(t4, t4_2)) {
// Vertical lines.
DrawLine(t1_2, b1_2, thickness, color);
DrawLine(t2_2, b2_2, thickness, color);
DrawLine(t3_2, b3_2, thickness, color);
DrawLine(t4_2, b4_2, thickness, color);
// Horizontal lines, lid.
DrawLine(t1_2, t2_2, thickness, color);
DrawLine(t2_2, t3_2, thickness, color);
DrawLine(t3_2, t4_2, thickness, color);
DrawLine(t4_2, t1_2, thickness, color);
// Horizontal lines, base.
DrawLine(b1_2, b2_2, thickness, color);
DrawLine(b2_2, b3_2, thickness, color);
DrawLine(b3_2, b4_2, thickness, color);
DrawLine(b4_2, b1_2, thickness, color);
}
}