2021-05-19 18:09:48 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
2022-07-12 22:42:07 +08:00
|
|
|
#include "util/water.hpp"
|
2021-05-19 18:09:48 +02:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2022-07-12 22:42:07 +08:00
|
|
|
static uint32_t last_bits = 0;
|
|
|
|
static float last_water_collistion_strength = 0;
|
|
|
|
|
|
|
|
void looped::self_godmode()
|
|
|
|
{
|
|
|
|
if (g_local_player == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float* water_collision_ptr = nullptr;
|
|
|
|
if (g_local_player->m_navigation != nullptr)
|
|
|
|
{
|
|
|
|
water_collision_ptr = water::get_water_collision_ptr(g_local_player->m_navigation);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t bits = g->self.proof_mask;
|
|
|
|
uint32_t changed_bits = bits ^ last_bits;
|
|
|
|
uint32_t changed_or_enabled_bits = bits | changed_bits;
|
|
|
|
|
|
|
|
if (changed_or_enabled_bits)
|
|
|
|
{
|
|
|
|
uint32_t unchanged_bits = g_local_player->m_damage_bits & ~changed_or_enabled_bits;
|
|
|
|
g_local_player->m_damage_bits = unchanged_bits | bits;
|
|
|
|
last_bits = bits;
|
|
|
|
|
|
|
|
|
|
|
|
if (changed_or_enabled_bits & (uint32_t)eEntityProofs::WATER)
|
|
|
|
{
|
|
|
|
water::reset_ped_oxygen_time(g_local_player);
|
|
|
|
|
|
|
|
if (water_collision_ptr != nullptr && *water_collision_ptr != 0.f)
|
|
|
|
{
|
|
|
|
last_water_collistion_strength = *water_collision_ptr;
|
|
|
|
*water_collision_ptr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2022-07-02 23:15:22 +08:00
|
|
|
}
|
2021-05-19 18:09:48 +02:00
|
|
|
}
|
2022-07-12 22:42:07 +08:00
|
|
|
|
|
|
|
if (last_water_collistion_strength != 0 && water_collision_ptr != nullptr)
|
|
|
|
{
|
|
|
|
*water_collision_ptr = last_water_collistion_strength;
|
|
|
|
last_water_collistion_strength = 0;
|
|
|
|
}
|
2021-05-19 18:09:48 +02:00
|
|
|
}
|
|
|
|
}
|