Raised This Month: $12 Target: $400
 3% 

Sound for a hero


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bladell
Senior Member
Join Date: Jun 2012
Old 02-24-2013 , 04: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, 80 views)

Last edited by Bladell; 02-24-2013 at 04:53.
Bladell is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-24-2013 , 09:53   Re: Sound for a hero
Reply With Quote #2

Use CHAN_VOICE instead.

Also make sure the sound quality is not too good. The HL engine won't play sounds unless they have a certain quality (very poor quality) I usually convert to 8 bit mono to make sure it will play.
Also it doesn't support .mp3 with emit_sound. You need to convert it to .wav.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Bladell
Senior Member
Join Date: Jun 2012
Old 02-24-2013 , 10:06   Re: Sound for a hero
Reply With Quote #3

I don't know what I need to change...i really can't udnerstand )
I will try with the sound, but I can't do anything with the code.

L.E:Can you make it to blind all player's in rage while the sound?

Last edited by Bladell; 02-24-2013 at 10:48.
Bladell is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-24-2013 , 11:09   Re: Sound for a hero
Reply With Quote #4

Change:

PHP Code:
emit_sound(idCHAN_ITEMgSoundPushVOL_NORMATTN_NORM0PITCH_NORM
to

PHP Code:
emit_sound(idCHAN_VOICEgSoundPushVOL_NORMATTN_NORM0PITCH_NORM
To add a blind use sh_screen_fade:

PHP Code:
/**
 * Creates a screen fade on the client.
 *
 * @param id        The index of the client.
 * @param fadeTime    The time in seconds the fade lasts.
 * @param holdTime    The time in seconds the fade is held.
 * @param red        The red rgb color value of the fade. (0-255)
 * @param green        The green rgb color value of the fade. (0-255)
 * @param blue        The blue rgb color value of the fade. (0-255)
 * @param alpha        The alpha transparency value of the fade. (0-255)
 * @param type        The type of fade. (see superheroconst.inc)
 * @noreturn
 */
stock sh_screen_fade(idFloat:fadeTimeFloat:holdTimeredgreenbluealphatype SH_FFADE_IN
Example:
PHP Code:
sh_screen_fade(id1.01.0255255255255SH_FFADE_IN
Makes the screen white in a second. Add it just after the line with the emit_sound and the screen will fade to white for a second.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Bladell
Senior Member
Join Date: Jun 2012
Old 02-26-2013 , 13:00   Re: Sound for a hero
Reply With Quote #5

Quote:
Originally Posted by Jelle View Post
Change:

PHP Code:
emit_sound(idCHAN_ITEMgSoundPushVOL_NORMATTN_NORM0PITCH_NORM
to

PHP Code:
emit_sound(idCHAN_VOICEgSoundPushVOL_NORMATTN_NORM0PITCH_NORM
The sound work...but I not understand what do this change.
Bladell is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 02-25-2013 , 09:20   Re: Sound for a hero
Reply With Quote #6

Code:
emit_sound(id, CHAN_VOICE, gSoundPush, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
this do nothing.
Code:
sh_screen_fade(id, 1.0, 1.0, 255, 255, 255, 255, SH_FFADE_IN)
this make my screen white, not the player's screen who is in my range.

I'd like the player in my range to become deaf and blind.And if you can make something with the sound it woul be great.
Bladell is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-25-2013 , 19:10   Re: Sound for a hero
Reply With Quote #7

If you want to do it on the one you are attacking with the hero change "id" from sh_screen_fade to "victim" and it shows up at the one who you attacked.

The sound is not playing because it is an mp3 file. You need to convert it into a wav file and make it 8 bit mono audio.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 02-26-2013 , 15:46   Re: Sound for a hero
Reply With Quote #8

The change will change the channel from CHAN_ITEM to CHAN_VOICE.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Yingryn
New Member
Join Date: Mar 2013
Old 03-07-2013 , 02:41   Re: Sound for a hero
Reply With Quote #9

friend it is same problem occur with me please give me reply if u find answer about it
__________________
Yingryn is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode