Advertisement
Kovitikus

Cooldown

Aug 3rd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.23 KB | None | 0 0
  1. '''
  2. [Success: 20 Roll: 82] You bash Bobby with your stave!
  3. Current time is 1564880769.9589822 and last command was 1564880769.662847
  4. You need to wait 0 more seconds.
  5. Current time is 1564880770.290676 and last command was 1564880769.662847
  6. You need to wait 0 more seconds.
  7. Current time is 1564880770.6375005 and last command was 1564880769.662847
  8. You need to wait 0 more seconds.
  9. Current time is 1564880771.0355637 and last command was 1564880769.662847
  10. You need to wait 1 more seconds.
  11. Current time is 1564880771.3988423 and last command was 1564880769.662847
  12. You need to wait 1 more seconds.
  13. Current time is 1564880771.7818737 and last command was 1564880769.662847
  14. You need to wait 2 more seconds.
  15. Current time is 1564880772.1136808 and last command was 1564880769.662847
  16. You need to wait 2 more seconds.
  17. Current time is 1564880772.4885728 and last command was 1564880769.662847
  18. You need to wait 2 more seconds.
  19. Current time is 1564880772.8268886 and last command was 1564880769.662847
  20. [Success: 48 Roll: 85] You bash Bobby with your stave!
  21. '''
  22.  
  23. class CmdStaveBash(BaseCommand):
  24.     '''
  25.    Use your staff to bash an enemy.
  26.  
  27.    Usage:
  28.        bash <target>
  29.    '''
  30.     key = 'bash'
  31.     help_category = 'combat'
  32.  
  33.     def func(self):
  34.         if not self.args:
  35.             self.caller.msg('Usage: bash <target>')
  36.             return
  37.        
  38.         attacker = self.caller
  39.         target = self.caller.search(self.args)
  40.         if not target:
  41.             self.caller.msg('That target does not exist.')
  42.             return
  43.        
  44.         now = time.time()
  45.         lastcast = self.caller.db.stave_bash
  46.  
  47.         self.caller.msg(f'Current time is {now} and last command was {lastcast}')
  48.  
  49.         if lastcast and now - lastcast < 3:
  50.             message = f"You need to wait {int(now - lastcast)} more seconds."
  51.             self.caller.msg(message)
  52.             return
  53.  
  54.         roll = random.randint(1, 100)
  55.         success = random.randint(5, 95)
  56.         if roll > success:
  57.             self.caller.msg(f'[Success: {success} Roll: {roll}] You bash {target} with your stave!')
  58.         else:
  59.             self.caller.msg(f'[Success: {success} Roll: {roll}] You miss {target} with your stave!')
  60.  
  61.         self.caller.db.stave_bash = now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement