import es
from wcs.wcs import wcsgroup

def bullet_impact(ev):
    bang = wcsgroup.getUser(ev["userid"],"explode_shot")
    if bang:
        name = "wcs_env_explosion_%s"%ev["userid"]
        index = es.createentity("env_explosion")
        es.setindexprop(index,"CBaseEntity.m_hOwnerEntity",es.getplayerhandle(ev["userid"]))
        es.entitysetvalue(index,"targetname",name)
        es.entitysetvalue(index,"imagnitude",bang)
        es.entitysetvalue(index,"iradiusoverride",200)
        es.entitysetvalue(index,"origin","%s %s %s"%(ev["x"],ev["y"],float(ev["z"]) + 10.0))
        es.spawnentity(index)
        es.fire(ev["userid"],name,"explode")
        es.fire(ev["userid"],name,"kill")
        es.playsound(ev["userid"],"weapons/shotgun/shotgun_dbl_fire.wav",1.0)
        wcsgroup.setUser(ev["userid"],"explode_shot",0)

def player_death(ev):
    wcsgroup.setUser(ev["userid"],"explode_shot",0)
