aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp28
-rw-r--r--src/client/game.h1
-rw-r--r--src/defaultsettings.cpp9
-rw-r--r--src/gui/cheatMenu.cpp66
-rw-r--r--src/gui/cheatMenu.h4
-rw-r--r--src/script/lua_api/l_clientobject.cpp9
-rw-r--r--src/script/lua_api/l_clientobject.h3
-rw-r--r--src/script/lua_api/l_inventoryaction.cpp2
-rw-r--r--src/script/lua_api/l_localplayer.cpp4
9 files changed, 100 insertions, 26 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index d8800d9ea..479484ae9 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2453,9 +2453,6 @@ PointedThing Game::updatePointedThing(
ClientMap &map = env.getClientMap();
const NodeDefManager *nodedef = map.getNodeDefManager();
- if (g_settings->getBool("killaura"))
- handleKillaura(shootline.start, shootline.getLength());
-
runData.selected_object = NULL;
hud->pointing_at_object = false;
RaycastState s(shootline, look_for_object, liquids_pointable, ! g_settings->getBool("dont_point_nodes"));
@@ -2532,22 +2529,6 @@ PointedThing Game::updatePointedThing(
return result;
}
-void Game::handleKillaura(v3f origin, f32 max_d)
-{
- ClientEnvironment &env = client->getEnv();
- std::vector<DistanceSortedActiveObject> allObjects;
- env.getActiveObjects(origin, max_d, allObjects);
- for (const auto &allObject : allObjects) {
- ClientActiveObject *obj = allObject.obj;
- s16 id = obj->getId();
- aabb3f selection_box;
- if (! obj->getSelectionBox(&selection_box))
- continue;
- PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0);
- client->interact(INTERACT_START_DIGGING, pointed);
- }
-}
-
void Game::handlePointingAtNothing(const ItemStack &playerItem)
{
infostream << "Right Clicked in Air" << std::endl;
@@ -3225,9 +3206,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
Cheat menu
*/
- 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);
-
+ if (! gui_chat_console->isOpen()) {
+ if (m_game_ui->m_flags.show_cheat_menu)
+ m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
+ if (g_settings->getBool("cheat_hud"))
+ m_cheat_menu->drawHUD(driver, dtime);
+ }
/*
Damage flash
*/
diff --git a/src/client/game.h b/src/client/game.h
index b8efa3a73..51accc679 100644
--- a/src/client/game.h
+++ b/src/client/game.h
@@ -773,7 +773,6 @@ public:
PointedThing updatePointedThing(
const core::line3d<f32> &shootline, bool liquids_pointable,
bool look_for_object, const v3s16 &camera_offset);
- void handleKillaura(v3f origin, f32 max_d);
void handlePointingAtNothing(const ItemStack &playerItem);
void handlePointingAtNode(const PointedThing &pointed,
const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 525f94678..619c26eec 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -118,6 +118,15 @@ void set_default_settings(Settings *settings)
settings->setDefault("crystal_pvp", "false");
settings->setDefault("autototem", "false");
settings->setDefault("dont_point_nodes", "false");
+ settings->setDefault("strip", "false");
+ settings->setDefault("autorefill", "false");
+ settings->setDefault("nuke", "false");
+ settings->setDefault("chat_color", "rainbow");
+ settings->setDefault("use_chat_color", "false");
+ settings->setDefault("chat_reverse", "false");
+ settings->setDefault("forcefield", "false");
+ settings->setDefault("friendlist", "");
+ settings->setDefault("cheat_hud", "true");
// Keymap
settings->setDefault("remote_port", "30000");
diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp
index f4f85c7fe..5a7f52477 100644
--- a/src/gui/cheatMenu.cpp
+++ b/src/gui/cheatMenu.cpp
@@ -151,6 +151,72 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug)
}
}
+void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime)
+{
+ CHEAT_MENU_GET_SCRIPTPTR
+
+ m_rainbow_offset += dtime;
+
+ m_rainbow_offset = fmod(m_rainbow_offset, 6.0f);
+
+ std::vector<std::string> enabled_cheats;
+
+ int cheat_count = 0;
+
+ for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) {
+ for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) {
+ if ((*cheat)->is_enabled()) {
+ enabled_cheats.push_back((*cheat)->m_name);
+ cheat_count++;
+ }
+ }
+ }
+
+ if (enabled_cheats.empty())
+ return;
+
+ std::vector<video::SColor> colors;
+
+ for (int i = 0; i < cheat_count; i++) {
+ video::SColor color;
+ f32 h = (f32)i * 2.0f / (f32)cheat_count - m_rainbow_offset;
+ if (h < 0)
+ h = 6.0f + h;
+ f32 x = (1 - fabs(fmod(h, 2.0f) - 1.0f)) * 255.0f;
+ switch((int)h) {
+ case 0:
+ color = video::SColor(255, 255, x, 0); break;
+ case 1:
+ color = video::SColor(255, x, 255, 0); break;
+ case 2:
+ color = video::SColor(255, 0, 255, x); break;
+ case 3:
+ color = video::SColor(255, 0, x, 255); break;
+ case 4:
+ color = video::SColor(255, x, 0, 255); break;
+ case 5:
+ color = video::SColor(255, 255, 0, x); break;
+ }
+ colors.push_back(color);
+ }
+
+ core::dimension2d<u32> screensize = driver->getScreenSize();
+
+ u32 y = 5;
+
+ int i = 0;
+ for (std::string cheat : enabled_cheats) {
+ core::dimension2d<u32> dim = m_font->getDimension(utf8_to_wide(cheat).c_str());
+ u32 x = screensize.Width - 5 - dim.Width;
+
+ core::rect<s32> fontbounds(x, y, x + dim.Width, y + dim.Height);
+ m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false);
+
+ y += dim.Height;
+ i++;
+ }
+}
+
void CheatMenu::selectLeft()
{
CHEAT_MENU_GET_SCRIPTPTR
diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h
index f12f10ac0..bedd7e048 100644
--- a/src/gui/cheatMenu.h
+++ b/src/gui/cheatMenu.h
@@ -48,6 +48,8 @@ public:
}
void draw(video::IVideoDriver *driver, bool show_debug);
+
+ void drawHUD(video::IVideoDriver *driver, double dtime);
void drawEntry(video::IVideoDriver *driver, std::string name,
std::size_t column_align_index, std::size_t cheat_entry_index,
@@ -81,4 +83,6 @@ private:
gui::IGUIFont *m_font = nullptr;
v2u32 m_fontsize;
+
+ float m_rainbow_offset = 0.0;
};
diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp
index 90f0bcd15..d88b538a1 100644
--- a/src/script/lua_api/l_clientobject.cpp
+++ b/src/script/lua_api/l_clientobject.cpp
@@ -87,6 +87,14 @@ int ClientObjectRef::l_is_player(lua_State *L)
return 1;
}
+int ClientObjectRef::l_is_local_player(lua_State *L)
+{
+ ClientObjectRef *ref = checkobject(L, 1);
+ GenericCAO *gcao = get_generic_cao(ref, L);
+ lua_pushboolean(L, gcao->isLocalPlayer());
+ return 1;
+}
+
int ClientObjectRef::l_get_name(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
@@ -210,6 +218,7 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_acceleration),
luamethod(ClientObjectRef, get_rotation),
luamethod(ClientObjectRef, is_player),
+ luamethod(ClientObjectRef, is_local_player),
luamethod(ClientObjectRef, get_name),
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h
index 88a6956bc..521591444 100644
--- a/src/script/lua_api/l_clientobject.h
+++ b/src/script/lua_api/l_clientobject.h
@@ -60,6 +60,9 @@ private:
// is_player(self)
static int l_is_player(lua_State *L);
+
+ // is_local_player(self)
+ static int l_is_local_player(lua_State *L);
// get_name(self)
static int l_get_name(lua_State *L);
diff --git a/src/script/lua_api/l_inventoryaction.cpp b/src/script/lua_api/l_inventoryaction.cpp
index 516d6d3b2..f3037ba83 100644
--- a/src/script/lua_api/l_inventoryaction.cpp
+++ b/src/script/lua_api/l_inventoryaction.cpp
@@ -133,7 +133,7 @@ void LuaInventoryAction::readFullInventoryLocationInto(lua_State *L, InventoryLo
loc->deSerialize(readParam<std::string>(L, 2));
std::string l = readParam<std::string>(L, 3);
*list = l;
- *index = luaL_checkinteger(L, 4);
+ *index = luaL_checkinteger(L, 4) - 1;
} catch (SerializationError &) {}
}
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 8057802a4..e40dd7b37 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -116,7 +116,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- lua_pushinteger(L, player->getWieldIndex());
+ lua_pushinteger(L, player->getWieldIndex() + 1);
return 1;
}
@@ -124,7 +124,7 @@ int LuaLocalPlayer::l_get_wield_index(lua_State *L)
int LuaLocalPlayer::l_set_wield_index(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
- u32 index = luaL_checkinteger(L, 2);
+ u32 index = luaL_checkinteger(L, 2) - 1;
player->setWieldIndex(index);
g_game->processItemSelection(&g_game->runData.new_playeritem);