Exemple #1
0
def send_map(map_id, *args):
    map_obj = general.get_map(map_id)
    if not map_obj:
        error = "send_map: map_id %s not exist." % map_id
        general.log_error(error)
        return error
    send_map_obj(map_id, *args)
Exemple #2
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) #キャラの状態
Exemple #3
0
def unset_usermap(pc, logout=False):
	with pc.lock:
		if not pc.usermap_obj:
			return
		i = pc.usermap_obj.id
		general.log("[umaps] del usermap id", i)
		usermap_obj = pc.usermap_obj
		map_obj = general.get_map(usermap_obj.entrance_map_id)
		if not map_obj:
			general.log_error(
				"[umaps] unset_usermap error: entrance_map_id not exist",
				usermap_obj.entrance_map_id,
			)
			return
		if logout:
			script.send_map_obj(map_obj, (pc,), "0bb9", pc) #飛空庭のひも・テント消去
		else:
			script.send_map_obj(map_obj, (), "0bb9", pc) #飛空庭のひも・テント消去
		for p in general.copy(usermap_obj.pc_list):
			if logout and p == pc:
				pc.set_map(usermap_obj.entrance_map_id)
				pc.set_coord(usermap_obj.entrance_x, usermap_obj.entrance_y)
				continue
			try:
				script.warp(
					p,
					usermap_obj.entrance_map_id,
					usermap_obj.entrance_x,
					usermap_obj.entrance_y,
				)
			except:
				general.log_error(traceback.format_exc())
		with usermap_list_lock:
			del usermap_list[i]
			pc.usermap_obj = None
Exemple #4
0
def send_map(map_id, *args):
	map_obj = general.get_map(map_id)
	if not map_obj:
		error = "send_map: map_id %s not exist."%map_id
		general.log_error(error)
		return error
	send_map_obj(map_id, *args)
Exemple #5
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)  #キャラの状態