Thread: a little modification to npc shopkeepers

Results 1 to 9 of 9
  1. #1 a little modification to npc shopkeepers 
    Registered Member
    Join Date
    May 2016
    Posts
    78
    Thanks given
    1
    Thanks received
    9
    Rep Power
    43
    Hellooo... Here is a lil modification you can add to any npc, especially for shopkeepers!

    Icons to show what sort of thing that NPC relates to. This nothing to big so don't be a smart ass and comment unuseful things lol.



    First Download these sprites and place them in your Sprites Folder: SpritesIcon.zip - Mediafire

    Ok first of all you can add more of these icons when ever and am sure this will an simple tutorial so you wont have trouble adding more later on.

    Client Sided

    Step 1: Open Client.java
    Add this:

    Code:
    	static Sprite bankerIcon;
    	
    	static Sprite retailIcon;
    	
    	static Sprite meleshopIcon;
    Step 2:
    Find:
    Code:
    private void updateEntities() {
    		try {
    			int anInt974 = 0;
    			for (int j = -1; j < playerCount + npcCount; j++) {
    				Object obj;
    				if (j == -1)
    					obj = myPlayer;
    				else if (j < playerCount)
    					obj = playerArray[playerIndices[j]];
    				else
    					obj = npcArray[npcIndices[j - playerCount]];
    				if (obj == null || !((Entity) (obj)).isVisible())
    					continue;
    				if (obj instanceof NPC) {
    Bellow that
    Add:
    Code:
    EntityDef entityDef = ((NPC) obj).desc;
    					npcScreenPos(((Entity) (obj)), ((Entity) (obj)).height+15);
                        bankerIcon = new Sprite(signlink.findcachedir()
            					+ "Sprites/bankerIcon.PNG",
            					1);
                        retailIcon = new Sprite(signlink.findcachedir()
            					+ "Sprites/retailIcon.PNG",
            					1);
                        meleshopIcon = new Sprite(signlink.findcachedir()
            					+ "Sprites/meleshopIcon.PNG",
            					1);
                        EntityDef entityDef_1 = ((NPC) obj).desc;
                        if (entityDef_1.type == 953) {
                        bankerIcon.drawAdvancedSprite(spriteDrawX - 12, spriteDrawY - 20);
                        } else if (entityDef_1.type == 9159) {
                        	retailIcon.drawAdvancedSprite(spriteDrawX - 12, spriteDrawY - 20);
                        } else if (entityDef_1.type == 883) {
                        	meleshopIcon.drawAdvancedSprite(spriteDrawX - 12, spriteDrawY - 20);
                        }
    That is it, your done.

    Good luck on adding more icons and and let us what else you have added!
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Registered Member
    Join Date
    Nov 2014
    Posts
    101
    Thanks given
    12
    Thanks received
    46
    Rep Power
    63
    Nice one!
    Reply With Quote  
     

  4. #3  
    Registered Member
    Join Date
    May 2016
    Posts
    78
    Thanks given
    1
    Thanks received
    9
    Rep Power
    43
    thank you glad to help, even though it is little
    Reply With Quote  
     

  5. #4  
    Registered Member
    Join Date
    Aug 2017
    Posts
    2
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Looks good here are two things i would do is make an enum that contains npc id and Sprite id ... or in the definitions for the npc make a new variable that is the icon id

    so headIcon = 20;
    so it looks a little cleaner but apart from that good job ... runescape does this atm for some quest npc's if u did not know
    Reply With Quote  
     

  6. #5  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Nice idea but why not use the built in headIcon system, used for prayer icons etc?
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    Registered Member
    Join Date
    May 2016
    Posts
    78
    Thanks given
    1
    Thanks received
    9
    Rep Power
    43
    Quote Originally Posted by JakeUK View Post
    Looks good here are two things i would do is make an enum that contains npc id and Sprite id ... or in the definitions for the npc make a new variable that is the icon id

    so headIcon = 20;
    so it looks a little cleaner but apart from that good job ... runescape does this atm for some quest npc's if u did not know
    thank you, i did not know that about rs but appreciate telling. and thank you for the guidance

    Quote Originally Posted by Professor Oak View Post
    Nice idea but why not use the built in headIcon system, used for prayer icons etc?
    because the headicon system isnt something i like so i went ahead with this because i wanted to code it the way i want. However, thank you for pointing out the head prayer icon, maybe that will help people who want to take that approach instead.
    Reply With Quote  
     

  9. #7  
    🖤Runic Developer🖤
    Castiel's Avatar
    Join Date
    Apr 2013
    Posts
    1,752
    Thanks given
    564
    Thanks received
    288
    Rep Power
    609
    sorry to ask but what are the npc ids
    Reply With Quote  
     

  10. #8  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    You're creating a new Sprite object every time that function is called. Store the god damn Sprite as a class member instead of locally.
    Reply With Quote  
     

  11. Thankful user:


  12. #9  
    Registered Member
    Join Date
    Mar 2014
    Posts
    6
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Code:
    final Sprite icon = ((NPC) entityDef).getSprite();
    if (icon != null) {
        icon.drawAdvancedSprite(spriteDrawX - 12, spriteDrawY - 20);
    }
    Like Jason said store the information instead of creating a new instance of the sprite every time

    if you really wanted to you could pack the sprite index into the NPC definitions or calculate which icon should go where depending on NPC type etc...

    nonetheless not a bad idea.
    Reply With Quote  
     

  13. Thankful user:



Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. A Little Fix to range
    By IGotSkillz in forum Tutorials
    Replies: 26
    Last Post: 03-07-2008, 12:45 PM
  2. How To Add Drops to npc's (for beginners)
    By Laz3r in forum Tutorials
    Replies: 4
    Last Post: 09-26-2007, 01:56 AM
  3. How to make phats turn you to NPCS!
    By RSSJ in forum Tutorials
    Replies: 14
    Last Post: 09-01-2007, 09:18 PM
  4. make phats turn you to npc
    By junkcrap83 in forum Tutorials
    Replies: 7
    Last Post: 08-01-2007, 12:10 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •