Thread: [TUT]Working Mage Bonuses + Splashing.

Results 1 to 9 of 9
  1. #1 [TUT]Working Mage Bonuses + Splashing. 
    Registered Member
    Naughty Panda's Avatar
    Join Date
    Dec 2007
    Posts
    631
    Thanks given
    12
    Thanks received
    46
    Rep Power
    347
    (H)Something I found rather funny...

    [Only registered and activated users can see links. ]

    I think people might know how to add npc drops by now?

    BEFORE PEOPLE SAY "OMG LEECHED," I MADE THIS TUTORIAL BASED ON ANOTHER TUTORIAL WHICH TAUGHT WORKING DEFENCE BONUSES. I SIMPLY EDITED IT TO MAGIC BONUSES TO HELP OTHERS, THEREFORE 80% CREDIT TO WHOEVER WROTE THAT FOR THE IDEA

    Purpose: To add working magic attack and defence bonuses to your server, as well as splashing.

    Difficulty: However hard you make it... 3/10?

    Assumed Knowledge: Understanding of booleans and what they do and how to edit them. How to declare a boolean to return a true or false statement.

    Server Base: Jukks Cleaned V3

    Classes Modified: client.java

    Procedure

    Step One:
    So first things first, make the boolean.

    Code:
    public boolean HitMage(int lal) {
    	  if(server.playerHandler.players[lal] == null) {
    	  		  return false;
    	  }
    	  client Target = (client) server.playerHandler.players[lal];
    	  int magzDef = Target.playerBonus[8];
    	  int loldef = 0;
    	  int magy = 0;
    	  if(magzDef > 0) {
    	 loldef = ((magzDef/2) + (playerLevel[0]/4));
      }
      if(magzDef < 1) {
    	  loldef = ((magzDef) + (playerLevel[0]/4));
      }
      int magB = playerBonus[3];
      if(magB > 0) {
    	  magy = playerBonus[3] + playerLevel[6];
      }
      if(magB < 1) {
    	  magy = (playerBonus[3]*2)+playerLevel[6];
      }
    		if(misc.random(magy) > misc.random(loldef)) {
    			return true;
    		}
    		return false;
    	}
    Basically that boolean works out whether or not you hit, judging by your magic attack bonus and your opponents magic defence bonus. "magzDef," excusing my silly variable names, is your opponents magic defence bonuses, which can be edited in order to make splashing more or less likely. At the moment the defence is determined by half of your opponents defence bonus plus one quarter of their defence level if their bonus is greater than 0, and simply their defence bonus plus one quarter of their defence level is their bonus is less than 0.

    But I suppose most of you will understand that by the code.

    The boolean then determines your magic attack bonus, and if a random number between 0 and your max bonus, is greater than a random number between 0 and their max bonus, then the boolean returns true, and you therefore hit. On the other hand if it less than your opponents bonus, the boolean returns false, which is when splashing occurs.

    Okay, thats pretty much just explaining for the sake of not being a "C&P" tutorial and an attempt to prove I do actually understand the code :woot:.

    Step Two: (OPTIONAL)
    Now, if your server is advanced enough to have working prayers (despite that xx nub xx has just released them...) then you can also add this:

    Code:
     if(Target.defLow) {
    	  	  			loldef += (Target.playerLevel[1]/10);
    	  	  		}
    	  	  		if(Target.defMid) {
    	  	  			loldef += (Target.playerLevel[1]/7);
    	  	  		}
    	  	  		if(Target.defHigh) {
    	  	  			loldef += (Target.playerLevel[1]/4);
    		}
    Somewhere in the boolean. Which basically adds to your opponents defence is they are using a defence prayer.

    Step Three:
    Now all you have to do, is call this boolean in order to check whether you splash when attacking your opponent. To save time adding it to every spell, declare this boolean:

    Code:
    public boolean splash = false;
    Step Four:
    Now somewhere within your magic attack void... usually:

    Code:
    public void AttackMage(int index) {
    Add this code:

    Code:
    if(HitMage(index)) {
    	splash = false;
    }
    else if (!HitMage(index)) {
    	splash = true;
    }
    So, if the boolean returns false, you splash, if not, you hit.

    Now, theres two ways you can go about this, the lazy route, or the more realistic route.

    Lazy Route

    Step Five:
    Find near the bottom something similar to:

    Code:
    castOnPlayer.hitDiff = hitDiff;
    And replace it with this code:

    Code:
    if(splash == false) {
    					castOnPlayer.hitDiff = hitDiff;
    				}
    				else if(splash == true) {
    					castOnPlayer.hitDiff = 0;
    					stillgfx(85, EnemyY, EnemyX);
    				}
    Which basically makes you hit 0 if you splash, but will still play the graphic of the spell hitting as well as the splashing graphic.

    The More Realistic Route
    Ok, this one will take alot more time, for those who are willing to put the effort in, can make your server more realistic.

    Step Five:
    For EVERY spell find:
    Code:
    hitDiff = (whatever)
    and replace it with:

    Code:
    if(splash == false) {
    								hitDiff = (whatever)
    								stillgfx(###, absY, absX);
    								stillgfx(###, EnemyY, EnemyX);
    							}
    							else if(splash == true) {
    								hitDiff = 0;
    								stillgfx(85, EnemyY, EnemyX);
    		}
    This will then play ONLY the splash graphic if you fail and hit a 0.
    Also note, that if the spell freezes your opponent, you will have to replace your

    Step Six: (Optional, for certain spells)
    Code:
    castOnPlayer.uberEntangle();
    With:

    Code:
    if(splash == false) {
    castOnPlayer.uberEntangle();
    }
    Which basically, only freezes the enemy if you do not splash.

    Well sorry if its a bit hard to understand, but I wanted to explain it as fully as possible. Cheers and enjoy.
     

  2. #2  
    Registered Member
    hoodlom's Avatar
    Join Date
    Dec 2007
    Age
    26
    Posts
    750
    Thanks given
    0
    Thanks received
    6
    Rep Power
    170
    nice tut, rep for you
    [Only registered and activated users can see links. ]
     

  3. #3  
    Banned

    Join Date
    Jan 2008
    Posts
    1,778
    Thanks given
    0
    Thanks received
    7
    Rep Power
    0
    I have something like this.. only my splashes if ur mage bonus fals under 5+ and if u fail hitting
     

  4. #4  
    Registered Member
    Naughty Panda's Avatar
    Join Date
    Dec 2007
    Posts
    631
    Thanks given
    12
    Thanks received
    46
    Rep Power
    347
    Quote Originally Posted by Callled Enzo View Post
    I have something like this.. only my splashes if ur mage bonus fals under 5+ and if u fail hitting
    Thats a cool idea, but mine is more similar to RS as you still have a chance, even if only slight of hitting with a very low magic bonus, and even a chance to splash with a high magic bonus... And my code also involves the other players defence & bonuses.
     

  5. #5  
    Damonsz
    Guest
    Nicely done.
     

  6. #6  
    Well, aren't you clever!

    Concious's Avatar
    Join Date
    Feb 2008
    Posts
    1,697
    Thanks given
    27
    Thanks received
    60
    Rep Power
    195
    Nice, Ty.
    ms2s
     

  7. #7  
    Lachlin
    Guest
    Nice work, Perhaps you should make it a little more N00B friendly? Bit more detailed
     

  8. #8  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Nice :O might replace my formula with yours, looks better :O

    [Only registered and activated users can see links. ]



     

  9. #9  
    ernisx
    Guest
    Pretty nice .
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •