Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config_template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ hide_effects = no
replace_shake = no
# hide chat
hide_chat = no
# ignore faction members when hiding shells/objects/names/health
ignore_own_faction = no

[plugin_playerlist]
visible = no
Expand Down
25 changes: 24 additions & 1 deletion plugins/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def onInit(self):
'hide_ally_objects': False,
'hide_effects': False,
'hide_chat': False,
'ignore_own_faction': False
})
self.config.option('damage_flash_intensity', 1, 'float')

Expand All @@ -41,11 +42,21 @@ def afterUpdate(self):
wv = self.refs.WorldView
if cw == ffi.NULL or wv == ffi.NULL:
return

ptype = util.getClassName(cw.player)
if ptype not in self.refs.CASTABLE['PlayerCharacter']:
return

worldplayer = ffi.cast('struct WorldObject *', cw.player)

# other players
allies = util.vec2list(cw.allies, 'struct WorldObject *')
for obj in allies:
props = obj.props

if self.checkFactionMatch(worldplayer, obj):
continue

if self.config.hide_shells:
# fail: triggers game's "unknown object" box drawing
ffi.cast('int *', props.vid.s)[-3] = 0
Expand All @@ -70,7 +81,7 @@ def afterUpdate(self):
cw.clientSubWorlds, 'struct ForeignSubWorld *')
for csubworld in worlds:
for obj in util.worldobjects(csubworld):
if obj in allies:
if obj in allies and self.checkFactionMatch(worldplayer, obj):
# shells are treated separately
continue
if obj.props.terraintype > 0:
Expand Down Expand Up @@ -136,3 +147,15 @@ def onPresent(self):
if len(s) > 0:
self.shaketxt.text = '[{}]'.format(', '.join(s))
self.shaketxt.draw(self.refs.windowW // 2, 20, anchorX=0.5)

def checkFactionMatch(self, obj1, obj2):
faction1 = ''
if obj1.props.playerdata != ffi.NULL:
faction1 = obj1.props.playerdata.factionname.s

faction2 = ''
if obj2.props.playerdata != ffi.NULL:
faction2 = obj2.props.playerdata.factionname.s

# this comparison is stupid
return (ffi.string(faction1).decode() == ffi.string(faction2).decode()) and self.config.ignore_own_faction