예제 #1
0
파일: do_goto.py 프로젝트: totalgit/PyRom
def do_goto(ch, argument):
    if not argument:
        ch.send("Goto where?\n")
        return
    location = game_utils.find_location(ch, argument)
    if not location:
        ch.send("No such location.\n")
        return
    count = len(location.people)
    if not ch.is_room_owner(location) and location.is_private() \
            and (count > 1 or ch.trust < merc.MAX_LEVEL):
        ch.send("That room is private right now.\n")
        return
    if ch.fighting:
        fight.stop_fighting(ch, True)
    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.is_npc() and ch.bamfout:
                handler_game.act("$t", ch, ch.bamfout, rch, merc.TO_VICT)
            else:
                handler_game.act("$n leaves in a swirling mist.", ch, None,
                                 rch, merc.TO_VICT)
    location.put(ch.in_room.get(ch))

    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.is_npc() and ch.bamfin:
                handler_game.act("$t", ch, ch.bamfin, rch, merc.TO_VICT)
            else:
                handler_game.act("$n appears in a swirling mist.", ch, None,
                                 rch, merc.TO_VICT)
    ch.do_look("auto")
    return
예제 #2
0
def spell_word_of_recall(sn, level, ch, victim, target):
    # RT recall spell is back */
    if victim.is_npc():
        return

    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        victim.send("You are completely lost.\n")
        return

    if state_checks.IS_SET(victim.in_room.room_flags,
                           merc.ROOM_NO_RECALL) or victim.is_affected(
                               merc.AFF_CURSE):
        victim.send("Spell failed.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)

    ch.move //= 2
    handler_game.act("$n disappears.", victim, None, None, merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n appears in the room.", victim, None, None,
                     merc.TO_ROOM)
    victim.do_look("auto")
예제 #3
0
def do_violate(ch, argument):
    if not argument:
        ch.send("Goto where?\n")
        return
    location = game_utils.find_location(ch, argument)
    if not location:
        ch.send("No such location.\n")
        return
    if not location.is_private():
        ch.send("That room isn't private, use goto.\n")
        return
    if ch.fighting:
        fight.stop_fighting(ch, True)

    for rch_id in ch.in_room.people:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.pcdata and ch.bamfout:
                handler_game.act("$t", ch, ch.bamfout, rch, merc.TO_VICT)
            else:
                handler_game.act("$n leaves in a swirling mist.", ch, None, rch, merc.TO_VICT)
    ch.get()
    ch.put(location)

    for rch_id in ch.in_room.people:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.pcdata and ch.bamfin:
                handler_game.act("$t", ch, ch.bamfin, rch, merc.TO_VICT)
            else:
                handler_game.act("$n appears in a swirling mist.", ch, None, rch, merc.TO_VICT)
    ch.do_look("auto")
    return
예제 #4
0
def do_delete(ch, argument):
    if ch.is_npc():
        return

    if ch.confirm_delete:
        if argument:
            ch.send("Delete status removed.\n")
            ch.confirm_delete = False
            return
        else:
            pfile = os.path.join(settings.PLAYER_DIR, ch.name + '.json')
            handler_game.wiznet("$N turns $Mself into line noise.", ch, None, 0, 0, 0)
            fight.stop_fighting(ch, True)
            ch.do_quit("")
            os.remove(pfile)
            return
    if argument:
        ch.send("Just type delete. No argument.\n")
        return

    ch.send("Type delete again to confirm this command.\n")
    ch.send("WARNING: this command is irreversible.\n")
    ch.send("Typing delete with an argument will undo delete status.\n")
    ch.confirm_delete = True
    handler_game.wiznet("$N is contemplating deletion.", ch, None, 0, 0, ch.trust)
예제 #5
0
파일: do_delete.py 프로젝트: totalgit/PyRom
def do_delete(ch, argument):
    if ch.is_npc():
        return

    if ch.confirm_delete:
        if argument:
            ch.send("Delete status removed.\n")
            ch.confirm_delete = False
            return
        else:
            pfile = os.path.join(settings.PLAYER_DIR, ch.name + '.json')
            handler_game.wiznet("$N turns $Mself into line noise.", ch, None,
                                0, 0, 0)
            fight.stop_fighting(ch, True)
            ch.do_quit("")
            os.remove(pfile)
            return
    if argument:
        ch.send("Just type delete. No argument.\n")
        return

    ch.send("Type delete again to confirm this command.\n")
    ch.send("WARNING: this command is irreversible.\n")
    ch.send("Typing delete with an argument will undo delete status.\n")
    ch.confirm_delete = True
    handler_game.wiznet("$N is contemplating deletion.", ch, None, 0, 0,
                        ch.trust)
예제 #6
0
def cmd_peace(ch, argument):
    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]

        if rch.fighting:
            fight.stop_fighting(rch, True)

    ch.send("Ok.\n")
예제 #7
0
파일: do_peace.py 프로젝트: totalgit/PyRom
def do_peace(ch, argument):
    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]
        if rch.fighting:
            fight.stop_fighting(rch, True)
        if rch.is_npc() and rch.act.is_set(merc.ACT_AGGRESSIVE):
            rch.act = state_checks.REMOVE_BIT(rch.act, merc.ACT_AGGRESSIVE)
    ch.send("Ok.\n")
    return
예제 #8
0
def spell_calm(sn, level, ch, victim, target):
    # get sum of all mobile levels in the room */
    count = 0
    mlevel = 0
    high_level = 0
    for vch_id in ch.in_room.people:
        vch = instance.characters[vch_id]
        if vch.position == merc.POS_FIGHTING:
            count = count + 1
        if vch.is_npc():
            mlevel += vch.level
        else:
            mlevel += vch.level // 2
        high_level = max(high_level, vch.level)

    # compute chance of stopping combat */
    chance = 4 * level - high_level + 2 * count

    if ch.is_immortal():  # always works */
        mlevel = 0

    if random.randint(0, chance) >= mlevel:  # hard to stop large fights */
        for vch_id in ch.in_room.people:
            vch = instance.characters[vch_id]
            if vch.is_npc() and (vch.imm_flags.is_set(merc.IMM_MAGIC) \
                                        or vch.act.is_set(merc.ACT_UNDEAD)):
                return

            if vch.is_affected(merc.AFF_CALM) or vch.is_affected(merc.AFF_BERSERK) \
                    or vch.is_affected('frenzy'):
                return

            vch.send("A wave of calm passes over you.\n")

            if vch.fighting or vch.position == merc.POS_FIGHTING:
                fight.stop_fighting(vch, False)
            af = handler_game.AFFECT_DATA()
            af.where = merc.TO_AFFECTS
            af.type = sn
            af.level = level
            af.duration = level // 4
            af.location = merc.APPLY_HITROLL
            if not vch.is_npc():
                af.modifier = -5
            else:
                af.modifier = -2
            af.bitvector = merc.AFF_CALM
            vch.affect_add(af)

            af.location = merc.APPLY_DAMROLL
            vch.affect_add(af)
