Thread: Music and Sounds

Page 1 of 5 123 ... LastLast
Results 1 to 10 of 44
  1. #1 Music and Sounds 
    Registered Member
    Join Date
    May 2008
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    51
    This is a tutorial about sounds and music ingame and how to use and handle them in a better way. If you accuse me of leeching then just leave.

    Why did I do this?

    I made this tutorial because there isn't many tutorials on sounds/music also because I want to try using enums

    Part 1: Add the 'Sound' class.

    Code:
    public class Sound {
    
    	//TODO : Implement more sounds...
    	public static enum SOUND_LIST {
    		/*
    		 * Miscellaneous sounds.
    		 */
    		FOOD_EAT(317),
    		ITEM_DROP(376),
    		ITEM_COOK(357),
    		ITEM_PICKUP(358),
    		FIRE_LIGHT(375),
    		ARROW_SHOOT(370),
    		TELEPORT(202),
    		BONE_BURY(380),
    		POTION_DRINK(334),
    		TREE_CUT_BEGIN(471),
    		TREE_CUTTING(472),
    		TREE_EMPTY(473),
    		LOG_FLETCH(375),
    
    		/*
    		 * Magic
    		 */
    		ALCHEMY_LOW(224),
    		ALCHEMY_HIGH(223),
    		BLITZ_ICE(1110),
    		
    		/*
    		 * Weapons
    		 */
    		ATTACK_WHIP(4151, 1080),
    		SPECIAL_WHIP(4151, 1081),
    		ATTACK_FLAIL(4755, 1059),
    		ATTACK_GMAUL(4153, 1079),
    		ATTACK_DDS(5698, 793),
    		SPECIAL_DDS(5698, 385),
    		SPECIAL_DLONG(1305, 390),
    		ATTACK_SCIMITAR(396),
    		ATTACK_LUNGE(398),
    		ATTACK_HAMMERS(4747, 1062),
    		ATTACK_GREATAXE_SLASH(4718, 1057),
    		SPECIAL_BOW(386),
    		SPECIAL_DBA(1377, 389),
    		SPECIAL_DSPEAR(1249, 388),
    		SPECIAL_MACE(1434, 387),
    		SPECIAL_MAUL(4153, 1082),
    		SHIELD_BLOCK(791);
    		
    		int weapon, weaponSound, sound;
    		
    		SOUND_LIST(int weapon, int weaponSound) {
    			this.weapon = weapon;
    			this.weaponSound = weaponSound;
    		}
    
    		SOUND_LIST(int sound) {
    			this.sound = sound;
    		}
    
    		public int getSound() {
    			return sound;
    		}
    
    		public int getWeaponSound(int weapon) {
    			if (weapon == this.weapon)
    				return weaponSound;
    			else
    				return sound;
    		}
    	}
    
    }
    Part 2: Add the 'Music' class.

    Code:
    public class Music {
    
    	public static enum CITY_MUSIC {
    		VARROCK(169),
    		WATERFALL(125);
    
    		int music;
    
    		CITY_MUSIC(int music) {
    			this.music = music;
    		}
    
    		public int getMusic() {
    			return music;
    		}
    	}
    
    }
    Thats just the handling of sounds/music if you want to add more then simply change the last ; to a , and then add a new sound. Sorry if thats not enough sounds for your likings.

    Part 3: Playing the sounds

    Go to your client class and declare the following method if it isn't declared;

    Code:
    	public void playSound(int i1, int i2, int i3) {
    		outStream.createFrame(174);
    		outStream.writeWord(i1);
    		outStream.writeByte(i2);
    		outStream.writeWord(i3);
    	}
    Part 4: Usage

    Search for case 87: and below it add:

    playSound(Sound.SOUND_LIST.ITEM_DROP.getSound(), 0, 0);

    Part 5: Playing and stopping music

    Code:
    	public void musicManager(String action, int songID) {
    		if (action == "PLAY") {
    			outStream.createFrame(74);
    			outStream.writeWordBigEndian(songID);
    		}
    		if (action == "STOP") {
    			outStream.createFrame(74);
    			outStream.writeWordBigEndian(-1);
    		}
    	}
    Part 6: Usage

    Search for case 121: and below it add:

    Code:
    musicManager("PLAY", Music.CITY_MUSIC.WATERFALL.getMusic());
    And you are done! There should be NO errors.

    Rep if I helped you
     

  2. #2  
    Donator Market Banned Market Banned



    Join Date
    Feb 2009
    Posts
    3,821
    Thanks given
    88
    Thanks received
    113
    Rep Power
    5000
    Very nice =)
     

  3. #3  
    Registered Member
    Join Date
    May 2008
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    51
    ty
     

  4. #4  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    isnt music frame74???
    ...
     

  5. #5  
    Registered Member
    Join Date
    May 2008
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    51
    Quote Originally Posted by mige5 View Post
    isnt music frame74???
    Sorry I edited it.
     

  6. #6  
    Codex
    Rowan's Avatar
    Join Date
    Sep 2008
    Age
    25
    Posts
    1,593
    Thanks given
    0
    Thanks received
    20
    Rep Power
    1092
    nice if not leeched.
    [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ]
     

  7. #7  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Nice if it works, gonna test later...

    ps. if i already have weaponsoundhandler, does this mess with is??
    ...
     

  8. #8  
    Registered Member

    Join Date
    Jul 2008
    Posts
    939
    Thanks given
    0
    Thanks received
    3
    Rep Power
    781
    Need the client edit.
    I'm Rog3r, fool.
     

  9. #9  
    Registered Member
    Join Date
    May 2008
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    51
    Quote Originally Posted by mige5 View Post
    Nice if it works, gonna test later...

    ps. if i already have weaponsoundhandler, does this mess with is??
    if you want to play those sounds you can. Just don't play my weapon sounds.

    Roger, I'll try find the client edit - I'm sure you can just download any client in the RS2 Client Section and your set.
     

  10. #10  
    Registered Member Paketa's Avatar
    Join Date
    Oct 2007
    Posts
    2,681
    Thanks given
    17
    Thanks received
    82
    Rep Power
    680
    Nice use of enums.
     

Page 1 of 5 123 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •