I have a plugin here is slightly older.
Cologne could help me to bring it on better in ES or also in SP code.
Perhaps also better in one plugin.
Thanks in advance
Orientation:
It causes a headshot + Sound and Overlay
And the head is bursting.
Syntax: Select all
import es
import gamethread
import playerlib
info = es.AddonInfo()
info.name = "RocKs Headshot"
info.version = "3.0"
info.author = "DMW"
info.url = "www.rocks-clan.de"
info.description = "RocKs Headshot"
es.ServerVar(info.name, info.version, info.description).makepublic()
#>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#>>>>>>>>>>>>>>>>>>>>>> C O N F I G <<<<<<<<<<<<<<<<<<<<<<<<<<<<
#>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
REMOVE_OVERLAY_TIME = 1.5
HEADSHOT_OVERLAY_VMT = "exae/rocksheadshot1.vmt"
HEADSHOT_OVERLAY_VTF = "exae/rocksheadshot1.vtf"
# Headshot but not dead sound + path
HEADSHOT_SOUND = "exae/quake/human-hit-4.mp3"
# <weapon> : <headshot_sound>
WEAPON_FILES = {
'weapon_crossbow_bolt': 'exae/quake/headshot2.mp3',
'weapon_357' : 'exae/quake/headshot-2.mp3',
'weapon_smg1' : 'exae/quake/wife-headshot.mp3',
'weapon_ar2' : 'exae/quake/boomheadshot.mp3',
'weapon_pistol' : 'exae/quake/headshot-1.mp3',
'weapon_shotgun' : 'exae/quake/headshot2.mp3'
}
#>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#>>>>>>>>>>>>>> E N D O F C O N F I G <<<<<<<<<<<<<<<<<<<<<
#>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
def event_hitgroup(event_var):
hitgroup = int(event_var['hitgroup'])
weapon = event_var['weapon']
health = int(event_var['health'])
attacker = int(event_var['attacker'])
victim = event_var['victim']
if attacker in (victim, None, 0):
return
if hitgroup == 1 and health == 0 and weapon in WEAPON_FILES: # Player is dead
es.cexec(attacker, "r_screenoverlay %s" %HEADSHOT_OVERLAY_VMT)
es.emitsound('player', attacker, WEAPON_FILES[weapon], 1.0, 0.0)
gamethread.delayed(REMOVE_OVERLAY_TIME, es.cexec, args=(attacker, "r_screenoverlay 0"))
doEffect(attacker, victim)
elif hitgroup == 1 and health > 0: # Headshot but player still alive
es.playsound(attacker, HEADSHOT_SOUND, 1.0)
def doEffect(attacker, victim):
x,y,z = es.getplayerlocation(victim)
z += 70
es.server.queuecmd("es est_effect 11 #a 0 exae/headshot/headshot_gore1.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.12, "es est_effect 11 #a 0 exae/headshot/headshot_gore2.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.18, "es est_effect 11 #a 0 exae/headshot/headshot_gore3.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.24, "es est_effect 11 #a 0 exae/headshot/headshot_gore4.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.30, "es est_effect 11 #a 0 exae/headshot/headshot_gore5.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.36, "es est_effect 11 #a 0 exae/headshot/headshot_gore6.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.42, "es est_effect 11 #a 0 exae/headshot/headshot_gore7.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.48, "es est_effect 11 #a 0 exae/headshot/headshot_gore8.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.54, "es est_effect 11 #a 0 exae/headshot/headshot_gore9.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.60, "es est_effect 11 #a 0 exae/headshot/headshot_gore10.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.delayed(0.66, "es est_effect 11 #a 0 exae/headshot/headshot_gore11.vmt %s %s %s 0.06 0.3 255" % (x, y, z))
es.server.queuecmd("es playerset model event_var(userid) headless_body/metrocop.mdl")
def player_spawn(ev):
is_spawned = getUser(ev['userid'], "is_spawned")
if is_spawned == 0:
setUser(ev['userid'], "is_spawned", 1)
model = playerlib.getPlayer(ev['userid']).model
setUser(ev['userid'], "model", model)
if is_spawned == 1:
playerlib.getPlayer(ev['userid']).setModel(getUser(ev['userid'], "model"))
def make_loadable():
for file in WEAPON_FILES.values():
es.stringtable("downloadables", 'sound/'+file)
es.stringtable("downloadables", 'sound/'+HEADSHOT_SOUND)
es.stringtable("downloadables", 'materials/'+HEADSHOT_OVERLAY_VMT)
es.stringtable("downloadables", 'materials/'+HEADSHOT_OVERLAY_VTF)
def load():
make_loadable()
def es_map_start(event_var):
make_loadable()
keys = {}
def addUser(userid):
userid = str(userid)
if not userid in keys:
keys[userid] = {}
def delUser(userid):
userid = str(userid)
if userid in keys:
del keys[userid]
def existsUser(userid):
userid = str(userid)
return userid in keys
def setUser(userid, key, value):
userid = str(userid)
addUser(userid)
keys[userid][key] = value
def getUser(userid, key):
userid = str(userid)
addUser(userid)
if key in keys[userid]:
value = str(keys[userid][key])
if value.isdigit():
return int(value)
return value
return None
Syntax: Select all
import spe
import es
from spe import HookAction
from spe import HookType
from spe import Conventions
PATH_RES = 'addons/eventscripts/custom_events/custom_events.res'
def load():
es.loadevents('declare', PATH_RES)
es.loadevents(PATH_RES)
spe.hookFunction(FUNC, 'piS)v', Conventions.CDECL, HookType.Pre,
preHook)
def unload():
spe.unHookFunction(FUNC, HookType.Pre, preHook)
def es_map_start(event_var):
es.loadevents(PATH_RES)
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>> Bullet Impact
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# event_var['x']
# event_var['y']
# event_var['z']
FUNC = spe.findSymbol('_Z16UTIL_ImpactTraceP10CGameTraceiPKc')
def preHook(args):
x = spe.makeObject('Vector', args[0] + 12)
es.event('initialize', "event_bullet_impact")
es.event('setfloat', "event_bullet_impact", "x", x.x)
es.event('setfloat', "event_bullet_impact", "y", x.y)
es.event('setfloat', "event_bullet_impact", "z", x.z)
es.event('fire', "event_bullet_impact")
return (HookAction.Continue, 0)
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>>>>>>>>> Hitgroups
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# event_var['hitgroup']
# event_var['attacker']
# event_var['victim']
# event_var['weapon']
# event_var['health']
OFFSET_HITGROUP = 1708 if spe.platform == 'nt' else 1728
def player_hurt(ev):
player = spe.getPlayer(int(ev['userid']))
hitgroup = spe.getLocVal('i', player + OFFSET_HITGROUP)
fire_event(hitgroup, ev['userid'], ev['attacker'], ev['es_attackerweapon'], ev['health'])
def fire_event(hitgroup, userid, attacker, weapon, health):
es.event('initialize', "event_hitgroup")
es.event('setint', "event_hitgroup", "hitgroup", hitgroup)
es.event('setint', "event_hitgroup", "attacker", attacker)
es.event('setint', "event_hitgroup", "victim", userid)
es.event('setstring', "event_hitgroup", "weapon", weapon)
es.event('setint', "event_hitgroup", "health", health)
es.event('fire', "event_hitgroup")
#http://www.eventscripts.com/pages/Hit_Groups