Advertisement
Guest User

Untitled

a guest
Mar 13th, 2010
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import random
  4. from Credentials import botowner, botname, botpassword
  5. from SubspaceBot import *
  6.  
  7. class PlayerInfo():
  8.     def __init__(self):
  9.         self.consecutive_kills = 0
  10.  
  11. if __name__ == '__main__':
  12.     bot = SubspaceBot(botowner, 'This bot announces kill sprees to the arena')
  13.     bot.connectToServer('66.235.184.102', 7900, botname, botpassword, '#python')
  14.    
  15.     print "Bot connected to server"
  16.    
  17.     while bot.isConnected():
  18.         event = bot.waitForEvent()
  19.         if event.type == EVENT_ENTER:
  20.             event.player.player_info = PlayerInfo()
  21.         if event.type == EVENT_KILL:
  22.             # increment the killers consecutive kills and announce if its time
  23.             p = event.killer
  24.             pi = event.killer.player_info
  25.             pi.consecutive_kills += 1
  26.             if pi.consecutive_kills >= 5 and pi.consecutive_kills % 5 == 0:
  27.                 bot.sendArenaMessage(event.killer.name + ' is on a spree with ' + str(pi.consecutive_kills) + ' kills!')
  28.            
  29.             # announce the end of a kill-streak if the player has one, then reset the killed players consecutive kill count
  30.             p = event.killed
  31.             pi = event.killed.player_info
  32.             if pi.consecutive_kills >= 5:
  33.                 bot.sendArenaMessage(p.name + '\'s ' + str(pi.consecutive_kills) + '-kill streak was ended by ' + event.killer.name + '!')
  34.             pi.consecutive_kills = 0
  35.        
  36.     print "Bot disconnected"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement