Source.Python icon indicating copy to clipboard operation
Source.Python copied to clipboard

Entities transmit alternative.

Open CookStar opened this issue 4 years ago • 2 comments

This draft is derived from #332 & https://github.com/Source-Python-Dev-Team/Source.Python/issues/332#issuecomment-674310749 & https://github.com/Source-Python-Dev-Team/Source.Python/commit/14a38d4c5f19cf5f31e4b7c6477a5f7ed8595c28

Currently, there are ongoing discussions on how to implement the feature. I've made a pull request as a draft for code review.

Example:

#Hide the teammates from each other.
@Event("player_spawn")
def on_player_spawn(game_event):
    player = Player.from_userid(game_event["userid"])
    for other in PlayerIter():
        if player.team_index == other.team_index:
            player.hide_entity(other.index)
            other.hide_entity(player.index)

#An optional reset, for spectating the game.
@Event("player_death")
def on_player_death(game_event):
    player = Player.from_userid(game_event["userid"])
    for other in PlayerIter():
        player.reset_entity(other.index)

Entity class https://github.com/Source-Python-Dev-Team/Source.Python/blob/f66ba09697f9aeb25f0eee5dc5cb8599780690fc/addons/source-python/packages/source-python/entities/_base.py#L783-L846

Player class https://github.com/Source-Python-Dev-Team/Source.Python/blob/f66ba09697f9aeb25f0eee5dc5cb8599780690fc/addons/source-python/packages/source-python/players/_base.py#L1005-L1053

Other Function https://github.com/Source-Python-Dev-Team/Source.Python/blob/f66ba09697f9aeb25f0eee5dc5cb8599780690fc/addons/source-python/packages/source-python/entities/transmit.py#L23-L28

CookStar avatar Sep 23 '20 12:09 CookStar

Here's my opinion on the Entities transmit (hidden/shown state) feature. https://github.com/Source-Python-Dev-Team/Source.Python/issues/332#issuecomment-707633794

CookStar avatar Oct 13 '20 10:10 CookStar

Hmm, something wrong

from _entities._transmit import transmit_manager

@ClientCommand('test')
def test(_, index):
    player = Player(index)
    print(transmit_manager.get_hidden_entity(player.index))

gives me:

1

[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\commands\auth.py", line 44, in __call__
    return self.callback(*args)
  File "..\addons\source-python\plugins\WCSSkills\commands\commands.py", line 33, in test
    print(transmit_manager.get_hidden_entity(player.index))
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 132, in __call__
    obj = super().__call__(index)
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 199, in __init__
    super().__init__(index)

ValueError: Conversion from "Index" (351) to "BaseEntity" failed.

I found the reason. I don't why, but when I hide weapon_c4 from Terrorist (me, tried alone and with bots — all the same), suddenly he can't find this c4. Idk why xD

He can't find c4 when: CT — when c4 on floor T — nevermind, even if bomb in player

That's so weird. After several round restarts, bomb entity changed, but he show in tuple previous entity, and new (if I add to no_transmit). But If I hide new bomb and restarts round, everything going the same

ArtichaTM avatar Sep 19 '21 14:09 ArtichaTM