Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added event EVT_SENTRY_KILL #213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 19 additions & 9 deletions b3/parsers/iourt41.py
Expand Up @@ -146,10 +146,11 @@
# - updated rcon command patterns
# 03/08/2014 - 1.22 - Fenix - syntax cleanup
# - reformat changelog
# 13/09/2014 - 1.23 - Fenix - added new event: EVT_SENTRY_KILL


__author__ = 'xlr8or, Courgette, Fenix'
__version__ = '1.22'
__version__ = '1.23'

import b3
import b3.events
Expand Down Expand Up @@ -345,6 +346,9 @@ class Iourt41Parser(AbstractParser):
HL_HELMET = '1'
HL_TORSO = '2'

# WORLD CID (used for Mr. Sentry detection)
WORLD = '1022'

## weapons id on Hit: lines are different than the one
## on the Kill: lines. Here the translation table
hitweapon2killweapon = {
Expand Down Expand Up @@ -434,6 +438,7 @@ def startup(self):
self.Events.createEvent('EVT_CLIENT_GEAR_CHANGE', 'Client gear change')
self.Events.createEvent('EVT_SURVIVOR_WIN', 'Survivor Winner')
self.Events.createEvent('EVT_BOMB_EXPLODED', 'Bomb exploded')
self.Events.createEvent('EVT_SENTRY_KILL', 'Mr Sentry kill')

# add event mappings
self._eventMap['warmup'] = self.getEventID('EVT_GAME_WARMUP')
Expand Down Expand Up @@ -495,6 +500,7 @@ def pluginsStarted(self):
self.warning(err)
else:
self.error("Cannot fix players teams: %s" % err)
return

for cid in plist.keys():
client = self.clients.getByCID(cid)
Expand Down Expand Up @@ -802,12 +808,16 @@ def OnKill(self, action, data, match=None):
## End fix attacker

if not attacker:
self.debug('No attacker')
return None
# handle the case where Mr.Sentry killed a player
if match.group('aweap') == self.UT_MOD_BERETTA and match.group('acid') == self.WORLD:
return self.getEvent('EVT_SENTRY_KILL', target=victim)
else:
self.debug('No attacker')
return None

d_type = match.group('text').split()[-1:][0]
if not d_type:
self.debug('no damage type, weapon: %s' % weapon)
damagetype = match.group('text').split()[-1:][0]
if not damagetype:
self.debug('No damage type, weapon: %s' % weapon)
return None

event = self.getEventID('EVT_CLIENT_KILL')
Expand All @@ -817,7 +827,7 @@ def OnKill(self, action, data, match=None):
if weapon == self.MOD_CHANGE_TEAM:
# do not pass a teamchange event here
# that event is passed shortly after the kill
self.verbose('team change event caught: exiting...')
self.verbose('Team change event caught: exiting...')
return None
else:
event = self.getEventID('EVT_CLIENT_SUICIDE')
Expand All @@ -835,7 +845,7 @@ def OnKill(self, action, data, match=None):
# self.verbose('OnKill Victim: %s, Attacker: %s, Weapon: %s, Hitloc: %s, dType: %s' %
# (victim.name, attacker.name, weapon, victim.hitloc, dType))
# need to pass some amount of damage for the teamkill plugin - 100 is a kill
return self.getEvent(event, (last_damage_data[0], weapon, last_damage_data[2], d_type), attacker, victim)
return self.getEvent(event, (last_damage_data[0], weapon, last_damage_data[2], damagetype), attacker, victim)

def OnClientdisconnect(self, action, data, match=None):
client = self.clients.getByCID(data)
Expand Down Expand Up @@ -895,7 +905,7 @@ def OnAction(self, cid, actiontype, data, match=None):
if not client:
self.debug('No client found')
return None
self.verbose('on_action: %s: %s %s' % (client.name, actiontype, data))
self.verbose('onAction: %s: %s %s' % (client.name, actiontype, data))
return self.getEvent('EVT_CLIENT_ACTION', data=actiontype, client=client)

def OnItem(self, action, data, match=None):
Expand Down
7 changes: 7 additions & 0 deletions tests/parsers/test_iourt41.py
Expand Up @@ -651,6 +651,13 @@ def test_lava(self):
event_target=self.joe,
event_data=(100, self.console.MOD_LAVA, 'body', 'MOD_LAVA'))

def test_mr_sentry(self):
self.assertEvent('5:19 Kill: 1022 0 14: <world> killed Joe by UT_MOD_BERETTA',
event_type='EVT_SENTRY_KILL',
event_client=None,
event_target=self.joe,
event_data=None)

def test_constants(self):
def assert_mod(kill_mod_number, kill_mod_name):
self.assertTrue(hasattr(self.console, kill_mod_name), "expecting parser to have a constant named %s" % kill_mod_name)
Expand Down