summaryrefslogtreecommitdiff
path: root/net/packet_out.py
blob: 2a73a59b81232831e7c61dfdbac93a953e78d63d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from packet import *
from protocol import *

def emote(emoteId):
    emote_packet = PacketOut(CMSG_PLAYER_EMOTE)
    emote_packet.write_int8(emoteId)
    return str(emote_packet)

def whisper(nick, message):
    whisp_packet = PacketOut(CMSG_CHAT_WHISPER)
    whisp_packet.write_int16(len(message) + 28)
    whisp_packet.write_string(nick, 24)
    whisp_packet.write_string(message, len(message))
    return str(whisp_packet)

def chat(text):
    chat_packet = PacketOut(CMSG_CHAT_MESSAGE)
    mes = "ManaMarket"+" : "+text
    chat_packet.write_int16(len(mes) + 4 + 1)
    # chat_packet = PacketOut(CMSG_CHAT_MESSAGE)
    chat_packet.write_string(mes, len(mes) + 1)
    return str(chat_packet)

def sit(val):
    sit_packet = PacketOut(CMSG_PLAYER_CHANGE_ACT)
    sit_packet.write_int32(0)
    if val == True:
        sit_packet.write_int8(2)
    else:
        sit_packet.write_int8(3)
    return str(sit_packet)

def trade_request(being_id):
    trade_req_packet = PacketOut(CMSG_TRADE_REQUEST)
    trade_req_packet.write_int32(being_id)
    return str(trade_req_packet)

def trade_respond(accept):
    trade_respond_packet = PacketOut(CMSG_TRADE_RESPONSE)
    if accept == True:
        trade_respond_packet.write_int8(3)
    elif accept == False:
        trade_respond_packet.write_int8(4)
    return str(trade_respond_packet)

def trade_add_item(item_index, amount):
    trade_add_packet = PacketOut(CMSG_TRADE_ITEM_ADD_REQUEST)
    trade_add_packet.write_int16(item_index + inventory_offset)
    trade_add_packet.write_int32(amount)
    return str(trade_add_packet)