case ACTION_USE_WEAPON:
if( cr.IsLife() && valid( proto ) )
{
int use = ( actionExt & 0xF );
int aim = ( ( actionExt >> 4 ) & 0xF );
bool fail = ( ( ( actionExt >> 8 ) & 1 ) != 0 );
cr.ClearAnim();
cr.Animate( 0, ANIM2_PREPARE_WEAPON );
if( proto.ProtId != PID_E3245_STOLE_MY_SOUND )
PlaySound( 'W', SOUND_WEAPON_USE, _WeaponSoundId( proto, use ), use != 1 ? '1' : '2' );[/b]
cr.Animate( 0, _WeaponAnim2( proto, use ), item );
if( fail )
cr.Animate( 0, ANIM2_DAMAGE_FRONT, item );
else
cr.Animate( 0, ANIM2_TURNOFF_WEAPON );
}
break;
Blocks sound for specific PID only
#pragma bindfield "const bool ProtoItem::Weapon_NoSound -> 273
[CreateTab]
TopTab=Weapon
ItemTab=WeaponCustom
Text=Custom
[Common]
ItemTab=WeaponCustom
Space=75
[Field]
Text=No sound
FieldName=Weapon_NoSound
DataType=bool
case ACTION_USE_WEAPON:
if( cr.IsLife() && valid( proto ) )
{
int use = ( actionExt & 0xF );
int aim = ( ( actionExt >> 4 ) & 0xF );
bool fail = ( ( ( actionExt >> 8 ) & 1 ) != 0 );
cr.ClearAnim();
cr.Animate( 0, ANIM2_PREPARE_WEAPON );
if( !proto.Weapon_NoSound )
PlaySound( 'W', SOUND_WEAPON_USE, _WeaponSoundId( proto, use ), use != 1 ? '1' : '2' );[/b]
cr.Animate( 0, _WeaponAnim2( proto, use ), item );
if( fail )
cr.Animate( 0, ANIM2_DAMAGE_FRONT, item );
else
cr.Animate( 0, ANIM2_TURNOFF_WEAPON );
}
break;
Blocks sound for many proto items, allows to set which weapons should be silent via ObjectEditor (creates "Weapon"->"Custom" tab, where it can be set).
If you still want attacker to hear some sound like in typical action movies (pling!), you need to tune server scripts a bit. I'm not doing combat stuff, so i won't even guess where, but call itself can be something like that.
void PlaySound( Critter& cr, string& soundName )
{
if( cr.IsPlayer() )
cr.RunClientScript( "_PlaySound", 0, 0, 0, soundName, null );
}
void _PlaySound( int, int, int, string@ soundName, array<int>@ )
{
if( valid(soundName) && soundName.length() > 0 )
PlaySound( soundName );
}
void PlaySoundRange( Critter& cr, string& soundName, uint16 range )
{
if( soundName.length() == 0 )
return;
Map@ map = cr.GetMap();
if( valid(map) )
map.PlaySound( soundName, cr.HexX, cr.HexY, range );
}
All that is just a fast c/p fest, i didn't actually test if it works at all