[Solved] How to handle custom weapons reloading sounds?
Posted: 18 Jun 2014, 13:16
Hello,
Does anyone know if there is a way to handle the reloading sound of a custom weapon? Because as I said in another post, I'm having some troubles with them.
First I only had a glitch which played this reloading sound in a loop when a player eliminated his last opponent with a custom weapon (there is a video). I fixed that by switching weapon just before the end of the round, which is really just a workaround:
Now I'm having another problem, I modified my gameplay so my custom weapons don't reload when they are not equipped (the reload is paused when it's unequipped and starts back from where it was when it's equipped again). The problem is if I switch from a custom weapon to a classic one when there is the reloading sound playing, this sound just loops until I switch back to this same custom weapon (there is a video showing it).
There is some code I'm using, the SwitchWeapon function:
And there is how I modified the custom weapon script to make the reload pausing:
Does anyone know if there is a way to handle the reloading sound of a custom weapon? Because as I said in another post, I'm having some troubles with them.
First I only had a glitch which played this reloading sound in a loop when a player eliminated his last opponent with a custom weapon (there is a video). I fixed that by switching weapon just before the end of the round, which is really just a workaround:
Code: Select all
// Elim attacker
if (Players[G_AtkPlayerId].Armor <= 0 && Event.Victim.Id == G_AtkPlayerId) {
PlaySound(CUIConfig::EUISound::VictoryPoint, 0);
AtkIsEliminated = True;
// Unequips the Shotgun and equips the Rocket to avoid reloading sound loop
ActionBind(Event.Shooter,CSmMode::EActionSlot::Slot_B,CSmMode::EActionInput::None);
SetPlayerWeapon(Event.Shooter, CSmMode::EWeapon::Rocket, False);
}
There is some code I'm using, the SwitchWeapon function:
Code: Select all
// Rocket
if (_Weapon == CSmModeEvent::EActionInput::Activable1 && CurWeaponNb != 2) {
// Unequips Shotgun
ActionBind(_Player,CSmMode::EActionSlot::Slot_B,CSmMode::EActionInput::None);
// Equips Rocket
SetPlayerWeapon(_Player, CSmMode::EWeapon::Rocket, True);
_Player.AmmoGain = C_DefRocketAmmoGain;
CurWeaponNb = 2;
}
// Shotgun
else if (_Weapon == CSmModeEvent::EActionInput::Activable2 && CurWeaponNb != 6) {
// Equips Nucleus for an instant to trigger switching sound (now and
// when switching back), and cooldown of classic weapons (when switching back)
SetPlayerWeapon(_Player, CSmMode::EWeapon::Nucleus, False);
SetPlayerAmmoMax(_Player, CSmMode::EWeapon::Nucleus, 1);
SetPlayerAmmo(_Player, CSmMode::EWeapon::Nucleus, 0);
// Equips Shotgun
ActionBind(_Player,CSmMode::EActionSlot::Slot_B,CSmMode::EActionInput::Weapon);
CurWeaponNb = 6;
}
Code: Select all
if (Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
// Pauses reloading when unequipped
if (Owner.CurWeapon != 3) Energy = EnergyPause;
// Reloads normally when it's equipped
else EnergyPause = Energy;
// Starts cooldown when switching to this weapon
if (LastCurrentWeapon != Owner.CurWeapon) Cooldown_Start();
}
LastCurrentWeapon = Owner.CurWeapon;