MinoMino / minqlx

Extends Quake Live's dedicated server with extra functionality and scripting.
GNU General Public License v3.0
112 stars 42 forks source link

Anti-Camp plugin question #36

Open rniebecker opened 8 years ago

rniebecker commented 8 years ago

I'm working on an anti-camp plugin by tracking the position of the players. Works good so far, only problem is that as punishment I want to kill the camping player but I could not find a way of doing that without side effects in FreezeTag.

Using slay/slap commands let the player immediately respawn instead of freezing them. The only thing killing and freezing the player is: minqlx.client_command(player.id, "kill") but that has a nasty side effect, a lot of the time the then frozen players can run around and shoot other players, which is funny to watch but not really what I would like to have.

Here is a video of me running around frozen: https://www.youtube.com/watch?v=coIJxsoany4

I guess the problem is that the kill command needs to be synched with the game logic but I don't know how to achieve that.

Any help would be appreciated.

Cheers, niewi

dsverdlo commented 8 years ago

As Mino would say: 'game logic should never be done in a thread'. You should refactor the game logic to a function that is decorated by @minqlx.next_frame, for example:

def foo(self):
    ...
    @minqlx.next_frame
    def logic():
        minqlx.client_command(player.id, "kill")
    logic()
    ...
rniebecker commented 8 years ago

And he is 100% right. I'm new to python, I'm a assembler/c/java coder and I actually coded some games myself. :)

I've added the next_frame annotation and will do some testing today.

Cheers & Thanks, niewi

rniebecker commented 8 years ago

I tested my script yesterday and it works great. Just working on tweaking the logic now, not easy to do a proper anti-camp. :)

I have another question, is there a way of detecting if a player is currently swimming in water? Because movement is slower in water I need to use different values in that case.

Cheers, niewi