Thread: How to add, Item on Item, and Item on Object to Emulous.

Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1 How to add, Item on Item, and Item on Object to Emulous. 
    rolfcopter
    Guest
    Explanation/Purpose: To add the Item on Item, and Item on Object packets to emulous
    Difficulty: 2/10, using this will require basic java knowledge.
    Classes Added/Modified: ItemOnObject.java, ItemOnItem.java, packetHandler.java, useItem.java
    Tested On: Emulous...
    Bugs/Problems: None =D as far as i know.


    Step 1:

    Go to server.players.packets, create a new java file named "ItemonItem.java"

    open it up and add this inside:

    Code:
    package server.players.packets;
    
    import server.util.*;
    import server.players.*;
    
    
    /**
     * ItemOnItem
     * @author Ritz/rolfcopter
     **/
    public class ItemOnItem implements PacketType {
    
    	
    	public void processPacket(Client c, int packetType, int packetSize) {
    
    		int usedWithSlot = c.getInStream().readUnsignedWord();
    		int itemUsedSlot = c.getInStream().readUnsignedWordA();
    		int useWith = c.playerItems[usedWithSlot] - 1;
    		int itemUsed = c.playerItems[itemUsedSlot] - 1;
    		UseItem.ItemonItem(c, itemUsed, useWith);
    	}
    }

    Step 2:

    also in server.players.packets create another new class called "ItemOnObject.java"

    put this inside:

    Code:
    package server.players.packets;
    
    import server.util.*;
    import server.players.*;
    
    
    /**
     * ItemOnObject
     * @author Ritz/rolfcopter
     **/
    public class ItemOnObject implements PacketType {
    
    	
    	public void processPacket(Client c, int packetType, int packetSize) {
    
    		int atObjectID = c.getInStream().readSignedWordBigEndian();
    		int useItemID = c.getInStream().readUnsignedWord();
    		UseItem.ItemonObject(c, atObjectID, useItemID);
    	
    	}
    }
    Step 3:

    still in server.players.packets create a third class called "UseItem.java"

    put this inside:

    Code:
    package server.players.packets;
    
    import server.players.Client;
    import server.util.Misc;
    
    /*
     * UseItem
     * @author Richscape4.3
     */
    public class UseItem {
    
    	static void ItemonObject(Client c, int Object, int Item) {
    
    		if (Object == 1) {
    			if (Item == 2) {
    				c.sendMessage("EXAMPLE");
    				} 
    			}
    			else {
    				c.sendMessage("Nothing Interesting Happens.");	
    		
    		}
    	}		
    
    	static void ItemonItem(Client c, int Item, int Item2) {
    
    		if ((Item == 2 && Item2 == 3)) {
    			Misc.println("EXAMPLE 2");
    		} else {
    			c.sendMessage("Nothing Interesting Happens.");	
    		}
    	}
    
    	
    }
    Step 4:

    Close those files as you don't need them anymore.
    Open up PacketHandler.java.

    Find:
    Code:
    	packetId.put(98, w);
    and underneath that add this:
    Code:
    		packetId.put(53, new ItemOnItem());
    		packetId.put(192, new ItemOnObject());

    Done!

    I included 2 examples in the useItem class, that should be enough to get you started, its possible to use switch statements if you find that easier, but its a smaller code to do it like it is there

    Enjoy?


    Credits: Me, Richscape 4.3 author, as i used the "UseItem" class from there
    Reply With Quote  
     

  2. #2  
    baghori1
    Guest
    Nice way of doing it.
    Reply With Quote  
     

  3. #3  
    rolfcopter
    Guest
    Thankyou
    Reply With Quote  
     

  4. #4  
    Expert Programmer


    Join Date
    Dec 2007
    Posts
    2,018
    Thanks given
    52
    Thanks received
    84
    Rep Power
    986
    Nice work dude
    Reply With Quote  
     

  5. #5  
    Registered Member
    Kelvin's Avatar
    Join Date
    Jun 2007
    Posts
    1,433
    Thanks given
    48
    Thanks received
    33
    Rep Power
    269
    seriously, we should stop doing this, because it will turn into Delta Number2.
    (No flame just prevent this) and, everyone with common sense could do this >.<
    Anyways nice tutorial..

    By the way, use conventions
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    ( ͡° ͜ʖ ͡°)
    Edgeville's Avatar
    Join Date
    Nov 2007
    Posts
    2,455
    Thanks given
    80
    Thanks received
    428
    Rep Power
    2589
    Nice job. MTS

    Reply With Quote  
     

  7. #7  
    rolfcopter
    Guest
    Quote Originally Posted by Kelvin
    seriously, we should stop doing this, because it will turn into Delta Number2.
    (No flame just prevent this) and, everyone with common sense could do this
    Anyways nice tutorial..

    By the way, use conventions
    Prevent what?

    and i cba with conventions
    Reply With Quote  
     

  8. #8  
    Registered Member
    Kelvin's Avatar
    Join Date
    Jun 2007
    Posts
    1,433
    Thanks given
    48
    Thanks received
    33
    Rep Power
    269
    Quote Originally Posted by rolfcopter View Post
    Prevent what?

    and i cba with conventions
    Prevent that emulous will turn in an another delta.
    because i see everywhere tutorials [Delta] Item fix, [Delta]Dupe fix, >.<
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  9. #9  
    rolfcopter
    Guest
    Oooh yeah i getcha lmao, just thought i'd release this because it only took 5 mins and nobody had posted it yet.
    Reply With Quote  
     

  10. #10  
    baghori1
    Guest
    I posted it in snippets, but yeah.. this is ok.
    Reply With Quote  
     

Page 1 of 3 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
  •