Syntax: Select all
@Event('player_hurt')
def player_hurt(ev):
if ev['attacker'] != ev['userid'] and ev['attacker'] != 0:
vindex = index_from_userid(ev['userid'])
aindex = index_from_userid(ev['attacker'])
victim = Player(vindex)
attacker = Player(aindex)
damage = int(ev['dmg_health'])
addPlayer(vindex)
addPlayer(aindex)
crit = random.randint(1,100)
if getClass(aindex) == 'Fighter' and getLevel(aindex) > 14:
crit += 10
if crit > 95:
dndDamage(vindex, damage, aindex)
playerMessage(aindex, 'Your attack was a critical hit!')
if victim.team != attacker.team:
if dndPlayers[vindex]['dodge']:
if random.randint(1,100) < dndPlayers[vindex]['dodge']:
playerMessage(vindex, 'You dodged %s damage!'%damage)
victim.health += damage
pass
if 'immune' in dndPlayers[vindex]:
if dndPlayers[vindex]['immune']:
victim.health += damage
playerMessage(vindex, 'A Hymn as prevented damage!')
pass
if 'curse' in dndPlayers[vindex]:
if dndPlayers[vindex]['curse']:
dndDamage(vindex, int(damage*.1), aindex)
invisColor = attacker.get_color() # Throws error on this line
def addPlayer(index):
global dndDB, dndPlayers
steamid = uniqueid_from_index(index)
if steamid not in dndDB:
dndDB[steamid] = {}
for item in ['kills', 'deaths', 'gold']:
if item not in dndDB[steamid]:
dndDB[steamid][item] = 0
for className in allClasses:
if className not in dndDB[steamid]:
dndDB[steamid][className] = {}
for item in ['xp','level']:
if item not in dndDB[steamid][className]:
dndDB[steamid][className] = {'xp':0,'level':1}
if index not in dndPlayers:
dndPlayers[index] = {}
dndPlayers[index]['className'] = 'Fighter'
dndPlayers[index]['race'] = 'Human'
dndPlayers[index]['spree'] = 0
resetPlayer(index)
if not isBot(index):
if 'last played class' in dndDB[uniqueid_from_index(index)]:
if dndDB[uniqueid_from_index(index)]['last played class']:
dndPlayers[index]['className'] = dndDB[uniqueid_from_index(index)]['last played class']
if 'last played race' in dndDB[uniqueid_from_index(index)]:
if dndDB[uniqueid_from_index(index)]['last played race']:
dndPlayers[index]['race'] = dndDB[uniqueid_from_index(index)]['last played race']
Code: Select all
SendNetMsg 192.168.56.1:27005: stream[netchan_t::unreliabledata] buffer overflow (maxsize = 4000)!
[SP] Caught an Exception:
Traceback (most recent call last):
File '..\addons\source-python\packages\source-python\events\listener.py', line 92, in fire_game_event
callback(game_event)
File '..\addons\source-python\plugins\dnd\dnd.py', line 441, in player_hurt
invisColor = invisPlayer.get_color()
File '..\addons\source-python\packages\source-python\entities\entity.py', line 238, in get_color
return self.render_color
File '..\addons\source-python\packages\source-python\entities\entity.py', line 99, in __getattr__
return getattr(make_object(server_class, self.pointer), attr)
File '..\addons\source-python\packages\source-python\memory\manager.py', line 135, in _obj
return cls(ptr, wrap=True)
File '..\addons\source-python\packages\source-python\memory\manager.py', line 87, in __init__
if self.__class__.__name__ not in self._manager:
RecursionError: maximum recursion depth exceeded while calling a Python object