本文整理汇总了Python中evennia.TICKER_HANDLER.remove方法的典型用法代码示例。如果您正苦于以下问题:Python TICKER_HANDLER.remove方法的具体用法?Python TICKER_HANDLER.remove怎么用?Python TICKER_HANDLER.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evennia.TICKER_HANDLER
的用法示例。
在下文中一共展示了TICKER_HANDLER.remove方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: at_object_leave
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def at_object_leave(self, obj, target_location):
if utils.inherits_from(obj, Character):
for item in self.contents:
# if item in room not self
if item.dbref != obj.dbref:
# if item is of class Character
if utils.inherits_from(item, Character):
obj.msg("DATA,char_remove," + item.name + item.dbref)
item.msg("DATA,char_remove," + obj.name + obj.dbref)
# else if item is of class Mob
elif utils.inherits_from(item, Mob):
obj.msg("DATA,char_remove," + item.name + item.dbref)
# else if item is of class Npc
elif utils.inherits_from(item, Npc):
obj.msg("DATA,char_remove," + item.name + item.dbref)
# else (an object)
else:
obj.msg("DATA,obj_remove," + item.name + item.dbref)
if utils.inherits_from(obj, Npc): # An NPC has left
pass
elif utils.inherits_from(obj, Mob): # A Mob has left
pass
else:
# Else if a PC has left the room
if utils.inherits_from(obj, Character):
# Any NPCs in the room ?
for item in self.contents:
if utils.inherits_from(item, Npc):
# Notify NPCs that a PC left the room
tickerhandler.remove(item,1)
示例2: _set_ticker
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def _set_ticker(self, interval, hook_key, stop=False):
"""
Set how often the given hook key should
be "ticked".
Args:
interval (int): The number of seconds
between ticks
hook_key (str): The name of the method
(on this mob) to call every interval
seconds.
stop (bool, optional): Just stop the
last ticker without starting a new one.
With this set, the interval and hook_key
arguments are unused.
In order to only have one ticker
running at a time, we make sure to store the
previous ticker subscription so that we can
easily find and stop it before setting a
new one. The tickerhandler is persistent so
we need to remember this across reloads.
"""
idstring = "tutorial_mob" # this doesn't change
last_interval = self.db.last_ticker_interval
if last_interval:
# we have a previous subscription, kill this first.
TICKER_HANDLER.remove(self, last_interval, idstring)
self.db.last_ticker_interval = interval
if not stop:
# set the new ticker
TICKER_HANDLER.add(self, interval, idstring, hook_key)
示例3: global_cooled_down
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def global_cooled_down(self):
"""
GCD finished.
"""
self.GLOBAL_COOLING_DOWN = False
# Remove the timer.
TICKER_HANDLER.remove(self, settings.GLOBAL_CD)
示例4: reborn
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def reborn(self):
"""
Reborn after being killed.
"""
TICKER_HANDLER.remove(self, self.reborn_cd)
# Recover all hp.
self.db.hp = self.max_hp
self.show_status()
# Reborn at its home.
if self.home:
self.move_to(self.home, quiet=True)
self.msg({"msg": LS("You are reborn at {c%s{n.") % self.home.get_name()})
示例5: _init_character
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def _init_character(self, character):
"""
This initializes handler back-reference
and combat cmdset on a character. It also
stops the tickerhandler that normally calls
at_turn_start every 6s
"""
if not character.nattributes.has('combat_handler'):
tickerhandler.remove(6, character.at_turn_start)
character.ndb.combat_handler = self
character.cmdset.add("commands.combat.CombatBaseCmdSet")
character.cmdset.add("commands.combat.CombatCmdSet")
prompt = _COMBAT_PROMPT.format(tr=character.traits)
character.msg(prompt=prompt)
示例6: at_tick
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def at_tick(self):
if self.db.attacking != None:
print self.attacking.location
# if character in same roome as self and aggressive
if self.location == self.db.attacking.location and self.db.count < 10:
# attack with probability and after cooldown
if (time() - self.db.last_attack) > randint(1, 3):
self.execute_cmd("say Graaah, die %s!" % self.db.attacking)
rules.roll_challenge(self, self.db.attacking, "combat")
self.db.last_attack = time()
self.db.count += 1
else:
tickerhandler.remove(self, 1)
else:
tickerhandler.remove(self, 1)
示例7: reborn
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def reborn(self):
"""
Reborn after being killed.
"""
TICKER_HANDLER.remove(self, settings.NPC_REBORN_CD)
# Recover all hp.
self.db.hp = self.max_hp
# Reborn at its home.
if self.home:
self.move_to(self.home, quiet=True)
for content in self.home.contents:
if content.has_player:
content.show_location()
示例8: at_tick
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def at_tick(self):
tickerhandler.remove(self, self.db.last_ticker_deley_value)
self.db.last_ticker_deley_value = random.randint(15, 120)
tickerhandler.add(self, self.db.last_ticker_deley_value)
if not self.goods:
return
goods_to_create = self.goods.values()
for good in goods_to_create:
good_in_inv = self.search(good["name"], location=self, nofound_string="")
if not good_in_inv:
new_good = create_object(good["typeclass"], good["name"], self, home=self)
if not new_good.db.desc:
if good["desc"]:
new_good.db.desc = good["desc"]
new_good.db.coast = good["coast"]
示例9: auto_cast_skill
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def auto_cast_skill(self):
"""
Cast a new skill automatically.
"""
if not self.can_auto_cast:
return
if not self.owner:
return
if not self.owner.ndb.combat_handler:
# combat is finished, stop ticker
TICKER_HANDLER.remove(self, settings.AUTO_CAST_SKILL_CD)
return
# Get target.
choose_new_target = True
if self.skill_target:
if self.skill_target.is_alive():
choose_new_target = False
if choose_new_target:
self.skill_target = self.choose_skill_target()
if not self.skill_target:
# No target.
return
# Get available skills.
available_skills = self.get_available_skills()
if not available_skills:
# No available skill.
return
# Random chooses a skill.
skill = random.choice(available_skills)
if skill:
self.cast_skill(skill, self.skill_target)
示例10: __del__
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def __del__(self):
"""
Remove tickers.
"""
if self.can_auto_cast:
TICKER_HANDLER.remove(self)
示例11: stop_auto_combat_skill
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def stop_auto_combat_skill(self):
"""
Stop auto cast skill.
"""
self.can_auto_cast = False
TICKER_HANDLER.remove(self, settings.AUTO_CAST_SKILL_CD)
示例12: anchor
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def anchor(self):
tickerhandler.remove(3, self.make_way, idstring="adrift")
self.db.power = 0
self.db.underway = False
self.db.adrift = False
示例13: __del__
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import remove [as 别名]
def __del__(self):
"""
Remove tickers.
"""
if self.GLOBAL_COOLING_DOWN or self.AUTO_CAST_SKILL:
TICKER_HANDLER.remove(self)