]> git.lizzy.rs Git - dragonfireclient.git/blob - builtin/client/cheats/combat.lua
World Cheats improvements; Add BlockLava; Readd minetest.request_http_api for Compati...
[dragonfireclient.git] / builtin / client / cheats / combat.lua
1 local placed_crystal
2 local switched_to_totem = 0
3 local used_sneak = true
4 local totem_move_action = InventoryAction("move")
5 totem_move_action:to("current_player", "main", 9)
6
7 core.register_list_command("friend", "Configure Friend List (friends dont get attacked by Killaura or Forcefield)", "friendlist")
8
9 core.register_globalstep(function(dtime)
10         local player = core.localplayer
11         if not player then return end
12         local control = player:get_control()
13         local pointed = core.get_pointed_thing()
14         local item = player:get_wielded_item():get_name()
15         if core.settings:get_bool("killaura") or core.settings:get_bool("forcefield") and control.dig then
16                 local friendlist = core.settings:get("friendlist"):split(",")
17                 for _, obj in ipairs(core.get_objects_inside_radius(player:get_pos(), 5)) do
18                         local do_attack = true
19                         if obj:is_local_player() then
20                                 do_attack = false
21                         else
22                                 for _, friend in ipairs(friendlist) do
23                                         if obj:get_name() == friend or obj:get_nametag() == friend then
24                                                 do_attack = false
25                                                 break
26                                         end
27                                 end
28                         end
29                         if do_attack then
30                                 obj:punch()
31                         end
32                 end
33         elseif core.settings:get_bool("crystal_pvp") then
34                 if placed_crystal then
35                         if core.switch_to_item("mobs_mc:totem") then
36                                 switched_to_totem = 5
37                         end
38                         placed_crystal = false
39                 elseif switched_to_totem > 0 then
40                         if item ~= "mobs_mc:totem"  then
41                                 switched_to_totem = 0
42                         elseif pointed and pointed.type == "object" then
43                                 pointed.ref:punch()
44                                 switched_to_totem = 0
45                         else
46                                 switched_to_totem = switched_to_totem
47                         end
48                 elseif control.place and item == "mcl_end:crystal" then
49                         placed_crystal = true
50                 elseif control.sneak then
51                         if pointed and pointed.type == "node" and not used_sneak then
52                                 local pos = core.get_pointed_thing_position(pointed)
53                                 local node = core.get_node_or_nil(pos)
54                                 if node and (node.name == "mcl_core:obsidian" or node.name == "mcl_core:bedrock") then
55                                         core.switch_to_item("mcl_end:crystal")
56                                         core.place_node(pos)
57                                         placed_crystal = true
58                                 end     
59                         end
60                         used_sneak = true
61                 else
62                         used_sneak = false
63                 end
64         end
65         
66         if core.settings:get_bool("autototem") then
67                 local totem_stack = core.get_inventory("current_player").main[9]
68                 if totem_stack and totem_stack:get_name() ~= "mobs_mc:totem" then
69                         local totem_index = core.find_item("mobs_mc:totem")
70                         if totem_index then
71                                 totem_move_action:from("current_player", "main", totem_index)
72                                 totem_move_action:apply()
73                                 player:set_wield_index(9)
74                         end
75                 end
76         end
77 end)