]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Moved Killaura to Lua; Added ForceField; Added Friendlist; Added ClientObjectRef...
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 11:28:00 +0000 (12:28 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 11:28:00 +0000 (12:28 +0100)
builtin/client/cheats/combat.lua
builtin/client/cheats/init.lua
builtin/settingtypes.txt
doc/client_lua_api.txt
src/client/game.cpp
src/client/game.h
src/defaultsettings.cpp
src/script/lua_api/l_clientobject.cpp
src/script/lua_api/l_clientobject.h

index 1f9ba9a918ee9ee92f2e260d2f18c62c45a741d2..4904d8c5265d3e1278dd13673217532e048eecbe 100644 (file)
@@ -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
index 6fd78b8b857cb4f8300ecb789bbabd6b7cedc496..466ce4aee919f735ca93ce9df2dca263ae69b1ed 100644 (file)
@@ -1,6 +1,7 @@
 core.cheats = {
        ["Combat"] = {
                ["Killaura"] = "killaura",
+               ["Forcefield"] = "forcefield",
                ["AntiKnockback"] = "antiknockback",
                ["FastHit"] = "spamclick",
                ["AttachmentFloat"] = "float_above_parent",
index 4dcfd10928a087436bea990fa4e8325f22a70232..ec05c619601187b742d969af0dd81dc703fd9d80 100644 (file)
@@ -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
index 2daac87fefcd7517fffc0a4873dd69e8294056b4..c332ca4c3432fc5a7ae98fa437d8cc685a95a908 100644 (file)
@@ -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
index d8800d9ea44c2e389117c31f0e640236324bf46c..491d55a348d913440aa20768ecd41cd70452a050 100644 (file)
@@ -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;
index b8efa3a733793158180274bd85943fd2d0b40277..51accc67903e06efb28f4440ac75182dab8d1976 100644 (file)
@@ -773,7 +773,6 @@ class Game {
        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);
index e3332b14f3140a430565c6d9e4ae11342f9a6a44..bcdd8007498e61635183b306f99332206a8a0f4c 100644 (file)
@@ -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");
index 90f0bcd15043e8fa6ccf6899ac92b530b08929ac..d88b538a181aed84a05a191e1497f5b78c9d0fb5 100644 (file)
@@ -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),
index 88a6956bc4a0868f7ab5f79366c84335cab91ac6..5215914446c178e2f5b00d07d2e6e7d42c11a63a 100644 (file)
@@ -60,6 +60,9 @@ class ClientObjectRef : public ModApiBase
 
        // 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);