Thread: [RUSE] NPC health bar issue

Results 1 to 6 of 6
  1. #1 [RUSE] NPC health bar issue 
    Registered Member
    Join Date
    Jun 2013
    Posts
    335
    Thanks given
    57
    Thanks received
    23
    Rep Power
    13
    For those who don't know what I'm going on about, when an npc has a lot off hp, the hp bar displayed in the top right corner showing npc health resets too around 60k, and repeats until you kill the NPC. It should display the full npc hp in 1 bar.

    Tried a few things and no results, I'll post the related code below, can anyone else figure it out? I'm sure it has something to do with the packet..

    The packet it's self

    Code:
    			case 207:
    				int flag = inStream.readUnsignedWord();// 1 player, 0 npc
    				int maxHealth = inStream.readUnsignedWord();
    				int currentHealth = inStream.readUnsignedWord();
    				int Max = inStream.readUnsignedWord();
    				int Current = inStream.readUnsignedWord();
    
    				currentEntityHealth = currentHealth;
    				maximumEntityHealth = maxHealth;
    				
    				MaxHealth = Max;
    				CurrentHealth = Current;
    
    				RSInterface entityInterface = RSInterface.interfaceCache[41020];
    				//RSInterface entityInterface = RSInterface.interfaceCache[7799];
    				if (!getOption("constitution")) {
    					entityInterface.message = currentHealth/10 + " / " + maxHealth/10;
    				} else {
    					entityInterface.message = currentHealth + " / " + maxHealth;
    				}
    				
    
    				opCode = -1;
    				return true;

    The code that sends the packets too the client I believe

    Code:
        /**
         * Sends the combat/entity information required to redraw the interface
         * @param flag - player flag, 1 = player, 0 = npc
         * @param maxHealth - maximum health of entity
         * @param currentHealth - current health of entity
         * @return 
         */
        public PacketSender sendEntityInterface(int flag, int maxHealth, int currentHealth, String entityName) {
            PacketBuilder out = new PacketBuilder(207);
            out.putShort(flag);
            out.putShort(maxHealth);
            out.putShort(currentHealth);
            player.getSession().queueMessage(out);
            sendEntityName(entityName);
            player.sendParallellInterfaceVisibility(41020, true);
            return this;
            
        }

    The method which calculates what data needs to be sent, correct me if I'm wrong..

    Code:
        public void handleEntityInterface(Character attacker, Character victim, int damage) {
            if (attacker.isPlayer()) {
                Player p = (Player) attacker;
                
                if (victim.isPlayer()) {//plrs
                    Player v = (Player) victim;
                    int maximumHealth = v.getSkillManager().getMaxLevel(Skill.CONSTITUTION);
                    int currentHealth = v.getSkillManager().getCurrentLevel(Skill.CONSTITUTION);
                    String entityName = v.getUsername();
                    p.getPacketSender().sendEntityInterface(victim.isPlayer() ? 1 : 0, maximumHealth, currentHealth, entityName);
                } else if (victim.isNpc()) {//npcs
                    NPC v = (NPC) victim;
                    int maximumHealth = v.getDefaultConstitution();
                    int currentHealth = v.getConstitution();
                    int id = v.getId();
                    NpcDefinition definition = NpcDefinition.forId(id);
                    int maxhp = definition.getHitpoints();
                    String entityName = v.getDefinition().getName();
                    p.getPacketSender().sendEntityInterface(victim.isPlayer() ? 1 : 0, maxhp, currentHealth, entityName);
                }
            }
        }

    The interface it's self.. Don't think it has anything to do with this

    Code:
            public static void entityInterface(TextDrawingArea wid[]) {
                RSInterface tab = addInterface(41020);
    
                addTransparentSpriteWSpriteLoader(41021, 947, 150);
                addText(41022, " ", wid, 1, 0xffffff, true, true);
    
                tab.message = " ";
                tab.x = 2;
                tab.y = 9;
                tab.children(2);
                tab.child(0, 41021, 0, 20);
                tab.child(1, 41022, 63, 22);                 
            }
    If you want you can contact me on discord @ Ab#3264

    Been trying to fix this on and off for the past 3 days. The code I posted is in original state, I've tried too manually set the NPC HP in the code too display too.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jun 2019
    Posts
    57
    Thanks given
    18
    Thanks received
    11
    Rep Power
    17
    Can you show an image or gif.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Sep 2018
    Posts
    35
    Thanks given
    13
    Thanks received
    12
    Rep Power
    12
    Pretty known issue with some Ruse bases.
    If I recall correctly on how to patch this, You need to change the data being sent from a short to something else that can contain more data.

    Change maxHealth and currentHealth from putShort to a different data type. Do not edit Flag.
    Code:
            out.putShort(flag);
            out.putShort(maxHealth);
            out.putShort(currentHealth);
    And whatever you change in the server, Change these ones client sided to reflect the new data types your sending
    Code:
    				int flag = inStream.readUnsignedWord();// 1 player, 0 npc
    				int maxHealth = inStream.readUnsignedWord();
    				int currentHealth = inStream.readUnsignedWord();
    				int Max = inStream.readUnsignedWord();
    				int Current = inStream.readUnsignedWord();
    If you need any more help after this, Feel free to message me on here and I'll reply asap.
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member
    Join Date
    Jun 2013
    Posts
    335
    Thanks given
    57
    Thanks received
    23
    Rep Power
    13
    Quote Originally Posted by Sado View Post
    Pretty known issue with some Ruse bases.
    If I recall correctly on how to patch this, You need to change the data being sent from a short to something else that can contain more data.

    Change maxHealth and currentHealth from putShort to a different data type. Do not edit Flag.
    Code:
            out.putShort(flag);
            out.putShort(maxHealth);
            out.putShort(currentHealth);
    And whatever you change in the server, Change these ones client sided to reflect the new data types your sending
    Code:
    				int flag = inStream.readUnsignedWord();// 1 player, 0 npc
    				int maxHealth = inStream.readUnsignedWord();
    				int currentHealth = inStream.readUnsignedWord();
    				int Max = inStream.readUnsignedWord();
    				int Current = inStream.readUnsignedWord();
    If you need any more help after this, Feel free to message me on here and I'll reply asap.

    I had a feeling it would be to do with that, I'll have a look thank you, was hoping I wouldn't have too touch these bits but life moves on


    Changed them too out.putInt(), however I have no idea what method client sided is able to read this.
    Reply With Quote  
     

  6. #5  
    Donator
    xWolfy's Avatar
    Join Date
    Sep 2011
    Posts
    104
    Thanks given
    9
    Thanks received
    4
    Rep Power
    28
    Nevermind
    Last edited by xWolfy; 07-12-2019 at 08:31 PM.
    Reply With Quote  
     

  7. #6  
    Donator
    xWolfy's Avatar
    Join Date
    Sep 2011
    Posts
    104
    Thanks given
    9
    Thanks received
    4
    Rep Power
    28
    Could use some help with this been trying a few thing but couldn't get it to work. Whatever I try I get errors or the npc doesn't show a bar at all lol. Don't Kno how I managed that one.. any help would be appreciated
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 12-22-2015, 03:53 AM
  2. Health bar Issue
    By Gnakos in forum Help
    Replies: 0
    Last Post: 02-08-2012, 07:20 PM
  3. Replies: 0
    Last Post: 12-15-2011, 12:40 AM
  4. npc hp bar issue?
    By Coder Miner in forum Help
    Replies: 1
    Last Post: 03-26-2011, 05:47 AM
  5. Npc Bundle 2 (Issue four)
    By Bobster in forum Tutorials
    Replies: 14
    Last Post: 01-03-2008, 04:28 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
  •