示例#1
0
def spell_haste(sn, level, ch, victim, target):
    # RT haste spell */
    if state_checks.is_affected(victim, sn) or victim.is_affected( merc.AFF_HASTE) or (victim.is_npc() and state_checks.IS_SET(victim.off_flags,merc.OFF_FAST)):
        if victim == ch:
            ch.send("You can't move any faster! \n")
        else:
            handler_game.act("$N is already moving as fast as $E can.", ch, None, victim, merc.TO_CHAR)
        return
    if victim.is_affected( merc.AFF_SLOW):
        if not handler_magic.check_dispel(level, victim, const.skill_table["slow"]):
            if victim != ch:
                ch.send("Spell failed.\n")
            victim.send("You feel momentarily faster.\n")
            return
        handler_game.act("$n is moving less slowly.", victim, None, None, merc.TO_ROOM)
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    if victim == ch:
        af.duration = level // 2
    else:
        af.duration = level // 4
    af.location = merc.APPLY_DEX
    af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32)
    af.bitvector = merc.AFF_HASTE
    victim.affect_add(af)
    victim.send("You feel yourself moving more quickly.\n")
    handler_game.act("$n is moving more quickly.", victim, None, None, merc.TO_ROOM)
    if ch != victim:
        ch.send("Ok.\n")
