diff --git a/config_template.ini b/config_template.ini index 5abca20..a7614b6 100644 --- a/config_template.ini +++ b/config_template.ini @@ -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 diff --git a/plugins/noise.py b/plugins/noise.py index 6f2a1b1..bf9a60c 100644 --- a/plugins/noise.py +++ b/plugins/noise.py @@ -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') @@ -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 @@ -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: @@ -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