View Single Post
Author Message
Bladell
Senior Member
Join Date: Jun 2012
Old 02-24-2013 , 05:52   Sound for a hero
Reply With Quote #1

I have the next code:
Code:
#include <superheromod>

// GLOBAL VARIABLES
new gHeroID
new bool:gHasNagatoPower[SH_MAXSLOTS+1]
new const gSoundPush[] = "shmod/shinra.mp3"
new const gSoundPain[] = "player/pl_pain2.wav"
new gPcvarCooldown,pradius,ppower,pdmg,pselfdmg
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Nagato", "1.3", "")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	new pcvarLevel = register_cvar("nagato_level", "9")
	gPcvarCooldown = register_cvar("nagato_cooldown", "10")
	pradius = register_cvar("nagato_radius", "400")
	ppower = register_cvar("nagato_power", "600")
	pdmg = register_cvar("nagato_damage", "10")
	pselfdmg = register_cvar("nagato_selfdmg", "0")

	// FIRE THE EVENT TO CREATE THIS SUPERHERO!
	gHeroID = sh_create_hero("Nagato", pcvarLevel)
	sh_set_hero_info(gHeroID, "Shinra tensei", "Push enemies away")
	sh_set_hero_bind(gHeroID)
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
	precache_sound(gSoundPush)
	precache_sound(gSoundPain)
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
	if ( gHeroID != heroID ) return

	gHasNagatoPower[id] = mode ? true : false
}
//----------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
	gPlayerInCooldown[id] = false
}
//----------------------------------------------------------------------------------------------
public sh_hero_key(id, heroID, key)
{
	if ( gHeroID != heroID || key != SH_KEYDOWN || sh_is_freezetime() ) return
	if ( !is_user_alive(id) || !gHasNagatoPower[id] ) return

	if ( gPlayerInCooldown[id] ) {
		sh_sound_deny(id)
		return
	}

	force_push(id)
}
//----------------------------------------------------------------------------------------------
public force_push(id)
{
	if ( !is_user_alive(id) ) return

	new players[32], playerCount, victim
	new origin[3], vorigin[3], parm[4], distance
	new bool:enemyPushed = false

	new CsTeams:idTeam = cs_get_user_team(id)
	get_user_origin(id, origin)

	get_players(players, playerCount, "a")

	for ( new i = 0; i < playerCount; i++ ) {
		victim = players[i]

		if ( victim != id && idTeam != cs_get_user_team(victim) ) {

			get_user_origin(victim, vorigin)

			distance = get_distance(origin, vorigin)
			distance = distance ? distance : 1	// Avoid dividing by 0

			if ( distance < get_pcvar_num(pradius) ) {

				// Set cooldown/sound/self damage only once, if push is used
				if ( !enemyPushed ) {
					new Float:seconds = get_pcvar_float(gPcvarCooldown)
					if ( seconds > 0.0 ) sh_set_cooldown(id, seconds)

					emit_sound(id, CHAN_ITEM, gSoundPush, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

					// Do damage to Nagato?
					new selfdamage = get_pcvar_num(pselfdmg)
					if ( selfdamage > 0 ) {
						sh_extra_damage(id, id, selfdamage, "Force Push")
					}
					enemyPushed = true
				}

				parm[0] = ((vorigin[0] - origin[0]) / distance) * get_pcvar_num(ppower)
				parm[1] = ((vorigin[1] - origin[1]) / distance) * get_pcvar_num(ppower)
				parm[2] = victim
				parm[3] = id

				// Stun enemy makes them easier to push
				sh_set_stun(victim, 1.0)
				set_user_maxspeed(victim, 1.0)

				// First lift them
				set_pev(victim, pev_velocity, {0.0, 0.0, 200.0})

				// Then push them back in x seconds after lift and do some damage
				set_task(0.1, "move_enemy", 0, parm, 4)
			}
		}
	}

	if ( !enemyPushed && is_user_alive(id) ) {
		sh_chat_message(id, gHeroID, "No enemies within range!")
		sh_sound_deny(id)
	}
}
//----------------------------------------------------------------------------------------------
public move_enemy(parm[])
{
	new victim = parm[2]
	new id = parm[3]

	new Float:fl_velocity[3]
	fl_velocity[0] = float(parm[0])
	fl_velocity[1] = float(parm[1])
	fl_velocity[2] = 200.0

	set_pev(victim, pev_velocity, fl_velocity)

	// do some damage
	new damage = get_pcvar_num(pdmg)
	if ( damage > 0 ) {
		emit_sound(victim, CHAN_BODY, gSoundPain, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

		if ( !is_user_alive(victim) ) return

		sh_extra_damage(victim, id, damage, "Force Push")
	}
}
//----------------------------------------------------------------------------------------------
This is the hero "Yoda".
Work fine, but I have a problem with the sound.I don't know why don't work.Maybe you can help me.
I want when I press a bind button all player's to hear "Shinra tensei" and after push him away and play the rest of the sound.So I want player to hear "Shinra Tensei" before push him away.

I don't know why this sound not work with this hero...maybe you can check.
Thanks !
Attached Files
File Type: zip shinra.zip (62.4 KB, 39 views)

Last edited by Bladell; 02-24-2013 at 05:53.
Bladell is offline