Added NodeESP

This commit is contained in:
Elias Fleckenstein 2020-11-05 10:57:31 +01:00
parent 75ecaa2173
commit 1f56317d5f
11 changed files with 110 additions and 47 deletions

View File

@ -27,6 +27,8 @@ core.cheats = {
["Coords"] = "coords",
["Tracers"] = "enable_tracers",
["ESP"] = "enable_esp",
["NodeTracers"] = "enable_node_tracers",
["NodeESP"] = "enable_node_esp",
["CheatHUD"] = "cheat_hud",
},
["World"] = {

View File

@ -1 +1,2 @@
core.register_list_command("xray", "Configure X-Ray", "xray_nodes")
core.register_list_command("search", "Configure NodeESP", "node_esp_nodes")

View File

@ -2345,3 +2345,9 @@ forcefield (Forcefield) bool false
friendlist (Killaura / Forcefield Friendlist) string
cheat_hud (CheatHUD) bool true
enable_node_esp (NodeESP) bool false
enable_node_tracers (NodeTracers) bool false
node_esp_nodes (NodeESP Nodes) string

View File

@ -3194,7 +3194,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
}
#endif
RenderingEngine::draw_scene(skycolor, m_game_ui->m_flags.show_hud,
m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_tracers"), g_settings->getBool("enable_esp"));
m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_esp"), g_settings->getBool("enable_tracers"), g_settings->getBool("enable_node_esp"), g_settings->getBool("enable_node_tracers"));
/*
Profiler graph

View File

@ -818,9 +818,10 @@ static void getTileInfo(
u16 *lights,
u8 &waving,
TileSpec &tile,
// lol more Input
bool xray,
std::set<content_t> xraySet
)
std::set<content_t> xraySet,
std::set<content_t> nodeESPSet)
{
VoxelManipulator &vmanip = data->m_vmanip;
const NodeDefManager *ndef = data->m_client->ndef();
@ -831,7 +832,8 @@ static void getTileInfo(
content_t c0 = n0.getContent();
if (xray && xraySet.find(c0) != xraySet.end())
c0 = CONTENT_AIR;
if (nodeESPSet.find(c0) != nodeESPSet.end())
data->m_esp_nodes.insert(blockpos_nodes + p);
// Don't even try to get n1 if n0 is already CONTENT_IGNORE
if (c0 == CONTENT_IGNORE) {
makes_face = false;
@ -909,7 +911,8 @@ static void updateFastFaceRow(
const v3s16 &&face_dir,
std::vector<FastFace> &dest,
bool xray,
std::set<content_t> xraySet)
std::set<content_t> xraySet,
std::set<content_t> nodeESPSet)
{
static thread_local const bool waving_liquids =
g_settings->getBool("enable_shaders") &&
@ -929,7 +932,7 @@ static void updateFastFaceRow(
// Get info of first tile
getTileInfo(data, p, face_dir,
makes_face, p_corrected, face_dir_corrected,
lights, waving, tile, xray, xraySet);
lights, waving, tile, xray, xraySet, nodeESPSet);
// Unroll this variable which has a significant build cost
TileSpec next_tile;
@ -946,15 +949,16 @@ static void updateFastFaceRow(
// the face must be drawn anyway
if (j != MAP_BLOCKSIZE - 1) {
p += translate_dir;
getTileInfo(data, p, face_dir,
next_makes_face, next_p_corrected,
next_face_dir_corrected, next_lights,
waving,
next_tile,
xray,
xraySet);
xraySet,
nodeESPSet);
if (next_makes_face == makes_face
&& next_p_corrected == p_corrected + translate_dir
&& next_face_dir_corrected == face_dir_corrected
@ -1003,7 +1007,7 @@ static void updateFastFaceRow(
}
static void updateAllFastFaceRows(MeshMakeData *data,
std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet)
std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet, std::set<content_t> nodeESPSet)
{
/*
Go through every y,z and get top(y+) faces in rows of x+
@ -1017,7 +1021,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
v3s16(0, 1, 0), //face dir
dest,
xray,
xraySet);
xraySet,
nodeESPSet);
/*
Go through every x,y and get right(x+) faces in rows of z+
@ -1031,7 +1036,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
v3s16(1, 0, 0), //face dir
dest,
xray,
xraySet);
xraySet,
nodeESPSet);
/*
Go through every y,z and get back(z+) faces in rows of x+
@ -1045,7 +1051,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
v3s16(0, 0, 1), //face dir
dest,
xray,
xraySet);
xraySet,
nodeESPSet);
}
static void applyTileColor(PreMeshBuffer &pmb)
@ -1096,10 +1103,12 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
X-Ray
*/
bool xray = g_settings->getBool("xray");
std::set<content_t> xraySet;
std::set<content_t> xraySet, nodeESPSet;
if (xray)
xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef());
nodeESPSet = splitToContentT(g_settings->get("node_esp_nodes"), data->m_client->ndef());
/*
We are including the faces of the trailing edges of the block.
This means that when something changes, the caller must
@ -1110,7 +1119,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
{
// 4-23ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated)
//TimeTaker timer2("updateAllFastFaceRows()");
updateAllFastFaceRows(data, fastfaces_new, xray, xraySet);
updateAllFastFaceRows(data, fastfaces_new, xray, xraySet, nodeESPSet);
}
// End of slow part
@ -1296,6 +1305,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
!m_crack_materials.empty() ||
!m_daynight_diffs.empty() ||
!m_animation_tiles.empty();
esp_nodes = data->m_esp_nodes;
}
MapBlockMesh::~MapBlockMesh()

View File

@ -46,6 +46,7 @@ struct MeshMakeData
Client *m_client;
bool m_use_shaders;
bool m_use_tangent_vertices;
std::set<v3s16> m_esp_nodes;
MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices = false);
@ -134,6 +135,8 @@ public:
void updateCameraOffset(v3s16 camera_offset);
std::set<v3s16> esp_nodes;
private:
scene::IMesh *m_mesh[MAX_TILE_LAYERS];
MinimapMapblock *m_minimap_mapblock;

View File

@ -26,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/hud.h"
#include "client/minimap.h"
#include "client/content_cao.h"
#include "mapblock.h"
#include "mapsector.h"
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
: device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),
@ -55,7 +57,7 @@ void RenderingCore::updateScreenSize()
}
void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap,
bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp)
bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp, bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers)
{
v2u32 ss = driver->getScreenSize();
if (screensize != ss) {
@ -67,8 +69,10 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min
show_minimap = _show_minimap;
draw_wield_tool = _draw_wield_tool;
draw_crosshair = _draw_crosshair;
draw_tracers = _draw_tracers;
draw_esp = _draw_esp;
draw_tracers = _draw_tracers;
draw_node_esp = _draw_node_esp;
draw_node_tracers = _draw_node_tracers;
beforeDraw();
drawAll();
@ -91,26 +95,58 @@ void RenderingCore::drawTracersAndESP()
material.setFlag(video::EMF_ZWRITE_ENABLE, false);
driver->setMaterial(material);
auto allObjects = env.getAllActiveObjects();
for (auto &it : allObjects) {
ClientActiveObject *cao = it.second;
if (cao->isLocalPlayer() || cao->getParent())
continue;
GenericCAO *obj = dynamic_cast<GenericCAO *>(cao);
if (! obj)
continue;
aabb3f box;
if (! obj->getSelectionBox(&box))
continue;
v3f pos = obj->getPosition();
pos -= camera_offset;
box.MinEdge += pos;
box.MaxEdge += pos;
pos = box.getCenter();
if (draw_esp)
driver->draw3DBox(box, video::SColor(255, 255, 255, 255));
if (draw_tracers)
driver->draw3DLine(eye_pos, pos, video::SColor(255, 255, 255, 255));
if (draw_esp || draw_tracers) {
auto allObjects = env.getAllActiveObjects();
for (auto &it : allObjects) {
ClientActiveObject *cao = it.second;
if (cao->isLocalPlayer() || cao->getParent())
continue;
GenericCAO *obj = dynamic_cast<GenericCAO *>(cao);
if (! obj)
continue;
aabb3f box;
if (! obj->getSelectionBox(&box))
continue;
v3f pos = obj->getPosition() - camera_offset;
box.MinEdge += pos;
box.MaxEdge += pos;
if (draw_esp)
driver->draw3DBox(box, video::SColor(255, 255, 255, 255));
if (draw_tracers)
driver->draw3DLine(eye_pos, box.getCenter(), video::SColor(255, 255, 255, 255));
}
}
if (draw_node_esp || draw_node_tracers) {
Map &map = env.getMap();
std::map<v2s16, MapSector*> *sectors = map.getSectorsPtr();
for (auto &sector_it : *sectors) {
MapSector *sector = sector_it.second;
MapBlockVect blocks;
sector->getBlocks(blocks);
for (MapBlock *block : blocks) {
if (! block->mesh)
continue;
for (v3s16 p : block->mesh->esp_nodes) {
v3f pos = intToFloat(p, BS) - camera_offset;
MapNode node = map.getNode(p);
std::vector<aabb3f> boxes;
node.getSelectionBoxes(client->getNodeDefManager(), &boxes, node.getNeighbors(p, &map));
video::SColor color = client->getNodeDefManager()->get(node).minimap_color;
for (aabb3f box : boxes) {
box.MinEdge += pos;
box.MaxEdge += pos;
if (draw_node_esp)
driver->draw3DBox(box, color);
if (draw_node_tracers)
driver->draw3DLine(eye_pos, box.getCenter(), color);
}
}
}
}
}
driver->setMaterial(oldmaterial);
@ -123,7 +159,7 @@ void RenderingCore::draw3D()
if (!show_hud)
return;
hud->drawSelectionMesh();
if (draw_tracers || draw_esp)
if (draw_esp || draw_tracers || draw_node_esp || draw_node_tracers)
drawTracersAndESP();
if (draw_wield_tool)
camera->drawWieldedTool();

View File

@ -36,8 +36,10 @@ protected:
bool show_minimap;
bool draw_wield_tool;
bool draw_crosshair;
bool draw_tracers;
bool draw_esp;
bool draw_tracers;
bool draw_node_esp;
bool draw_node_tracers;
IrrlichtDevice *device;
video::IVideoDriver *driver;
@ -72,8 +74,8 @@ public:
void initialize();
void draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap,
bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers,
bool _draw_esp);
bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp,
bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers);
inline v2u32 getVirtualSize() const { return virtual_size; }
};

View File

@ -604,9 +604,9 @@ void RenderingEngine::_finalize()
}
void RenderingEngine::_draw_scene(video::SColor skycolor, bool show_hud,
bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers)
{
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers);
}
const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type)

View File

@ -32,7 +32,6 @@ class Client;
class LocalPlayer;
class Hud;
class Minimap;
class Tracers;
class RenderingCore;
@ -118,10 +117,10 @@ public:
}
inline static void draw_scene(video::SColor skycolor, bool show_hud,
bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers)
{
s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers);
}
inline static void initialize(Client *client, Hud *hud)
@ -149,7 +148,7 @@ private:
bool clouds = true);
void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap,
bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp);
bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers);
void _initialize(Client *client, Hud *hud);

View File

@ -131,6 +131,9 @@ void set_default_settings(Settings *settings)
settings->setDefault("forcefield", "false");
settings->setDefault("friendlist", "");
settings->setDefault("cheat_hud", "true");
settings->setDefault("enable_node_esp", "false");
settings->setDefault("enable_node_tracers", "false");
settings->setDefault("node_esp_nodes", "");
// Keymap
settings->setDefault("remote_port", "30000");