#CBaseEntity.StopSound method doesn't work

1 messages · Page 1 of 1 (latest)

crisp crypt
#

I'm encountering an issue with trying to stop a sound using the StopSound method in my custom game. I have implemented a custom arcane bolt ability, following the TypeScript introduction guide at https://moddota.com/scripting/Typescript/typescript-ability.

The problem arises when I attempt to stop the cast sound of the arcane bolt ability after it hits the target. I'm currently using the StopSound method provided by the CBaseEntity class, but it doesn't seem to have any effect. The sound continues to play in its entirety, instead of being stopped.

@registerAbility()
export class typescript_skywrath_mage_arcane_bolt extends BaseAbility
{
    sound_cast: string = "Hero_SkywrathMage.ArcaneBolt.Cast";
    sound_impact: string = "Hero_SkywrathMage.ArcaneBolt.Impact";
    projectile_arcane_bolt: string = "particles/units/heroes/hero_skywrath_mage/skywrath_mage_arcane_bolt.vpcf";

    OnSpellStart()
    {
        const target = this.GetCursorTarget();

        const bolt_speed = this.GetSpecialValueFor("bolt_speed");
        const bolt_vision = this.GetSpecialValueFor("bolt_vision");

        EmitSoundOn(this.sound_cast, this.GetCaster());

        ProjectileManager.CreateTrackingProjectile(
            {
                Ability: this,
                EffectName: this.projectile_arcane_bolt,
                Source: this.GetCaster(),
                Target: target,
                bDodgeable: false,
                bProvidesVision: true,
                iMoveSpeed: bolt_speed,
                iVisionRadius: bolt_vision,
                iVisionTeamNumber: this.GetCaster().GetTeamNumber(),
            }
        )
    }

    OnProjectileHit(target: CDOTA_BaseNPC | undefined, location: Vector)
    {
        if (!target) return;

        this.StopSound(this.sound_cast); // This method should stop the arcane_bolt cast sound from playing, but it doesn't
        EmitSoundOn(this.sound_impact, target);
    }
}```
shadow tiger
#

Use next code to stop sound:

StopSoundOn(this.sound_cast, this.caster):

You are trying to stop sound using ability (not sure if this even supposed to work), but started sound using unit(caster) so it silently fail

crisp crypt
#

Hey, tried StopSoundOn(), got the same result, the sound doesn't stop.

StopSoundOn(this.sound_cast, this.GetCaster());
EmitSoundOn(this.sound_impact, target);
this.GetCaster().StopSound(this.sound_cast); // also doesnt work
cunning fiber
#

Isn't Arcane Bolt cast sound stopped automatically because it's short? When I used it, everything was fine.

#

Ah nvm, you are not stopping the sound even if the target doesn't exist