Thread: [838 Matrix] In combat render emote

Results 1 to 5 of 5
  1. #1 [838 Matrix] In combat render emote 
    Registered Member
    Join Date
    May 2015
    Posts
    13
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Hi, I've currently got it so that I check if a player is in combat:
    Code:
    public boolean inCombat() {
    		if (player.getAttackedByDelay() + 10000 > Utils.currentTimeMillis()) {
    			return true;
    		} else {
    			return false;
    		}
    	}
    Then I check if the player is in combat in appearance and it changes the render emote, it all works great except I have to manually refresh the render emote. What I'm asking is, is there a way that I can automatically refresh the render emote when someone goes in and out of combat?

    This is what it looks like atm

    Thanks in advance.
    Reply With Quote  
     

  2. #2  
    Reverse Engineering

    freeezr's Avatar
    Join Date
    Dec 2011
    Posts
    1,067
    Thanks given
    288
    Thanks received
    444
    Rep Power
    401
    i guess add a listener for render emote changes, and when the listener detects a change, it refreshes the appearance

    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    May 2015
    Posts
    13
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Im Frizzy View Post
    i guess add a listener for render emote changes, and when the listener detects a change, it refreshes the appearance
    Thank you, but I'm not quite sure what one of those is. I've looked it up and this is what I've come up with:
    private Object remote;
    private int oldRE;
    Code:
    synchronized(remote) {
    				    try {
    				    	remote.wait();
    				    } catch (InterruptedException e) {
    				    	player.getAppearence().generateAppearenceData();
    				    	oldRE = player.getAppearence().getRenderEmote();
    				    }
    				}
    				
    if (player.getAppearence().getRenderEmote() != oldRE) {//I believe I put this somewhere else
    			synchronized(remote) {
    			remote.notify();
    			}
    		}
    Would that work, if so where could I put it so that it's used? Thanks again, sorry if it's obvious.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Sep 2013
    Posts
    70
    Thanks given
    23
    Thanks received
    46
    Rep Power
    6
    Think simple & be careful where and how you use synchronized blocks.
    Do something like this inside of your Player class:
    Code:
            private boolean inCombat;
            
            private void checkCombat() {
                boolean inCombat = getAttackDelay() + 10000 > Utils.currentTimeMillis();
                if(this.inCombat == inCombat) {
                    /**
                     * Already set.
                     */
                    return;
                }
                if(inCombat) {
                    /**
                     * Being attacked.
                     */
                    appearance.setRenderId(combatRenderId);
                } else {
                    /**
                     * No longer being attacked.
                     */
                    appearance.setRenderId(defaultRenderId);
                }
                this.inCombat = inCombat;
            }
            
            public boolean inCombat() {
                return inCombat;
            }
    and put method checkCombat() inside of Player.process()
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    May 2015
    Posts
    13
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Archon View Post
    Think simple & be careful where and how you use synchronized blocks.
    Thanks very much it worked , and thanks for the advice, I'm not sure I'll be using synchronized blocks too much; really don't know what they do...
    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: 2
    Last Post: 05-18-2015, 06:16 AM
  2. Disable Teleporting in combat
    By Pj then Pk in forum Requests
    Replies: 7
    Last Post: 02-19-2009, 07:05 PM
  3. Using Grahams Event Manager in Combat.
    By DefNotVastico in forum Tutorials
    Replies: 10
    Last Post: 02-03-2009, 02:53 PM
  4. Replies: 21
    Last Post: 01-20-2009, 07:42 AM
  5. NPC's face you in combat!
    By Pkitten in forum Tutorials
    Replies: 73
    Last Post: 11-28-2008, 05:36 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
  •