예제 #9
0
def cmd_flee(ch, argument):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    if ch.is_affected(merc.AFF_WEBBED):
        ch.send("You are unable to move with all this sticky webbing on.\n")
        return

    if not ch.is_npc() and ch.powers[merc.UNI_RAGE] >= 0:
        if ch.is_vampire(
        ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE]:
            ch.send("Your inner beast refuses to let you run!\n")
            ch.wait_state(merc.PULSE_VIOLENCE)
            return
        elif ch.is_werewolf(
        ) and game_utils.number_percent() <= ch.powers[merc.UNI_RAGE] * 0.3:
            ch.send("Your rage is too great!\n")
            ch.wait_state(merc.PULSE_VIOLENCE)
            return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()

        pexit = was_in.exit[door]
        if not pexit or not pexit.to_room or pexit.exit_info.is_set(merc.EX_CLOSED) or \
                (ch.is_npc() and state_checks.is_set(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door)

        now_in = ch.in_room
        if now_in == was_in:
            continue

        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!  Coward!\n")

        fight.stop_fighting(ch, True)
        return

    ch.send("You were unable to escape!\n")
예제 #10
0
파일: living.py 프로젝트: carriercomm/PyRom
    def extract(self, fPull):
        if not self.in_room:
            logger.warn('Character being extracted is not in a room.')

        # nuke_pets(ch)
        self.pet = None  # just in case

        #if fPull:
        #    die_follower( ch )
        fight.stop_fighting(self, True)

        for item_id in self.equipped.values():
            if item_id:
                item = instance.global_instances[item_id]
                self.raw_unequip(item)
        for item_id in self.inventory[:]:
            item = instance.global_instances[item_id]
            item.extract()

        if self.in_room:
            self.in_room.get(self)

        # Death room is set in the clan table now
        if not fPull:
            room_id = instance.instances_by_room[self.clan.hall][0]
            room = instance.rooms[room_id]
            if self.in_room:
                self.in_room.get(self)
                room.put(self)
            else:
                room.put(self)
            return

        if self.desc and self.desc.original:
            self.do_return("")
            self.desc = None

        for wch in instance.players.values():
            if wch.reply == self:
                wch.reply = None

        if self.instance_id not in instance.characters:
            logger.error("Extract_char: char not found.")
            return

        self.instance_destructor()
        if self.desc:
            self.desc.character = None

        return
예제 #11
0
def cmd_rescue(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Rescue whom?\n")
        return

    victim = ch.get_char_room(arg)
    if not victim:
        ch.not_here(arg)
        return

    if victim == ch:
        ch.send("What about fleeing instead?\n")
        return

    if not ch.is_npc() and victim.is_npc():
        ch.send("Doesn't need your help!\n")
        return

    if ch.fighting == victim:
        ch.send("Too late.\n")
        return

    fch = victim.fighting
    if not fch:
        ch.send("That person is not fighting right now.\n")
        return

    if fight.is_safe(ch, fch) or fight.is_safe(ch, victim):
        return

    ch.wait_state(const.skill_table["rescue"].beats)

    if not ch.is_npc() and game_utils.number_percent() > ch.learned["rescue"]:
        ch.send("You fail the rescue.\n")
        return

    handler_game.act("You rescue $N!", ch, None, victim, merc.TO_CHAR)
    handler_game.act("$n rescues you!", ch, None, victim, merc.TO_VICT)
    handler_game.act("$n rescues $N!", ch, None, victim, merc.TO_NOTVICT)
    fight.stop_fighting(fch, False)
    fight.stop_fighting(victim, False)
    fight.check_killer(ch, fch)
    fight.set_fighting(ch, fch)
    fight.set_fighting(fch, ch)
예제 #12
0
def do_rescue(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Rescue whom?\n")
        return
    victim = ch.get_char_room(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim == ch:
        ch.send("What about fleeing instead?\n")
        return
    if not ch.is_npc() and victim.is_npc():
        ch.send("Doesn't need your help!\n")
        return
    if ch.fighting == victim:
        ch.send("Too late.\n")
        return
    fch = victim.fighting
    if not fch:
        ch.send("That person is not fighting right now.\n")
        return
    if state_checks.IS_NPC(fch) and not ch.is_same_group(victim):
        ch.send("Kill stealing is not permitted.\n")
        return
    state_checks.WAIT_STATE(ch, const.skill_table['rescue'].beats)
    if random.randint(1, 99) > ch.get_skill('rescue'):
        ch.send("You fail the rescue.\n")
        if ch.is_pc():
            ch.check_improve( 'rescue', False, 1)
        return
    handler_game.act("You rescue $N!", ch, None, victim, merc.TO_CHAR)
    handler_game.act("$n rescues you!", ch, None, victim, merc.TO_VICT)
    handler_game.act("$n rescues $N!", ch, None, victim, merc.TO_NOTVICT)
    if ch.is_pc():
        ch.check_improve( 'rescue', True, 1)

    fight.stop_fighting(fch, False)
    fight.stop_fighting(victim, False)

    fight.check_killer(ch, fch)
    fight.set_fighting(ch, fch)
    fight.set_fighting(fch, ch)
    return
예제 #13
0
def do_rescue(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Rescue whom?\n")
        return
    victim = ch.get_char_room(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim == ch:
        ch.send("What about fleeing instead?\n")
        return
    if not ch.is_npc() and victim.is_npc():
        ch.send("Doesn't need your help!\n")
        return
    if ch.fighting == victim:
        ch.send("Too late.\n")
        return
    fch = victim.fighting
    if not fch:
        ch.send("That person is not fighting right now.\n")
        return
    if state_checks.IS_NPC(fch) and not ch.is_same_group(victim):
        ch.send("Kill stealing is not permitted.\n")
        return
    state_checks.WAIT_STATE(ch, const.skill_table['rescue'].beats)
    if random.randint(1, 99) > ch.get_skill('rescue'):
        ch.send("You fail the rescue.\n")
        if ch.is_pc():
            ch.check_improve('rescue', False, 1)
        return
    handler_game.act("You rescue $N!", ch, None, victim, merc.TO_CHAR)
    handler_game.act("$n rescues you!", ch, None, victim, merc.TO_VICT)
    handler_game.act("$n rescues $N!", ch, None, victim, merc.TO_NOTVICT)
    if ch.is_pc():
        ch.check_improve('rescue', True, 1)

    fight.stop_fighting(fch, False)
    fight.stop_fighting(victim, False)

    fight.check_killer(ch, fch)
    fight.set_fighting(ch, fch)
    fight.set_fighting(fch, ch)
    return
예제 #14
0
def do_transfer(ch, argument):
    argument, arg1 = game_utils.read_word(argument)
    argument, arg2 = game_utils.read_word(argument)
    if not arg1:
        ch.send("Transfer whom (and where)?\n")
        return
    if arg1 == "all":
        for d in merc.descriptor_list:
            if d.is_connected(nanny.con_playing) \
                    and d.character != ch \
                    and d.character.in_room \
                    and ch.can_see(d.character):
                ch.do_transfer("%s %s" % d.character.name, arg2)
        return
    # Thanks to Grodyn for the optional location parameter.
    if not arg2:
        location = ch.in_room
    else:
        location = game_utils.find_location(ch, arg2)
        if not location:
            ch.send("No such location.\n")
            return
        if not ch.is_room_owner(location) and location.is_private() \
                and ch.trust < merc.MAX_LEVEL:
            ch.send("That room is private right now.\n")
            return
    victim = ch.get_char_world(arg1)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.in_room is None:
        ch.send("They are in limbo.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)
    handler_game.act("$n disappears in a mushroom cloud.", victim, None, None, merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n arrives from a puff of smoke.", victim, None, None, merc.TO_ROOM)
    if ch != victim:
        handler_game.act("$n has transferred you.", ch, None, victim, merc.TO_VICT)
    victim.do_look("auto")
    ch.send("Ok.\n")
예제 #15
0
def cmd_goto(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if not arg:
        ch.send("Goto where?\n")
        return

    location = game_utils.find_location(ch, arg)
    if not location:
        ch.send("No such location.\n")
        return

    if location.is_private():
        ch.send("That room is private right now.\n")
        return

    if ch.fighting:
        fight.stop_fighting(ch, True)

    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.is_npc() and ch.bamfout:
                handler_game.act("$t", ch, ch.bamfout, rch, merc.TO_VICT)
            else:
                handler_game.act("$n leaves in a swirling mist.", ch, None, rch, merc.TO_VICT)

    location.put(ch.in_room.get(ch))

    for rch_id in ch.in_room.people[:]:
        rch = instance.characters[rch_id]
        if rch.trust >= ch.invis_level:
            if ch.is_npc() and ch.bamfin:
                handler_game.act("$t", ch, ch.bamfin, rch, merc.TO_VICT)
            else:
                handler_game.act("$n appears in a swirling mist.", ch, None, rch, merc.TO_VICT)

    ch.cmd_look("auto")

    mount = ch.mount
    if mount:
        ch.in_room.put(mount.in_room.get(mount))
        mount.cmd_look("")
예제 #16
0
파일: do_flee.py 프로젝트: totalgit/PyRom
def do_flee(ch, argument):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()
        pexit = was_in.exit[door]
        if not pexit \
                or not pexit.to_room \
                or pexit.exit_info.is_set(merc.EX_CLOSED) \
                or random.randint(0, ch.daze) != 0 \
                or (ch.is_npc()
                    and state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door, False)
        now_in = ch.in_room
        if now_in == was_in:
            continue
        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!\n")
            if ch.guild.name == 'thief' and (random.randint(1, 99) < 3 *
                                             (ch.level // 2)):
                ch.send("You snuck away safely.\n")
            else:
                ch.send("You lost 10 exp.\n")
                update.gain_exp(ch, -10)

        fight.stop_fighting(ch, True)
        return
    ch.send("PANIC! You couldn't escape!\n")
    return
예제 #17
0
def cmd_recall(ch, argument):
    handler_game.act("Your body flickers with green energy.", ch, None, None,
                     merc.TO_CHAR)
    handler_game.act("$n's body flickers with green energy.", ch, None, None,
                     merc.TO_ROOM)

    location = handler_room.get_room_by_vnum(ch.home)
    if not location:
        location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
        if not location:
            ch.send("You are completely lost.\n")
            return

    if ch.in_room == location:
        return

    if ch.in_room.room_flags.is_set(merc.ROOM_NO_RECALL) or ch.is_affected(
            merc.AFF_CURSE):
        ch.send("You are unable to recall.\n")
        return

    victim = ch.fighting
    if victim:
        if game_utils.number_bits(1) == 0:
            ch.wait_state(4)
            ch.send("You failed!\n")
            return

        ch.send("You recall from combat!\n")
        fight.stop_fighting(ch, True)

    handler_game.act("$n disappears.", ch, None, None, merc.TO_ROOM)
    ch.in_room.get(ch)
    location.put(ch)
    handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM)
    ch.cmd_look("auto")

    mount = ch.mount
    if mount:
        mount.in_room.get(mount)
        location.put(mount)
예제 #18
0
def do_flee( ch, argument ):
    victim = ch.fighting
    if not victim:
        if ch.position == merc.POS_FIGHTING:
            ch.position = merc.POS_STANDING
        ch.send("You aren't fighting anyone.\n")
        return

    was_in = ch.in_room
    for attempt in range(6):
        door = handler_room.number_door()
        pexit = was_in.exit[door]
        if not pexit \
                or not pexit.to_room \
                or pexit.exit_info.is_set(merc.EX_CLOSED) \
                or random.randint(0, ch.daze) != 0 \
                or (ch.is_npc()
                    and state_checks.IS_SET(instance.rooms[pexit.to_room].room_flags, merc.ROOM_NO_MOB)):
            continue

        handler_ch.move_char(ch, door, False)
        now_in = ch.in_room
        if now_in == was_in:
            continue
        ch.in_environment = was_in.instance_id
        handler_game.act("$n has fled!", ch, None, None, merc.TO_ROOM)
        ch.in_environment = now_in.instance_id

        if not ch.is_npc():
            ch.send("You flee from combat!\n")
            if ch.guild.name == 'thief' and (random.randint(1, 99) < 3 * (ch.level // 2)):
                ch.send("You snuck away safely.\n")
            else:
                ch.send("You lost 10 exp.\n")
                update.gain_exp(ch, -10)

        fight.stop_fighting(ch, True)
        return
    ch.send("PANIC! You couldn't escape!\n")
    return
예제 #19
0
def do_recall(ch, argument):
    if ch.is_npc() and not ch.act.is_set(merc.ACT_PET):
        ch.send("Only players can recall.\n")
        return
    handler_game.act("$n prays for transportation!", ch, 0, 0, merc.TO_ROOM)
    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        ch.send("You are completely lost.\n")
        return
    if ch.in_room == location:
        return
    if state_checks.IS_SET(ch.in_room.room_flags, merc.ROOM_NO_RECALL) or ch.is_affected(merc.AFF_CURSE):
        ch.send("Mota has forsaken you.\n")
        return
    victim = ch.fighting
    if victim:
        skill = ch.get_skill("recall")
        if random.randint(1, 99) < 80 * skill / 100:
            if ch.is_pc():
                ch.check_improve( "recall", False, 6)
            state_checks.WAIT_STATE(ch, 4)
            ch.send("You failed!.\n")
            return
        lose = 25 if ch.desc else 50
        update.gain_exp(ch, 0 - lose)
        if ch.is_pc():
            ch.check_improve( "recall", True, 4)
        ch.send("You recall from combat!  You lose %d exps.\n" % lose)
        fight.stop_fighting(ch, True)
    ch.move /= 2
    handler_game.act("$n disappears.", ch, None, None, merc.TO_ROOM)
    ch.in_room.get(ch)
    location.put(ch)
    handler_game.act("$n appears in the room.", ch, None, None, merc.TO_ROOM)
    ch.do_look("auto")

    if ch.pet is not None:
        ch.pet.do_recall("")
    return
예제 #20
0
def spell_word_of_recall(sn, level, ch, victim, target):
    # RT recall spell is back */
    if victim.is_npc():
        return

    location = handler_room.get_room_by_vnum(merc.ROOM_VNUM_TEMPLE)
    if not location:
        victim.send("You are completely lost.\n")
        return

    if state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NO_RECALL) or victim.is_affected(merc.AFF_CURSE):
        victim.send("Spell failed.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)

    ch.move //= 2
    handler_game.act("$n disappears.", victim, None, None, merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n appears in the room.", victim, None, None, merc.TO_ROOM)
    victim.do_look("auto")
예제 #21
0
def do_deny(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Deny whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    victim.act = state_checks.SET_BIT(victim.act, merc.PLR_DENY)
    victim.send("You are denied access!\n")
    handler_game.wiznet("$N denies access to %s" % victim.name, ch, None, merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    ch.send("OK.\n")
    victim.save(logout=True, force=True)
    fight.stop_fighting(victim, True)
    victim.do_quit("")
    return
예제 #22
0
def do_deny(ch, argument):
    argument, arg = game_utils.read_word(argument)
    if not arg:
        ch.send("Deny whom?\n")
        return
    victim = ch.get_char_world(arg)
    if not victim:
        ch.send("They aren't here.\n")
        return
    if victim.is_npc():
        ch.send("Not on NPC's.\n")
        return
    if victim.trust >= ch.trust:
        ch.send("You failed.\n")
        return
    victim.act = state_checks.SET_BIT(victim.act, merc.PLR_DENY)
    victim.send("You are denied access!\n")
    handler_game.wiznet("$N denies access to %s" % victim.name, ch, None,
                        merc.WIZ_PENALTIES, merc.WIZ_SECURE, 0)
    ch.send("OK.\n")
    victim.save(logout=True, force=True)
    fight.stop_fighting(victim, True)
    victim.do_quit("")
    return
예제 #23
0
파일: update.py 프로젝트: carriercomm/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("")
예제 #24
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("")
예제 #25
0
def cmd_punch(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if ch.is_npc():
        return

    if ch.level < const.skill_table["punch"].skill_level:
        ch.send("First you should learn to punch.\n")
        return

    victim = ch.get_char_room(arg)
    if not victim:
        ch.not_here(arg)
        return

    if ch == victim:
        ch.not_self()
        return

    if fight.is_safe(ch, victim):
        return

    if victim.hit < victim.max_hit:
        ch.send("They are hurt and suspicious.\n")
        return

    if victim.position < merc.POS_FIGHTING:
        ch.send("You can only punch someone who is standing.\n")
        return

    ch.wait_state(const.skill_table["punch"].beats)

    if ch.is_npc() or game_utils.number_percent() < ch.learned["punch"]:
        dam = game_utils.number_range(1, 4)
    else:
        fight.damage(ch, victim, 0, "punch")
        return

    dam += ch.damroll

    if dam == 0:
        dam = 1

    if not victim.is_awake():
        dam *= 2

    if not ch.is_npc():
        dam += (dam * (ch.wpn[0] // 100))

    if dam <= 0:
        dam = 1

    if not victim.is_npc() and victim.is_werewolf(
    ) and victim.powers[merc.WPOWER_BOAR] > 3:
        fight.damage(ch, victim, 0, "punch")

        if game_utils.number_percent() <= 25 and not ch.arm_left.is_set(
                merc.LOST_ARM) and not ch.arm_left.is_set(merc.LOST_HAND):
            broke = False
            if not ch.arm_left.is_set(
                    merc.LOST_FINGER_I) and not ch.arm_left.is_set(
                        merc.BROKEN_FINGER_I):
                ch.arm_left.set_bit(merc.BROKEN_FINGER_I)
                broke = True
            if not ch.arm_left.is_set(
                    merc.LOST_FINGER_M) and not ch.arm_left.is_set(
                        merc.BROKEN_FINGER_M):
                ch.arm_left.set_bit(merc.BROKEN_FINGER_M)
                broke = True
            if not ch.arm_left.is_set(
                    merc.LOST_FINGER_R) and not ch.arm_left.is_set(
                        merc.BROKEN_FINGER_R):
                ch.arm_left.set_bit(merc.BROKEN_FINGER_R)
                broke = True
            if not ch.arm_left.is_set(
                    merc.LOST_FINGER_L) and not ch.arm_left.is_set(
                        merc.BROKEN_FINGER_L):
                ch.arm_left.set_bit(merc.BROKEN_FINGER_L)
                broke = True

            if broke:
                handler_game.act(
                    "The fingers on your left hand shatter under the impact of the blow!",
                    ch, None, None, merc.TO_CHAR)
                handler_game.act(
                    "The fingers on $n's left hand shatter under the impact of the blow!",
                    ch, None, None, merc.TO_ROOM)
        elif game_utils.number_percent() <= 25 and not ch.arm_right.is_set(
                merc.LOST_ARM) and not ch.arm_right.is_set(merc.LOST_HAND):
            broke = False
            if not ch.arm_right.is_set(
                    merc.LOST_FINGER_I) and not ch.arm_right.is_set(
                        merc.BROKEN_FINGER_I):
                ch.arm_right.set_bit(merc.BROKEN_FINGER_I)
                broke = True
            if not ch.arm_right.is_set(
                    merc.LOST_FINGER_M) and not ch.arm_right.is_set(
                        merc.BROKEN_FINGER_M):
                ch.arm_right.set_bit(merc.BROKEN_FINGER_M)
                broke = True
            if not ch.arm_right.is_set(
                    merc.LOST_FINGER_R) and not ch.arm_right.is_set(
                        merc.BROKEN_FINGER_R):
                ch.arm_right.set_bit(merc.BROKEN_FINGER_R)
                broke = True
            if not ch.arm_right.is_set(
                    merc.LOST_FINGER_L) and not ch.arm_right.is_set(
                        merc.BROKEN_FINGER_L):
                ch.arm_right.set_bit(merc.BROKEN_FINGER_L)
                broke = True

            if broke:
                handler_game.act(
                    "The fingers on your right hand shatter under the impact of the blow!",
                    ch, None, None, merc.TO_CHAR)
                handler_game.act(
                    "The fingers on $n's right hand shatter under the impact of the blow! ",
                    ch, None, None, merc.TO_ROOM)
        fight.stop_fighting(victim, True)
        return

    fight.damage(ch, victim, dam, "punch")

    if not victim or victim.position == merc.POS_DEAD or dam < 1:
        return

    if victim.position == merc.POS_FIGHTING:
        fight.stop_fighting(victim, True)

    if game_utils.number_percent() <= 25 and not victim.head.is_set(
            merc.BROKEN_NOSE) and not victim.head.is_set(merc.LOST_NOSE):
        handler_game.act("Your nose shatters under the impact of the blow!",
                         victim, None, None, merc.TO_CHAR)
        handler_game.act("$n's nose shatters under the impact of the blow!",
                         victim, None, None, merc.TO_ROOM)
        victim.head.set_bit(merc.BROKEN_NOSE)
    elif game_utils.number_percent() <= 25 and not victim.head.is_set(
            merc.BROKEN_JAW):
        handler_game.act("Your jaw shatters under the impact of the blow!",
                         victim, None, None, merc.TO_CHAR)
        handler_game.act("$n's jaw shatters under the impact of the blow!",
                         victim, None, None, merc.TO_ROOM)
        victim.head.set_bit(merc.BROKEN_JAW)

    handler_game.act("You fall to the ground stunned!", victim, None, None,
                     merc.TO_CHAR)
    handler_game.act("$n falls to the ground stunned!", victim, None, None,
                     merc.TO_ROOM)
    victim.position = merc.POS_STUNNED
예제 #26
0
def cmd_transfer(ch, argument):
    argument, arg1 = game_utils.read_word(argument)
    argument, arg2 = game_utils.read_word(argument)

    if not arg1:
        ch.send("Transfer whom (and where)?\n")
        return

    if game_utils.str_cmp(arg1, "all"):
        for wch in list(instance.players.values()):
            if wch != ch and wch.in_room and ch.can_see(wch):
                if wch.act.is_set(
                        merc.PLR_GODLESS
                ) and ch.trust < merc.NO_GODLESS and not ch.extra.is_set(
                        merc.EXTRA_ANTI_GODLESS):
                    continue

                ch.cmd_transfer("{} {}".format(wch.name, arg2))
        return

    # Thanks to Grodyn for the optional location parameter.
    if not arg2:
        location = ch.in_room
    else:
        location = game_utils.find_location(ch, arg2)
        if not location:
            ch.send("No such location.\n")
            return

        if location.is_private():
            ch.send("That room is private right now.\n")
            return

    victim = ch.get_char_world(arg1)
    if not victim:
        ch.not_here(arg1)
        return

    if not victim.in_room:
        ch.send("They are in limbo.\n")
        return

    if victim.act.is_set(
            merc.PLR_GODLESS
    ) and ch.trust < merc.NO_GODLESS and not ch.extra.is_set(
            merc.EXTRA_ANTI_GODLESS):
        ch.send("You failed.\n")
        return

    if victim.fighting:
        fight.stop_fighting(victim, True)

    handler_game.act("$n disappears in a mushroom cloud.", victim, None, None,
                     merc.TO_ROOM)
    victim.in_room.get(victim)
    location.put(victim)
    handler_game.act("$n arrives from a puff of smoke.", victim, None, None,
                     merc.TO_ROOM)

    if ch != victim:
        handler_game.act("$n has transferred you.", ch, None, victim,
                         merc.TO_VICT)

    victim.cmd_look("auto")
    ch.send("Ok.\n")

    mount = victim.mount
    if mount:
        mount.in_room.get(mount)
        location.put(mount)

        if ch != mount:
            handler_game.act("$n has transferred you.", ch, None, mount,
                             merc.TO_VICT)
        mount.cmd_look("auto")
예제 #27
0
def cmd_voodoo(ch, argument):
    argument, arg1 = game_utils.read_word(argument)
    argument, arg2 = game_utils.read_word(argument)

    if not arg1:
        ch.send("Who do you wish to use voodoo magic on?\n")
        return

    item = ch.get_eq("left_hand")
    if not item:
        item = ch.get_eq("right_hand")
        if not item:
            ch.send("You are not holding a voodoo doll.\n")
            return

    victim = ch.get_char_world(arg1)
    if not victim:
        ch.not_here(arg1)
        return

    if victim.is_npc():
        ch.not_npc()
        return

    part1 = "{} voodoo doll".format(victim.name)
    part2 = item.name

    if not game_utils.str_cmp(part1, part2):
        ch.send("But you are holding {}, not {}!\n".format(item.short_descr, victim.name))
        return

    if game_utils.str_cmp(arg2, "stab"):
        ch.wait_state(merc.PULSE_VIOLENCE)
        handler_game.act("You stab a pin through $p.", ch, item, None, merc.TO_CHAR)
        handler_game.act("$n stabs a pin through $p.", ch, item, None, merc.TO_ROOM)

        if not victim.is_npc() and victim.immune.is_set(merc.IMM_VOODOO):
            return

        handler_game.act("You feel an agonising pain in your chest!", victim, None, None, merc.TO_CHAR)
        handler_game.act("$n clutches $s chest in agony!", victim, None, None, merc.TO_ROOM)
    elif game_utils.str_cmp(arg2, "burn"):
        ch.wait_state(merc.PULSE_VIOLENCE)
        handler_game.act("You set fire to $p.", ch, item, None, merc.TO_CHAR)
        handler_game.act("$n sets fire to $p.", ch, item, None, merc.TO_ROOM)
        handler_game.act("$p burns to ashes.", ch, item, None, merc.TO_CHAR)
        handler_game.act("$p burns to ashes.", ch, item, None, merc.TO_ROOM)
        ch.get(item)
        item.extract()

        if not victim.is_npc() and victim.immune.is_set(merc.IMM_VOODOO) or victim.is_affected(merc.AFF_FLAMING):
            return

        victim.affected_by.set_bit(merc.AFF_FLAMING)
        handler_game.act("You suddenly burst into flames!", victim, None, None, merc.TO_CHAR)
        handler_game.act("$n suddenly bursts into flames!", victim, None, None, merc.TO_ROOM)
    elif game_utils.str_cmp(arg2, "throw"):
        ch.wait_state(merc.PULSE_VIOLENCE)
        handler_game.act("You throw $p to the ground.", ch, item, None, merc.TO_CHAR)
        handler_game.act("$n throws $p to the ground.", ch, item, None, merc.TO_ROOM)
        ch.get(item)
        ch.in_room.put(item)

        if not victim.is_npc() and victim.immuen.is_set(merc.IMM_VOODOO) or victim.position < merc.POS_STANDING:
            return

        if victim.position == merc.POS_FIGHTING:
            fight.stop_fighting(victim, True)

        handler_game.act("A strange force picks you up and hurls you to the ground!", victim, None, None, merc.TO_CHAR)
        handler_game.act("$n is hurled to the ground by a strange force.", victim, None, None, merc.TO_ROOM)
        victim.position = merc.POS_RESTING
        victim.hit = victim.hit - game_utils.number_range(ch.level, (5 * ch.level))
        fight.update_pos(victim)

        if victim.position == merc.POS_DEAD and not victim.is_npc():
            ch.cmd_killperson(victim)
            return
    else:
        ch.send("You can 'stab', 'burn' or 'throw' the doll.\n")
예제 #28
0
def char_update():
    drop_out = False
    save_time = merc.current_time
    ch_save = None
    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 not ch.environment:
            continue

        if not ch.is_npc() and (ch.head.is_set(merc.LOST_HEAD)
                                or ch.extra.is_set(merc.EXTRA_OSWITCH)):
            is_obj = True
        elif not ch.is_npc() and ch.obj_vnum != 0:
            is_obj = True
            ch.extra.set_bit(merc.EXTRA_OSWITCH)
        else:
            is_obj = False

        # Find dude with oldest save time.
        if not ch.is_npc() and (
                not ch.desc or ch.desc.is_connected(nanny.con_playing)
        ) and ch.level >= 2 and ch.save_time < save_time:
            ch_save = ch
            save_time = ch.save_time

        if ch.position > merc.POS_STUNNED and not is_obj:
            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 and not is_obj:
            ch.hit += game_utils.number_range(2, 4)
            fight.update_pos(ch)

        if not ch.is_npc() and ch.level < merc.LEVEL_IMMORTAL and not is_obj:
            item1 = ch.get_eq("right_hand")
            item2 = ch.get_eq("left_hand")
            if (item1 and item1.item_type == merc.ITEM_LIGHT and item1.value[2] > 0) or \
                    (item2 and item2.item_type == merc.ITEM_LIGHT and item2.value[2] > 0):
                if item1:
                    item1.value[2] -= 1
                    if item1.value[2] == 0 and ch.in_room:
                        ch.in_room.available_light -= 1
                        handler_game.act("$p goes out.", ch, item1, None,
                                         merc.TO_ROOM)
                        handler_game.act("$p goes out.", ch, item1, None,
                                         merc.TO_CHAR)
                        item1.extract()
                elif item2:
                    item2.value[2] -= 1
                    if item2.value[2] == 0 and ch.in_room:
                        ch.in_room.available_light -= 1
                        handler_game.act("$p goes out.", ch, item2, None,
                                         merc.TO_ROOM)
                        handler_game.act("$p goes out.", ch, item2, None,
                                         merc.TO_CHAR)
                        item2.extract()

            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")
                    ch.save(force=True)
                    limbo_id = instance.instances_by_room[
                        merc.ROOM_VNUM_LIMBO][0]
                    limbo = instance.rooms[limbo_id]
                    ch.in_room.get(ch)
                    limbo.put(ch)

            if ch.timer > 30:
                ch_quit.append(ch)

            if ch.is_vampire():
                blood = -1

                if ch.beast > 0:
                    if ch.vampaff.is_set(merc.VAM_CLAWS):
                        blood -= game_utils.number_range(1, 3)

                    if ch.vampaff.is_set(merc.VAM_FANGS):
                        blood -= 1

                    if ch.vampaff.is_set(merc.VAM_NIGHTSIGHT):
                        blood -= 1

                    if ch.vampaff.is_set(merc.AFF_SHADOWSIGHT):
                        blood -= game_utils.number_range(1, 3)

                    if ch.act.is_set(merc.PLR_HOLYLIGHT):
                        blood -= game_utils.number_range(1, 5)

                    if ch.vampaff.is_set(merc.VAM_DISGUISED):
                        blood -= game_utils.number_range(5, 10)

                    if ch.vampaff.is_set(merc.VAM_CHANGED):
                        blood -= game_utils.number_range(5, 10)

                    if ch.immune.is_set(merc.IMM_SHIELDED):
                        blood -= game_utils.number_range(1, 3)

                    if ch.polyaff.is_set(merc.POLY_SERPENT):
                        blood -= game_utils.number_range(1, 3)

                    if ch.beast == 100:
                        blood *= 2
                gain_condition(ch, blood)

        for aff in ch.affected[:]:
            if aff.duration > 0:
                aff.duration -= 1
            elif aff.duration < 0:
                pass
            else:
                multi = [
                    a for a in ch.affected
                    if a.type == aff.type and a is not aff and a.duration > 0
                ]
                if not multi and aff.type and const.skill_table[
                        aff.type].msg_off:
                    ch.send(const.skill_table[aff.type].msg_off + "\n")
                ch.affect_remove(aff)

        # Careful with the damages here,
        #   MUST NOT refer to ch after damage taken,
        #   as it may be lethal damage (on NPC).
        if not ch.bleeding.empty() and not is_obj and ch.in_room:
            dam = 0
            minhit = 0 if ch.is_npc() else -11

            if ch.bleeding.is_set(
                    merc.BLEEDING_HEAD) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's neck.", ch,
                    None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your neck.\n")
                dam += game_utils.number_range(20, 50)

            if ch.bleeding.is_set(
                    merc.BLEEDING_THROAT) and ch.hit - dam > minhit:
                handler_game.act("Blood pours from the slash in $n's throat.",
                                 ch, None, None, merc.TO_ROOM)
                ch.send("Blood pours from the slash in your throat.\n")
                dam += game_utils.number_range(10, 20)

            if ch.bleeding.is_set(
                    merc.BLEEDING_ARM_L) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's left arm.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your left arm.\n"
                )
                dam += game_utils.number_range(10, 20)
            elif ch.bleeding.is_set(
                    merc.BLEEDING_HAND_L) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's left wrist.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your left wrist.\n"
                )
                dam += game_utils.number_range(5, 10)

            if ch.bleeding.is_set(
                    merc.BLEEDING_ARM_R) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's right arm.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your right arm.\n"
                )
                dam += game_utils.number_range(10, 20)
            elif ch.bleeding.is_set(
                    merc.BLEEDING_HAND_R) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's right wrist.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your right wrist.\n"
                )
                dam += game_utils.number_range(5, 10)

            if ch.bleeding.is_set(
                    merc.BLEEDING_LEG_L) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's left leg.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your left leg.\n"
                )
                dam += game_utils.number_range(10, 20)
            elif ch.bleeding.is_set(
                    merc.BLEEDING_FOOT_L) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's left ankle.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your left ankle.\n"
                )
                dam += game_utils.number_range(5, 10)

            if ch.bleeding.is_set(
                    merc.BLEEDING_LEG_R) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's right leg.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your right leg.\n"
                )
                dam += game_utils.number_range(10, 20)
            elif ch.bleeding.is_set(
                    merc.BLEEDING_FOOT_R) and ch.hit - dam > minhit:
                handler_game.act(
                    "A spray of blood shoots from the stump of $n's right ankle.",
                    ch, None, None, merc.TO_ROOM)
                ch.send(
                    "A spray of blood shoots from the stump of your right ankle.\n"
                )
                dam += game_utils.number_range(5, 10)

            ch.hit -= dam
            if ch.is_hero() and ch.hit < 1:
                ch.hit = 1
            fight.update_pos(ch)
            ch.in_room.blood += dam
            if ch.in_room.blood > 1000:
                ch.in_room.blood = 1000

            if ch.hit <= -11 or (ch.is_npc() and ch.hit < 1):
                ch.killperson(ch)
                drop_out = True

        if ch.is_affected(merc.AFF_FLAMING
                          ) and not is_obj and not drop_out and ch.in_room:
            if not (
                    not ch.is_npc() and
                (ch.is_hero() or
                 (ch.immune.is_set(merc.IMM_HEAT) and not ch.is_vampire()))):
                handler_game.act("$n's flesh burns and crisps.", ch, None,
                                 None, merc.TO_ROOM)
                ch.send("Your flesh burns and crisps.\n")
                dam = game_utils.number_range(10, 20)

                if not ch.is_npc():
                    if ch.immune.is_set(merc.IMM_HEAT):
                        dam //= 2

                    if ch.is_vampire():
                        dam *= 2

                ch.hit -= dam
                fight.update_pos(ch)

                if ch.hit <= -11:
                    ch.killperson(ch)
                    drop_out = True
        elif not ch.is_npc() and ch.is_vampire() and not ch.is_affected(merc.AFF_SHADOWPLANE) and not ch.immune.is_set(merc.IMM_SUNLIGHT) and \
                ch.in_room and ch.in_room.sector_type != merc.SECT_INSIDE and not is_obj and not ch.in_room.is_dark() and \
                handler_game.weather_info.sunlight != merc.SUN_DARK:
            handler_game.act("$n's flesh smolders in the sunlight!", ch, None,
                             None, merc.TO_ROOM)
            ch.send("Your flesh smolders in the sunlight!\n")

            # This one's to keep Zarkas quiet ;)
            if ch.polyaff.is_set(merc.POLY_SERPENT):
                ch.hit -= game_utils.number_range(2, 4)
            else:
                ch.hit -= game_utils.number_range(5, 10)
            fight.update_pos(ch)

            if ch.hit <= -11:
                ch.killperson(ch)
                drop_out = True
        elif ch.is_affected(merc.AFF_POISON) and not is_obj and not drop_out:
            handler_game.act("$n shivers and suffers.", ch, None, None,
                             merc.TO_ROOM)
            ch.send("You shiver and suffer.\n")
            fight.damage(ch, ch, 2, "poison")
        elif ch.position == merc.POS_INCAP and not is_obj and not drop_out:
            if ch.is_hero():
                ch.hit += game_utils.number_range(2, 4)
            else:
                ch.hit += game_utils.number_range(1, 2)
            fight.update_pos(ch)

            if ch.position > merc.POS_INCAP:
                handler_game.act("$n's wounds stop bleeding and seal up.", ch,
                                 None, None, merc.TO_ROOM)
                ch.send("Your wounds stop bleeding and seal up.\n")

            if ch.position > merc.POS_STUNNED:
                handler_game.act("$n clambers back to $s feet.", ch, None,
                                 None, merc.TO_ROOM)
                ch.send("You clamber back to your feet.\n")
        elif ch.position == merc.POS_MORTAL and not is_obj and not drop_out:
            drop_out = False

            if ch.is_hero():
                ch.hit += game_utils.number_range(2, 4)
            else:
                ch.hit -= game_utils.number_range(1, 2)

                if not ch.is_npc() and ch.hit <= -11:
                    ch.killperson(ch)
                drop_out = True

            if not drop_out:
                fight.update_pos(ch)

                if ch.position == merc.POS_INCAP:
                    handler_game.act(
                        "$n's wounds begin to close, and $s bones pop back into place.",
                        ch, None, None, merc.TO_ROOM)
                    ch.send(
                        "Your wounds begin to close, and your bones pop back into place.\n"
                    )
        elif ch.position == merc.POS_DEAD and not is_obj and not drop_out:
            fight.update_pos(ch)
            if not ch.is_npc():
                ch.killperson(ch)
        drop_out = False

    # Autosave and autoquit.
    # Check that these chars still exist.
    if ch_quit or ch_save:
        for ch in list(instance.players.values()):
            if ch == ch_save:
                ch.save()

        for ch in ch_quit[:]:
            ch.cmd_quit("")