Thread: NPC Name Bugged

Results 1 to 6 of 6
  1. #1 NPC Name Bugged 
    Registered Member
    Join Date
    Feb 2019
    Posts
    21
    Thanks given
    6
    Thanks received
    1
    Rep Power
    0
    Hello. So I have the information clerk npc spawned and dialogue works fine. If I use King Fox's cache editor for 592 and change information clerk's name to 'Guide Lady', her npc skin sets to default one and her face doesn't show in dialogue box anymore. Been stuck for a while here. Many thanks!

    Update: Also tried to set name of NPC ID 5938 in NPC.java shown at the bottom of this code (but it didn't change the name):

    Code:
    	public void processNPC() {
    		if (isDead() || locked)
    			return;
    		if (!combat.process()) { // if not under combat
    			if (!isForceWalking()) {// combat still processed for attack delay
    				// go down
    				// random walk
    				if (!cantInteract) {
    					if (!checkAgressivity()) {
    						if (getFreezeDelay() < Utils.currentTimeMillis()) {
    							if (!hasWalkSteps() && (walkType & NORMAL_WALK) != 0) {
    								boolean can = false;
    								for (int i = 0; i < 2; i++) {
    									if (Math.random() * 1000.0 < 100.0) {
    										can = true;
    										break;
    									}
    								}
    
    								if (can) {
    									int moveX = (int) Math.round(Math.random() * 10.0 - 5.0);
    									int moveY = (int) Math.round(Math.random() * 10.0 - 5.0);
    									resetWalkSteps();
    									if (getMapAreaNameHash() != -1) {
    										if (!MapAreas.isAtArea(getMapAreaNameHash(), this)) {
    											forceWalkRespawnTile();
    											return;
    										}
    										// fly walk noclips for now, nothing
    										// uses it anyway
    										addWalkSteps(getX() + moveX, getY() + moveY, 5, (walkType & FLY_WALK) == 0);
    									} else
    										addWalkSteps(respawnTile.getX() + moveX, respawnTile.getY() + moveY, 5, (walkType & FLY_WALK) == 0);
    								}
    
    							}
    						}
    					}
    				}
    			}
    		}
    		if (isForceWalking()) {
    			if (getFreezeDelay() < Utils.currentTimeMillis()) {
    				if (getX() != forceWalk.getX() || getY() != forceWalk.getY()) {
    					if (!hasWalkSteps()) {
    						int steps = RouteFinder.findRoute(RouteFinder.WALK_ROUTEFINDER, getX(), getY(), getPlane(), getSize(), new FixedTileStrategy(forceWalk.getX(), forceWalk.getY()), true);
    						int[] bufferX = RouteFinder.getLastPathBufferX();
    						int[] bufferY = RouteFinder.getLastPathBufferY();
    						for (int i = steps - 1; i >= 0; i--) {
    							if (!addWalkSteps(bufferX[i], bufferY[i], 25, true))
    								break;
    						}
    					}
    					if (!hasWalkSteps()) { // failing finding route
    						setNextWorldTile(new WorldTile(forceWalk)); // force
    						// tele
    						// to
    						// the
    						// forcewalk
    						// place
    						forceWalk = null; // so ofc reached forcewalk place
    					}
    				} else
    					// walked till forcewalk place
    					forceWalk = null;
    			}
    		}
    		if (id == 5938) {
    			setName("Guide Lady"); // Change name of NPC 5938 (Information Clerk)
    			setRandomWalk(0);
    		}
    	}
    Reply With Quote  
     

  2. #2  
    Registered Member
    Grant_'s Avatar
    Join Date
    Aug 2014
    Posts
    469
    Thanks given
    92
    Thanks received
    99
    Rep Power
    91
    Yikes. Please don't put this in the process. This means every game tick you're doing a call to set the name and walk type of the NPC. This task is meant for the things above such as combat and walking/path scripts of NPC's. Also where did that 'id' variable come from? It's no where else in the method, how can you assume that it is the id of the NPC?

    Aside from this, setting the NPC name server sided has no affect on the visual name you click and see in-game. I'd maybe recommend going into some of your definition files client sided and finding the NPCDefinition file. The naming could vary depending on your client. From here you can check for the case of 5938 and set its name variable accordingly.
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Jun 2018
    Posts
    14
    Thanks given
    0
    Thanks received
    4
    Rep Power
    82
    Quote Originally Posted by DevBe View Post
    Hello. So I have the information clerk npc spawned and dialogue works fine. If I use King Fox's cache editor for 592 and change information clerk's name to 'Guide Lady', her npc skin sets to default one and her face doesn't show in dialogue box anymore. Been stuck for a while here. Many thanks!

    Update: Also tried to set name of NPC ID 5938 in NPC.java shown at the bottom of this code (but it didn't change the name):
    The reason this won't work...
    Code:
    		if (id == 5938) {
    			setName("Guide Lady"); // Change name of NPC 5938 (Information Clerk)
    			setRandomWalk(0);
    		}
    is because 592 doesn't have a npc mask that allows you to change the npc name on demand like that. The realistic approach to this is to change the npc name in the cache. I'll give you a small cheaphax though.

    Open Class253 class in the client and find this bit of code

    Code:
    					} else
    						((Class253) this).f_db = stream.readString((byte) -40);
    And you do something like this

    Code:
    					} else {
    						((Class253) this).f_db = stream.readString((byte) -40);
    						if (anInt3587 == 5938)
    							name = "Guide Lady";
    					}
    Screenshot just so you get a visual look



    This way you also won't be setting the npc name each time "processNPC()" is called which iirc is every tick too.

    Thanks,
    Zero.
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member
    Join Date
    Feb 2019
    Posts
    21
    Thanks given
    6
    Thanks received
    1
    Rep Power
    0
    Thanks guys! I'd love to know how to learn more client side but those numbered class files and codes don't make sense at all to me. What does 'f_db' and 'anInt537' both even do? xD
    Tried Frosty's cache editor for 592 but it bugs out when I change npc names. It stops their faces showing in dialogue boxes and changes their appearance to old Runescape style. But it's the only cache editor that shows on Google for 592 unfortunately.
    Zero, I'll give it a go when I get in from work. You're awesome, cheers buddy!
    Reply With Quote  
     

  6. #5  
    Registered Member

    Join Date
    Jun 2018
    Posts
    14
    Thanks given
    0
    Thanks received
    4
    Rep Power
    82
    Quote Originally Posted by DevBe View Post
    Thanks guys! I'd love to know how to learn more client side but those numbered class files and codes don't make sense at all to me. What does 'f_db' and 'anInt537' both even do? xD
    Tried Frosty's cache editor for 592 but it bugs out when I change npc names. It stops their faces showing in dialogue boxes and changes their appearance to old Runescape style. But it's the only cache editor that shows on Google for 592 unfortunately.
    Zero, I'll give it a go when I get in from work. You're awesome, cheers buddy!
    f_db represents the npc name
    anInt537 represents the file id in the cache. (which is also the npc id) but the cache reads the file like this

    Code:
    return id & 0x7f;
    the naming is like that because of the automatic renamer from JODE.
    Thanks,
    Zero.
    Reply With Quote  
     

  7. #6  
    Registered Member
    Join Date
    Feb 2019
    Posts
    21
    Thanks given
    6
    Thanks received
    1
    Rep Power
    0
    Wow thanks Zero!! I understand more now. Someone give this man lots of cake, lol!
    All works well, but I haveone more question if you don't mind:

    1. How would one go about changing the dialog name of the NPC so that it reads the new name from the client?
    I'm guessing the client knows of the name change but the server doesn't.



    Many thanks!

    EDIT: I've set the NPC definitions name just before opening the dialog. Is this a decent way to do it?

    Code:
    package com.rs.game.player.dialogues.impl;
    
    import com.rs.cache.loaders.NPCDefinitions;
    import com.rs.game.player.dialogues.Dialogue;
    
    public class GuideLady extends Dialogue {
    
    	private int npcId = 5938;
    
    	@Override
    	public void start() {
    		stage = 0;
    		NPCDefinitions.getNPCDefinitions(npcId).name = "Guide Lady"; // !-- I ADDED THIS --!
    		sendNPCDialogue(npcId, 9828, "Howdy there. Welcome to Generation X!", "What's your name?");
    	}
    
    	@Override
    	public void run(int interfaceId, int componentId) { // Guider Lady
    		if (stage == 0) {
    			stage = 1;
    			sendPlayerDialogue(9760, "Hello. I'm " + player.getUsername() + ".", "So how shall I get started?");
    		}else if (stage == 1) {
    			stage = 2;
    			sendNPCDialogue(npcId, 9827, "Well, " + player.getUsername() + ", you should first give mining,", "fishing or combat training a chance.", "That's because those are my personal favourites.");
    		}else if (stage == 2) {
    			stage = 3;
    			sendPlayerDialogue(9760, "Righty...");
    		}else if (stage == 3) {
    			stage = 4;
    			if (player.getStarterPickaxe() == true) {
    				stage = 6;
    			}
    			sendNPCDialogue(npcId, 9827, "Plenty more to do but I'll not ruin the fun!");
    		}else if (stage == 4) {
    			stage = 5;
    			sendNPCDialogue(npcId, 9827, "Oh.. Here's a pickaxe to get you started.", "You can find pickaxe stores near some mining sites.");
    		}else if (stage == 5) {
    			stage = 6;
    			sendDialogue("The Guide Lady gives you a Bronze Pickaxe.");
    			player.getInventory().addItem(1265, 1);
    			player.setStarterPickaxe(true);
    		}else if (stage == 6) {
    			end();
    		}
    	}
    
    	@Override
    	public void finish() {
    		// TODO Auto-generated method stub
    
    	}
    
    }
    Reply With Quote  
     


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. Replies: 13
    Last Post: 02-16-2011, 03:29 AM
  2. Player name bugs fixed!
    By Scu11 in forum Show-off
    Replies: 30
    Last Post: 02-16-2009, 01:38 AM
  3. Npc Dialogue bug
    By joshscape123 in forum Help
    Replies: 2
    Last Post: 11-04-2008, 12:10 AM
  4. [RS2E] Player name bug
    By Scu11 in forum Tutorials
    Replies: 14
    Last Post: 06-22-2008, 10:27 AM
  5. Replies: 13
    Last Post: 04-11-2008, 10:33 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
  •