Exemplo n.º 1
0
def o_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'O': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if pArea.player_count > 0 or handler_item.count_obj_list(
            itemTemplate, roomInstance.items) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(
        itemTemplate, min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
    item.cost = 0
    roomInstance.put(item)
    item = None
    last = True
    return last, level, npc
Exemplo n.º 2
0
def spl_charm_person(sn, level, ch, victim, target):
    if ch == victim:
        ch.send("You like yourself even better!\n")
        return

    if not victim.is_npc() and victim.immune.is_set(merc.IMM_CHARM):
        ch.send("You failed.\n")
        return

    # I don't want people charming ghosts and stuff - KaVir
    if victim.is_npc() and victim.is_affected(merc.AFF_ETHEREAL):
        ch.send("You failed.\n")
        return

    if victim.is_immortal():
        ch.send("You can cast puny mortal magic on immortals!\n")
        return

    if victim.is_affected(merc.AFF_CHARM) or ch.is_affected(
            merc.AFF_CHARM
    ) or level < victim.level or handler_magic.saves_spell(level, victim):
        return

    if victim.master:
        victim.stop_follower()

    victim.add_follower(ch)
    aff = handler_game.AffectData(type=sn,
                                  duration=game_utils.number_fuzzy(level // 4),
                                  bitvector=merc.AFF_CHARM)
    victim.affect_add(aff)
    handler_game.act("Isn't $n just so nice?", ch, None, victim, merc.TO_VICT)

    if ch != victim:
        ch.send("Ok.\n")
Exemplo n.º 3
0
def o_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'O': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.room_templates.keys():
        logger.error("Reset_area: 'R': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        roomInstance_id = instance.instances_by_room[pReset.arg3][0]
        roomInstance = instance.global_instances[roomInstance_id]

    if pArea.player_count > 0 or handler_item.count_obj_list(itemTemplate, roomInstance.items) > 0:
        last = False
        return last, level, npc

    item = object_creator.create_item(itemTemplate, min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
    item.cost = 0
    roomInstance.put(item)
    item = None
    last = True
    return last, level, npc
Exemplo n.º 4
0
def load_npcs(area, parea):
    area, w = game_utils.read_word(area, False)
    w = w[1:]  # strip the pound
    while w != "0":
        vnum = int(w)
        if vnum in instance.npc_templates:
            comm.notify("load_npcs: vnum {} duplicated.".format(vnum),
                        merc.CONSOLE_CRITICAL)
            sys.exit(1)

        npc = handler_npc.Npc()
        npc.vnum = vnum
        instance.npc_templates[npc.vnum] = npc
        npc.area = parea.name

        area, npc.name = game_utils.read_string(area)
        npc.name = npc.name.lower()
        area, npc.short_descr = game_utils.read_string(area)

        area, npc.long_descr = game_utils.read_string(area)
        npc.long_descr = miniboa.terminal.escape(npc.long_descr, "ANSI")
        area, npc.description = game_utils.read_string(area)
        npc.description = miniboa.terminal.escape(npc.description, "ANSI")

        area, act = game_utils.read_int(area)
        npc.act.bits = act | merc.ACT_IS_NPC
        area, affected_by = game_utils.read_int(area)
        npc.affected_by.bits = affected_by
        area, npc.alignment = game_utils.read_int(area)

        area, letter = game_utils.read_letter(area)
        area, level = game_utils.read_int(area)
        npc.level = game_utils.number_fuzzy(level)
        area, npc.hitroll = game_utils.read_int(area)
        area, npc.armor = game_utils.read_word(area)
        area, dummy = game_utils.read_int(area)
        area = game_utils.read_forward(area)
        area, dummy = game_utils.read_int(area)
        area = game_utils.read_forward(area)
        area, dummy = game_utils.read_int(area)
        area, dummy = game_utils.read_int(area)
        area = game_utils.read_forward(area)
        area, dummy = game_utils.read_int(area)
        area = game_utils.read_forward(area)
        area, dummy = game_utils.read_int(area)
        area, npc.gold = game_utils.read_int(area)
        area, dummy = game_utils.read_int(area)
        area, dummy = game_utils.read_int(area)
        area, dummy = game_utils.read_int(area)
        area, npc.sex = game_utils.read_int(area)

        area, w = game_utils.read_word(area, False)
        w = w[1:]  # strip the pound
    return area
Exemplo n.º 5
0
def spl_pass_door(sn, level, ch, victim, target):
    if victim.is_affected(merc.AFF_PASS_DOOR):
        return

    aff = handler_game.AffectData(type=sn,
                                  duration=game_utils.number_fuzzy(level // 6),
                                  location=merc.APPLY_NONE,
                                  bitvector=merc.AFF_PASS_DOOR)
    victim.affect_join(aff)
    handler_game.act("$n turns translucent.", victim, None, None, merc.TO_ROOM)
    victim.send("You turn translucent.\n")
Exemplo n.º 6
0
def spl_sanctuary(sn, level, ch, victim, target):
    if victim.is_affected(merc.AFF_SANCTUARY):
        return

    aff = handler_game.AffectData(type=sn,
                                  duration=game_utils.number_fuzzy(level // 8),
                                  location=merc.APPLY_NONE,
                                  bitvector=merc.AFF_SANCTUARY)
    victim.affect_add(aff)
    handler_game.act("$n is surrounded by a white aura.", victim, None, None,
                     merc.TO_ROOM)
    victim.send("You are surrounded by a white aura.\n")
Exemplo n.º 7
0
def p_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        item_toTemplate = instance.item_templates[pReset.arg3]
    if pReset.arg2 > 50:  # old format */
        limit = 6
    elif pReset.arg2 == -1:  # no limit */
        limit = 999
    else:
        limit = pReset.arg2
    item_to = None
    item_to_list = instance.instances_by_item.get(item_toTemplate.vnum, None)
    if item_to_list:
        item_to = instance.global_instances[item_to_list[0]]

    if pArea.player_count > 0 \
            or not item_to \
            or (not item_to.in_room and not last) \
            or (itemTemplate.count >= limit and random.randint(0, 4) != 0) \
            or handler_item.count_obj_list(itemTemplate, item_to.inventory) > pReset.arg4:
        last = False
        return last, level, npc
    count = handler_item.count_obj_list(itemTemplate, item_to.inventory)
    #Converted while to For Loop, testing indicated
    #While loop was ~.002-.004
    #For loop ~.0009-.001
    if item_to:
        for i in range(pReset.arg4):
            item = object_creator.create_item(
                itemTemplate, game_utils.number_fuzzy(item_to.level))
            item_to.put(item)
            item = None
            count += 1
            if count >= pReset.arg4:
                break
            if itemTemplate.count >= limit:
                break

    # fix object lock state! */
        item_to.value[1] = item_toTemplate.value[1]
    last = True
    return last, level, npc
Exemplo n.º 8
0
def p_reset(pArea, pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]

    if pReset.arg3 not in instance.item_templates.keys():
        logger.error("Reset_area: 'P': bad vnum %d.", pReset.arg3)
        return last, level, npc
    else:
        item_toTemplate = instance.item_templates[pReset.arg3]
    if pReset.arg2 > 50:  # old format */
        limit = 6
    elif pReset.arg2 == -1:  # no limit */
        limit = 999
    else:
        limit = pReset.arg2
    item_to = None
    item_to_list = instance.instances_by_item.get(item_toTemplate.vnum, None)
    if item_to_list:
        item_to = instance.global_instances[item_to_list[0]]

    if pArea.player_count > 0 \
            or not item_to \
            or (not item_to.in_room and not last) \
            or (itemTemplate.count >= limit and random.randint(0, 4) != 0) \
            or handler_item.count_obj_list(itemTemplate, item_to.inventory) > pReset.arg4:
        last = False
        return last, level, npc
    count = handler_item.count_obj_list(itemTemplate, item_to.inventory)
    #Converted while to For Loop, testing indicated
    #While loop was ~.002-.004
    #For loop ~.0009-.001
    if item_to:
        for i in range(pReset.arg4):
            item = object_creator.create_item(itemTemplate, game_utils.number_fuzzy(item_to.level))
            item_to.put(item)
            item = None
            count += 1
            if count >= pReset.arg4:
                break
            if itemTemplate.count >= limit:
                break

    # fix object lock state! */
        item_to.value[1] = item_toTemplate.value[1]
    last = True
    return last, level, npc
Exemplo n.º 9
0
def do_eat(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Eat what?\n")
        return
    obj = ch.get_item_carry(arg, ch)
    if not obj:
        ch.send("You do not have that item.\n")
        return
    if not ch.is_immortal():
        if obj.item_type != merc.ITEM_FOOD and obj.item_type != merc.ITEM_PILL:
            ch.send("That's not edible.\n")
            return
        if not ch.is_npc() and ch.condition[merc.COND_FULL] > 40:
            ch.send("You are too full to eat more.\n")
            return
    handler_game.act("$n eats $p.", ch, obj, None, merc.TO_ROOM)
    handler_game.act("You eat $p.", ch, obj, None, merc.TO_CHAR)
    if obj.item_type == merc.ITEM_FOOD:
        if not ch.is_npc():
            condition = ch.condition[merc.COND_HUNGER]
            update.gain_condition(ch, merc.COND_FULL, obj.value[0])
            update.gain_condition(ch, merc.COND_HUNGER, obj.value[1])
            if condition == 0 and ch.condition[merc.COND_HUNGER] > 0:
                ch.send("You are no longer hungry.\n")
            elif ch.condition[merc.COND_FULL] > 40:
                ch.send("You are full.\n")
        if obj.value[3] != 0:
            # The food was poisoned!
            af = handler_game.AFFECT_DATA()
            handler_game.act("$n chokes and gags.", ch, 0, 0, merc.TO_ROOM)
            ch.send("You choke and gag.\n")
            af.where = merc.TO_AFFECTS
            af.type = "poison"
            af.level = game_utils.number_fuzzy(obj.value[0])
            af.duration = 2 * obj.value[0]
            af.location = merc.APPLY_NONE
            af.modifier = 0
            af.bitvector = merc.AFF_POISON
            ch.affect_join(af)
    elif obj.item_type == merc.ITEM_PILL:
        handler_magic.obj_cast_spell(obj.value[1], obj.value[0], ch, ch, None)
        handler_magic.obj_cast_spell(obj.value[2], obj.value[0], ch, ch, None)
        handler_magic.obj_cast_spell(obj.value[3], obj.value[0], ch, ch, None)
    obj.extract()
    return
Exemplo n.º 10
0
def spell_fireproof(sn, level, ch, victim, target):
    obj = victim
    if obj.flags.burn_proof:
        handler_game.act("$p is already protected from burning.", ch, obj, None, merc.TO_CHAR)
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_OBJECT
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = merc.APPLY_NONE
    af.modifier = 0
    af.bitvector = merc.ITEM_BURN_PROOF

    obj.affect_add(af)

    handler_game.act("You protect $p from fire.", ch, obj, None, merc.TO_CHAR)
    handler_game.act("$p is surrounded by a protective aura.", ch, obj, None, merc.TO_ROOM)
Exemplo n.º 11
0
def spell_pass_door(sn, level, ch, victim, target):
    if victim.is_affected( merc.AFF_PASS_DOOR):
        if victim == ch:
            ch.send("You are already out of phase.\n")
        else:
            handler_game.act("$N is already shifted out of phase.", ch, None, victim, merc.TO_CHAR)
        return

    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = merc.APPLY_NONE
    af.modifier = 0
    af.bitvector = merc.AFF_PASS_DOOR
    victim.affect_add(af)
    handler_game.act("$n turns translucent.", victim, None, None, merc.TO_ROOM)
    victim.send("You turn translucent.\n")
Exemplo n.º 12
0
def spell_fireproof(sn, level, ch, victim, target):
    obj = victim
    if obj.flags.burn_proof:
        handler_game.act("$p is already protected from burning.", ch, obj,
                         None, merc.TO_CHAR)
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_OBJECT
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = merc.APPLY_NONE
    af.modifier = 0
    af.bitvector = merc.ITEM_BURN_PROOF

    obj.affect_add(af)

    handler_game.act("You protect $p from fire.", ch, obj, None, merc.TO_CHAR)
    handler_game.act("$p is surrounded by a protective aura.", ch, obj, None,
                     merc.TO_ROOM)
Exemplo n.º 13
0
def spell_pass_door(sn, level, ch, victim, target):
    if victim.is_affected(merc.AFF_PASS_DOOR):
        if victim == ch:
            ch.send("You are already out of phase.\n")
        else:
            handler_game.act("$N is already shifted out of phase.", ch, None,
                             victim, merc.TO_CHAR)
        return

    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = merc.APPLY_NONE
    af.modifier = 0
    af.bitvector = merc.AFF_PASS_DOOR
    victim.affect_add(af)
    handler_game.act("$n turns translucent.", victim, None, None, merc.TO_ROOM)
    victim.send("You turn translucent.\n")
Exemplo n.º 14
0
def spell_charm_person(sn, level, ch, victim, target):
    if fight.is_safe(ch, victim):
        return

    if victim == ch:
        ch.send("You like yourself even better! \n")
        return

    if ( victim.is_affected( merc.AFF_CHARM) \
                 or ch.is_affected(merc.AFF_CHARM) \
                 or level < victim.level \
                 or state_checks.IS_SET(victim.imm_flags, merc.IMM_CHARM) \
                 or handler_magic.saves_spell(level, victim, merc.DAM_CHARM) ):
        return

    if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_LAW):
        ch.send("The mayor does not allow charming in the city limits.\n")
        return

    if victim.master:
        handler_ch.stop_follower(victim)
    handler_ch.add_follower(victim, ch)
    victim.leader = ch
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = 0
    af.modifier = 0
    af.bitvector = merc.AFF_CHARM
    victim.affect_add(af)
    #TODO: Known broken. Mob will immediately try to fight you after casting this, because this is an offensive spell.
    #ROM had some stipulation to prevent this combat, possibly in fight.py:is_safe()
    handler_game.act("Isn't $n just so nice?", ch, None, victim, merc.TO_VICT)
    if ch is not victim:
        handler_game.act("$N looks at you with adoring eyes.", ch, None,
                         victim, merc.TO_CHAR)
Exemplo n.º 15
0
def spell_charm_person(sn, level, ch, victim, target):
    if fight.is_safe(ch, victim):
        return

    if victim == ch:
        ch.send("You like yourself even better! \n")
        return

    if ( victim.is_affected( merc.AFF_CHARM) \
                 or ch.is_affected(merc.AFF_CHARM) \
                 or level < victim.level \
                 or state_checks.IS_SET(victim.imm_flags, merc.IMM_CHARM) \
                 or handler_magic.saves_spell(level, victim, merc.DAM_CHARM) ):
        return

    if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_LAW):
        ch.send("The mayor does not allow charming in the city limits.\n")
        return

    if victim.master:
        handler_ch.stop_follower(victim)
    handler_ch.add_follower(victim, ch)
    victim.leader = ch
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = game_utils.number_fuzzy(level // 4)
    af.location = 0
    af.modifier = 0
    af.bitvector = merc.AFF_CHARM
    victim.affect_add(af)
    #TODO: Known broken. Mob will immediately try to fight you after casting this, because this is an offensive spell.
    #ROM had some stipulation to prevent this combat, possibly in fight.py:is_safe()
    handler_game.act("Isn't $n just so nice?", ch, None, victim, merc.TO_VICT)
    if ch is not victim:
        handler_game.act("$N looks at you with adoring eyes.", ch, None, victim, merc.TO_CHAR)
Exemplo n.º 16
0
def create_mobile(npc_template):
    if not npc_template:
        comm.notify("create_mobile: no npc_template", merc.CONSOLE_CRITICAL)
        sys.exit(1)

    npc = handler_npc.Npc(npc_template)
    npc.id = game_utils.get_mob_id(npc=True)
    npc.level = max(1, game_utils.number_fuzzy(npc_template.level))
    npc.armor = game_utils.interpolate(npc.level, 100, -100)

    if npc_template.spec_fun:
        npc.spec_fun = special.spec_table[npc_template.spec_fun]

    tempvalue = min(
        30000, npc.level * 8 + game_utils.number_range(
            npc.level * npc.level // 4, npc.level * npc.level))
    npc.max_hit = tempvalue
    npc.hit = npc.max_hit
    npc.hitroll = npc.level
    npc.damroll = npc.level

    # link the mob to the world list
    npc_template.count += 1
    return npc
Exemplo n.º 17
0
def do_berserk(ch, argument):
    chance = ch.get_skill('berserk')
    if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_BERSERK)) \
            or (not ch.is_npc() and ch.level < const.skill_table['berserk'].skill_level[ch.guild.name]):
        ch.send("You turn red in the face, but nothing happens.\n")
        return

    if ch.is_affected(merc.AFF_BERSERK) or state_checks.is_affected(ch, 'berserk') or state_checks.is_affected(ch, "frenzy"):
        ch.send("You get a little madder.\n")
        return
    if ch.is_affected(merc.AFF_CALM):
        ch.send("You're feeling to mellow to berserk.\n")
        return
    if ch.mana < 50:
        ch.send("You can't get up enough energy.\n")
        return
    # modifiers
    # fighting
    if ch.position == merc.POS_FIGHTING:
        chance += 10

    # damage -- below 50% of hp helps, above hurts
    hp_percent = 100 * ch.hit // ch.max_hit
    chance += 25 - hp_percent // 2

    if random.randint(1, 99) < chance:
        state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE)
        ch.mana -= 50
        ch.move //= 2
        # heal a little damage
        ch.hit += ch.level * 2
        ch.hit = min(ch.hit, ch.max_hit)
        ch.send("Your pulse races as you are consumed by rage!\n")
        handler_game.act("$n gets a wild look in $s eyes.", ch, None, None, merc.TO_ROOM)
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve( 'berserk', True, 2)
        af = handler_game.AFFECT_DATA()
        af.where = merc.TO_AFFECTS
        af.type = 'berserk'
        af.level = ch.level
        af.duration = game_utils.number_fuzzy(ch.level // 8)
        af.modifier = max(1, ch.level // 5)
        af.bitvector = merc.AFF_BERSERK

        af.location = merc.APPLY_HITROLL
        ch.affect_add(af)

        af.location = merc.APPLY_DAMROLL
        ch.affect_add(af)

        af.modifier = max(10, 10 * (ch.level // 5))
        af.location = merc.APPLY_AC
        ch.affect_add(af)
    else:
        state_checks.WAIT_STATE(ch, 3 * merc.PULSE_VIOLENCE)
        ch.mana -= 25
        ch.move //= 2

        ch.send("Your pulse speeds up, but nothing happens.\n")
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve('berserk', False, 2)
Exemplo n.º 18
0
def create_item(item_template, level, prev_instance_id: int=None):
    if not item_template:
        logger.critical("Create_object: No objTemplate.")
        sys.exit(1)

    item = handler_item.Items(item_template)
    if not prev_instance_id:
        pass  # item.instancer()
    else:
        item.instance_id = prev_instance_id
    #item.instance_setup()
    #item.enchanted = False

    if item_template.new_format is False:
        item.level = max(0, level)

    if level == -1 or not item_template.new_format:
        item.cost = game_utils.number_fuzzy(10) * game_utils.number_fuzzy(level) * game_utils.number_fuzzy(level)

        # Mess with object properties.
    if item.item_type == merc.ITEM_LIGHT:
        if item.value[2] == 999:
            item.value[2] = -1
    elif item.item_type == merc.ITEM_FURNITURE \
            or item.item_type == merc.ITEM_TRASH \
            or item.item_type == merc.ITEM_CONTAINER \
            or item.item_type == merc.ITEM_DRINK_CON \
            or item.item_type == merc.ITEM_KEY \
            or item.item_type == merc.ITEM_FOOD \
            or item.item_type == merc.ITEM_BOAT \
            or item.item_type == merc.ITEM_CORPSE_NPC \
            or item.item_type == merc.ITEM_CORPSE_PC \
            or item.item_type == merc.ITEM_FOUNTAIN \
            or item.item_type == merc.ITEM_MAP \
            or item.item_type == merc.ITEM_CLOTHING \
            or item.item_type == merc.ITEM_PORTAL:
        if not item_template.new_format:
            item.cost //= 5
    elif item.item_type == merc.ITEM_TREASURE \
            or item.item_type == merc.ITEM_WARP_STONE \
            or item.item_type == merc.ITEM_ROOM_KEY \
            or item.item_type == merc.ITEM_GEM \
            or item.item_type == merc.ITEM_JEWELRY:
        pass
    elif item.item_type == merc.ITEM_JUKEBOX:
        item.value = [-1 for i in range(5)]
    elif item.item_type == merc.ITEM_SCROLL:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(item.value[0])
    elif item.item_type == merc.ITEM_WAND \
            or item.item_type == merc.ITEM_STAFF:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(item.value[0])
            item.value[1] = game_utils.number_fuzzy(item.value[1])
            item.value[2] = item.value[1]
        if not item_template.new_format:
            item.cost *= 2
    elif item.item_type == merc.ITEM_WEAPON:
        if level != -1 and not item_template.new_format:
            item.value[1] = game_utils.number_fuzzy(game_utils.number_fuzzy(1 * level // 4 + 2))
            item.value[2] = game_utils.number_fuzzy(game_utils.number_fuzzy(3 * level // 4 + 6))
    elif item.item_type == merc.ITEM_ARMOR:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(level // 5 + 3)
            item.value[1] = game_utils.number_fuzzy(level // 5 + 3)
            item.value[2] = game_utils.number_fuzzy(level // 5 + 3)
    elif item.item_type == merc.ITEM_POTION \
            or item.item_type == merc.ITEM_PILL:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(game_utils.number_fuzzy(item.value[0]))
    elif item.item_type == merc.ITEM_MONEY:
        if not item_template.new_format:
            item.value[0] = item.cost
    else:
        logger.error("Bad item_type objTemplate vnum: %s(%s)" % (item_template.vnum, item.item_type))

    #for paf in item_template.affected:
     #   if paf.location == merc.APPLY_SPELL_AFFECT:
      #      item.affect_add(paf)
    return item
Exemplo n.º 19
0
def g_e_reset(pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'E' or 'G': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]
    #if not last:
    #    continue

    if not npc:
        logger.error("Reset_area: 'E' or 'G': None mob for vnum %d.",
                     pReset.arg1)
        last = False
        return last, level, npc

    olevel = 0
    if instance.npc_templates[npc.vnum].pShop:
        if not itemTemplate.new_format:
            if itemTemplate.item_type == merc.ITEM_PILL \
                    or itemTemplate.item_type == merc.ITEM_POTION \
                    or itemTemplate.item_type == merc.ITEM_SCROLL:
                olevel = 53
                for i in itemTemplate.value:
                    if i > 0:
                        for j in const.skill_table[
                                itemTemplate.value[i]].skill_level:
                            olevel = min(olevel, j)

                olevel = max(0, (olevel * 3 // 4) - 2)

            elif itemTemplate.item_type == merc.ITEM_WAND:
                olevel = random.randint(10, 20)
            elif itemTemplate.item_type == merc.ITEM_STAFF:
                olevel = random.randint(15, 25)
            elif itemTemplate.item_type == merc.ITEM_ARMOR:
                olevel = random.randint(5, 15)
            elif itemTemplate.item_type == merc.ITEM_WEAPON:
                olevel = random.randint(5, 15)
            elif itemTemplate.item_type == merc.ITEM_TREASURE:
                olevel = random.randint(10, 20)

        item = object_creator.create_item(itemTemplate, olevel)
        item.flags.shop_inventory = True
    else:
        if pReset.arg2 > 50:  # old format */
            limit = 6
        elif pReset.arg2 == -1:  # no limit */
            limit = 999
        else:
            limit = pReset.arg2

        if itemTemplate.count < limit or random.randint(0, 4) == 0:
            item = object_creator.create_item(
                itemTemplate,
                min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
            # error message if it is too high */
            if item.level > npc.level + 3 \
                    or (item.item_type == merc.ITEM_WEAPON
                        and pReset.command == 'E'
                        and item.level < npc.level - 5
                        and item.level < 45):
                logger.error("Err: obj %s (%d) -- %d, mob %s (%d) -- %d",
                             item.short_descr, item.vnum, item.level,
                             npc.short_descr, npc.vnum, npc.level)
        else:
            return last, level, npc
    npc.put(item)
    if pReset.command == 'E':
        npc.equip(item, True)
    item = None
    last = True
    return last, level, npc
Exemplo n.º 20
0
def do_drink(ch, argument):
    argument, arg = game_utils.read_word(argument)
    obj = None
    if not arg:
        for f_id in ch.in_room.items:
            f = instance.items[f_id]
            if f.item_type == merc.ITEM_FOUNTAIN:
                obj = f
                break
        if not obj:
            ch.send("Drink what?\n")
            return
    else:
        obj = ch.get_item_here(arg)
        if not obj:
            ch.send("You can't find it.\n")
            return

    if not ch.is_npc() and ch.condition[merc.COND_DRUNK] > 10:
        ch.send("You fail to reach your mouth.  *Hic*\n")
        return
    amount = 0
    liquid = -1
    if obj.item_type == merc.ITEM_FOUNTAIN:
        liquid = obj.value[2]
        if liquid < 0:
            logger.warn("BUG: Do_drink: bad liquid number %s.", liquid)
            liquid = obj.value[2] = 0
        amount = const.liq_table[liquid].liq_affect[4] * 3
    elif obj.item_type == merc.ITEM_DRINK_CON:
        if obj.value[1] <= 0:
            ch.send("It is already empty.\n")
            return
        liquid = obj.value[2]
        if not liquid:
            logger.warn("BUG: Do_drink: bad liquid number %s.", liquid)
            liquid = obj.value[2] = 0
        amount = const.liq_table[liquid].liq_affect[4]
        amount = min(amount, obj.value[1])
    else:
        ch.send("You can't drink from that.\n")
        return
    if not ch.is_npc() and not ch.is_immortal() and ch.condition[merc.COND_FULL] > 45:
        ch.send("You're too full to drink more.\n")
        return
    handler_game.act("$n drinks $T from $p.", ch, obj, const.liq_table[liquid].name, merc.TO_ROOM)
    handler_game.act("You drink $T from $p.", ch, obj, const.liq_table[liquid].name, merc.TO_CHAR)
    update.gain_condition(ch, merc.COND_DRUNK, amount * const.liq_table[liquid].proof / 36)
    update.gain_condition(ch, merc.COND_FULL, amount * const.liq_table[liquid].full / 4)
    update.gain_condition(ch, merc.COND_THIRST, amount * const.liq_table[liquid].thirst / 10)
    update.gain_condition(ch, merc.COND_HUNGER, amount * const.liq_table[liquid].food / 2)
    if not ch.is_npc() and ch.condition[merc.COND_DRUNK] > 10:
        ch.send("You feel drunk.\n")
    if not ch.is_npc() and ch.condition[merc.COND_FULL] > 40:
        ch.send("You are full.\n")
    if not ch.is_npc() and ch.condition[merc.COND_THIRST] > 40:
        ch.send("Your thirst is quenched.\n")
    if obj.value[3] != 0:
        # The drink was poisoned !
        af = handler_game.AFFECT_DATA()
        handler_game.act("$n chokes and gags.", ch, None, None, merc.TO_ROOM)
        ch.send("You choke and gag.\n")
        af.where = merc.TO_AFFECTS
        af.type = "poison"
        af.level = game_utils.number_fuzzy(amount)
        af.duration = 3 * amount
        af.location = merc.APPLY_NONE
        af.modifier = 0
        af.bitvector = merc.AFF_POISON
        ch.affect_join(af)
    if obj.value[0] > 0:
        obj.value[1] -= amount
    return
Exemplo n.º 21
0
def create_item(item_template, level, prev_instance_id: int = None):
    if not item_template:
        comm.notify("create_item: no item_template", merc.CONSOLE_INFO)
        sys.exit(1)

    item = handler_item.Items(item_template)
    if not prev_instance_id:
        pass  # item.instancer()
    else:
        item.instance_id = prev_instance_id

    item.level = level

    if item.vnum in merc.irange(29500, 29599):
        item.flags.artifact = True
        item.condition = 100
        item.toughness = 100
        item.resistance = 1
        item.level = 60
        item.cost = 1000000
    elif item.vnum in merc.irange(29600, 29699):
        item.flags.relic = True
        item.condition = 100
        item.toughness = 100
        item.resistance = 1
    else:
        item.condition = 100
        item.toughness = 5
        item.resistance = 25

    # Mess with object properties.
    if item.item_type == merc.ITEM_SCROLL:
        item.value[0] = game_utils.number_fuzzy(item.value[0])
    elif item.item_type in [merc.ITEM_WAND, merc.ITEM_STAFF]:
        item.value[0] = game_utils.number_fuzzy(item.value[0])
        item.value[1] = game_utils.number_fuzzy(item.value[1])
        item.value[2] = item.value[1]
    elif item.item_type == merc.ITEM_WEAPON:
        if not item.flags.artifact and not item.flags.relic:
            item.value[1] = game_utils.number_range(1, 10)
            item.value[2] = game_utils.number_range(item.value[1] + 1,
                                                    item.value[1] * 2)
    elif item.item_type == merc.ITEM_ARMOR:
        if not item.flags.artifact and not item.flags.relic:
            item.value[0] = game_utils.number_range(5, 15)
    elif item.item_type in [merc.ITEM_POTION, merc.ITEM_PILL]:
        item.value[0] = game_utils.number_fuzzy(
            game_utils.number_fuzzy(item.value[0]))
    elif item.item_type == merc.ITEM_MONEY:
        item.value[0] = item.cost
    elif item.item_type in [
            merc.ITEM_LIGHT, merc.ITEM_TREASURE, merc.ITEM_FURNITURE,
            merc.ITEM_TRASH, merc.ITEM_CONTAINER, merc.ITEM_DRINK_CON,
            merc.ITEM_KEY, merc.ITEM_FOOD, merc.ITEM_BOAT,
            merc.ITEM_CORPSE_NPC, merc.ITEM_CORPSE_PC, merc.ITEM_FOUNTAIN,
            merc.ITEM_PORTAL, merc.ITEM_EGG, merc.ITEM_VOODOO, merc.ITEM_STAKE,
            merc.ITEM_MISSILE, merc.ITEM_AMMO, merc.ITEM_QUEST,
            merc.ITEM_QUESTCARD, merc.ITEM_QUESTMACHINE, merc.ITEM_SYMBOL,
            merc.ITEM_BOOK, merc.ITEM_PAGE, merc.ITEM_TOOL
    ]:
        pass
    else:
        comm.notify(
            "create_item: bad item_type {} ({})".format(
                item_template.vnum, item.item_type), merc.CONSOLE_WARNING)

    item_template.count += 1
    return item
Exemplo n.º 22
0
def create_item(item_template, level, prev_instance_id: int = None):
    if not item_template:
        logger.critical("Create_object: No objTemplate.")
        sys.exit(1)

    item = handler_item.Items(item_template)
    if not prev_instance_id:
        pass  # item.instancer()
    else:
        item.instance_id = prev_instance_id
    #item.instance_setup()
    #item.enchanted = False

    if item_template.new_format is False:
        item.level = max(0, level)

    if level == -1 or not item_template.new_format:
        item.cost = game_utils.number_fuzzy(10) * game_utils.number_fuzzy(
            level) * game_utils.number_fuzzy(level)

        # Mess with object properties.
    if item.item_type == merc.ITEM_LIGHT:
        if item.value[2] == 999:
            item.value[2] = -1
    elif item.item_type == merc.ITEM_FURNITURE \
            or item.item_type == merc.ITEM_TRASH \
            or item.item_type == merc.ITEM_CONTAINER \
            or item.item_type == merc.ITEM_DRINK_CON \
            or item.item_type == merc.ITEM_KEY \
            or item.item_type == merc.ITEM_FOOD \
            or item.item_type == merc.ITEM_BOAT \
            or item.item_type == merc.ITEM_CORPSE_NPC \
            or item.item_type == merc.ITEM_CORPSE_PC \
            or item.item_type == merc.ITEM_FOUNTAIN \
            or item.item_type == merc.ITEM_MAP \
            or item.item_type == merc.ITEM_CLOTHING \
            or item.item_type == merc.ITEM_PORTAL:
        if not item_template.new_format:
            item.cost //= 5
    elif item.item_type == merc.ITEM_TREASURE \
            or item.item_type == merc.ITEM_WARP_STONE \
            or item.item_type == merc.ITEM_ROOM_KEY \
            or item.item_type == merc.ITEM_GEM \
            or item.item_type == merc.ITEM_JEWELRY:
        pass
    elif item.item_type == merc.ITEM_JUKEBOX:
        item.value = [-1 for i in range(5)]
    elif item.item_type == merc.ITEM_SCROLL:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(item.value[0])
    elif item.item_type == merc.ITEM_WAND \
            or item.item_type == merc.ITEM_STAFF:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(item.value[0])
            item.value[1] = game_utils.number_fuzzy(item.value[1])
            item.value[2] = item.value[1]
        if not item_template.new_format:
            item.cost *= 2
    elif item.item_type == merc.ITEM_WEAPON:
        if level != -1 and not item_template.new_format:
            item.value[1] = game_utils.number_fuzzy(
                game_utils.number_fuzzy(1 * level // 4 + 2))
            item.value[2] = game_utils.number_fuzzy(
                game_utils.number_fuzzy(3 * level // 4 + 6))
    elif item.item_type == merc.ITEM_ARMOR:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(level // 5 + 3)
            item.value[1] = game_utils.number_fuzzy(level // 5 + 3)
            item.value[2] = game_utils.number_fuzzy(level // 5 + 3)
    elif item.item_type == merc.ITEM_POTION \
            or item.item_type == merc.ITEM_PILL:
        if level != -1 and not item_template.new_format:
            item.value[0] = game_utils.number_fuzzy(
                game_utils.number_fuzzy(item.value[0]))
    elif item.item_type == merc.ITEM_MONEY:
        if not item_template.new_format:
            item.value[0] = item.cost
    else:
        logger.error("Bad item_type objTemplate vnum: %s(%s)" %
                     (item_template.vnum, item.item_type))

    #for paf in item_template.affected:
    #   if paf.location == merc.APPLY_SPELL_AFFECT:
    #      item.affect_add(paf)
    return item
Exemplo n.º 23
0
def g_e_reset(pReset, last, level, npc):
    item = None
    if pReset.arg1 not in instance.item_templates.keys():
        logger.error("Reset_area: 'E' or 'G': bad vnum %d.", pReset.arg1)
        return last, level, npc
    else:
        itemTemplate = instance.item_templates[pReset.arg1]
    #if not last:
    #    continue

    if not npc:
        logger.error("Reset_area: 'E' or 'G': None mob for vnum %d.", pReset.arg1)
        last = False
        return last, level, npc

    olevel = 0
    if instance.npc_templates[npc.vnum].pShop:
        if not itemTemplate.new_format:
            if itemTemplate.item_type == merc.ITEM_PILL \
                    or itemTemplate.item_type == merc.ITEM_POTION \
                    or itemTemplate.item_type == merc.ITEM_SCROLL:
                olevel = 53
                for i in itemTemplate.value:
                    if i > 0:
                        for j in const.skill_table[itemTemplate.value[i]].skill_level:
                            olevel = min(olevel, j)

                olevel = max(0, (olevel * 3 // 4) - 2)

            elif itemTemplate.item_type == merc.ITEM_WAND:
                olevel = random.randint(10, 20)
            elif itemTemplate.item_type == merc.ITEM_STAFF:
                olevel = random.randint(15, 25)
            elif itemTemplate.item_type == merc.ITEM_ARMOR:
                olevel = random.randint(5, 15)
            elif itemTemplate.item_type == merc.ITEM_WEAPON:
                olevel = random.randint(5, 15)
            elif itemTemplate.item_type == merc.ITEM_TREASURE:
                olevel = random.randint(10, 20)

        item = object_creator.create_item(itemTemplate, olevel)
        item.flags.shop_inventory = True
    else:
        if pReset.arg2 > 50:  # old format */
            limit = 6
        elif pReset.arg2 == -1:  # no limit */
            limit = 999
        else:
            limit = pReset.arg2

        if itemTemplate.count < limit or random.randint(0, 4) == 0:
            item = object_creator.create_item(itemTemplate,
                                              min(game_utils.number_fuzzy(level), merc.LEVEL_HERO - 1))
            # error message if it is too high */
            if item.level > npc.level + 3 \
                    or (item.item_type == merc.ITEM_WEAPON
                        and pReset.command == 'E'
                        and item.level < npc.level - 5
                        and item.level < 45):
                logger.error("Err: obj %s (%d) -- %d, mob %s (%d) -- %d",
                             item.short_descr, item.vnum, item.level,
                             npc.short_descr, npc.vnum, npc.level)
        else:
            return last, level, npc
    npc.put(item)
    if pReset.command == 'E':
        npc.equip(item, True)
    item = None
    last = True
    return last, level, npc
Exemplo n.º 24
0
def do_drink(ch, argument):
    argument, arg = game_utils.read_word(argument)
    obj = None
    if not arg:
        for f_id in ch.in_room.items:
            f = instance.items[f_id]
            if f.item_type == merc.ITEM_FOUNTAIN:
                obj = f
                break
        if not obj:
            ch.send("Drink what?\n")
            return
    else:
        obj = ch.get_item_here(arg)
        if not obj:
            ch.send("You can't find it.\n")
            return

    if not ch.is_npc() and ch.condition[merc.COND_DRUNK] > 10:
        ch.send("You fail to reach your mouth.  *Hic*\n")
        return
    amount = 0
    liquid = -1
    if obj.item_type == merc.ITEM_FOUNTAIN:
        liquid = obj.value[2]
        if liquid < 0:
            logger.warn("BUG: Do_drink: bad liquid number %s.", liquid)
            liquid = obj.value[2] = 0
        amount = const.liq_table[liquid].liq_affect[4] * 3
    elif obj.item_type == merc.ITEM_DRINK_CON:
        if obj.value[1] <= 0:
            ch.send("It is already empty.\n")
            return
        liquid = obj.value[2]
        if not liquid:
            logger.warn("BUG: Do_drink: bad liquid number %s.", liquid)
            liquid = obj.value[2] = 0
        amount = const.liq_table[liquid].liq_affect[4]
        amount = min(amount, obj.value[1])
    else:
        ch.send("You can't drink from that.\n")
        return
    if not ch.is_npc() and not ch.is_immortal() and ch.condition[
            merc.COND_FULL] > 45:
        ch.send("You're too full to drink more.\n")
        return
    handler_game.act("$n drinks $T from $p.", ch, obj,
                     const.liq_table[liquid].name, merc.TO_ROOM)
    handler_game.act("You drink $T from $p.", ch, obj,
                     const.liq_table[liquid].name, merc.TO_CHAR)
    update.gain_condition(ch, merc.COND_DRUNK,
                          amount * const.liq_table[liquid].proof / 36)
    update.gain_condition(ch, merc.COND_FULL,
                          amount * const.liq_table[liquid].full / 4)
    update.gain_condition(ch, merc.COND_THIRST,
                          amount * const.liq_table[liquid].thirst / 10)
    update.gain_condition(ch, merc.COND_HUNGER,
                          amount * const.liq_table[liquid].food / 2)
    if not ch.is_npc() and ch.condition[merc.COND_DRUNK] > 10:
        ch.send("You feel drunk.\n")
    if not ch.is_npc() and ch.condition[merc.COND_FULL] > 40:
        ch.send("You are full.\n")
    if not ch.is_npc() and ch.condition[merc.COND_THIRST] > 40:
        ch.send("Your thirst is quenched.\n")
    if obj.value[3] != 0:
        # The drink was poisoned !
        af = handler_game.AFFECT_DATA()
        handler_game.act("$n chokes and gags.", ch, None, None, merc.TO_ROOM)
        ch.send("You choke and gag.\n")
        af.where = merc.TO_AFFECTS
        af.type = "poison"
        af.level = game_utils.number_fuzzy(amount)
        af.duration = 3 * amount
        af.location = merc.APPLY_NONE
        af.modifier = 0
        af.bitvector = merc.AFF_POISON
        ch.affect_join(af)
    if obj.value[0] > 0:
        obj.value[1] -= amount
    return
Exemplo n.º 25
0
def do_berserk(ch, argument):
    chance = ch.get_skill('berserk')
    if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_BERSERK)) \
            or (not ch.is_npc() and ch.level < const.skill_table['berserk'].skill_level[ch.guild.name]):
        ch.send("You turn red in the face, but nothing happens.\n")
        return

    if ch.is_affected(merc.AFF_BERSERK) or state_checks.is_affected(
            ch, 'berserk') or state_checks.is_affected(ch, "frenzy"):
        ch.send("You get a little madder.\n")
        return
    if ch.is_affected(merc.AFF_CALM):
        ch.send("You're feeling to mellow to berserk.\n")
        return
    if ch.mana < 50:
        ch.send("You can't get up enough energy.\n")
        return
    # modifiers
    # fighting
    if ch.position == merc.POS_FIGHTING:
        chance += 10

    # damage -- below 50% of hp helps, above hurts
    hp_percent = 100 * ch.hit // ch.max_hit
    chance += 25 - hp_percent // 2

    if random.randint(1, 99) < chance:
        state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE)
        ch.mana -= 50
        ch.move //= 2
        # heal a little damage
        ch.hit += ch.level * 2
        ch.hit = min(ch.hit, ch.max_hit)
        ch.send("Your pulse races as you are consumed by rage!\n")
        handler_game.act("$n gets a wild look in $s eyes.", ch, None, None,
                         merc.TO_ROOM)
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve('berserk', True, 2)
        af = handler_game.AFFECT_DATA()
        af.where = merc.TO_AFFECTS
        af.type = 'berserk'
        af.level = ch.level
        af.duration = game_utils.number_fuzzy(ch.level // 8)
        af.modifier = max(1, ch.level // 5)
        af.bitvector = merc.AFF_BERSERK

        af.location = merc.APPLY_HITROLL
        ch.affect_add(af)

        af.location = merc.APPLY_DAMROLL
        ch.affect_add(af)

        af.modifier = max(10, 10 * (ch.level // 5))
        af.location = merc.APPLY_AC
        ch.affect_add(af)
    else:
        state_checks.WAIT_STATE(ch, 3 * merc.PULSE_VIOLENCE)
        ch.mana -= 25
        ch.move //= 2

        ch.send("Your pulse speeds up, but nothing happens.\n")
        if not ch.is_npc():
            if ch.is_pc():
                ch.check_improve('berserk', False, 2)