From ea88dde4be225d19c12bea4a581aa21f17237070 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 21 Oct 2020 18:51:57 +0200 Subject: Added Strip, AutoRefill, indexing for InventoryActions and Wield Index starts at 1 now --- src/defaultsettings.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/defaultsettings.cpp') diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2899f2509..6cc28ac32 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -111,6 +111,8 @@ 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"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3 From 8bc7d49b32afb215d262d8282988adf9e836396c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 22 Oct 2020 20:05:18 +0200 Subject: Added Nuke --- builtin/client/cheats/init.lua | 1 + builtin/client/cheats/world.lua | 17 +++++++++++++++++ builtin/settingtypes.txt | 2 ++ src/defaultsettings.cpp | 1 + 4 files changed, 21 insertions(+) (limited to 'src/defaultsettings.cpp') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index c579f2b89..8d634a766 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -38,6 +38,7 @@ core.cheats = { ["BlockWater"] = "block_water", ["PlaceOnTop"] = "autotnt", ["Replace"] = "replace" + ["Nuke"] = "nuke" }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", diff --git a/builtin/client/cheats/world.lua b/builtin/client/cheats/world.lua index 5b97b206b..6cbdd67fc 100644 --- a/builtin/client/cheats/world.lua +++ b/builtin/client/cheats/world.lua @@ -48,6 +48,23 @@ core.register_globalstep(function(dtime) end end end + if core.settings:get_bool("nuke") then + local i = 0 + for x = pos.x - 5, pos.x + 5 do + for y = pos.y - 5, pos.y + 5 do + for z = pos.z - 5, pos.z + 5 do + local p = vector.new(x, y, z) + local node = core.get_node_or_nil(p) + local def = node and core.get_node_def(node.name) + if def and def.diggable then + if i > nodes_per_tick then return end + core.dig_node(p) + i = i + 1 + end + end + end + end + end end) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index a7a92291d..15c62ead1 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2306,3 +2306,5 @@ dont_point_nodes (ThroughWalls) bool false strip (Strip) bool false autorefill (AutoRefill) bool false + +nuke (Nuke) bool false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 6cc28ac32..bde6505a0 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -113,6 +113,7 @@ void set_default_settings(Settings *settings) settings->setDefault("dont_point_nodes", "false"); settings->setDefault("strip", "false"); settings->setDefault("autorefill", "false"); + settings->setDefault("nuke", "false"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3 From 7cbe42b1dd0051a0c8a516700c2ef63f1ec090fc Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 11:57:16 +0100 Subject: Re-Added Chat Effects --- builtin/client/cheats/chat.lua | 35 +++++++++++++++++++++++++++++++++++ builtin/client/cheats/init.lua | 8 +++++--- builtin/client/util.lua | 9 +++++++-- builtin/settingtypes.txt | 6 ++++++ src/defaultsettings.cpp | 3 +++ 5 files changed, 56 insertions(+), 5 deletions(-) (limited to 'src/defaultsettings.cpp') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 1b8094768..1f3ecbaa2 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -6,3 +6,38 @@ core.register_on_receiving_chat_message(function(message) return true end end) + +function core.send_colorized(message) + local starts_with = message:sub(1, 1) + + if starts_with == "/" or starts_with == "." then return end + + local reverse = core.settings:get_bool("chat_reverse") + + if reverse then + local msg = "" + for i = 1, #message do + msg = message:sub(i, i) .. msg + end + message = msg + end + + local use_chat_color = core.settings:get("use_chat_color") + local color = core.settings:get("chat_color") + + if color then + local msg + if color == "rainbow" then + msg = core.rainbow(message) + else + msg = core.colorize(color, message) + end + message = msg + end + + core.send_chat_message(message) + return true +end + +core.register_on_sending_chat_message(core.send_colorized) + diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 8d634a766..6fd78b8b8 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -37,8 +37,8 @@ core.cheats = { ["ScaffoldPlus"] = "scaffold_plus", ["BlockWater"] = "block_water", ["PlaceOnTop"] = "autotnt", - ["Replace"] = "replace" - ["Nuke"] = "nuke" + ["Replace"] = "replace", + ["Nuke"] = "nuke", }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", @@ -55,7 +55,9 @@ core.cheats = { }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", - ["Deathmessages"] = "mark_deathmessages" + ["Deathmessages"] = "mark_deathmessages", + ["ColoredChat"] = "use_chat_color", + ["ReversedChat"] = "chat_reverse", }, ["Inventory"] = { ["AutoEject"] = "autoeject", diff --git a/builtin/client/util.lua b/builtin/client/util.lua index 20e0e1d1b..783d0ceb1 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -42,6 +42,11 @@ end function core.get_pointed_thing() local pos = core.camera:get_pos() local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 5)) - local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or core.get_item_def(core.localplayer:get_wielded_item():get_name()).liquids_pointable) - return ray:next() + local player = core.localplayer + if not player then return end + local item = player:get_wielded_item() + if not item then return end + local def = core.get_item_def(item:get_name()) + local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or def and def.liquids_pointable) + return ray and ray:next() end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 15c62ead1..4dcfd1092 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2308,3 +2308,9 @@ strip (Strip) bool false autorefill (AutoRefill) bool false nuke (Nuke) bool false + +chat_color (Chat Color) string rainbow + +use_chat_color (ColoredChat) bool false + +chat_reverse (ReversedChat) bool false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bde6505a0..e3332b14f 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -114,6 +114,9 @@ void set_default_settings(Settings *settings) 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"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3 From f1d9ac014efc6403e73223f36d3dbb7f5ed50236 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 12:28:00 +0100 Subject: Moved Killaura to Lua; Added ForceField; Added Friendlist; Added ClientObjectRef:is_local_player(); Documented LocalPlayer:get_object() --- builtin/client/cheats/combat.lua | 22 +++++++++++++++++++++- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 4 ++++ doc/client_lua_api.txt | 3 +++ src/client/game.cpp | 19 ------------------- src/client/game.h | 1 - src/defaultsettings.cpp | 2 ++ src/script/lua_api/l_clientobject.cpp | 9 +++++++++ src/script/lua_api/l_clientobject.h | 3 +++ 9 files changed, 43 insertions(+), 21 deletions(-) (limited to 'src/defaultsettings.cpp') diff --git a/builtin/client/cheats/combat.lua b/builtin/client/cheats/combat.lua index 1f9ba9a91..4904d8c52 100644 --- a/builtin/client/cheats/combat.lua +++ b/builtin/client/cheats/combat.lua @@ -4,13 +4,33 @@ local used_sneak = true local totem_move_action = InventoryAction("move") totem_move_action:to("current_player", "main", 9) +core.register_list_command("friend", "Configure Friend List (friends dont get attacked by Killaura or Forcefield)", "friendlist") + core.register_globalstep(function(dtime) local player = core.localplayer if not player then return end local control = player:get_control() local pointed = core.get_pointed_thing() local item = player:get_wielded_item():get_name() - if core.settings:get_bool("crystal_pvp") then + if core.settings:get_bool("killaura") or core.settings:get_bool("forcefield") and control.LMB then + local friendlist = core.settings:get("friendlist"):split(",") + for _, obj in ipairs(core.get_objects_inside_radius(player:get_pos(), 5)) do + local do_attack = true + if obj:is_local_player() then + do_attack = false + else + for _, friend in ipairs(friendlist) do + if obj:get_name() == friend or obj:get_nametag() == friend then + do_attack = false + break + end + end + end + if do_attack then + obj:punch() + end + end + elseif core.settings:get_bool("crystal_pvp") then if placed_crystal then if core.switch_to_item("mobs_mc:totem") then switched_to_totem = 5 diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 6fd78b8b8..466ce4aee 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -1,6 +1,7 @@ core.cheats = { ["Combat"] = { ["Killaura"] = "killaura", + ["Forcefield"] = "forcefield", ["AntiKnockback"] = "antiknockback", ["FastHit"] = "spamclick", ["AttachmentFloat"] = "float_above_parent", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4dcfd1092..ec05c6196 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2314,3 +2314,7 @@ chat_color (Chat Color) string rainbow use_chat_color (ColoredChat) bool false chat_reverse (ReversedChat) bool false + +forcefield (Forcefield) bool false + +friendlist (Killaura / Forcefield Friendlist) string diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt index 2daac87fe..c332ca4c3 100644 --- a/doc/client_lua_api.txt +++ b/doc/client_lua_api.txt @@ -1296,6 +1296,8 @@ Methods: * change a value of a previously added HUD element * element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir` * Returns `true` on success, otherwise returns `nil` +* `get_object()` + * Returns the ClientObjectRef for the player ### Settings An interface to read config files in the format of `minetest.conf`. @@ -1336,6 +1338,7 @@ This is basically a reference to a C++ `GenericCAO`. * `get_acceleration()`: returns the acceleration, a vector * `get_rotation()`: returns the rotation, a vector (radians) * `is_player()`: returns true if the object is a player +* `is_local_player()`: returns true if the object is the local player * `get_attach()`: returns parent or nil if it isn't attached. * `get_nametag()`: returns the nametag (string) * `get_item_textures()`: returns the textures diff --git a/src/client/game.cpp b/src/client/game.cpp index d8800d9ea..491d55a34 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 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; 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 &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 e3332b14f..bcdd80074 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -117,6 +117,8 @@ void set_default_settings(Settings *settings) settings->setDefault("chat_color", "rainbow"); settings->setDefault("use_chat_color", "false"); settings->setDefault("chat_reverse", "false"); + settings->setDefault("forcefield", "false"); + settings->setDefault("friendlist", ""); // Keymap settings->setDefault("remote_port", "30000"); 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); -- cgit v1.2.3 From a7dc1135e94bde5f8c3385d54388563eaffe7553 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 14:19:15 +0100 Subject: Added CheatHUD --- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 2 ++ src/client/game.cpp | 9 ++++-- src/defaultsettings.cpp | 1 + src/gui/cheatMenu.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++ src/gui/cheatMenu.h | 4 +++ 6 files changed, 80 insertions(+), 3 deletions(-) (limited to 'src/defaultsettings.cpp') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 466ce4aee..03fc20c60 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -27,6 +27,7 @@ core.cheats = { ["Coords"] = "coords", ["Tracers"] = "enable_tracers", ["ESP"] = "enable_esp", + ["CheatHUD"] = "cheat_hud", }, ["World"] = { ["FastDig"] = "fastdig", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ec05c6196..adb8e7a00 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2318,3 +2318,5 @@ chat_reverse (ReversedChat) bool false forcefield (Forcefield) bool false friendlist (Killaura / Forcefield Friendlist) string + +cheat_hud (CheatHUD) bool true diff --git a/src/client/game.cpp b/src/client/game.cpp index 491d55a34..479484ae9 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -3206,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/defaultsettings.cpp b/src/defaultsettings.cpp index bcdd80074..9e32a11fe 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -119,6 +119,7 @@ void set_default_settings(Settings *settings) 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 f796fb0ba..1485541c2 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -94,6 +94,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 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 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 screensize = driver->getScreenSize(); + + u32 y = 5; + + int i = 0; + for (std::string cheat : enabled_cheats) { + core::dimension2d dim = m_font->getDimension(utf8_to_wide(cheat).c_str()); + u32 x = screensize.Width - 5 - dim.Width; + + core::rect 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::selectUp() { CHEAT_MENU_GET_SCRIPTPTR diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index ea9a9d853..f67cdea5a 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -42,6 +42,8 @@ public: CheatMenu(Client *client); void draw(video::IVideoDriver *driver, bool show_debug); + + void drawHUD(video::IVideoDriver *driver, double dtime); void drawEntry(video::IVideoDriver *driver, std::string name, int number, bool selected, bool active, @@ -72,4 +74,6 @@ private: gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; + + float m_rainbow_offset = 0.0; }; -- cgit v1.2.3