//Client script for positioning h4xbow bolt sounds from NPCs
//NPC's don't use the h4xbow projectile - they just pick where the bolt's gonna land.
#scope client

{
	const SPRITE_EXPLODE explode1.spr
	const SOUND_BOLT_HIT weapons/bow/bolthit1.wav
	const SOUND_EXPLODE weapons/explode3.wav
	const MODEL_BOLT weapons/bows/boltexplosive.mdl
	precache MODEL_BOLT
	precache SPRITE_EXPLODE
	precache SOUND_BOLT_HIT
	precache SOUND_EXPLODE
}

{ client_activate //<begin> <end> <owner_angles> [explode:0|1]

	setvard BOLT_START PARAM1
	setvard BOLT_END PARAM2
	setvard BOLT_ANGLES PARAM3
	setvard BOLT_EXPLODE PARAM4

	setvard BOLT_SPEED 1000
	calleventloop 5 shadow_bolts

	callevent 0.05 hit_wall

	if BOLT_EXPLODE
	callevent 0.1 do_splodie
}

{ shadow_bolts
	//stream of bolt effect
	cleffect tempent model MODEL_BOLT BOLT_START setup_bolt
	subtract BOLT_SPEED 100
}

{ hit_wall
	sound.play3d "weapons/bow/bolthit1.wav" 10 BOLT_END
}

{ do_splodie
	sound.play3d "weapons/explode3.wav" 10 BOLT_END
	cleffect tempent sprite SPRITE_EXPLODE BOLT_END explode_sprite
	cleffect light new BOLT_END 256 (255,128,64) 1.0
}

{ explode_sprite
	cleffect tempent set_current_prop death_delay 	0.6
	cleffect tempent set_current_prop fadeout 	0.5
	cleffect tempent set_current_prop gravity 	-0.25
	cleffect tempent set_current_prop collide 	none
	cleffect tempent set_current_prop framerate	15
	cleffect tempent set_current_prop frames	9
}

{ setup_bolt
	cleffect tempent set_current_prop death_delay 	0.5
	cleffect tempent set_current_prop scale 1.0
	cleffect tempent set_current_prop gravity 	0
	cleffect tempent set_current_prop angles BOLT_ANGLES
	cleffect tempent set_current_prop velocity $relvel(BOLT_ANGLES,$vec(0,BOLT_SPEED,0))
	//cleffect tempent set_current_prop body 	44
	cleffect tempent set_current_prop fadeout lifetime
	cleffect tempent set_current_prop framerate 1.0
	cleffect tempent set_current_prop frames 1
}