def handle(world_session, socket, reader): if world_session.player_mgr.is_alive and len(reader.data) >= 12: emote_text_id, guid = unpack('<IQ', reader.data) emote = DbcDatabaseManager.emote_text_get_by_id(emote_text_id) if emote: data = pack('<QI', world_session.player_mgr.guid, emote_text_id) target = GridManager.get_surrounding_unit_by_guid( world_session.player_mgr, guid, include_players=True) if not target: data += pack('<B', 0) elif target.get_type() == ObjectTypes.TYPE_PLAYER: player_name_bytes = PacketWriter.string_to_bytes( target.player.name) data += pack('<%us' % len(player_name_bytes), player_name_bytes) elif target.get_type( ) == ObjectTypes.TYPE_UNIT and target.creature_template: unit_name_bytes = PacketWriter.string_to_bytes( target.creature_template.name) data += pack('<%us' % len(unit_name_bytes), unit_name_bytes) else: data += pack('<B', 0) GridManager.send_surrounding_in_range( PacketWriter.get_packet(OpCode.SMSG_TEXT_EMOTE, data), world_session.player_mgr, config.World.Chat.ChatRange.emote_range) # Perform visual emote action if needed emote_id = emote.EmoteID state = StandState.UNIT_STANDING needs_broadcast = True if emote_text_id == Emotes.SIT: if not world_session.player_mgr.is_sitting: state = StandState.UNIT_SITTING world_session.player_mgr.stand_state = state elif emote_text_id == Emotes.STAND: world_session.player_mgr.stand_state = state elif emote_text_id == Emotes.SLEEP: if world_session.player_mgr.stand_state != StandState.UNIT_SLEEPING: state = StandState.UNIT_SLEEPING world_session.player_mgr.stand_state = state elif emote_text_id == Emotes.KNEEL: if world_session.player_mgr.stand_state != StandState.UNIT_KNEEL: state = StandState.UNIT_KNEEL world_session.player_mgr.stand_state = state else: needs_broadcast = False world_session.player_mgr.play_emote(emote_id) if needs_broadcast: world_session.player_mgr.flagged_for_update = True return 0
def send_chat_message(world_session, guid, chat_flags, message, chat_type, lang, range_): GridManager.send_surrounding_in_range(ChatManager._get_message_packet( guid, chat_flags, message, chat_type, lang), world_session.player_mgr, range_, use_ignore=True)
def send_chat_message(world_session, guid, chat_flags, message, chat_type, lang, range_): GridManager.send_surrounding_in_range( ChatManager._get_message_packet(guid, chat_flags, message, chat_type, 0), # TODO Handle language world_session.player_mgr, range_)
def play_emote(self, emote): if emote != 0: data = pack('<IQ', emote, self.guid) GridManager.send_surrounding_in_range( PacketWriter.get_packet(OpCode.SMSG_EMOTE, data), self, config.World.Chat.ChatRange.emote_range)