示例#2
0
def spell_change_sex(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You've already been changed.\n")
        else:
            handler_game.act("$N has already had $s(?) sex changed.", ch, None,
                             victim, merc.TO_CHAR)
        return

    if handler_magic.saves_spell(level, victim, merc.DAM_OTHER):
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = 2 * level
    af.location = merc.APPLY_SEX

    while af.modifier == 0:
        af.modifier = random.randint(0, 2) - victim.sex

    af.bitvector = 0
    victim.affect_add(af)
    victim.send("You feel different.\n")
    handler_game.act("$n doesn't look like $mself anymore...", victim, None,
                     None, merc.TO_ROOM)
示例#3
0
def spell_slow(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn) or victim.is_affected( merc.AFF_SLOW):
        if victim == ch:
            ch.send("You can't move any slower! \n")
        else:
            handler_game.act("$N can't get any slower than that.", ch, None, victim, merc.TO_CHAR)
        return

    if handler_magic.saves_spell(level, victim, merc.DAM_OTHER) or state_checks.IS_SET(victim.imm_flags, merc.IMM_MAGIC):
        if victim != ch:
            ch.send("Nothing seemed to happen.\n")
        victim.send("You feel momentarily lethargic.\n")
        return

    if victim.is_affected( merc.AFF_HASTE):
        if not handler_magic.check_dispel(level, victim, const.skill_table['haste']):
            if victim != ch:
                ch.send("Spell failed.\n")
            victim.send("You feel momentarily slower.\n")
            return
        handler_game.act("$n is moving less quickly.", victim, None, None, merc.TO_ROOM)
        return

    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = level // 2
    af.location = merc.APPLY_DEX
    af.modifier = -1 - (level >= 18) - (level >= 25) - (level >= 32)
    af.bitvector = merc.AFF_SLOW
    victim.affect_add(af)
    victim.send("You feel yourself slowing d o w n...\n")
    handler_game.act("$n starts to move in slow motion.", victim, None, None, merc.TO_ROOM)
示例#4
0
def spell_bless(sn, level, ch, victim, target):
    # deal with the object case first */
    if target == merc.TARGET_ITEM:
        obj = victim
        if obj.flags.bless:
            handler_game.act("$p is already blessed.", ch, obj, send_to=merc.TO_CHAR)
            return
        if obj.flags.evil:
            paf = state_checks.affect_find(obj.affected, "curse")
            level = obj.level
            if paf:
                level = paf.level
            if not handler_magic.saves_dispel(level, level, 0):
                if paf:
                    obj.affect_remove(paf)
                    handler_game.act("$p glows a pale blue.", ch, obj, None, merc.TO_ALL)
                    obj.extra_bits = state_checks.REMOVE_BIT(obj.extra_flags, merc.ITEM_EVIL)
                    return
                else:
                    handler_game.act("The evil of $p is too powerful for you to overcome.", ch, obj, send_to=merc.TO_CHAR)
                    return
        af = handler_game.AFFECT_DATA()
        af.where = merc.TO_OBJECT
        af.type = sn
        af.level = level
        af.duration = 6 + level
        af.location = merc.APPLY_SAVES
        af.modifier = -1
        af.bitvector = merc.ITEM_BLESS
        obj.affect_add(af)
        handler_game.act("$p glows with a holy aura.", ch, obj, send_to=merc.TO_ALL)
        if obj.wear_loc != merc.WEAR_NONE:
            ch.saving_throw = ch.saving_throw - 1
        return


    # character target */
    if victim.position == merc.POS_FIGHTING or state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already blessed.\n")
        else:
            handler_game.act("$N already has divine favor.", 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 = 6 + level
    af.location = merc.APPLY_HITROLL
    af.modifier = level // 8
    af.bitvector = 0
    victim.affect_add(af)

    af.location = merc.APPLY_SAVING_SPELL
    af.modifier = 0 - level // 8
    victim.affect_add(af)
    victim.send("You feel righteous.\n")
    if ch is not victim:
        handler_game.act("You grant $N the favor of your god.", ch, None, victim, merc.TO_CHAR)
示例#5
0
def spell_dispel_magic(sn, level, ch, victim, target):
    # modified for enhanced use */
    if handler_magic.saves_spell(level, victim, merc.DAM_OTHER):
        victim.send("You feel a brief tingling sensation.\n")
        ch.send("You failed.\n")
        return

    spells = {
        'armor': None,
        'bless': None,
        'blindness': '$n is no longer blinded',
        'calm': '$n no longer looks so peaceful...',
        'change sex': '$n looks more like $mself again.',
        'charm person': '$n regains $s free will.',
        'chill touch': '$n looks warmer',
        'curse': None,
        'detect evil': None,
        'detect good': None,
        'detect hidden': None,
        'detect invis': None,
        'detect magic': None,
        'faerie fire': "$n's outline fades",
        'fly': '$n falls to the ground! ',
        'frenzy': "$n no longer looks so wild.",
        'giant strength': "$n no longer looks so mighty.",
        'haste': '$n is no longer moving so quickly',
        'infravision': None,
        'invis': '$n fades into existence.',
        'mass invis': '$n fades into existence',
        'pass door': None,
        'protection evil': None,
        'protection good': None,
        'sanctuary': "The white aura around $n's body vanishes.",
        'shield': 'The shield protecting $n vanishes',
        'sleep': None,
        'slow': '$n is no longer moving so slowly.',
        'stone skin': "$n's skin regains its normal texture.",
        'weaken': "$n looks stronger."
    }

    for k, v in spells.items():
        if handler_magic.check_dispel(level, victim, const.skill_table[k]):
            if v:
                handler_game.act(v, victim, None, None, merc.TO_ROOM)
            found = True

    if victim.is_affected(
            merc.AFF_SANCTUARY) and not handler_magic.saves_dispel(
                level, victim.level, -1) and not state_checks.is_affected(
                    victim, const.skill_table["sanctuary"]):
        state_checks.REMOVE_BIT(victim.affected_by, merc.AFF_SANCTUARY)
        handler_game.act("The white aura around $n's body vanishes.", victim,
                         None, None, merc.TO_ROOM)
        found = True

    if found:
        ch.send("Ok.\n")
    else:
        ch.send("Spell failed.\n")
示例#6
0
def spell_frenzy(sn, level, ch, victim, target):
    # RT clerical berserking spell */
    if state_checks.is_affected(victim, sn) or victim.is_affected( merc.AFF_BERSERK):
        if victim == ch:
            ch.send("You are already in a frenzy.\n")
        else:
            handler_game.act("$N is already in a frenzy.", ch, None, victim, merc.TO_CHAR)
        return

    if state_checks.is_affected(victim, const.skill_table['calm']):
        if victim == ch:
            ch.send("Why don't you just relax for a while?\n")
        else:
            handler_game.act("$N doesn't look like $e wants to fight anymore.", ch, None, victim, merc.TO_CHAR)
        return
    if (ch.is_good() and not state_checks.IS_GOOD(victim)) or \
            (state_checks.IS_NEUTRAL(ch) and not state_checks.IS_NEUTRAL(victim)) or \
            (ch.is_evil() and not state_checks.IS_EVIL(victim)):
        handler_game.act("Your god doesn't seem to like $N", 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 = level // 3
    af.modifier = level // 6
    af.bitvector = 0

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

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

    af.modifier = 10 * (level // 12)
    af.location = merc.APPLY_AC
    victim.affect_add(af)

    victim.send("You are filled with holy wrath! \n")
    handler_game.act("$n gets a wild look in $s eyes! ", victim, None, None, merc.TO_ROOM)
示例#7
0
def check_dispel(dis_level, victim, skill):
    from const import skill_table
    if state_checks.is_affected(victim, skill):
        for af in victim.affected[:]:
            if af.type == skill:
                if not saves_dispel(dis_level, af.level, af.duration):
                    victim.affect_strip(skill)
                    if skill.msg_off:
                        victim.send(skill_table[skill.name].msg_off + "\n")
                    return True
                else:
                    af.level -= 1
    return False
示例#8
0
def spell_cure_blindness(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['blindness']):
        if victim == ch:
            ch.send("You aren't blind.\n")
        else:
            handler_game.act("$N doesn't appear to be blinded.", ch, None, victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim, const.skill_table['blindness']):
        victim.send("Your vision returns!\n")
        handler_game.act("$n is no longer blinded.", victim, None, None, merc.TO_ROOM)
    else:
        ch.send("Spell failed.\n")
示例#9
0
def check_dispel(dis_level, victim, skill):
    from const import skill_table
    if state_checks.is_affected(victim, skill):
        for af in victim.affected[:]:
            if af.type == skill:
                if not saves_dispel(dis_level,af.level,af.duration):
                    victim.affect_strip(skill)
                    if skill.msg_off:
                        victim.send(skill_table[skill.name].msg_off + "\n")
                    return True
                else:
                    af.level -= 1
    return False
示例#10
0
def spell_cure_poison(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['poison']):
        if victim == ch:
            ch.send("You aren't poisoned.\n")
        else:
            handler_game.act("$N doesn't appear to be poisoned.", ch, None, victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim, const.skill_table['poison']):
        victim.send("A warm feeling runs through your body.\n")
        handler_game.act("$n looks much better.", victim, None, None, merc.TO_ROOM)
        return

    ch.send("Spell failed.\n")
示例#11
0
def spell_weaken(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn) or handler_magic.saves_spell(level, victim, merc.DAM_OTHER):
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = level // 2
    af.location = merc.APPLY_STR
    af.modifier = -1 * (level // 5)
    af.bitvector = merc.AFF_WEAKEN
    victim.affect_add(af)
    victim.send("You feel your strength slip away.\n")
    handler_game.act("$n looks tired and weak.", victim, None, None, merc.TO_ROOM)
示例#12
0
def spell_cure_disease(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['plague']):
        if victim == ch:
            ch.send("You aren't ill.\n")
        else:
            handler_game.act("$N doesn't appear to be diseased.", ch, None, victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim, const.skill_table['plague']):
        victim.send("Your sores vanish.\n")
        handler_game.act("$n looks relieved as $s sores vanish.", victim, None, None, merc.TO_ROOM)
        return

    ch.send("Spell failed.\n")
示例#13
0
def spell_cure_blindness(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['blindness']):
        if victim == ch:
            ch.send("You aren't blind.\n")
        else:
            handler_game.act("$N doesn't appear to be blinded.", ch, None,
                             victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim,
                                  const.skill_table['blindness']):
        victim.send("Your vision returns!\n")
        handler_game.act("$n is no longer blinded.", victim, None, None,
                         merc.TO_ROOM)
    else:
        ch.send("Spell failed.\n")
示例#14
0
def spell_cure_disease(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['plague']):
        if victim == ch:
            ch.send("You aren't ill.\n")
        else:
            handler_game.act("$N doesn't appear to be diseased.", ch, None,
                             victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim, const.skill_table['plague']):
        victim.send("Your sores vanish.\n")
        handler_game.act("$n looks relieved as $s sores vanish.", victim, None,
                         None, merc.TO_ROOM)
        return

    ch.send("Spell failed.\n")
示例#15
0
def spell_cure_poison(sn, level, ch, victim, target):
    if not state_checks.is_affected(victim, const.skill_table['poison']):
        if victim == ch:
            ch.send("You aren't poisoned.\n")
        else:
            handler_game.act("$N doesn't appear to be poisoned.", ch, None,
                             victim, merc.TO_CHAR)
        return

    if handler_magic.check_dispel(level, victim, const.skill_table['poison']):
        victim.send("A warm feeling runs through your body.\n")
        handler_game.act("$n looks much better.", victim, None, None,
                         merc.TO_ROOM)
        return

    ch.send("Spell failed.\n")
示例#16
0
def spell_weaken(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn) or handler_magic.saves_spell(
            level, victim, merc.DAM_OTHER):
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = level // 2
    af.location = merc.APPLY_STR
    af.modifier = -1 * (level // 5)
    af.bitvector = merc.AFF_WEAKEN
    victim.affect_add(af)
    victim.send("You feel your strength slip away.\n")
    handler_game.act("$n looks tired and weak.", victim, None, None,
                     merc.TO_ROOM)
示例#17
0
def spell_giant_strength(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already as strong as you can get! \n")
        else:
            handler_game.act("$N can't get any stronger.", 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 = level
    af.location = merc.APPLY_STR
    af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32)
    af.bitvector = 0
    victim.affect_add(af)
    victim.send("Your muscles surge with heightened power! \n")
    handler_game.act("$n's muscles surge with heightened power.", victim, None, None, merc.TO_ROOM)
示例#18
0
def spell_stone_skin(sn, level, ch, victim, target):
    if state_checks.is_affected(ch, sn):
        if victim == ch:
            ch.send("Your skin is already as hard as a rock.\n")
        else:
            handler_game.act("$N is already as hard as can be.", 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 = level
    af.location = merc.APPLY_AC
    af.modifier = -40
    af.bitvector = 0
    victim.affect_add(af)
    handler_game.act("$n's skin turns to stone.", victim, None, None, merc.TO_ROOM)
    victim.send("Your skin turns to stone.\n")
示例#19
0
def spell_shield(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already shielded from harm.\n")
        else:
            handler_game.act("$N is already protected by a shield.", 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 = 8 + level
    af.location = merc.APPLY_AC
    af.modifier = -20
    af.bitvector = 0
    victim.affect_add(af)
    handler_game.act("$n is surrounded by a force shield.", victim, None, None, merc.TO_ROOM)
    victim.send("You are surrounded by a force shield.\n")
    return
示例#20
0
def spell_armor(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already armored.\n")
        else:
            handler_game.act("$N is already armored.", 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 = 24
    af.modifier = -20
    af.location = merc.APPLY_AC
    af.bitvector = 0
    victim.affect_add(af)
    victim.send("You feel someone protecting you.\n")
    if ch is not victim:
        handler_game.act("$N is protected by your magic.", ch, None, victim, merc.TO_CHAR)
示例#21
0
def spell_stone_skin(sn, level, ch, victim, target):
    if state_checks.is_affected(ch, sn):
        if victim == ch:
            ch.send("Your skin is already as hard as a rock.\n")
        else:
            handler_game.act("$N is already as hard as can be.", 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 = level
    af.location = merc.APPLY_AC
    af.modifier = -40
    af.bitvector = 0
    victim.affect_add(af)
    handler_game.act("$n's skin turns to stone.", victim, None, None,
                     merc.TO_ROOM)
    victim.send("Your skin turns to stone.\n")
示例#22
0
def spell_giant_strength(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already as strong as you can get! \n")
        else:
            handler_game.act("$N can't get any stronger.", 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 = level
    af.location = merc.APPLY_STR
    af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32)
    af.bitvector = 0
    victim.affect_add(af)
    victim.send("Your muscles surge with heightened power! \n")
    handler_game.act("$n's muscles surge with heightened power.", victim, None,
                     None, merc.TO_ROOM)
示例#23
0
def spell_armor(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already armored.\n")
        else:
            handler_game.act("$N is already armored.", 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 = 24
    af.modifier = -20
    af.location = merc.APPLY_AC
    af.bitvector = 0
    victim.affect_add(af)
    victim.send("You feel someone protecting you.\n")
    if ch is not victim:
        handler_game.act("$N is protected by your magic.", ch, None, victim,
                         merc.TO_CHAR)
示例#24
0
def spell_shield(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You are already shielded from harm.\n")
        else:
            handler_game.act("$N is already protected by a shield.", 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 = 8 + level
    af.location = merc.APPLY_AC
    af.modifier = -20
    af.bitvector = 0
    victim.affect_add(af)
    handler_game.act("$n is surrounded by a force shield.", victim, None, None,
                     merc.TO_ROOM)
    victim.send("You are surrounded by a force shield.\n")
    return
示例#25
0
def spell_haste(sn, level, ch, victim, target):
    # RT haste spell */
    if state_checks.is_affected(victim, sn) or victim.is_affected(
            merc.AFF_HASTE) or (victim.is_npc() and state_checks.IS_SET(
                victim.off_flags, merc.OFF_FAST)):
        if victim == ch:
            ch.send("You can't move any faster! \n")
        else:
            handler_game.act("$N is already moving as fast as $E can.", ch,
                             None, victim, merc.TO_CHAR)
        return
    if victim.is_affected(merc.AFF_SLOW):
        if not handler_magic.check_dispel(level, victim,
                                          const.skill_table["slow"]):
            if victim != ch:
                ch.send("Spell failed.\n")
            victim.send("You feel momentarily faster.\n")
            return
        handler_game.act("$n is moving less slowly.", victim, None, None,
                         merc.TO_ROOM)
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    if victim == ch:
        af.duration = level // 2
    else:
        af.duration = level // 4
    af.location = merc.APPLY_DEX
    af.modifier = 1 + (level >= 18) + (level >= 25) + (level >= 32)
    af.bitvector = merc.AFF_HASTE
    victim.affect_add(af)
    victim.send("You feel yourself moving more quickly.\n")
    handler_game.act("$n is moving more quickly.", victim, None, None,
                     merc.TO_ROOM)
    if ch != victim:
        ch.send("Ok.\n")
示例#26
0
def spell_change_sex(sn, level, ch, victim, target):
    if state_checks.is_affected(victim, sn):
        if victim == ch:
            ch.send("You've already been changed.\n")
        else:
            handler_game.act("$N has already had $s(?) sex changed.", ch, None, victim, merc.TO_CHAR)
        return

    if handler_magic.saves_spell(level, victim, merc.DAM_OTHER):
        return
    af = handler_game.AFFECT_DATA()
    af.where = merc.TO_AFFECTS
    af.type = sn
    af.level = level
    af.duration = 2 * level
    af.location = merc.APPLY_SEX

    while af.modifier == 0:
        af.modifier = random.randint(0, 2) - victim.sex

    af.bitvector = 0
    victim.affect_add(af)
    victim.send("You feel different.\n")
    handler_game.act("$n doesn't look like $mself anymore...", victim, None, None, merc.TO_ROOM)
示例#27
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)
示例#28
0
def spell_dispel_magic(sn, level, ch, victim, target):
    # modified for enhanced use */
    if handler_magic.saves_spell(level, victim, merc.DAM_OTHER):
        victim.send("You feel a brief tingling sensation.\n")
        ch.send("You failed.\n")
        return

    spells = {'armor': None,
              'bless': None,
              'blindness': '$n is no longer blinded',
              'calm': '$n no longer looks so peaceful...',
              'change sex': '$n looks more like $mself again.',
              'charm person': '$n regains $s free will.',
              'chill touch': '$n looks warmer',
              'curse': None,
              'detect evil': None,
              'detect good': None,
              'detect hidden': None,
              'detect invis': None,
              'detect magic': None,
              'faerie fire': "$n's outline fades",
              'fly': '$n falls to the ground! ',
              'frenzy': "$n no longer looks so wild.",
              'giant strength': "$n no longer looks so mighty.",
              'haste': '$n is no longer moving so quickly',
              'infravision': None,
              'invis': '$n fades into existence.',
              'mass invis': '$n fades into existence',
              'pass door': None,
              'protection evil': None,
              'protection good': None,
              'sanctuary': "The white aura around $n's body vanishes.",
              'shield': 'The shield protecting $n vanishes',
              'sleep': None,
              'slow': '$n is no longer moving so slowly.',
              'stone skin': "$n's skin regains its normal texture.",
              'weaken': "$n looks stronger."}

    for k, v in spells.items():
        if handler_magic.check_dispel(level, victim, const.skill_table[k]):
            if v:
                handler_game.act(v, victim, None, None, merc.TO_ROOM)
            found = True

    if victim.is_affected(
                                merc.AFF_SANCTUARY) and not handler_magic.saves_dispel(level, victim.level, -1) and not state_checks.is_affected(victim,
                                                                                                            const.skill_table[
                                                                                                                "sanctuary"]):
        state_checks.REMOVE_BIT(victim.affected_by, merc.AFF_SANCTUARY)
        handler_game.act("The white aura around $n's body vanishes.", victim, None, None, merc.TO_ROOM)
        found = True

    if found:
        ch.send("Ok.\n")
    else:
        ch.send("Spell failed.\n")
示例#29
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)
示例#30
0
文件: update.py 项目: totalgit/PyRom
def char_update():
    # update save counter */
    global save_number
    save_number += 1

    if save_number > 29:
        save_number = 0
    ch_quit = []
    id_list = [instance_id for instance_id in instance.characters.keys()]
    for character_id in id_list:
        ch = instance.characters[character_id]
        if ch.timer > 30:
            ch_quit.append(ch)

        if ch.position >= merc.POS_STUNNED:
            # check to see if we need to go home */
            if ch.is_npc() and ch.zone and ch.zone != instance.area_templates[ch.zone] \
                    and not ch.desc and not ch.fighting\
                    and not ch.is_affected(merc.AFF_CHARM) and random.randint(1, 99) < 5:
                handler_game.act("$n wanders on home.", ch, None, None,
                                 merc.TO_ROOM)
                ch.extract(True)
                id_list.remove(character_id)
                continue

        if ch.hit < ch.max_hit:
            ch.hit += hit_gain(ch)
        else:
            ch.hit = ch.max_hit

        if ch.mana < ch.max_mana:
            ch.mana += mana_gain(ch)
        else:
            ch.mana = ch.max_mana

        if ch.move < ch.max_move:
            ch.move += move_gain(ch)
        else:
            ch.move = ch.max_move

        if ch.position == merc.POS_STUNNED:
            fight.update_pos(ch)

        if not ch.is_npc() and ch.level < merc.LEVEL_IMMORTAL:
            item = ch.get_eq('light')
            if item and item.item_type == merc.ITEM_LIGHT and item.value[2] > 0:
                item.value[2] -= 1
                if item.value[2] == 0 and ch.in_room is not None:
                    ch.in_room.available_light -= 1
                    handler_game.act("$p goes out.", ch, item, None,
                                     merc.TO_ROOM)
                    handler_game.act("$p flickers and goes out.", ch, item,
                                     None, merc.TO_CHAR)
                    item.extract()
                elif item.value[2] <= 5 and ch.in_room:
                    handler_game.act("$p flickers.", ch, item, None,
                                     merc.TO_CHAR)

            if ch.is_immortal():
                ch.timer = 0
            ch.timer += 1
            if ch.timer >= 12:
                if not ch.was_in_room and ch.in_room:
                    ch.was_in_room = ch.in_room
                    if ch.fighting:
                        fight.stop_fighting(ch, True)
                    handler_game.act("$n disappears into the void.", ch, None,
                                     None, merc.TO_ROOM)
                    ch.send("You disappear into the void.\n")
                    if ch.level > 1:
                        ch.save()
                    limbo_id = instance.instances_by_room[
                        merc.ROOM_VNUM_LIMBO][0]
                    limbo = instance.rooms[limbo_id]
                    ch.in_room.get(ch)
                    limbo.put(ch)

            gain_condition(ch, merc.COND_DRUNK, -1)
            gain_condition(ch, merc.COND_FULL,
                           -4 if ch.size > merc.SIZE_MEDIUM else -2)
            gain_condition(ch, merc.COND_THIRST, -1)
            gain_condition(ch, merc.COND_HUNGER,
                           -2 if ch.size > merc.SIZE_MEDIUM else -1)

        for paf in ch.affected[:]:
            if paf.duration > 0:
                paf.duration -= 1
                if random.randint(0, 4) == 0 and paf.level > 0:
                    paf.level -= 1  # spell strength fades with time */
            elif paf.duration < 0:
                pass
            else:
                # multiple affects. don't send the spelldown msg
                multi = [
                    a for a in ch.affected
                    if a.type == paf.type and a is not paf and a.duration > 0
                ]
                if not multi and paf.type and const.skill_table[
                        paf.type].msg_off:
                    ch.send(const.skill_table[paf.type].msg_off + "\n")

                ch.affect_remove(paf)
                #
                # * Careful with the damages here,
                # *   MUST NOT refer to ch after damage taken,
                # *   as it may be lethal damage (on NPC).
                # */

        if state_checks.is_affected(ch, 'plague') and ch:
            if ch.in_room is None:
                continue

            handler_game.act(
                "$n writhes in agony as plague sores erupt from $s skin.", ch,
                None, None, merc.TO_ROOM)
            ch.send("You writhe in agony from the plague.\n")
            af = [a for a in ch.affected if af.type == 'plague'][:1]
            if not af:
                ch.affected_by.rem_bit(merc.AFF_PLAGUE)
                continue
            if af.level == 1:
                continue
            plague = handler_game.AFFECT_DATA()
            plague.where = merc.TO_AFFECTS
            plague.type = 'plague'
            plague.level = af.level - 1
            plague.duration = random.randint(1, 2 * plague.level)
            plague.location = merc.APPLY_STR
            plague.modifier = -5
            plague.bitvector = merc.AFF_PLAGUE

            for vch_id in ch.in_room.people[:]:
                vch = instance.characters[vch_id]
                if not handler_magic.saves_spell(plague.level - 2, vch, merc.DAM_DISEASE) and not vch.is_immmortal() \
                        and not vch.is_affected(merc.AFF_PLAGUE) and random.randint(0, 4) == 0:
                    vch.send("You feel hot and feverish.\n")
                    handler_game.act("$n shivers and looks very ill.", vch,
                                     None, None, merc.TO_ROOM)
                    vch.affect_join(plague)
            dam = min(ch.level, af.level // 5 + 1)
            ch.mana -= dam
            ch.move -= dam
            fight.damage(ch, ch, dam, 'plague', merc.DAM_DISEASE, False)
        elif ch.is_affected(
                merc.AFF_POISON) and ch and not ch.is_affected(merc.AFF_SLOW):
            poison = state_checks.affect_find(ch.affected, 'poison')
            if poison:
                handler_game.act("$n shivers and suffers.", ch, None, None,
                                 merc.TO_ROOM)
                ch.send("You shiver and suffer.\n")
                fight.damage(ch, ch, poison.level // 10 + 1, 'poison',
                             merc.DAM_POISON, False)
        elif ch.position == merc.POS_INCAP and random.randint(0, 1) == 0:
            fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False)
        elif ch.position == merc.POS_MORTAL:
            fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False)

    #
    # * Autosave and autoquit.
    # * Check that these chars still exist.
    # */
    for ch in instance.characters.values():
        if not ch.is_npc() and ch.desc and save_number == 28:
            ch.save()
    for ch in ch_quit[:]:
        ch.do_quit("")
示例#31
0
def spell_bless(sn, level, ch, victim, target):
    # deal with the object case first */
    if target == merc.TARGET_ITEM:
        obj = victim
        if obj.flags.bless:
            handler_game.act("$p is already blessed.",
                             ch,
                             obj,
                             send_to=merc.TO_CHAR)
            return
        if obj.flags.evil:
            paf = state_checks.affect_find(obj.affected, "curse")
            level = obj.level
            if paf:
                level = paf.level
            if not handler_magic.saves_dispel(level, level, 0):
                if paf:
                    obj.affect_remove(paf)
                    handler_game.act("$p glows a pale blue.", ch, obj, None,
                                     merc.TO_ALL)
                    obj.extra_bits = state_checks.REMOVE_BIT(
                        obj.extra_flags, merc.ITEM_EVIL)
                    return
                else:
                    handler_game.act(
                        "The evil of $p is too powerful for you to overcome.",
                        ch,
                        obj,
                        send_to=merc.TO_CHAR)
                    return
        af = handler_game.AFFECT_DATA()
        af.where = merc.TO_OBJECT
        af.type = sn
        af.level = level
        af.duration = 6 + level
        af.location = merc.APPLY_SAVES
        af.modifier = -1
        af.bitvector = merc.ITEM_BLESS
        obj.affect_add(af)
        handler_game.act("$p glows with a holy aura.",
                         ch,
                         obj,
                         send_to=merc.TO_ALL)
        if obj.wear_loc != merc.WEAR_NONE:
            ch.saving_throw = ch.saving_throw - 1
        return

    # character target */
    if victim.position == merc.POS_FIGHTING or state_checks.is_affected(
            victim, sn):
        if victim == ch:
            ch.send("You are already blessed.\n")
        else:
            handler_game.act("$N already has divine favor.", 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 = 6 + level
    af.location = merc.APPLY_HITROLL
    af.modifier = level // 8
    af.bitvector = 0
    victim.affect_add(af)

    af.location = merc.APPLY_SAVING_SPELL
    af.modifier = 0 - level // 8
    victim.affect_add(af)
    victim.send("You feel righteous.\n")
    if ch is not victim:
        handler_game.act("You grant $N the favor of your god.", ch, None,
                         victim, merc.TO_CHAR)
示例#32
0
def char_update():
    # update save counter */
    global save_number
    save_number += 1

    if save_number > 29:
        save_number = 0
    ch_quit = []
    id_list = [instance_id for instance_id in instance.characters.keys()]
    for character_id in id_list:
        ch = instance.characters[character_id]
        if ch.timer > 30:
            ch_quit.append(ch)

        if ch.position >= merc.POS_STUNNED:
            # check to see if we need to go home */
            if ch.is_npc() and ch.zone and ch.zone != instance.area_templates[ch.zone] \
                    and not ch.desc and not ch.fighting\
                    and not ch.is_affected(merc.AFF_CHARM) and random.randint(1, 99) < 5:
                handler_game.act("$n wanders on home.", ch, None, None, merc.TO_ROOM)
                ch.extract(True)
                id_list.remove(character_id)
                continue

        if ch.hit < ch.max_hit:
            ch.hit += hit_gain(ch)
        else:
            ch.hit = ch.max_hit

        if ch.mana < ch.max_mana:
            ch.mana += mana_gain(ch)
        else:
            ch.mana = ch.max_mana

        if ch.move < ch.max_move:
            ch.move += move_gain(ch)
        else:
            ch.move = ch.max_move

        if ch.position == merc.POS_STUNNED:
            fight.update_pos(ch)

        if not ch.is_npc() and ch.level < merc.LEVEL_IMMORTAL:
            item = ch.get_eq('light')
            if item and item.item_type == merc.ITEM_LIGHT and item.value[2] > 0:
                item.value[2] -= 1
                if item.value[2] == 0 and ch.in_room is not None:
                    ch.in_room.available_light -= 1
                    handler_game.act("$p goes out.", ch, item, None, merc.TO_ROOM)
                    handler_game.act("$p flickers and goes out.", ch, item, None, merc.TO_CHAR)
                    item.extract()
                elif item.value[2] <= 5 and ch.in_room:
                    handler_game.act("$p flickers.", ch, item, None, merc.TO_CHAR)

            if ch.is_immortal():
                ch.timer = 0
            ch.timer += 1
            if ch.timer >= 12:
                if not ch.was_in_room and ch.in_room:
                    ch.was_in_room = ch.in_room
                    if ch.fighting:
                        fight.stop_fighting(ch, True)
                    handler_game.act("$n disappears into the void.", ch, None, None, merc.TO_ROOM)
                    ch.send("You disappear into the void.\n")
                    if ch.level > 1:
                        ch.save()
                    limbo_id = instance.instances_by_room[merc.ROOM_VNUM_LIMBO][0]
                    limbo = instance.rooms[limbo_id]
                    ch.in_room.get(ch)
                    limbo.put(ch)

            gain_condition(ch, merc.COND_DRUNK, -1)
            gain_condition(ch, merc.COND_FULL, -4 if ch.size > merc.SIZE_MEDIUM else -2)
            gain_condition(ch, merc.COND_THIRST, -1)
            gain_condition(ch, merc.COND_HUNGER, -2 if ch.size > merc.SIZE_MEDIUM else -1)

        for paf in ch.affected[:]:
            if paf.duration > 0:
                paf.duration -= 1
                if random.randint(0, 4) == 0 and paf.level > 0:
                    paf.level -= 1  # spell strength fades with time */
            elif paf.duration < 0:
                pass
            else:
                # multiple affects. don't send the spelldown msg
                multi = [a for a in ch.affected if a.type == paf.type and a is not paf and a.duration > 0]
                if not multi and paf.type and const.skill_table[paf.type].msg_off:
                    ch.send(const.skill_table[paf.type].msg_off + "\n")

                ch.affect_remove(paf)
                #
                # * Careful with the damages here,
                # *   MUST NOT refer to ch after damage taken,
                # *   as it may be lethal damage (on NPC).
                # */

        if state_checks.is_affected(ch, 'plague') and ch:
            if ch.in_room is None:
                continue

            handler_game.act("$n writhes in agony as plague sores erupt from $s skin.", ch, None, None, merc.TO_ROOM)
            ch.send("You writhe in agony from the plague.\n")
            af = [a for a in ch.affected if af.type == 'plague'][:1]
            if not af:
                ch.affected_by.rem_bit(merc.AFF_PLAGUE)
                continue
            if af.level == 1:
                continue
            plague = handler_game.AFFECT_DATA()
            plague.where = merc.TO_AFFECTS
            plague.type = 'plague'
            plague.level = af.level - 1
            plague.duration = random.randint(1, 2 * plague.level)
            plague.location = merc.APPLY_STR
            plague.modifier = -5
            plague.bitvector = merc.AFF_PLAGUE

            for vch_id in ch.in_room.people[:]:
                vch = instance.characters[vch_id]
                if not handler_magic.saves_spell(plague.level - 2, vch, merc.DAM_DISEASE) and not vch.is_immmortal() \
                        and not vch.is_affected(merc.AFF_PLAGUE) and random.randint(0, 4) == 0:
                    vch.send("You feel hot and feverish.\n")
                    handler_game.act("$n shivers and looks very ill.", vch, None, None, merc.TO_ROOM)
                    vch.affect_join(plague)
            dam = min(ch.level, af.level // 5 + 1)
            ch.mana -= dam
            ch.move -= dam
            fight.damage(ch, ch, dam, 'plague', merc.DAM_DISEASE, False)
        elif ch.is_affected(merc.AFF_POISON) and ch and not ch.is_affected(merc.AFF_SLOW):
            poison = state_checks.affect_find(ch.affected, 'poison')
            if poison:
                handler_game.act("$n shivers and suffers.", ch, None, None, merc.TO_ROOM)
                ch.send("You shiver and suffer.\n")
                fight.damage(ch, ch, poison.level // 10 + 1, 'poison', merc.DAM_POISON, False)
        elif ch.position == merc.POS_INCAP and random.randint(0, 1) == 0:
            fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False)
        elif ch.position == merc.POS_MORTAL:
            fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False)

    #
    # * Autosave and autoquit.
    # * Check that these chars still exist.
    # */
    for ch in instance.characters.values():
        if not ch.is_npc() and ch.desc and save_number == 28:
            ch.save()
    for ch in ch_quit[:]:
        ch.do_quit("")