play a sound when the attack key is released?

Users who are viewing this thread

HokieBT

Grandmaster Knight
I'm currently using the following code for the lightsaber swing in my star wars mod.

Code:
lightsaber_noise_player = (
       #SW - special weapon noise code by Jinnai	  
	0, 0, 1, 	#there's a 1 second refresh timer to give the attack sound time to complete
		[
                  (game_key_clicked, gk_attack),
                  (neg|conversation_screen_is_active)
                ], 
		[     
		  (get_player_agent_no, ":agent"),    
		  (agent_is_alive, ":agent"),    
		  (agent_get_wielded_item, ":handone", ":agent", 0),    
		  (agent_get_wielded_item, ":handtwo", ":agent", 1),    
		  (this_or_next|is_between, ":handone", lightsaber_noise_begin, lightsaber_noise_end),
		  (is_between, ":handtwo", lightsaber_noise_begin, lightsaber_noise_end), 		  		  		  
		  (agent_play_sound,":agent","snd_lightsaber_swing"),   
		]
)

The problem is, the sound plays when you first click the attack button, so if you hold the attack button down, and then release it the sound has already played.  Is there anyway to modify this so that the sound is played when the attack button is released?
 
all melee swings (axe, swords, punches, staff, etc) are hard-coded to use the sword_swing sound effect.  So if I modify that then everything in my mod sounds like a lightsaber....  so I'm testing keeping the native sound, but using code like this so only lightsabers make that noise.  But as I described this concept isn't perfect......
 
I am not a coder, but is there a game_key_released or something similar?
if not you could use (game_key_is_down, gk_attack) to pause the script until that state is no longer true
causing the script to run right?... :???:
 
I just have to check you all that you know that it's possible to modify hardcoded stuff to using different kinds of programs. And for the code part why don't you make the sound when the lightsaber hits the target. And making the sounds abit pre-mature. I maen that it actually goes of when hitting but starts soundng abit to early. But I don't know if this is possible.
 
Well, since I had to make a manual attack for my jousting, I had to control the release of the thrust as well.  Same kind of idea.

What I would do is make an agent slot for weapon sound.  when the attack key is pressed, play the start sound and set the sound slot to 1.  May a similar trigger for game key released.  In it's conditions, the slot must be equal to run.  If it is (meaning they have the key down), then run the code to make the finishing sound.

If you want to see my code, let me know (though it's for attacking not sound, but same idea)
 
Back
Top Bottom