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);
}
}```