def smsg_char_login(data): netlog.info("SMSG_CHAR_LOGIN {}".format(data)) char_slot = -1 for c in data.chars: if c.name == server.char_name: char_slot = c.slot mapserv.player_money = c.money mapserv.player_stats[stats.EXP] = c.exp mapserv.player_stats[stats.MONEY] = c.money mapserv.player_stats[stats.JOB] = c.job mapserv.player_stats[stats.CHAR_POINTS] = c.charpoints mapserv.player_stats[stats.HP] = c.hp mapserv.player_stats[stats.MAX_HP] = c.max_hp mapserv.player_stats[stats.MP] = c.mp mapserv.player_stats[stats.MAX_MP] = c.max_mp mapserv.player_stats[stats.WALK_SPEED] = c.speed mapserv.player_stats[stats.LEVEL] = c.level mapserv.player_stats[stats.SKILL_POINTS] = c.skillpoints break if char_slot < 0: netlog.error("CharName {} not found".format(server.char_name)) server.close() else: cmsg_char_select(char_slot)
def smsg_login_data(data): netlog.info("SMSG_LOGIN_DATA {}".format(data)) server.close() charserv.connect(data.worlds[0].address, data.worlds[0].port) charserv.server.char_name = server.char_name charserv.cmsg_char_server_connect(data.account, data.session1, data.session2, 1, data.gender)
def cmsg_login_register(username, password): netlog.info("CMSG_LOGIN_REGISTER username={} password={}".format( username, password)) send_packet(server, CMSG_LOGIN_REGISTER, (ULInt32("clientversion"), 6), (StringZ("username", 24), username), (StringZ("password", 24), password), (Byte("flags"), 3))
def smsg_char_map_info(data): netlog.info("SMSG_CHAR_MAP_INFO CID={} map={} address={} port={}".format( data.char_id, data.map_name, data.address, data.port)) server.close() mapserv.connect(data.address, data.port) mapserv.server.char_name = server.char_name mapserv.server.char_id = data.char_id mapserv.cmsg_map_server_connect(server.account, data.char_id, server.session1, server.session2, server.gender)
def smsg_char_login(data): netlog.info("SMSG_CHAR_LOGIN {}".format(data)) char_slot = -1 for c in data.chars: if c.name == server.char_name: char_slot = c.slot mapserv.player_money = c.money break if char_slot < 0: raise Exception("CharName {} not found".format(server.char_name)) cmsg_char_select(char_slot)
def cmsg_char_server_connect(account, session1, session2, proto, gender): netlog.info(("CMSG_CHAR_SERVER_CONNECT account={} session1={} " "session2={} proto={} gender={}").format( account, session1, session2, proto, gender)) # save session data server.account = account server.session1 = session1 server.session2 = session2 server.gender = gender send_packet(server, CMSG_CHAR_SERVER_CONNECT, (ULInt32("account"), account), (ULInt32("session1"), session1), (ULInt32("session2"), session2), (ULInt16("proto"), proto), (Gender("gender"), gender))
def cmsg_player_emote(emote): netlog.info("CMSG_PLAYER_EMOTE {}".format(emote)) send_packet(server, CMSG_PLAYER_EMOTE, (Byte("emote"), emote))
def smsg_server_version(data): netlog.info("SMSG_SERVER_VERSION {}.{}".format(data.hi, data.lo)) cmsg_login_register(server.username, server.password)
def smsg_party_chat(data): netlog.info("SMSG_PARTY_CHAT {} : {}".format(data.id, data.message))
def smsg_gm_chat(data): netlog.info("SMSG_GM_CHAT {}".format(data.message))
def smsg_player_update(data): netlog.info("SMSG_PLAYER_UPDATE_ {}".format(data)) beings_cache.findName(data.id, data.job) beings_cache[data.id].speed = data.speed beings_cache[data.id].x = data.coor.x beings_cache[data.id].y = data.coor.y
def smsg_player_inventory_use(data): netlog.info("SMSG_PLAYER_INVENTORY_USE {}".format(data)) if data.amount > 0: player_inventory[data.index] = (data.item_id, data.amount) else: del player_inventory[data.index]
def cmsg_player_unequip(index): netlog.info("CMSG_PLAYER_UNEQUIP index={}".format(index)) send_packet(server, CMSG_PLAYER_UNEQUIP, (ULInt16("index"), index))
def cmsg_npc_close(npcId): netlog.info("CMSG_NPC_CLOSE id={}".format(npcId)) send_packet(server, CMSG_NPC_CLOSE, (ULInt32("npcId"), npcId))
def cmsg_npc_next_request(npcId): netlog.info("CMSG_NPC_NEXT_REQUEST id={}".format(npcId)) send_packet(server, CMSG_NPC_NEXT_REQUEST, (ULInt32("npcId"), npcId))
def cmsg_npc_talk(npcId): netlog.info("CMSG_NPC_TALK id={}".format(npcId)) send_packet(server, CMSG_NPC_TALK, (ULInt32("npcId"), npcId), (Byte("unused"), 0))
def smsg_player_chat(data): netlog.info("SMSG_PLAYER_CHAT {}".format(data.message))
def cmsg_player_inventory_drop(index, amount): netlog.info("CMSG_PLAYER_INVENTORY_DROP index={} amount={}".format( index, amount)) send_packet(server, CMSG_PLAYER_INVENTORY_DROP, (ULInt16("index"), index), (ULInt16("amount"), amount))
def cmsg_player_inventory_use(index, item_id): netlog.info("CMSG_PLAYER_INVENTORY_USE index={} id={}".format( index, item_id)) send_packet(server, CMSG_PLAYER_INVENTORY_USE, (ULInt16("index"), index), (ULInt32("id"), item_id))
def cmsg_player_respawn(): netlog.info("CMSG_PLAYER_RESPAWN") send_packet(server, CMSG_PLAYER_RESPAWN, (Byte("action"), 0))
def cmsg_char_select(slot): netlog.info("CMSG_CHAR_SELECT slot={}".format(slot)) send_packet(server, CMSG_CHAR_SELECT, (Byte("slot"), slot))
def cmsg_npc_list_choice(npcId, choice): netlog.info("CMSG_NPC_LIST_CHOICE id={} choice={}".format(npcId, choice)) send_packet(server, CMSG_NPC_LIST_CHOICE, (ULInt32("npcId"), npcId), (Byte("choice"), choice))
def smsg_player_inventory_remove(data): netlog.info("SMSG_PLAYER_INVENTORY_REMOVE index={} amount={}".format( data.index, data.amount)) remove_from_inventory(data.index, data.amount)
def cmsg_npc_int_response(npcId, value): netlog.info("CMSG_NPC_INT_RESPONSE id={} value={}".format(npcId, value)) send_packet(server, CMSG_NPC_INT_RESPONSE, (ULInt32("npcId"), npcId), (SLInt32("value"), value))
def smsg_player_stop(data): netlog.info("SMSG_PLAYER_STOP id={} x={} y={}".format( data.id, data.x, data.y)) beings_cache.findName(data.id) beings_cache[data.id].x = data.x beings_cache[data.id].y = data.y
def cmsg_npc_buy_sell_request(npcId, action): netlog.info("CMSG_NPC_BUY_SELL_REQUEST id={} action={}".format( npcId, action)) send_packet(server, CMSG_NPC_BUY_SELL_REQUEST, (ULInt32("npcId"), npcId), (Byte("action"), action))
def smsg_ip_response(data): netlog.info("SMSG_IP_RESPONSE id={} ip={}".format(data.id, data.ip))
def smsg_player_equipment(data): netlog.info("SMSG_PLAYER_EQUIPMENT {}".format(data)) for item in data.equipment: player_inventory[item.index] = (item.id, 1)
def smsg_party_info(data): global party_info, party_members party_info = data for m in data.members: party_members[m.id] = m.nick netlog.info("SMSG_PARTY_INFO {}".format(data))
def cmsg_stat_update_request(stat, value): netlog.info("CMSG_STAT_UPDATE_REQUEST stat={} value={}".format( stat, value)) send_packet(server, CMSG_STAT_UPDATE_REQUEST, (ULInt16("stat"), stat), (Byte("value"), value))
def smsg_trade_request(data): netlog.info("SMSG_TRADE_REQUEST {}".format(data.nick))
def cmsg_skill_levelup_request(skillId): netlog.info("CMSG_SKILL_LEVELUP_REQUEST skillId={}".format(skillId)) send_packet(server, CMSG_SKILL_LEVELUP_REQUEST, (ULInt16("id"), skillId))
def smsg_update_host(data): netlog.info("SMSG_UPDATE_HOST {}".format(data.host))
def cmsg_move_from_storage(index, amount): netlog.info("CMSG_MOVE_FROM_STORAGE index={} amount={}".format( index, amount)) send_packet(server, CMSG_MOVE_FROM_STORAGE, (ULInt16("index"), index), (ULInt32("amount"), amount))
def cmsg_server_version_request(): netlog.info("CMSG_SERVER_VERSION_REQUEST") ULInt16("opcode").build_stream(0x7530, server)
def cmsg_item_pickup(item_id): netlog.info("CMSG_ITEM_PICKUP id={}".format(item_id)) send_packet(server, CMSG_ITEM_PICKUP, (ULInt32("id"), item_id))
def smsg_player_inventory(data): netlog.info("SMSG_PLAYER_INVENTORY {}".format(data)) for item in data.inventory: player_inventory[item.index] = (item.id, item.amount)
def smsg_player_inventory_add(data): netlog.info("SMSG_PLAYER_INVENTORY_ADD index={} id={} amount={}".format( data.index, data.id, data.amount)) add_to_inventory(data.index, data.id, data.amount)
def cmsg_storage_close(): netlog.info("CMSG_CLOSE_STORAGE") ULInt16("opcode").build_stream(CMSG_CLOSE_STORAGE, server)
def cmsg_player_stop_attack(): netlog.info("CMSG_PLAYER_STOP_ATTACK") ULInt16("opcode").build_stream(CMSG_PLAYER_STOP_ATTACK, server)