SHARE
TWEET

Untitled

a guest May 19th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #crib sheet:
  2. #realm.write = echoing
  3. #realm.send = send to Achaea
  4. #wib = wield bow
  5. #sh TARGET DIR = aim and snipe
  6.  
  7. from mudpyl.modules import EarlyInitialisingModule
  8. from mudpyl.aliases import binding_alias
  9. from mudpyl.triggers import binding_trigger
  10.  
  11. class MultiArcher(EarlyInitialisingModule):
  12.  
  13.     def __init__(self, targets):
  14.         self.targets = targets
  15.         self.direction = None
  16.         self.index = None
  17.         self.aliases = [self.shoot]
  18.         self.triggers = [self.no_target, self.hit]
  19.  
  20.     @binding_alias("^ms(n|ne|e|se|s|sw|w|nw|i|o|u|d|m)$")
  21.     def shoot(self, match, realm):
  22.         realm.send_to_mud = False
  23.         if not self.targets:
  24.             realm.write("No target to shoot!")
  25.             return
  26.         self.direction = match.group(1)
  27.         self.index = 0
  28.         realm.send("wib")
  29.         self.next_shot(realm)
  30.  
  31.     @binding_trigger("^(You are prevented from doing that by the magical shield around \w+|You detect nothing here by that name|Nothing can be seen here by that name|Ahh, I am truly sorry, but I do not see anyone by that name here|I do not recognise anything called that here|You cannot see that being here)\.$")
  32.     def no_target(self, match, realm):
  33.         if self.index is None:
  34.             return
  35.         if self.index < len(self.targets):
  36.             self.next_shot(realm)
  37.         else:
  38.             self.index = None
  39.             self.direction = None
  40.  
  41.     def next_shot(self, realm):
  42.         realm.write("Trying to shoot " + self.targets[self.index])
  43.         realm.send("sh %s %s" % (self.targets[self.index], self.direction))
  44.         self.index += 1
  45.  
  46.     @binding_trigger("^You train your expert eye on \w+ and let fly an arrow with breathtaking precision\.$")
  47.     def hit(self, match, realm):
  48.         self.index = None
  49.         self.direction = None
RAW Paste Data
Top