def func(self): caller = self.caller tr = self.caller.traits lastcast = caller.db.vt_lastcast if not self.args: self.caller.msg("You dont have a target!") return target = self.caller.search(self.args) if not target: return if tr.SP.current < 35: caller.msg("You don't have enough power to cast this spell") return if lastcast and time.time() - lastcast < 5: caller.msg("You cannot cast that again yet") return tr.SP.current -= 30 caller.msg('|rYou take a cursed bone and begin chanting.|n ') caller.location.msg_contents( "|r{actor} takes a cursed bone and begins chanting.|n", mapping=dict(actor=caller), exclude=caller) utils.delay(3, callback=self.vamptouch)
def func(self): caller = self.caller tr = self.caller.traits lc = caller.db.ds_lc item = "|xcursed bone" if not self.args: self.caller.msg("You dont have a target!") return target = self.caller.search(self.args) if not target: return if tr.SP.current < 30: caller.msg("You don't have enough power to cast this spell") return if item not in caller.contents: caller.msg("you don't have any cursed bones.") if lc and time.time() - lc < 5: mess = "You cannot cast that again yet" caller.msg(mess) return tr.SP.current -= 30 caller.msg('|mYou take a cursed bone and begin chanting.|n ') caller.location.msg_contents( "|m{actor} takes a cursed bone and begins chanting.|n", mapping=dict(actor=caller), exclude=caller) utils.delay(3, callback=self.death_spike)
def forge_two(self): caller = self.caller metal = ("iron", "steel", "mithril", "adamantine", "copper", "bronze", "brass", "silver", "gold") wood = ("cedar", "cypress", "fir", "yew", "larch", "pine", "spruce", "acacia", "aldar", "ash", "beech", "birch", "cherry", "ebony", "elm", "ironwood", "mahogany", "maple", "oak", "poplar", "walnut", "willow", "zingana", "leafweave") if self.material in metal: caller.msg('|511You take the {material} bar and start forging a {recipe} at the anvil.|n'.format( material=self.material, recipe=RECIPES.get(self.recipe).get("key"))) caller.location.msg_contents( "|511{actor} takes the {material} bar and starts forging it into a {recipe} at the anvil.|n", mapping=dict(actor=caller, material=self.material, recipe=RECIPES.get(self.recipe).get("key")), exclude=caller) elif self.material in wood: caller.msg('|511You begin carving the {material} board into a {recipe} at the workbench.|n'.format( material=self.material, recipe=RECIPES.get(self.recipe).get("key"))) caller.location.msg_contents( "|511{actor} begins carving a {material} board into a {recipe} at the workbench.|n", mapping=dict(actor=caller, material=self.material, recipe=RECIPES.get(self.recipe).get("key")), exclude=caller) utils.delay(20, callback=self.forge_three)
def at_start(self): """handles the phases of death""" super(CharDeathHandler, self).at_start() self.obj.msg("you have died") self.obj.location.msg_contents('{character} falls to the ground dead.', mapping={'character': self.obj}, exclude=self.obj) self.obj.traits.XP.current -= int(floor(0.15 * self.obj.traits.XP.current)) corpse_name = 'corpse of %s' % self.obj corpse_desc = "A dead body that was once %s in life." % self.obj corpse_proto = {'key': corpse_name, "desc": corpse_desc} corpse = spawn(corpse_proto)[0] corpse.location = self.obj.location for i in self.obj.equip: self.obj.equip.remove(i) for i in self.obj.contents: dest_chance = randint(1, 100) if dest_chance <= 15: i.delete else: i.move_to(corpse, quiet=True) void = self.obj.search('Void', global_search=True) self.obj.move_to(void, quiet=True, move_hooks=False) #create a corpse of the character that died Corpse of {character} #move the equipped,worn and inventory of character that died to corpse #check over each item to see what survives remove destroyed items delay(20, getattr(self, self.db.death_sequence[self.db.death_step]))
def kick(self, target): if self.db.position is 1: self.msg("You can't fight while resting.") return #target = self.args.strip() if self.db.cooldown is True: self.msg("You are really tired.") return if not target or target == "me": self.msg("Use a valid target.") return else: #target = self.search(self.args.strip()) target = self.search(target) if not target: return if target.account is self.account: self.msg("You try to kick yourself.") return self.db.cooldown = True cooldown = self.get_cooldown() self.check_health() target.db.health = round(target.db.health - (randint(1, 4) + (self.db.strength + self.db.offense) * .05)) target.msg("{0} kicks you hard in the head!".format(self.db._sdesc)) self.msg("Damn! You kicked {0}, dog.".format(target.db._sdesc.lower())) if target.db.health <= 0: self.msg("Your kick sends {0} to the realm of drov!".format( target.db._sdesc.lower())) if target.db.position is 1: target.stand() target.check_health() utils.delay(cooldown, self.kick_cooldown)
def attack(self, hand, caller, target): if self.db.attacking[hand]: self.msg("You're already attacking with your %s!" % self.db.unarmed_name) return self.msg("Ok - Attacking %s with %s." % (target.key, self.db.unarmed_name)) self.db.attacking[hand] = True delay(self.db.cooldown, attack_roll, weapon=None, hand=hand, caller=self, target=target)
def forge_one(self): caller = self.caller metal = ("iron", "steel", "mithril", "adamantine", "copper", "bronze", "brass", "silver", "gold") wood = ("cedar", "cypress", "fir", "yew", "larch", "pine", "spruce", "acacia", "aldar", "ash", "beech", "birch", "cherry", "ebony", "elm", "ironwood", "mahogany", "maple", "oak", "poplar", "walnut", "willow", "zingana", "leafweave") if self.material in metal: if "steel" in self.material: caller.msg("|511You begin smelting a usable {material} bar from iron ore and some coal.|n".format( material=self.material)) caller.location.msg_contents( "|511{actor} begins smelting a usable {material} bar from iron ore and coal.|n", mapping=dict(actor=caller, material=self.material), exclude=caller) elif "brass" in self.material: caller.msg("|511You begin smelting a usable {material} bar from copper and zinc ores.|n".format( material=self.material)) caller.location.msg_contents( "|511{actor} begins smelting a usable {material} bar from copper and zinc ores.|n", mapping=dict(actor=caller, material=self.material), exclude=caller) elif "bronze" in self.material: caller.msg("|511You begin smelting a usable {material} bar from copper and tin ores.|n".format( material=self.material)) caller.location.msg_contents( "|511{actor} begins smelting a usable {material} bar from copper and tin ores.|n", mapping=dict(actor=caller, material=self.material), exclude=caller) else: caller.msg('|511You begin smelting the {material} ore into a usable bar for forging at the smelter.|n' .format(material=self.material)) caller.location.msg_contents( "|511{actor} begins smelting the {material} ore into a usable bar for forging at the smelter.|n", mapping=dict(actor=caller, material=self.material), exclude=caller) elif self.material in wood: caller.msg('|511You begin milling the {material} log into a usable board at the mill table.|n'.format( material=self.material)) caller.location.msg_contents( "|511{actor} begins milling a {material} log into a usable board at the mill table.|n", mapping=dict(actor=caller, material=self.material), exclude=caller) utils.delay(20, callback=self.forge_two)
def returning(self): self.obj.msg( "You feel a quickening in your energy as you feel pulled back toward |mthe world...|n." ) self.obj.home.msg_contents( "A sudden roar fills the chamber as the fire grows tall and the surface |/" "of the purple pool becomes agitated, spattering droplets into the air |/" "surrounding the flame.") self.db.death_step += 1 delay(3, getattr(self, self.db.death_sequence[self.db.death_step]))
def at_start(self): """Handles the 'phases' of death""" super(NPCDeathHandler, self).at_start() self.obj.location.msg_contents("{character} falls dead.", mapping={'character': self.obj}, exclude=self.obj) self.obj.db.pose = self.obj.db.pose_death delay(10 * d_roll('1d6'), getattr(self, self.db.death_sequence[self.db.death_step]))
def func(self): caller = self.caller tr = self.caller.traits lastcast = caller.db.presence_lastcast if lastcast and time.time() - lastcast < 2 * 60: mess = "You cannot cast this again so soon" caller.msg(mess) return tr.SP.current -= (10 + tr.LVL.actual) utils.delay(1, callback=self.fortify_defense)
def fortify_will(self): caller = self.caller tr = self.caller.traits sk = self.caller.skills mess1 = '|m.You focus your mind on survival|n ' caller.msg(mess1) tr.WILL.mod += (sk.FOC.current / 5) # if the spell was successfully cast, store the casting time caller.db.willpower_lastcast = time.time() utils.delay(2 * 60, callback=self.unfortify_will)
def fortify_armor(self): caller = self.caller tr = self.caller.traits sk = self.caller.skills mess1 = '|mYou take out a vial of oil and fortify your armor.|n ' caller.msg(mess1) tr.PDEF.mod += (sk.FRG.current / 5) # if the spell was successfully cast, store the casting time caller.db.fortify_lastcast = time.time() utils.delay(2 * 60, callback=self.unfortify_armor)
def fortify_reflex(self): caller = self.caller tr = self.caller.traits sk = self.caller.skills mess1 = '|mYou move lithely as a dancer.|n ' caller.msg(mess1) tr.REFL.mod += (sk.DOD.current / 5) # if the spell was successfully cast, store the casting time caller.db.reflex_lastcast = time.time() utils.delay(2 * 60, callback=self.unfortify_reflex)
def fortify_fortitude(self): caller = self.caller tr = self.caller.traits sk = self.caller.skills mess1 = '|mYou take on a defensive stance.|n ' caller.msg(mess1) tr.FORT.mod += (sk.MAR.current / 5) # if the spell was successfully cast, store the casting time caller.db.fortitude_lastcast = time.time() utils.delay(2 * 60, callback=self.unfortify_fortitude)
def fortify_defense(self): caller = self.caller tr = self.caller.traits sk = self.caller.skills mess1 = '|mYou stand up straight exhibiting an aura of leadership.|n ' caller.msg(mess1) tr.MDEF.mod += (sk.LDR.current / 5) # if the spell was successfully cast, store the casting time caller.db.presence_lastcast = time.time() utils.delay(2 * 60, callback=self.unfortify_defense)
def storage(self): # remove the body self.obj.location.msg_contents("The body of {npc} rots away to dust.", mapping={'npc': self.obj}, exclude=self.obj) limbo = self.obj.search('Limbo', global_search=True) self.obj.move_to(limbo, quiet=True, move_hooks=False) self.db.death_step += 1 delay(10 * d_roll('1d12') + 30, getattr(self, self.db.death_sequence[self.db.death_step]))
def func(self): caller = self.caller lastcast = caller.db.cursedbone_lastcast if lastcast and time.time() - lastcast < 5 * 60: mess = "You cannot create another cursed bone yet" caller.msg(mess) return caller.db.sp.current -= 10 mess1 = '{mYou take a fragment of bone and begin chanting.{n ' caller.msg(mess1) utils.delay(5, callback=self.create_bone)
def at_start(self): """Handles the 'phases' of death""" super(CharDeathHandler, self).at_start() self.obj.msg("You have died.") self.obj.location.msg_contents("{character} falls dead.", mapping={'character': self.obj}, exclude=self.obj) self.obj.db.pose = self.obj.db.pose_death self.obj.traits.XP.base = int(floor(0.1 * self.obj.traits.XP.actual)) delay(20, getattr(self, self.db.death_sequence[self.db.death_step]))
def attack(self, hand, caller, target): if caller.db.attacking[hand]: caller.msg("You're already attacking with your %s!" % self.key) return caller.msg("Ok - Attacking %s with %s." % (target.key, self.key)) caller.db.attacking[hand] = True delay(self.db.cooldown, attack_roll, weapon=self, hand=hand, caller=caller, target=target)
def floating(self): self.obj.msg( "Your awareness blinks back into existence briefly. You float in the aethers." ) # remove the body self.obj.location.msg_contents( "The body of {character} rots away to dust.", mapping={'character': self.obj}, exclude=self.obj) limbo = self.obj.search('Limbo', global_search=True) self.obj.move_to(limbo, quiet=True, move_hooks=False) self.db.death_step += 1 delay(8, getattr(self, self.db.death_sequence[self.db.death_step]))
def at_die(self): """ Хук смерти игрока. Создает труп, скидывает в него вещи, деньги, переносит игрока в лимб. """ # создаем труп corpse = create_object(Corpse, self.key, location=self.location) # денюшки if self.db.money: corpse.db.money = self.db.money self.db.money = 0 # corpse.key = "Труп %s" % self.key descriptions = [ "Изуродованный труп %s" % self.key, "Бренное тело %s" % self.key, "Останки %s" % self.key, "Все, что оcталось от %s" % self.key, ] corpse.db.desc = random.choice(descriptions) # скидываем внего вещи items = self.contents if items: for item in items: item.move_to(corpse, quiet=True) if self.db.hands: in_hands = self.db.hands.contents if in_hands: item = in_hands[0] item.move_to(corpse, quiet=True) # сбарсываем пати, если ты умер, или умер лидер leader = self.db.party_leader party = self.db.party if party: for member in party: player = self.search(member, global_search=True, nofound_string="Сопартиец %s не найден!" % member) if not player: return player.db.party_leader = None player.msg("Ваш лидер погиб и ваша группа распалась.") self.db.party = [] self.msg("Твоя группа распалась.") if leader: your_leader = self.search(leader, global_search=True, nofound_string="Лидер %s не найден!" % leader) your_leader.db.party.remove(self.key) your_leader.msg("%s погиб и вышел и твой группы." % self.key) self.db.party_leader = None self.msg("Ты покинул группу %s" % your_leader.key) # задрежка delay(5, callback=self.TelToLimb)
def pre_revive(self): self.obj.msg( "A blinding light flashes before you and you feel your body lurch forward onto |/" "a smooth stone floor. Your ears ring from the deafening sound of your return." ) self.obj.home.msg_contents( "More and more purple droplets arise in a column around the flame which roars|/" "ever brighter. Without warning, the column erupts in a blinding flash of light.|/" "When your sight returns, the figure of {character} stands at the center of the|/" "shrine looking confused.", mapping=dict(character=self.obj), exclude=self.obj) self.db.death_step += 1 delay(3, getattr(self, self.db.death_sequence[self.db.death_step]))
def at_die(self): """ Хук смерти игрока. Создает труп, скидывает в него вещи, деньги, переносит игрока в лимб. """ #создаем труп corpse = create_object(Corpse,self.key, location=self.location) #денюшки if self.db.money: corpse.db.money = self.db.money self.db.money = 0 #corpse.key = "Труп %s" % self.key descriptions = ["Изуродованный труп %s" % self.key, "Бренное тело %s" % self.key, "Останки %s" % self.key, "Все, что оcталось от %s" % self.key] corpse.db.desc = random.choice(descriptions) #скидываем внего вещи items = self.contents if items: for item in items: item.move_to(corpse, quiet=True) if self.db.hands: in_hands = self.db.hands.contents if in_hands: item = in_hands[0] item.move_to(corpse,quiet=True) #сбарсываем пати, если ты умер, или умер лидер leader = self.db.party_leader party = self.db.party if party: for member in party: player = self.search(member, global_search=True,nofound_string="Сопартиец %s не найден!" % member) if not player: return player.db.party_leader = None player.msg("Ваш лидер погиб и ваша группа распалась.") self.db.party = [] self.msg("Твоя группа распалась.") if leader: your_leader = self.search(leader, global_search=True,nofound_string="Лидер %s не найден!" % leader) your_leader.db.party.remove(self.key) your_leader.msg("%s погиб и вышел и твой группы." % self.key) self.db.party_leader = None self.msg("Ты покинул группу %s" % your_leader.key) # задрежка delay(5, callback=self.TelToLimb)
def open_wall(self): """ This method is called by the push button command once the puzzle is solved. It opens the wall and sets a timer for it to reset itself. """ # this will make it into a proper exit (this returns a list) eloc = search.search_object(self.db.destination) if not eloc: self.caller.msg("The exit leads nowhere, there's just more stone behind it ...") else: self.destination = eloc[0] self.exit_open = True # start a 45 second timer before closing again utils.delay(45, self.reset)
def at_traverse(self, traversing_object, target_location): """ Implements the actual traversal, using utils.delay to delay the move_to. """ # if the traverser has an Attribute move_speed, use that, # otherwise default to "walk" speed move_speed = traversing_object.db.move_speed or "walk" move_delay = MOVE_DELAY.get(move_speed, 4) def move_callback(): "This callback will be called by utils.delay after move_delay seconds." source_location = traversing_object.location if traversing_object.move_to(target_location): self.at_after_traverse(traversing_object, source_location) else: if self.db.err_traverse: # if exit has a better error message, let's use it. self.caller.msg(self.db.err_traverse) else: # No shorthand error message. Call hook. self.at_failed_traverse(traversing_object) traversing_object.msg("You start moving %s at a %s." % (self.key, move_speed)) # create a delayed movement deferred = utils.delay(move_delay, callback=move_callback) # we store the deferred on the character, this will allow us # to abort the movement. We must use an ndb here since # deferreds cannot be pickled. traversing_object.ndb.currently_moving = deferred
def at_traverse(self, traversing_object, target_location): """ Implements the actual traversal, using utils.delay to delay the move_to. """ move_delay = self.destination.mv_delay move_cost = self.destination.mv_cost # make sure the character isn't already moving if traversing_object.nattributes.has('currently_moving'): traversing_object.msg("You are aleady moving. Use the 'stop' " "command and try again to change " "destinations.") return # check the movement cost if (hasattr(traversing_object, 'traits') and 'MV' in traversing_object.traits.all): if traversing_object.traits.MV.actual < move_cost: traversing_object.msg('Moving so far so fast has worn you out. ' 'You pause for a moment to gather your ' 'composure.') return # then handle the move with the appropriate delay def move_callback(): "This callback will be called by utils.delay after move_delay seconds." source_location = traversing_object.location if traversing_object.move_to(target_location): # deduct MV cost for the move if (hasattr(traversing_object, 'traits') and 'MV' in traversing_object.traits.all): traversing_object.traits.MV.current -= move_cost self.at_after_traverse(traversing_object, source_location) else: if self.db.err_traverse: # if exit has a better error message, let's use it. self.caller.msg(self.db.err_traverse) else: # No shorthand error message. Call hook. self.at_failed_traverse(traversing_object) # clean up the 'currently_moving' ndb attribute if traversing_object.nattributes.has('currently_moving'): del traversing_object.ndb.currently_moving if move_delay > 0: start_msg = self.destination.db.msg_start_move or "You start moving {exit}." traversing_object.msg(start_msg.format(exit=self.key)) # create a delayed movement deferred = utils.delay(move_delay, callback=move_callback) # we store the deferred on the character, this will allow us # to abort the movement. We must use an ndb here since # deferreds cannot be pickled. traversing_object.ndb.currently_moving = deferred else: # delay is 0, so we just run the callback now move_callback()
def at_traverse(self, traversing_object, target_location): """ Implements the actual traversal, using utils.delay to delay the move_to. """ # Call back handles the movement after a delay. def traverse_callback(): "This callback will be called by utils.delay after self.db.delay seconds." # If movement has been stopped or interrupted, kill movement. if not traversing_object.ndb.destination == target_location: return # Otherwise deal with movement. source_location = traversing_object.location if traversing_object.move_to(target_location): self.at_after_traverse(traversing_object, source_location) else: if self.db.err_traverse: # if exit has a better error message, let's use it. traversing_object.msg(self.db.err_traverse) else: # No shorthand error message. Call hook. self.at_failed_traverse(traversing_object) # Initialise Move traversing_object.ndb.destination = target_location delay = int(self.attributes.get("delay", default=5)) if delay == 0: # Move straight away. traverse_callback() if delay > 0: # Telegraph movement personal_leave_msg = self.attributes.get( "player_leave_msg", default=f"You start moving towards {self.name}") room_leave_msg = self.attributes.get( "room_leave_msg", default= f"{traversing_object.name} starts moving towards {self.name}") traversing_object.msg(personal_leave_msg) traversing_object.location.msg_contents(room_leave_msg) # Start delayed exit. utils.delay(delay, callback=traverse_callback)
def pre_revive(self): if self.obj.db.permadeath is False: self.obj.msg( '') spiritrealm = self.obj.search('Spirit Realm', global_search=True) spiritrealm.msg_contents( '' ) delay(10, getattr(self, self.db.death_sequence[self.db.death_step])) else: self.obj.msg( '' ) eternaldeath = self.obj.search('Realm of Eternal Death', global_search=True) eternaldeath.msg_contents( '' ) delay(10, getattr(self, self.db.death_sequence[self.db.death_step]))
def returning(self): if self.obj.db.permadeath is False: self.obj.msg( "you feel pulled towards the |mSpirit Realm|n." ) spiritrealm = self.obj.search('Spirit Realm', global_search=True) spiritrealm.msg_contents( '' ) self.db.death_step += 1 delay(8, getattr(self, self.db.death_sequence[self.db.death_step])) else: self.obj.msg( "you feel a rending of your spirit as you are pulled towards the |mRealm of Eternal Death|n.") eternaldeath = self.obj.search('Realm of Eternal Death', global_search=True) eternaldeath.msg_contents( '' ) self.db.death_step += 1 delay(8, getattr(self, self.db.death_sequence[self.db.death_step]))
def at_traverse(self, traveller, destination): """ Implements the actual traversal, using utils.delay to delay the move_to. if the exit has an attribute is_path and and traveller has move_speed, use that, otherwise default to normal exit behavior and "walk" speed. """ if traveller.ndb.currently_moving: traveller.msg("You are already moving toward %s." % destination.get_display_name(traveller)) return False entry = self.cmdset.current.commands[0].cmdstring # The name/alias of the exit used to initiate traversal traveller.ndb.exit_used = entry is_path = self.tags.get('path', category='flags') or False source_location = traveller.location move_speed = traveller.db.move_speed or 'walk' # TODO use Traits move_delay = MOVE_DELAY.get(move_speed, 8) if not traveller.at_before_move(destination): return False if self.db.grid_loc or self.db.grid_locs: coord = self.db.grid_loc if not self.db.grid_locs else self.db.grid_locs.get(entry, None) if coord: grid_loc = traveller.ndb.grid_loc if grid_loc: traveller.ndb.grid_loc_last = grid_loc traveller.ndb.grid_loc = coord name = destination.point(coord, 'name') or '' print('%s> %r (%s->%s: %s@%r)' % (traveller, entry, source_location, destination, name, coord)) if not is_path: success = traveller.move_to(self, quiet=False) if success: self.at_after_traverse(traveller, source_location) return success if traveller.location == destination: # If object is at destination... return True def move_callback(): """This callback will be called by utils.delay after move_delay seconds.""" start_location = traveller.location if traveller.move_to(destination): traveller.nattributes.remove('currently_moving') self.at_after_traverse(traveller, start_location) else: self.at_failed_traverse(traveller) traveller.msg("You start moving %s at a %s." % (self.key, move_speed)) if traveller.location != self: # If object is not inside exit... success = traveller.move_to(self, quiet=False, use_destination=False) if not success: return False self.at_after_traverse(traveller, source_location) # Create a delayed movement and Store the deferred on the moving object. # ndb is used since deferrals cannot be pickled to store in the database. deferred = utils.delay(move_delay, callback=move_callback) traveller.ndb.currently_moving = deferred return True
def func(self): caller = self.caller tr = self.caller.traits lastcast = caller.db.cursedbone_lastcast if tr.SP.current < 10: caller.msg("You don't have enough power to cast this spell") return if lastcast and time.time() - lastcast < 5 * 60: caller.msg("You cannot create another cursed bone yet") return tr.SP.current -= 10 caller.msg('|mYou take a fragment of bone and begin chanting.|n ') caller.location.msg_contents( "|m{actor} takes a fragment of bone and begins chanting.|n", mapping=dict(actor=caller), exclude=caller) utils.delay(5, callback=self.create_bone)
def cast(self, spell): self.db.position = self.db.position if self.db.position is not 0: self.msg("You need to be standing.") return if self.db.focus is not True and self.db.cooldown is not True: self.msg("You begin to concentrate.") self.db.focus = True self.db.cooldown = True for Character in self.location.contents: if Character is not self: Character.msg("{0} begins to cast a spell".format( self.db._sdesc)) if "fire" in spell: utils.delay(2, self.fire) if "heal" in spell: utils.delay(2, self.heal) else: self.msg("You've already got too much on your mind!") return
def light(self): """ Light this object - this is called by Light command. """ if self.db.is_giving_light: return False # burn for 3 minutes before calling _burnout self.db.is_giving_light = True # if we are in a dark room, trigger its light check try: self.location.location.check_light_state() except AttributeError: try: # maybe we are directly in the room self.location.check_light_state() except AttributeError: pass finally: # start the burn timer. When it runs out, self._burnout # will be called. utils.delay(60 * 3, self._burnout) return True
def init_delayed_message(caller, formdata): """ Initializes a delayed message, using data from the example form. Args: caller (obj): Character submitting the message. formdata (dict): Data from submitted form. """ # Retrieve data from the filled out form. # We stored the character to message as an object ref using a verifyfunc # So we don't have to do any more searching or matching here! player_to_message = formdata["Character"] message_delay = formdata["Delay"] sender = str(caller) if formdata["Anonymous"] is True: sender = "anonymous" message = ("Message from %s: " % sender) + str(formdata["Message"]) caller.msg("Message sent to %s!" % player_to_message) # Make a deferred call to 'sendmessage' above. delay(message_delay, sendmessage, player_to_message, message) return
def at_traverse(self, traversing_object, target_location): """ Implements the actual traversal, using utils.delay to delay the move_to. """ # if the traverser has an Attribute move_speed, use that, # otherwise default to "walk" speed move_speed = traversing_object.db.move_speed or "walk" move_delay = max(traversing_object.location.db.RoomSize / 2, 1) # Keep players from moving in combat or with 0 HP. if traversing_object.db.Combat_TurnHandler: traversing_object.msg("You can't move, you're in combat!") return if traversing_object.db.HP <= 0: traversing_object.msg("You can't move, you've been defeated! Type 'return' to go back to the Institute and recover!") return def move_callback(): "This callback will be called by utils.delay after move_delay seconds." source_location = traversing_object.location if traversing_object.move_to(target_location): self.at_after_traverse(traversing_object, source_location) else: if self.db.err_traverse: # if exit has a better error message, let's use it. self.caller.msg(self.db.err_traverse) else: # No shorthand error message. Call hook. self.at_failed_traverse(traversing_object) traversing_object.location.msg_contents("%s starts moving %s." % (traversing_object, self.key)) # create a delayed movement deferred = utils.delay(move_delay, callback=move_callback) # we store the deferred on the character, this will allow us # to abort the movement. We must use an ndb here since # deferreds cannot be pickled. traversing_object.ndb.currently_moving = deferred
def makeBusy(self): "This will add busy status." self.caller.ndb.is_busy = True self.caller.ndb.busy_timer = utils.delay(self.base_speed / (self.obj.db.attack_speed_mod * self.caller.db.stats['spd'] / 100), callback=self.noLongerBusy)