Added ESP, fixed Tracers, improved Jesus

This commit is contained in:
Elias Fleckenstein 2020-10-05 18:41:10 +02:00
parent ee88f4b94f
commit faa32610e3
27 changed files with 99 additions and 140 deletions

View File

@ -22,6 +22,7 @@ core.cheats = {
["BrightNight"] = "no_night",
["Coords"] = "coords",
["Tracers"] = "enable_tracers",
["ESP"] = "enable_esp",
},
["World"] = {
["FastDig"] = "fastdig",

View File

@ -2271,4 +2271,6 @@ no_force_rotate (NoForceRotate) bool false
enable_tracers (Tracers) bool false
enable_esp (ESP) bool false
no_slow (NoSlow) bool false

View File

@ -44,7 +44,6 @@ public:
virtual void updateLight(u32 day_night_ratio) {}
virtual bool isItem() const { return false; }
virtual bool getCollisionBox(aabb3f *toset) const { return false; }
virtual bool getSelectionBox(aabb3f *toset) const { return false; }
virtual bool collideWithObjects() const { return false; }

View File

@ -215,8 +215,6 @@ public:
m_is_visible = toset;
}
bool isItem() const { return m_prop.visual == "wielditem" || m_prop.visual == "item"; }
void setChildrenVisible(bool toset);
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
void getAttachment(int *parent_id, std::string *bone, v3f *position,

View File

@ -228,7 +228,7 @@ bool Game::startup(bool *kill,
if (!createClient(start_data))
return false;
RenderingEngine::initialize(client, hud, m_tracers);
RenderingEngine::initialize(client, hud);
return true;
}
@ -348,9 +348,6 @@ void Game::shutdown()
if (m_cheat_menu)
delete m_cheat_menu;
if (m_tracers)
delete m_tracers;
if (sky)
sky->drop();
@ -626,14 +623,6 @@ bool Game::initGui()
errorstream << *error_message << std::endl;
return false;
}
m_tracers = new Tracers();
if (!m_tracers) {
*error_message = "Could not allocate memory for tracers";
errorstream << *error_message << std::endl;
return false;
}
#ifdef HAVE_TOUCHSCREENGUI
@ -3196,7 +3185,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"));
m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_tracers"), g_settings->getBool("enable_esp"));
/*
Profiler graph

View File

@ -50,7 +50,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gui/guiVolumeChange.h"
#include "gui/mainmenumanager.h"
#include "gui/profilergraph.h"
#include "gui/tracers.h"
#include "mapblock.h"
#include "minimap.h"
#include "nodedef.h" // Needed for determining pointing to nodes
@ -869,7 +868,6 @@ public:
std::unique_ptr<GameUI> m_game_ui;
GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop()
CheatMenu *m_cheat_menu = nullptr;
Tracers *m_tracers = nullptr;
MapDrawControl *draw_control = nullptr;
Camera *camera = nullptr;
Clouds *clouds = nullptr; // Free using ->Drop()

View File

@ -301,7 +301,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime,
&position, &m_speed, accel_f);
&position, &m_speed, accel_f, NULL, true, true);
bool could_sneak = control.sneak && !free_move && !in_liquid &&
!is_climbing && physics_override_sneak;
@ -923,7 +923,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime,
&position, &m_speed, accel_f);
&position, &m_speed, accel_f, NULL, true, true);
// Positition was slightly changed; update standing node pos
if (touching_ground)
@ -1175,7 +1175,7 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
// try at peak of jump, zero step height
collisionMoveResult jump_result = collisionMoveSimple(env, m_client, pos_max_d,
m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f));
m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f), NULL, true, true);
// see if we can get a little bit farther horizontally if we had
// jumped

View File

@ -18,18 +18,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <iostream>
#include "core.h"
#include "client/camera.h"
#include "client/client.h"
#include "client/clientmap.h"
#include "client/hud.h"
#include "client/minimap.h"
#include "gui/tracers.h"
#include "client/content_cao.h"
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
: device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),
guienv(device->getGUIEnvironment()), client(_client), camera(client->getCamera()),
mapper(client->getMinimap()), hud(_hud), tracers(_tracers)
mapper(client->getMinimap()), hud(_hud)
{
screensize = driver->getScreenSize();
virtual_size = screensize;
@ -54,7 +55,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_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp)
{
v2u32 ss = driver->getScreenSize();
if (screensize != ss) {
@ -67,23 +68,63 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min
draw_wield_tool = _draw_wield_tool;
draw_crosshair = _draw_crosshair;
draw_tracers = _draw_tracers;
draw_esp = _draw_esp;
beforeDraw();
drawAll();
}
void RenderingCore::drawTracersAndESP()
{
ClientEnvironment &env = client->getEnv();
Camera *camera = client->getCamera();
v3f camera_offset = intToFloat(camera->getOffset(), BS);
v3f eye_pos = (camera->getPosition() + camera->getDirection() - camera_offset);
video::SMaterial material, oldmaterial;
oldmaterial = driver->getMaterial2D();
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setFlag(video::EMF_ZBUFFER, false);
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));
}
driver->setMaterial(oldmaterial);
}
void RenderingCore::draw3D()
{
smgr->drawAll();
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (!show_hud)
return;
hud->drawSelectionMesh();
if (draw_tracers) {
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
tracers->draw(driver, client);
}
if (draw_tracers || draw_esp)
drawTracersAndESP();
if (draw_wield_tool)
camera->drawWieldedTool();
}

View File

@ -25,7 +25,6 @@ class Camera;
class Client;
class Hud;
class Minimap;
class Tracers;
class RenderingCore
{
@ -38,6 +37,7 @@ protected:
bool draw_wield_tool;
bool draw_crosshair;
bool draw_tracers;
bool draw_esp;
IrrlichtDevice *device;
video::IVideoDriver *driver;
@ -48,8 +48,7 @@ protected:
Camera *camera;
Minimap *mapper;
Hud *hud;
Tracers *tracers;
void updateScreenSize();
virtual void initTextures() {}
virtual void clearTextures() {}
@ -57,12 +56,13 @@ protected:
virtual void beforeDraw() {}
virtual void drawAll() = 0;
void drawTracersAndESP();
void draw3D();
void drawHUD();
void drawPostFx();
public:
RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud);
RenderingCore(const RenderingCore &) = delete;
RenderingCore(RenderingCore &&) = delete;
virtual ~RenderingCore();
@ -72,7 +72,7 @@ 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_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp);
inline v2u32 getVirtualSize() const { return virtual_size; }
};

View File

@ -27,23 +27,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "sidebyside.h"
RenderingCore *createRenderingCore(const std::string &stereo_mode, IrrlichtDevice *device,
Client *client, Hud *hud, Tracers *tracers)
Client *client, Hud *hud)
{
if (stereo_mode == "none")
return new RenderingCorePlain(device, client, hud, tracers);
return new RenderingCorePlain(device, client, hud);
if (stereo_mode == "anaglyph")
return new RenderingCoreAnaglyph(device, client, hud, tracers);
return new RenderingCoreAnaglyph(device, client, hud);
if (stereo_mode == "interlaced")
return new RenderingCoreInterlaced(device, client, hud, tracers);
return new RenderingCoreInterlaced(device, client, hud);
#ifdef STEREO_PAGEFLIP_SUPPORTED
if (stereo_mode == "pageflip")
return new RenderingCorePageflip(device, client, hud, tracers);
return new RenderingCorePageflip(device, client, hud);
#endif
if (stereo_mode == "sidebyside")
return new RenderingCoreSideBySide(device, client, hud, tracers);
return new RenderingCoreSideBySide(device, client, hud);
if (stereo_mode == "topbottom")
return new RenderingCoreSideBySide(device, client, hud, tracers, true);
return new RenderingCoreSideBySide(device, client, hud, true);
if (stereo_mode == "crossview")
return new RenderingCoreSideBySide(device, client, hud, tracers, false, true);
return new RenderingCoreSideBySide(device, client, hud, false, true);
throw std::invalid_argument("Invalid rendering mode: " + stereo_mode);
}

View File

@ -24,4 +24,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "core.h"
RenderingCore *createRenderingCore(const std::string &stereo_mode, IrrlichtDevice *device,
Client *client, Hud *hud, Tracers *tracers);
Client *client, Hud *hud);

View File

@ -24,8 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/tile.h"
RenderingCoreInterlaced::RenderingCoreInterlaced(
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: RenderingCoreStereo(_device, _client, _hud, _tracers)
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCoreStereo(_device, _client, _hud)
{
initMaterial();
}

View File

@ -38,6 +38,6 @@ protected:
void merge();
public:
RenderingCoreInterlaced(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
RenderingCoreInterlaced(IrrlichtDevice *_device, Client *_client, Hud *_hud);
void drawAll() override;
};

View File

@ -27,8 +27,8 @@ inline u32 scaledown(u32 coef, u32 size)
}
RenderingCorePlain::RenderingCorePlain(
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: RenderingCore(_device, _client, _hud, _tracers)
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCore(_device, _client, _hud)
{
scale = g_settings->getU16("undersampling");
}

View File

@ -33,6 +33,6 @@ protected:
void upscale();
public:
RenderingCorePlain(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
RenderingCorePlain(IrrlichtDevice *_device, Client *_client, Hud *_hud);
void drawAll() override;
};

View File

@ -23,8 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/hud.h"
RenderingCoreSideBySide::RenderingCoreSideBySide(
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers, bool _horizontal, bool _flipped)
: RenderingCoreStereo(_device, _client, _hud, _tracers), horizontal(_horizontal), flipped(_flipped)
IrrlichtDevice *_device, Client *_client, Hud *_hud, bool _horizontal, bool _flipped)
: RenderingCoreStereo(_device, _client, _hud), horizontal(_horizontal), flipped(_flipped)
{
}

View File

@ -37,7 +37,7 @@ protected:
void resetEye() override;
public:
RenderingCoreSideBySide(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers,
RenderingCoreSideBySide(IrrlichtDevice *_device, Client *_client, Hud *_hud,
bool _horizontal = false, bool _flipped = false);
void drawAll() override;
};

View File

@ -24,8 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
RenderingCoreStereo::RenderingCoreStereo(
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: RenderingCore(_device, _client, _hud, _tracers)
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCore(_device, _client, _hud)
{
eye_offset = BS * g_settings->getFloat("3d_paralax_strength");
}

View File

@ -34,5 +34,5 @@ protected:
void renderBothImages();
public:
RenderingCoreStereo(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
RenderingCoreStereo(IrrlichtDevice *_device, Client *_client, Hud *_hud);
};

View File

@ -591,10 +591,10 @@ std::vector<irr::video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers
return drivers;
}
void RenderingEngine::_initialize(Client *client, Hud *hud, Tracers *tracers)
void RenderingEngine::_initialize(Client *client, Hud *hud)
{
const std::string &draw_mode = g_settings->get("3d_mode");
core.reset(createRenderingCore(draw_mode, m_device, client, hud, tracers));
core.reset(createRenderingCore(draw_mode, m_device, client, hud));
core->initialize();
}
@ -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 show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
{
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_tracers);
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
}
const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type)

View File

@ -118,15 +118,15 @@ 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 show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
{
s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
draw_wield_tool, draw_crosshair, draw_tracers);
draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
}
inline static void initialize(Client *client, Hud *hud, Tracers *tracers)
inline static void initialize(Client *client, Hud *hud)
{
s_singleton->_initialize(client, hud, tracers);
s_singleton->_initialize(client, hud);
}
inline static void finalize() { s_singleton->_finalize(); }
@ -149,9 +149,9 @@ 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_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp);
void _initialize(Client *client, Hud *hud, Tracers *tracers);
void _initialize(Client *client, Hud *hud);
void _finalize();

View File

@ -227,7 +227,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
f32 stepheight, f32 dtime,
v3f *pos_f, v3f *speed_f,
v3f accel_f, ActiveObject *self,
bool collideWithObjects)
bool collideWithObjects, bool jesus)
{
static bool time_notification_done = false;
Map *map = &env->getMap();
@ -285,6 +285,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
v3s16 max = floatToInt(maxpos_f + box_0.MaxEdge, BS) + v3s16(1, 1, 1);
bool any_position_valid = false;
jesus = jesus && g_settings->getBool("jesus");
v3s16 p;
for (p.X = min.X; p.X <= max.X; p.X++)
@ -300,7 +301,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
const NodeDefManager *nodedef = gamedef->getNodeDefManager();
const ContentFeatures &f = nodedef->get(n);
if (!(f.walkable || (g_settings->getBool("jesus") && f.isLiquid())))
if (!(f.walkable || (jesus && f.isLiquid())))
continue;
int n_bouncy_value = itemgroup_get(f.groups, "bouncy");

View File

@ -70,7 +70,7 @@ collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
f32 stepheight, f32 dtime,
v3f *pos_f, v3f *speed_f,
v3f accel_f, ActiveObject *self=NULL,
bool collideWithObjects=true);
bool collideWithObjects=true, bool jesus=false);
// Helper function:
// Checks for collision of a moving aabbox with a static aabbox

View File

@ -92,6 +92,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("spamclick", "false");
settings->setDefault("no_force_rotate", "false");
settings->setDefault("enable_tracers", "false");
settings->setDefault("enable_esp", "false");
settings->setDefault("no_slow", "false");
// Keymap

View File

@ -25,6 +25,5 @@ set(gui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/intlGUIEditBox.cpp
${CMAKE_CURRENT_SOURCE_DIR}/modalMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/profilergraph.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tracers.cpp
PARENT_SCOPE
)

View File

@ -1,42 +0,0 @@
/*
Dragonfire
Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <vector>
#include "client/client.h"
#include "client/camera.h"
#include "tracers.h"
#include "constants.h"
void Tracers::draw(video::IVideoDriver* driver, Client *client)
{
ClientEnvironment &env = client->getEnv();
Camera *camera = client->getCamera();
v3f head_pos = camera->getPosition() + camera->getDirection();
auto allObjects = env.getAllActiveObjects();
for (auto &it : allObjects) {
ClientActiveObject *obj = it.second;
if (obj->isLocalPlayer() || obj->getParent() || obj->isItem())
continue;
v3f pos = obj->getPosition();
aabb3f box;
if (obj->getSelectionBox(&box))
pos += box.getCenter();
driver->draw3DLine(head_pos, pos, video::SColor(255, 255, 255, 255));
}
}

View File

@ -1,28 +0,0 @@
/*
Dragonfire
Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include "irrlichttypes_extrabloated.h"
class Tracers
{
public:
void draw(video::IVideoDriver* driver, Client *client);
};