This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/backend/looped/self/godmode.cpp
maybegreat48 70efa40afe
Lua Scripting (#1334)
Closes #83
Fixes #1309
Fixes #1287
Fixes #1129 (actually fixed now)
2023-06-06 09:40:40 +02:00

41 lines
1005 B
C++

#include "backend/looped/looped.hpp"
#include "backend/looped_command.hpp"
#include "natives.hpp"
namespace big
{
class godmode_internal : looped_command
{
using looped_command::looped_command;
uint32_t last_bits = 0;
virtual void on_tick() override
{
if (g_local_player == nullptr)
{
return;
}
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;
}
}
virtual void on_disable() override
{
g_local_player->m_damage_bits = 0;
}
};
static bool true_ref = true;
godmode_internal g_godmode_internal("$$godmode", "", "", true_ref);
bool_command g_godmode("godmode", "GODMODE", "GODMODE_DESC", g.self.god_mode);
}