[HL2:DM] Crossbow
Posted: Mon Apr 13, 2020 9:00 am
Hello SourcePython Team and Community,
could somebody turn that into SP for me?
It causes the file to make an orange circle at the point of impact, which lights up and flashes.
I find this:
Thanks in advance.
could somebody turn that into SP for me?
It causes the file to make an orange circle at the point of impact, which lights up and flashes.
Syntax: Select all
event event_bullet_impact
{
es_xset vector2 0
es_xset vector1 0
es_createvectorstring vector1 event_var(x) event_var(y) event_var(z)
es est_effect_18 #a 0 server_var(vector1) 255 88 00 08 200 100 150
}
I find this:
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 = 1712 if spe.platform == 'nt' else 1732
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
Code: Select all
"custom_events"
{
"event_bullet_impact"
{
"x" "float"
"y" "float"
"z" "float"
}
"event_hitgroup"
{
"hitgroup" "int"
"attacker" "int"
"victim" "int"
"weapon" "string"
"health" "int"
}
}
Thanks in advance.