Skip to content

Commit

Permalink
improve efficiency of nearby player check
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxionary committed Feb 22, 2024
1 parent 1dc93d6 commit f67f0c0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .check_date.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
grep $(date -u -I) mod.conf
exit $?
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ repos:
pass_filenames: true
exclude: .pre-commit-config.yaml
fail_fast: true
- id: date_version
name: date version
language: script
entry: .check_date.sh
files: mod.conf
always_run: true
fail_fast: true
- id: stylua
name: stylua
language: system
Expand Down
11 changes: 6 additions & 5 deletions compat/invisibility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ mobs_balrog.api.register_on_do_custom(function(self, dtime)
return
end

-- TODO: radius configurable
for _, obj in pairs(minetest.get_objects_inside_radius(p, 10)) do
if obj:is_player() then
local pname = obj:get_player_name()
local players = minetest.get_connected_players()
for i = 1, #players do
local player = players[i]
if p:distance(player:get_pos()) <= mobs_balrog.settings.invisibility_radius then
local pname = player:get_player_name()
local is_staff = minetest.check_player_privs(pname, { staff = true })
local is_invisible = invisibility[pname]
local is_target = self.player_invisibility_target == pname
Expand All @@ -53,7 +54,7 @@ mobs_balrog.api.register_on_do_custom(function(self, dtime)
local str = reveal_phrases[math.random(1, #reveal_phrases)]
minetest.chat_send_player(pname, str)
if minetest.global_exists("invisible") then
invisible(obj, false)
invisible(player, false)
else
invisibility[pname] = nil
end
Expand Down
2 changes: 1 addition & 1 deletion mod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ website = https://content.minetest.net/packages/rheo/mobs_balrog/
author = fluxionary
license = LGPL-3.0-or-later
media_license = CC-BY-SA-3.0
version = 2022-11-27
version = 2024-02-22
min_minetest_version = 5.7.0
depends = default, fire, fmod, futil, mobs, tnt
optional_depends = 3d_armor, armor_admin, armor_crystal, armor_monoid, armor_nether, invisibility, nether, nether_mobs, pvpplus, rainbow_ore, shields, yl_cities, yl_events, yl_speak_up
3 changes: 3 additions & 0 deletions settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ mobs_balrog.flame_node (Whip fire node) string mobs_balrog:flame

# set to true to enable some additional debugging output
mobs_balrog.debug (balrog debugging) bool false

# if players are invisible and within this radius, the balrog will reveal them
mobs_balrog.invisibility_radius (invisibility unmask radius) float 10 0

0 comments on commit f67f0c0

Please sign in to comment.