We also added constants for damage types, so you do not have to remember them, and if they change, it will be a quick plugin-side fix instead of a script-by-script fix. The test script I use is as follows:
Syntax: Select all
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
from filters.players import PlayerIter
from entities.constants import DamageTypes
hitgroups = [
'Generic',
'Head',
'Chest',
'Stomach',
'Left Arm',
'Right Arm',
'Left Leg',
'Right Leg'
]
@Event
def round_freeze_end(GameEvent):
for player in PlayerIter(return_types='player'):
player.freeze = True
@Event
def player_say(GameEvent):
userid = GameEvent.GetInt('userid')
index = index_from_userid(userid)
player = PlayerEntity(index)
team = player.team
other = get_other_player(team)
player.damage(other, 400, DamageTypes.HEADSHOT, hitgroup=2, iObjectsPenetrated=2)
def get_other_player(team):
for player in PlayerIter(return_types='player'):
if player.team != team and not player.isdead:
return player.index
return None
@Event
def player_hurt(GameEvent):
userid = GameEvent.GetInt('userid')
index = index_from_userid(userid)
player = PlayerEntity(index)
attackerid = GameEvent.GetInt('attacker')
attacker_index = index_from_userid(attackerid)
attacker = PlayerEntity(attacker_index)
damage = GameEvent.GetInt('dmg_health')
armor = GameEvent.GetInt('dmg_armor')
weapon = GameEvent.GetString('weapon')
hitgroup = hitgroups[GameEvent.GetInt('hitgroup')]
print('%s damaged %s for %s/%s health with his %s in the %s' % (
attacker.name, player.name, damage, armor, weapon, hitgroup))
Satoon