Advertisement
ZoriaRPG

SwordSounds.zs

Jul 27th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. const int MAX_LINK_VOICES = 15;
  2. int LinkVoices[16]; //GLobal array to hold the voices.
  3.  
  4. //Adds a voice to the array using the init script.
  5. void AddLinkVoice(int sfx){
  6.     LinkVoices[0]++;
  7.     if (!( GetLinkVoices() > MAX_LINK_VOICES ) ) {
  8.         LinkVoices[GetLinkVoices()] = sfx;
  9.     }
  10.     else {
  11.         int _____err[]="Too many voices set to LinkVoices[]. The maximum number of voices is: ";
  12.         TraceS(_____err); TraceMAX_LINK_VOICES); TraceNL();
  13.     }
  14. }
  15.    
  16.  
  17. //Accessor to get the number of voices used.
  18. int GetLinkVoices(){ return LinkVoices[0]; }
  19.  
  20.  
  21. global script Init{
  22.     AddLinkVoice(65);  //Change these numbers to the SFX numbers that you want to use.
  23.     AddLinkVoice(66);  //Add additional calls to add more voices, max 15 voices.
  24.     AddLinkVoice(67);
  25.     AddLinkVoice(68);  
  26. }
  27.  
  28. item script SwordSFX{
  29.     void run(){
  30.         Game->PlaySound( LinkVoices[ Rand(1,GetLinkVoices()) ] );
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement