def do_0a0a(self, data_io): #send trade ask target_id = io_unpack_int(data_io) p = users.get_pc_from_id(target_id) if not p: general.log("[ map ] trade ask: target not exist", target_id) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return with self.pc.lock and p.lock and p.user.lock: if not p.online: general.log("[ map ] trade ask: target not online", target_id) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return if self.pc.map_id != p.map_id: general.log("[ map ] trade ask: target not on the same map", target_id) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return if self.pc.trade: self.send("0a0b", -1) #trade ask result, トレード中です return if self.pc.event_id: self.send("0a0b", -2) #trade ask result, イベント中です return if p.trade: self.send("0a0b", -3) #trade ask result, 相手がトレード中です return if p.event_id: self.send("0a0b", -4) #trade ask result, 相手がイベント中です return p.map_send("0a0c", self.pc) #receive trade ask self.pc.trade_target_id = p.id p.trade_target_id = self.pc.id
def do_0a0a(self, data_io): #send trade ask target_id = io_unpack_int(data_io) p = users.get_pc_from_id(target_id) if not p: general.log("[ map ] trade ask: target not exist", target_id) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return with self.pc.lock and p.lock and p.user.lock: if not p.online: general.log("[ map ] trade ask: target not online", target_id) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return if self.pc.map_id != p.map_id: general.log( "[ map ] trade ask: target not on the same map", target_id ) self.send("0a0b", -5) #trade ask result, 相手が見つかりません return if self.pc.trade: self.send("0a0b", -1) #trade ask result, トレード中です return if self.pc.event_id: self.send("0a0b", -2) #trade ask result, イベント中です return if p.trade: self.send("0a0b", -3) #trade ask result, 相手がトレード中です return if p.event_id: self.send("0a0b", -4) #trade ask result, 相手がイベント中です return p.map_send("0a0c", self.pc) #receive trade ask self.pc.trade_target_id = p.id p.trade_target_id = self.pc.id
def do_09c4(self, data_io): #アイテム使用 item_iid = io_unpack_int(data_io) target_id = io_unpack_int(data_io) x = io_unpack_unsigned_byte(data_io) y = io_unpack_unsigned_byte(data_io) with self.pc.lock: item = self.pc.item.get(item_iid) if not item: return event_id = item.event_id item_event_id = item.item_id item_skill_id = item.skill_id p = self.pc if target_id == -1: #対象:地面 pass elif target_id != self.pc.id: #対象:単体 p = users.get_pc_from_id(target_id) if not (p and p.online): return if event_id: script.run(p, event_id, item_event_id) else: #アイテム使用結果 #success self.send("09c5", self.pc, item_event_id, target_id, x, y) #アイテム使用効果 (対象:地面) self.send("09c6", self.pc, item_event_id, target_id, x, y) skills.use(self.pc, target_id, x, y, item_skill_id, 1)
def do_09c4(self, data_io): #アイテム使用 item_iid = io_unpack_int(data_io) target_id = io_unpack_int(data_io) x = io_unpack_unsigned_byte(data_io) y = io_unpack_unsigned_byte(data_io) with self.pc.lock: item = self.pc.item.get(item_iid) if not item: return event_id = item.event_id item_event_id = item.item_id item_skill_id = item.skill_id p = self.pc if target_id == -1: #対象:地面 pass elif target_id != self.pc.id: #対象:単体 p = users.get_pc_from_id(target_id) if not (p and p.online): return if event_id: script.run(p, event_id, item_event_id) else: #アイテム使用結果 #success self.send("09c5", self.pc, item_event_id, target_id, x, y) #アイテム使用効果 (対象:地面) self.send("09c6", self.pc, item_event_id, target_id, x, y) skills.use(self.pc, target_id, x, y, item_skill_id, 1)
def get_trade_target(self): if not self.trade_target_id: return None if not self.online: general.log("[ pc ] get_trade_target: not self.online") return False p = users.get_pc_from_id(self.trade_target_id) if not p: general.log("[ pc ] get_trade_target: not p") return False if not p.online: general.log("[ pc ] get_trade_target: not p.online") return False if self.map_id != p.map_id: general.log("[ pc ] get_trade_target: self.map_id != p.map_id") return False return p
def get_trade_target(self): if not self.trade_target_id: return None if not self.online: general.log("[ pc ] get_trade_target: not self.online") return False p = users.get_pc_from_id(self.trade_target_id) if not p: general.log("[ pc ] get_trade_target: not p") return False if not p.online: general.log("[ pc ] get_trade_target: not p.online") return False if self.map_id != p.map_id: general.log("[ pc ] get_trade_target: self.map_id != p.map_id") return False return p
def do_1d4c(self, data_io): #greeting target_id = io_unpack_int(data_io) p = users.get_pc_from_id(target_id) with self.pc.lock and p.lock: rawdir = general.get_angle_from_coord(self.pc.x, self.pc.y, p.x, p.y) p_rawdir = general.get_angle_from_coord(p.x, p.y, self.pc.x, self.pc.y) if rawdir is None or p_rawdir is None: self.pc.set_raw_dir(0.0) p.set_raw_dir(180.0) else: self.pc.set_raw_dir(rawdir) p.set_raw_dir(p_rawdir) self.send_map("11f9", self.pc, 0x01) #キャラ移動アナウンス 向き変更のみ self.send_map("11f9", p, 0x01) #キャラ移動アナウンス 向き変更のみ motion = random.choice((113, 163, 164)) self.pc.set_motion(motion, False) p.set_motion(motion, False)
def send_object_detail(self, i): if i >= pets.MIN_PET_ID: pet = pets.get_pet_from_id(i) if not pet: return if not pet.master: return self.send("020d", pet) #キャラ情報 #self.send_map("11f9", self.pc.pet, 0x06) #キャラ移動アナウンス else: p = users.get_pc_from_id(i) if not p: return with p.lock: if not p.online: return if not p.visible: return self.send("020d", p) #キャラ情報 self.send("041b", p) #kanban
def do_1d4c(self, data_io): #greeting target_id = io_unpack_int(data_io) p = users.get_pc_from_id(target_id) with self.pc.lock and p.lock: rawdir = general.get_angle_from_coord(self.pc.x, self.pc.y, p.x, p.y) p_rawdir = general.get_angle_from_coord(p.x, p.y, self.pc.x, self.pc.y) if rawdir is None or p_rawdir is None: self.pc.set_raw_dir(0.0) p.set_raw_dir(180.0) else: self.pc.set_raw_dir(rawdir) p.set_raw_dir(p_rawdir) self.send_map("11f9", self.pc, 0x01) #キャラ移動アナウンス 向き変更のみ self.send_map("11f9", p, 0x01) #キャラ移動アナウンス 向き変更のみ motion = random.choice((113, 163, 164)) self.pc.set_motion(motion, False) p.set_motion(motion, False)
def send_object_detail(self, i): if i >= pets.MIN_PET_ID: pet = pets.get_pet_from_id(i) if not pet: return if not pet.master: return self.send("020d", pet) #キャラ情報 #self.send_map("11f9", self.pc.pet, 0x06) #キャラ移動アナウンス else: p = users.get_pc_from_id(i) if not p: return with p.lock: if not p.online: return if not p.visible: return self.send("020d", p) #キャラ情報 self.send("041b", p) #kanban