Toy book handlers

Experimental: players who open newspapers will persist after changing rooms.
This commit is contained in:
Ben
2019-08-19 02:28:42 +01:00
parent a6e1d05a52
commit 337c2048cd
4 changed files with 34 additions and 1 deletions

View File

@@ -102,6 +102,7 @@ async def handle_pbsm_finish(p):
async def handle_set_player_position(p, x: int, y: int):
p.x, p.y = x, y
p.frame = 1
p.toy = None
await p.room.send_xt('sp', p.data.id, x, y)

View File

@@ -0,0 +1,29 @@
from houdini import handlers, ClientType
from houdini.handlers import XTPacket
@handlers.handler(XTPacket('t', 'at'))
async def handle_open_book(p, toy_id: int):
p.toy = toy_id
await p.room.send_xt('at', p.data.id, toy_id)
@handlers.handler(XTPacket('t', 'rt'))
async def handle_close_book(p):
p.toy = None
await p.room.send_xt('rt', p.data.id)
@handlers.handler(XTPacket('j', 'jr'), client=ClientType.Legacy)
async def handle_join_room_toy(p):
for penguin in p.room.penguins:
if penguin.toy is not None:
await p.send_xt('at', penguin.data.id, penguin.toy)
@handlers.handler(XTPacket('j', 'crl'), client=ClientType.Vanilla)
@handlers.depends_on_packet(XTPacket('j', 'jr'))
async def handle_client_room_loaded_toy(p):
for penguin in p.room.penguins:
if penguin.toy is not None:
await p.send_xt('at', penguin.data.id, penguin.toy)