Thread: Diagonal Combat Fix

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Diagonal Combat Fix 
    WhiteDownMb | HYBRID JEFE

    Join Date
    Dec 2009
    Posts
    1,873
    Thanks given
    269
    Thanks received
    395
    Rep Power
    1276
    Not sure if this has been released, was cleaning up my PC and remember I had it on my 718 when not many did....

    IF this has been released before feel free to take this down I haven't touched this for 4 years but for those who might need it here ya go, quit 718 and won't be returning back to that revision maybe 667. Good day.

    If you're in hybrid fight and got your opponent frozen and side step him he cannot attack you with melee, only mage (Like rs). As well if you're both frozen diagonally you cannot melee only mage or range.


    Place this in your CheckAll method in PlayerCombat class

    Code:
    if (player.getFreezeDelay() >= Utils.currentTimeMillis()) {
       if (isRanging(player) == 0 && player.getCombatDefinitions().getSpellId() <= 0 && size == 1)
                    if (target.getX() == player.getX()+1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()-1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()+1 && target.getY() == player.getY()-1)
                        return false;
      }
    Last edited by Brett the Don; 01-31-2019 at 03:30 AM.

    All of humanity's problems stem from man's
    inability to sit quietly in a room by himself

    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Junior Programmer

    Stoked's Avatar
    Join Date
    Apr 2012
    Age
    20
    Posts
    3,668
    Thanks given
    436
    Thanks received
    441
    Rep Power
    180
    [Only registered and activated users can see links. ]

    I'm pretty sure this works too,

    Code:
    		if (player.getFreezeDelay() >= Utils.currentTimeMillis()) {
    			if (player.withinDistance(target, 0))
    				return false;
    			return true;
    		}
    But i guess thanks for the share?
    Spoiler for sig too large:


    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #3  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    21
    Posts
    3,404
    Thanks given
    563
    Thanks received
    2,044
    Rep Power
    2811
    Quote Originally Posted by Stoked View Post
    [Only registered and activated users can see links. ]

    I'm pretty sure this works too,

    Code:
    		if (player.getFreezeDelay() >= Utils.currentTimeMillis()) {
    			if (player.withinDistance(target, 0))
    				return false;
    			return true;
    		}
    But i guess thanks for the share?
    Yours won't work. It'll block combat entirely, not just diagonally.

    As for OP - the way yours is, is actually a little incorrect. Diagonal combat blocking does not only apply to size-1 monsters. It applies to everything.
    As for the code, local variables would not only clean the code up a lot, but also apply a micro-optimization.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     

  5. Thankful users:


  6. #4  
    Registered Member
    Join Date
    May 2016
    Posts
    383
    Thanks given
    52
    Thanks received
    30
    Rep Power
    29
    That exact code has been released here years ago by _Dennis
    donald trump approves this message
    Reply With Quote  
     

  7. #5  
    Registered Member
    Teemuzz's Avatar
    Join Date
    Oct 2009
    Posts
    2,700
    Thanks given
    1,122
    Thanks received
    396
    Rep Power
    701
    Blah blah take x delta and y delta or difference in other words
    If yDelta==0 & xDelta ==1||xDelta ==-1
    And the other way around then you don't need a million comparisons

    Not trying to turn you down just to say that there is an easier way for the future
    I'm back.
    ScapeEmulator #592 Convert [Only registered and activated users can see links. ]/[Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. Thankful user:


  9. #6  
    WhiteDownMb | HYBRID JEFE

    Join Date
    Dec 2009
    Posts
    1,873
    Thanks given
    269
    Thanks received
    395
    Rep Power
    1276
    Quote Originally Posted by Java100 View Post
    That exact code has been released here years ago by _Dennis
    He got it from my source so it was mine to begin with.

    All of humanity's problems stem from man's
    inability to sit quietly in a room by himself

    Reply With Quote  
     

  10. #7  
    Registered Member
    Join Date
    Dec 2016
    Posts
    81
    Thanks given
    8
    Thanks received
    25
    Rep Power
    61
    Quote Originally Posted by Brett the Don View Post
    Not sure if this has been released, was cleaning up my PC and remember I had it on my 718 when not many did....

    IF this has been released before feel free to take this down I haven't touched this for 4 years but for those who might need it here ya go, quit 718 and won't be returning back to that revision maybe 667. Good day.

    If you're in hybrid fight and got your opponent frozen and side step him he cannot attack you with melee, only mage (Like rs). As well if you're both frozen diagonally you cannot melee only mage or range.


    Place this in your CheckAll method in PlayerCombat class

    Code:
    if (player.getFreezeDelay() >= Utils.currentTimeMillis()) {
       if (isRanging(player) == 0 && player.getCombatDefinitions().getSpellId() <= 0 && size == 1)
                    if (target.getX() == player.getX()+1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()-1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()+1 && target.getY() == player.getY()-1)
                        return false;
      }
    Thanks the for the release, but why opt for listing all cases and not just go for
    Code:
    if((Math.pow(target.getX() - player.getX(), 2) + Math.pow(target.getY() - player.getY(), 2)) <= 2 && (Math.pow(target.getX() - player.getX(), 2) + Math.pow(target.getY() - player.getY(), 2)) > 1){  }
    instead of:
    Code:
    if (target.getX() == player.getX()+1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()-1
                        || target.getX() == player.getX()-1 && target.getY() == player.getY()+1
                        || target.getX() == player.getX()+1 && target.getY() == player.getY()-1)
    I'm not sure if there is any particular reason (like more efficient idk)
    Reply With Quote  
     


  11. #8  
    Somewhere in the Mojave desert...
    EnlistedGhost's Avatar
    Join Date
    Nov 2015
    Age
    26
    Posts
    26
    Thanks given
    41
    Thanks received
    7
    Rep Power
    56
    Used this in my server as well just now, thank you very much you guys

    Both to the OP and the comments on how to further improve upon it.
    Reply With Quote  
     

  12. Thankful user:


  13. #9  
    Registered Member
    Join Date
    May 2017
    Posts
    64
    Thanks given
    15
    Thanks received
    28
    Rep Power
    51
    Code:
     if (Math.abs(dx) == 1 && Math.abs(dy) == 1) return false;
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  14. #10  
    Textures developer

    Kris's Avatar
    Join Date
    Jun 2016
    Age
    21
    Posts
    3,404
    Thanks given
    563
    Thanks received
    2,044
    Rep Power
    2811
    Quote Originally Posted by Dragonsevery View Post
    Code:
     if (Math.abs(dx) == 1 || Math.abs(dy) == 1) return false;
    That ain't it chief.
    Spoiler for sig too large:

    [Only registered and activated users can see links. ]

    Discord: Kris#1337
    Reply With Quote  
     

  15. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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

Similar Threads

  1. Diagonal combat fix - Project Insanity
    By Rhubarb in forum Snippets
    Replies: 22
    Last Post: 05-25-2014, 04:53 PM
  2. Dementhium 637 diagonal combat fix
    By Simmo in forum Snippets
    Replies: 0
    Last Post: 11-10-2013, 10:52 PM
  3. Diagonal Combat fix ?
    By -Andreas in forum Help
    Replies: 2
    Last Post: 02-26-2013, 06:51 PM
  4. Sell 614 Diagonal Combat Fix
    By bracket in forum Selling
    Replies: 1
    Last Post: 05-22-2012, 03:44 PM
  5. [Dementhium] Diagonal Combat Fix (Working)
    By EvanFaise in forum Help
    Replies: 10
    Last Post: 01-25-2012, 06:29 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •