Added Tracers, NoSlow and NoForceRotate; GUI Colors changed

This commit is contained in:
Elias Fleckenstein 2020-10-04 17:43:37 +02:00
parent b9f8f0a232
commit 044a12666e
26 changed files with 140 additions and 70 deletions

View File

@ -11,6 +11,8 @@ core.cheats = {
["PitchMove"] = "pitch_move",
["AutoJump"] = "autojump",
["Jesus"] = "jesus",
["NoSlow"] = "no_slow",
},
["Render"] = {
["Xray"] = "xray",
@ -19,6 +21,7 @@ core.cheats = {
["NoHurtCam"] = "no_hurt_cam",
["BrightNight"] = "no_night",
["Coords"] = "coords",
["Tracers"] = "enable_tracers",
},
["World"] = {
["FastDig"] = "fastdig",
@ -36,6 +39,7 @@ core.cheats = {
},
["Player"] = {
["NoFallDamage"] = "prevent_natural_damage",
["NoForceRotate"] = "no_force_rotate",
},
}

View File

@ -2262,3 +2262,13 @@ no_night (BrightNight) bool false
coords (Coords) bool false
point_liquids (PointLiquids) bool false
log_particles (ParticleExploit) bool false
spamclick (FastHit) bool false
no_force_rotate (NoForceRotate) bool false
enable_tracers (Tracers) bool false
no_slow (NoSlow) bool false

View File

@ -932,9 +932,9 @@ void Client::Send(NetworkPacket* pkt)
// Will fill up 12 + 12 + 4 + 4 + 4 bytes
void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt)
{
v3f pf = myplayer->getPosition() * 100;
v3f sf = myplayer->getSpeed() * 100;
{
v3f pf = myplayer->getLegitPosition() * 100;
v3f sf = myplayer->getLegitSpeed() * 100;
s32 pitch = myplayer->getPitch() * 100;
s32 yaw = myplayer->getYaw() * 100;
u32 keyPressed = myplayer->keyPressed;

View File

@ -891,7 +891,7 @@ u16 GenericCAO::getLightPosition(v3s16 *pos)
void GenericCAO::updateNametag()
{
if (m_is_local_player) // No nametag for local player
if (m_is_local_player && ! g_settings->getBool("freecam")) // No nametag for local player
return;
if (m_prop.nametag.empty()) {
@ -943,12 +943,14 @@ void GenericCAO::updateNodePos()
void GenericCAO::step(float dtime, ClientEnvironment *env)
{
// Handle model animations and update positions instantly to prevent lags
if (m_is_local_player && ! g_settings->getBool("freecam")) {
if (m_is_local_player) {
LocalPlayer *player = m_env->getLocalPlayer();
m_position = player->getPosition();
m_position = player->getLegitPosition();
pos_translator.val_current = m_position;
m_rotation.Y = wrapDegrees_0_360(player->getYaw());
rot_translator.val_current = m_rotation;
if (! g_settings->getBool("freecam")) {
m_rotation.Y = wrapDegrees_0_360(player->getYaw());
rot_translator.val_current = m_rotation;
}
if (m_is_visible) {
int old_anim = player->last_animation;
@ -958,9 +960,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
const PlayerControl &controls = player->getPlayerControl();
bool walking = false;
if (controls.up || controls.down || controls.left || controls.right ||
if ((controls.up || controls.down || controls.left || controls.right ||
controls.forw_move_joystick_axis != 0.f ||
controls.sidew_move_joystick_axis != 0.f)
controls.sidew_move_joystick_axis != 0.f) && ! g_settings->getBool("freecam"))
walking = true;
f32 new_speed = player->local_animation_speed;
@ -976,7 +978,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
m_client->checkLocalPrivilege("fly"))))
new_speed *= 1.5;
// slowdown speed if sneeking
if (controls.sneak && walking)
if (controls.sneak && walking && ! g_settings->getBool("no_slow"))
new_speed /= 2;
if (walking && (controls.LMB || controls.RMB)) {

View File

@ -228,7 +228,7 @@ bool Game::startup(bool *kill,
if (!createClient(start_data))
return false;
RenderingEngine::initialize(client, hud);
RenderingEngine::initialize(client, hud, m_tracers);
return true;
}
@ -3196,7 +3196,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);
m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_tracers"));
/*
Profiler graph
@ -3211,12 +3211,6 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
if (m_game_ui->m_flags.show_cheat_menu && ! gui_chat_console->isOpen())
m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
/*
Tracers
*/
m_tracers->draw(driver);
/*
Damage flash
*/
@ -3234,7 +3228,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
if (player->hurt_tilt_timer > 0.0f) {
player->hurt_tilt_timer -= dtime * 6.0f;
if (player->hurt_tilt_timer < 0.0f)
if (player->hurt_tilt_timer < 0.0f || g_settings->getBool("no_hurt_cam"))
player->hurt_tilt_strength = 0.0f;
}
@ -3249,6 +3243,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
End scene
*/
driver->endScene();
stats->drawtime = tt_draw.stop(true);
@ -3334,15 +3329,11 @@ void Game::freecamChangedCallback(const std::string &setting_name, void *data)
{
Game *game = (Game *) data;
LocalPlayer *player = game->client->getEnv().getLocalPlayer();
static v3f player_pos = player->getPosition();
static v3f player_speed = player->getSpeed();
if (g_settings->getBool("freecam")) {
player_pos = player->getPosition();
player_speed = player->getSpeed();
game->camera->setCameraMode(CAMERA_MODE_FIRST);
player->freecamEnable();
} else {
player->setPosition(player_pos);
player->setSpeed(player_speed);
player->freecamDisable();
}
game->updatePlayerCAOVisibility();
}

View File

@ -461,6 +461,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
m_speed.Y += jumpspeed;
}
setSpeed(m_speed);
if (! m_freecam)
m_legit_speed = m_speed;
m_can_jump = false;
}
@ -639,7 +641,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
if (superspeed || (is_climbing && fast_climb) ||
((in_liquid || in_liquid_stable) && fast_climb))
speedH = speedH.normalize() * movement_speed_fast;
else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable)
else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable && !g_settings->getBool("no_slow"))
speedH = speedH.normalize() * movement_speed_crouch;
else
speedH = speedH.normalize() * movement_speed_walk;

View File

@ -132,11 +132,37 @@ public:
inline void setPosition(const v3f &position)
{
m_position = position;
if (! m_freecam)
m_legit_position = position;
m_sneak_node_exists = false;
}
v3f getPosition() const { return m_position; }
v3f getLegitPosition() const { return m_legit_position; }
v3f getLegitSpeed() const { return m_legit_speed; }
inline void setLegitPosition(const v3f &position)
{
if (m_freecam)
m_legit_position = position;
else
setPosition(position);
}
inline void freecamEnable()
{
m_freecam = true;
}
inline void freecamDisable()
{
m_freecam = false;
setPosition(m_legit_position);
setSpeed(m_legit_speed);
}
// Non-transformed eye offset getters
// For accurate positions, use the Camera functions
v3f getEyePosition() const { return m_position + getEyeOffset(); }
@ -175,7 +201,10 @@ private:
const v3f &position_before_move, const v3f &speed_before_move,
f32 pos_max_d);
bool m_freecam = false;
v3f m_position;
v3f m_legit_position;
v3f m_legit_speed;
v3s16 m_standing_node;
v3s16 m_sneak_node = v3s16(32767, 32767, 32767);

View File

@ -24,11 +24,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/clientmap.h"
#include "client/hud.h"
#include "client/minimap.h"
#include "gui/tracers.h"
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),
guienv(device->getGUIEnvironment()), client(_client), camera(client->getCamera()),
mapper(client->getMinimap()), hud(_hud)
mapper(client->getMinimap()), hud(_hud), tracers(_tracers)
{
screensize = driver->getScreenSize();
virtual_size = screensize;
@ -53,7 +54,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_wield_tool, bool _draw_crosshair, bool _draw_tracers)
{
v2u32 ss = driver->getScreenSize();
if (screensize != ss) {
@ -65,6 +66,7 @@ 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;
beforeDraw();
drawAll();
@ -72,11 +74,14 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min
void RenderingCore::draw3D()
{
smgr->drawAll();
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (!show_hud)
return;
hud->drawSelectionMesh();
if (draw_tracers)
tracers->draw(driver, client);
if (draw_wield_tool)
camera->drawWieldedTool();
}

View File

@ -25,6 +25,7 @@ class Camera;
class Client;
class Hud;
class Minimap;
class Tracers;
class RenderingCore
{
@ -36,6 +37,7 @@ protected:
bool show_minimap;
bool draw_wield_tool;
bool draw_crosshair;
bool draw_tracers;
IrrlichtDevice *device;
video::IVideoDriver *driver;
@ -46,6 +48,7 @@ protected:
Camera *camera;
Minimap *mapper;
Hud *hud;
Tracers *tracers;
void updateScreenSize();
virtual void initTextures() {}
@ -59,7 +62,7 @@ protected:
void drawPostFx();
public:
RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud);
RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
RenderingCore(const RenderingCore &) = delete;
RenderingCore(RenderingCore &&) = delete;
virtual ~RenderingCore();
@ -69,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_wield_tool, bool _draw_crosshair, bool _draw_tracers);
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)
Client *client, Hud *hud, Tracers *tracers)
{
if (stereo_mode == "none")
return new RenderingCorePlain(device, client, hud);
return new RenderingCorePlain(device, client, hud, tracers);
if (stereo_mode == "anaglyph")
return new RenderingCoreAnaglyph(device, client, hud);
return new RenderingCoreAnaglyph(device, client, hud, tracers);
if (stereo_mode == "interlaced")
return new RenderingCoreInterlaced(device, client, hud);
return new RenderingCoreInterlaced(device, client, hud, tracers);
#ifdef STEREO_PAGEFLIP_SUPPORTED
if (stereo_mode == "pageflip")
return new RenderingCorePageflip(device, client, hud);
return new RenderingCorePageflip(device, client, hud, tracers);
#endif
if (stereo_mode == "sidebyside")
return new RenderingCoreSideBySide(device, client, hud);
return new RenderingCoreSideBySide(device, client, hud, tracers);
if (stereo_mode == "topbottom")
return new RenderingCoreSideBySide(device, client, hud, true);
return new RenderingCoreSideBySide(device, client, hud, tracers, true);
if (stereo_mode == "crossview")
return new RenderingCoreSideBySide(device, client, hud, false, true);
return new RenderingCoreSideBySide(device, client, hud, tracers, 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);
Client *client, Hud *hud, Tracers *tracers);

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)
: RenderingCoreStereo(_device, _client, _hud)
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: RenderingCoreStereo(_device, _client, _hud, _tracers)
{
initMaterial();
}

View File

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

View File

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

View File

@ -33,6 +33,6 @@ protected:
void upscale();
public:
RenderingCorePlain(IrrlichtDevice *_device, Client *_client, Hud *_hud);
RenderingCorePlain(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
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, bool _horizontal, bool _flipped)
: RenderingCoreStereo(_device, _client, _hud), horizontal(_horizontal), flipped(_flipped)
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers, bool _horizontal, bool _flipped)
: RenderingCoreStereo(_device, _client, _hud, _tracers), horizontal(_horizontal), flipped(_flipped)
{
}

View File

@ -37,7 +37,7 @@ protected:
void resetEye() override;
public:
RenderingCoreSideBySide(IrrlichtDevice *_device, Client *_client, Hud *_hud,
RenderingCoreSideBySide(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers,
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)
: RenderingCore(_device, _client, _hud)
IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers)
: RenderingCore(_device, _client, _hud, _tracers)
{
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);
RenderingCoreStereo(IrrlichtDevice *_device, Client *_client, Hud *_hud, Tracers *_tracers);
};

View File

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

View File

@ -32,6 +32,7 @@ class Client;
class LocalPlayer;
class Hud;
class Minimap;
class Tracers;
class RenderingCore;
@ -117,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 show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers)
{
s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
draw_wield_tool, draw_crosshair);
draw_wield_tool, draw_crosshair, draw_tracers);
}
inline static void initialize(Client *client, Hud *hud)
inline static void initialize(Client *client, Hud *hud, Tracers *tracers)
{
s_singleton->_initialize(client, hud);
s_singleton->_initialize(client, hud, tracers);
}
inline static void finalize() { s_singleton->_finalize(); }
@ -148,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_wield_tool, bool draw_crosshair, bool draw_tracers);
void _initialize(Client *client, Hud *hud);
void _initialize(Client *client, Hud *hud, Tracers *tracers);
void _finalize();

