Ejemplo n.º 1
0
 def reset_map(self):
     with self.lock:
         if self.map_obj:
             if self.online:
                 self.unset_pet(True)
                 self.unset_usermap(True)
                 #PC消去
                 script.send_map_obj(self.map_obj, (self, ), "1211", self)
             with self.map_obj.lock:
                 self.map_obj.pc_list.remove(self)
         self.online = False
         self.visible = False
         self.size = 1000
         self.motion_id = 111
         self.motion_loop = False
         self.rawx = 0
         self.rawy = 0
         self.rawdir = 0
         self.battlestatus = 0
         self.wrprank = 0
         self.event_id = 0
         self.item_event_id = 0
         #self.loginevent = False
         self.logout = False
         self.pet = None  #Pet()
         self.kanban = ""
         self.map_obj = None
         self.usermap_obj = None
         self.warehouse_open = None  #warehouse_id
         self.shop_open = None  #shop_id or shop_item_list
         self.select_result = None
         self.reset_trade()
Ejemplo n.º 2
0
	def reset_map(self):
		with self.lock:
			if self.map_obj:
				if self.online:
					self.unset_pet(True)
					self.unset_usermap(True)
					#PC消去
					script.send_map_obj(self.map_obj, (self,), "1211", self)
				with self.map_obj.lock:
					self.map_obj.pc_list.remove(self)
			self.online = False
			self.visible = False
			self.size = 1000
			self.motion_id = 111
			self.motion_loop = False
			self.rawx = 0
			self.rawy = 0
			self.rawdir = 0
			self.battlestatus = 0
			self.wrprank = 0
			self.event_id = 0
			self.item_event_id = 0
			#self.loginevent = False
			self.logout = False
			self.pet = None #Pet()
			self.kanban = ""
			self.map_obj = None
			self.usermap_obj = None
			self.warehouse_open = None #warehouse_id
			self.shop_open = None #shop_id or shop_item_list
			self.select_result = None
			self.reset_trade()
Ejemplo n.º 3
0
 def send_map(self, *args):
     with self.pc.lock:
         if not self.pc.map_obj:
             general.log_error("[ map ] send_map: not self.pc.map_obj",
                               self.pc)
             return
         script.send_map_obj(self.pc.map_obj, (), *args)
Ejemplo n.º 4
0
def delete(monster):
	with monster_list_lock and monster.lock:
		monster_list.remove(monster)
		monster_id_list.remove(monster.id)
		if monster.map_obj:
			script.send_map_obj(monster.map_obj, (), "1225", monster) #モンスター消去
		general.log("[monster] delete monster id %s"%(monster.id))
		monster.reset()
	del monster
Ejemplo n.º 5
0
def delete(monster):
    with monster_list_lock and monster.lock:
        monster_list.remove(monster)
        monster_id_list.remove(monster.id)
        if monster.map_obj:
            script.send_map_obj(monster.map_obj, (), "1225", monster)  #モンスター消去
        general.log("[monster] delete monster id %s" % (monster.id))
        monster.reset()
    del monster
Ejemplo n.º 6
0
	def damage(self, i):
		with self.lock:
			if self.status.hp <= 0:
				general.log_error("[monster] monster.hp <= 0", self)
				return 0
			state_list = dict((j, 0) for j in xrange(10))
			self.status.hp -= i
			if self.status.hp <= 0:
				self.status.hp = 0
				state_list[0] |= 0x200 #行動不能
				general.start_thread(monsters.delete_monster_thread, (self,))
		script.send_map_obj(self.map_obj, (), "021c", self) #現在のHP/MP/SP/EP
		script.send_map_obj(self.map_obj, (), "157c", self, state_list) #キャラの状態
		return self.status.hp
Ejemplo n.º 7
0
 def damage(self, i):
     with self.lock:
         if self.status.hp <= 0:
             general.log_error("[monster] monster.hp <= 0", self)
             return 0
         state_list = dict((j, 0) for j in xrange(10))
         self.status.hp -= i
         if self.status.hp <= 0:
             self.status.hp = 0
             state_list[0] |= 0x200  #行動不能
             general.start_thread(monsters.delete_monster_thread, (self, ))
     script.send_map_obj(self.map_obj, (), "021c", self)  #現在のHP/MP/SP/EP
     script.send_map_obj(self.map_obj, (), "157c", self,
                         state_list)  #キャラの状態
     return self.status.hp
Ejemplo n.º 8
0
def spawn(monster_id, map_id, x, y):
	error = None
	monster = general.get_monster(monster_id)
	if not monster:
		error = "spawn: monster_id %s not exist."%monster_id
		general.log_error(error)
		return error
	map_obj = general.get_map(map_id)
	if not map_obj:
		error = "spawn: map_id %s not exist."%map_id
		general.log_error(error)
		return error
	monster.reset()
	with monster_list_lock and monster.lock:
		monster_id = general.make_id(monster_id_list, MIN_MONSTER_ID)
		if monster_id >= MAX_MONSTER_ID:
			error = "[monster] ERROR: monster_id [%s] >= MAX_MONSTER_ID"%monster_id
			general.log_error(error)
			return error
		monster.id = monster_id
		monster.set_map(map_id)
		monster.set_coord(x, y)
		monster_list.append(monster)
		monster_id_list.append(monster.id)
	script.send_map_obj(map_obj, (), "122a", (monster.id,)) #モンスターID通知
	if error:
		delete(monster)
		return error
	general.log("[monster] spawn monster id %s"%(monster.id))
	script.send_map_obj(map_obj, (), "1220", monster) #モンスター情報
	script.send_map_obj(map_obj, (), "157c", monster) #キャラの状態
Ejemplo n.º 9
0
def spawn(monster_id, map_id, x, y):
    error = None
    monster = general.get_monster(monster_id)
    if not monster:
        error = "spawn: monster_id %s not exist." % monster_id
        general.log_error(error)
        return error
    map_obj = general.get_map(map_id)
    if not map_obj:
        error = "spawn: map_id %s not exist." % map_id
        general.log_error(error)
        return error
    monster.reset()
    with monster_list_lock and monster.lock:
        monster_id = general.make_id(monster_id_list, MIN_MONSTER_ID)
        if monster_id >= MAX_MONSTER_ID:
            error = "[monster] ERROR: monster_id [%s] >= MAX_MONSTER_ID" % monster_id
            general.log_error(error)
            return error
        monster.id = monster_id
        monster.set_map(map_id)
        monster.set_coord(x, y)
        monster_list.append(monster)
        monster_id_list.append(monster.id)
    script.send_map_obj(map_obj, (), "122a", (monster.id, ))  #モンスターID通知
    if error:
        delete(monster)
        return error
    general.log("[monster] spawn monster id %s" % (monster.id))
    script.send_map_obj(map_obj, (), "1220", monster)  #モンスター情報
    script.send_map_obj(map_obj, (), "157c", monster)  #キャラの状態
Ejemplo n.º 10
0
	def send_map(self, *args):
		with self.pc.lock:
			if not self.pc.map_obj:
				general.log_error("[ map ] send_map: not self.pc.map_obj", self.pc)
				return
			script.send_map_obj(self.pc.map_obj, (), *args)
Ejemplo n.º 11
0
	def send_map_without_self(self, *args):
		with self.pc.lock:
			if not self.pc.map_obj:
				return
			script.send_map_obj(self.pc.map_obj, (self.pc,), *args)
Ejemplo n.º 12
0
	def mapitem_append(self, item, x, y, id_from):
		with self.lock:
			mapitem_id = general.make_id(mi.id for mi in self.mapitem_list)
			mapitem_obj = mapitem.MapItem(item, x, y, id_from, mapitem_id)
			self.mapitem_list.append(mapitem_obj)
			script.send_map_obj(self, (), "07d5", mapitem_obj) #drop item info
Ejemplo n.º 13
0
 def send_map_without_self(self, *args):
     with self.pc.lock:
         if not self.pc.map_obj:
             return
         script.send_map_obj(self.pc.map_obj, (self.pc, ), *args)
Ejemplo n.º 14
0
 def mapitem_append(self, item, x, y, id_from):
     with self.lock:
         mapitem_id = general.make_id(mi.id for mi in self.mapitem_list)
         mapitem_obj = mapitem.MapItem(item, x, y, id_from, mapitem_id)
         self.mapitem_list.append(mapitem_obj)
         script.send_map_obj(self, (), "07d5", mapitem_obj)  #drop item info