- User ID
- 25934
- Messages
- 326
- Reactions
- 290
- Level
- 40
By Rushensky
Code:
// client.dll 48 8B C4 4C 89 40 18 48 89 48 08 55 53 57
class origin_wrapper
{
public:
Vector origin; //0x0000
};
class sound_data
{
public:
char pad_0000[8]; //0x0000
char *sound_name; //0x0008
char pad_0010[16]; //0x0010
class origin_wrapper *get_origin; //0x0020
};
using sound_t = DWORD * (__fastcall*)(void *, DWORD *, int, int, sound_data*);
DWORD *__fastcall hooked_sound(void *sound_patch, DWORD *a2, int a3, int a4, sound_data *data)
{
auto ret = ((sound_t)hooks[hook::sound].m_orig)(sound_patch, a2, a3, entity_index, data);
if (data)
{
auto get_origin = data->get_origin;
if (get_origin)
{
my_sound_t sound;
sound.origin = get_origin->origin;
sound.timestamp = g_game->m_globalvars->m_curtime;
g_game->m_my_sound.push_back(sound);
}
}
return ret;
}
Code:
struct my_sound_t
{
Vector origin;
const char* name;
float timestamp;
};
using my_sound_deq = std::deque<my_sound_t>;
...
my_sound_deq m_my_sound;
Render part:
while (g_game->m_my_sound.size() && static_cast<float>(g_game->m_globalvars->m_curtime) -
g_game->m_my_sound.front().timestamp >= 1.0f)
g_game->m_my_sound.pop_front();
for (auto& sound : g_game->m_my_sound)
{
if (!strstr(sound.name, "Step"))
continue;
if (sound.origin.IsZero())
continue;
static auto step = IM_PI * 0.075f;
auto prev_point = Vector();
for (float lat = 0.f; lat <= IM_PI * 3.f; lat += step)
{
const auto sin1 = sinf(lat);
const auto cos1 = cosf(lat);
const auto sin3 = sinf(0);
const auto cos3 = cosf(0);
const auto point1 = Vector(sin1 * cos3, cos1, sin1 * sin3) * 15.0f;
const auto point3 = sound.origin + point1;
Vector point, prev;
if (world_to_screen(point3, point) && world_to_screen(prev_point, prev) && lat > 0.f)
g_renderer->add_line(ImVec2(prev[0], prev[1]), ImVec2(point[0], point[1]), IM_COL32_WHITE);
prev_point = point3;
}
}
You must be registered for see links