View File

@ -90,6 +90,9 @@ void set_default_settings(Settings *settings)
settings->setDefault("point_liquids", "false");
settings->setDefault("log_particles", "false");
settings->setDefault("spamclick", "false");
settings->setDefault("no_force_rotate", "false");
settings->setDefault("enable_tracers", "false");
settings->setDefault("no_slow", "false");
// Keymap
settings->setDefault("remote_port", "30000");

View File

@ -59,10 +59,11 @@ private:
int m_entry_width = 200;
int m_gap = 3;
video::SColor m_bg_color = video::SColor(192, 255, 175, 191);
video::SColor m_active_bg_color = video::SColor(192, 255, 32, 76);
video::SColor m_bg_color = video::SColor(192, 255, 145, 88);
video::SColor m_active_bg_color = video::SColor(192, 255, 87, 53);
video::SColor m_font_color = video::SColor(255, 0, 0, 0);
video::SColor m_selected_font_color = video::SColor(255, 250, 32, 129);
video::SColor m_selected_font_color = video::SColor(255, 255, 252, 88);
Client *m_client;

View File

@ -17,10 +17,25 @@ 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)
void Tracers::draw(video::IVideoDriver* driver, Client *client)
{
driver->draw3DLine(v3f(0, 0, 0), v3f(1000, 1000, 1000) * BS, video::SColor(255, 0, 0, 0));
ClientEnvironment &env = client->getEnv();
LocalPlayer *player = env.getLocalPlayer();
Camera *camera = client->getCamera();
v3f player_pos = camera->getPosition() + camera->getDirection();
v3f head_pos = player_pos;
std::vector<DistanceSortedActiveObject> allObjects;
env.getActiveObjects(player_pos, 1000000, allObjects);
for (const auto &allObject : allObjects) {
ClientActiveObject *obj = allObject.obj;
if (obj->isLocalPlayer())
continue;
driver->draw3DLine(head_pos, obj->getPosition(), video::SColor(255, 255, 255, 255));
}
}

View File

@ -24,5 +24,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class Tracers
{
public:
void draw(video::IVideoDriver* driver);
void draw(video::IVideoDriver* driver, Client *client);
};

View File

@ -608,7 +608,7 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
*pkt >> pos >> pitch >> yaw;
player->setPosition(pos);
player->setLegitPosition(pos);
infostream << "Client got TOCLIENT_MOVE_PLAYER"
<< " pos=(" << pos.X << "," << pos.Y << "," << pos.Z << ")"
@ -622,6 +622,10 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
it would just force the pitch and yaw values to whatever
the camera points to.
*/
if (g_settings->getBool("no_force_rotate"))
return;
ClientEvent *event = new ClientEvent();
event->type = CE_PLAYER_FORCE_MOVE;
event->player_force_move.pitch = pitch;