Welcome to Jc - Scape!

Please log-in if you already have a JCscape forum account,

If you don't, please register!

Best regards, JCscape staff.
Welcome to Jc - Scape!

Please log-in if you already have a JCscape forum account,

If you don't, please register!

Best regards, JCscape staff.
Would you like to react to this message? Create an account in a few clicks or log in to continue.


.
 
HomeHome  Portal*Portal*  GalleryGallery  SearchSearch  Latest imagesLatest images  RegisterRegister  Log inLog in  
Navigation
 Index
 FinalX
 Server Status
Who is online
In total there are 4 users online :: 0 Registered, 0 Hidden and 4 Guests

None

Most users ever online was 167 on Mon May 18, 2009 10:33 pm
Top posters
♫ Steven ♫ (1243)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Jamie (1112)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Norway (1110)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Immense Jelly <3 Obliv (1072)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Mod Robbie (984)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
J A M I E (832)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Oblivious (780)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
Disturb3d (760)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
ErenGurkan ツ (740)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 
James (710)
Improving Fishing I_vote_lcapImproving Fishing I_voting_barImproving Fishing I_vote_rcap 

Advert

Interested to advertise at jcscape.org? Contact Evanna@graphicscene.net

 

Improving Fishing

View previous topic View next topic Go down 
Author Message
The Soul
Moderator
Moderator
The Soul

Number of posts : 8
Points :
Improving Fishing Left_bar_bleue0 / 1000 / 100Improving Fishing Right_bar_bleue

Registration date : 2009-12-31

Improving Fishing Vide
PostSubject: Improving Fishing   Improving Fishing EmptyThu Dec 31, 2009 12:57 am

Although very simple, this should improve your 'fishing system' on DeltaScape / Devolution derived servers.
All explanations are done within the code tags.

We'll need to start off with importing this class:
Code:
import java.util.Random;

Add this method:
Code:
   public boolean randomFishTries(int fishID) {
      Random rand = new Random(); // creates new instance of Random class
         switch(fishID) { // creates switch statement using parameter variable 'fishID'
            case 316: // if the variable 'fishID' in the parameter is equal to '316', then it will carry out the action below
               if(playerLevel[playerFishing] > 0 && playerLevel[playerFishing] < 21) { // checks if fishing level is greater than 0 and less than 21
                  fishTries = rand.nextInt(18); // takes the instance of the Random class, 'rand', and sets it at a range of 18 (it will take 0-18 tries to fish something); this is assigned to the fishTries variable
               }
               if(playerLevel[playerFishing] > 20 && playerLevel[playerFishing] < 46) { // checks if fishing level is greater than 20 and less than 46
                  fishTries = rand.nextInt(14); // takes the instance of the Random class, 'rand', and sets it at a range of 14 (it will take 0-14 tries to fish something); this is assigned to the fishTries variable
               }
               if(playerLevel[playerFishing] > 45 && playerLevel[playerFishing] < 71) { // checks if fishing level is greater than 45 and less than 71
                  fishTries = rand.nextInt(11); // takes the instance of the Random class, 'rand', and sets it at a range of 11 (it will take 0-11 tries to fish something); this is assigned to the fishTries variable

               }
               if(playerLevel[playerFishing] > 70 && playerLevel[playerFishing] < 94) { // checks if fishing level is greater than 70 and less than 94
                  fishTries = rand.nextInt(7); // takes the instance of the Random class, 'rand', and sets it at a range of 7 (it will take 0-7 tries to fish something); this is assigned to the fishTries variable
               }
               if(playerLevel[playerFishing] > 93 && playerLevel[playerFishing] < 100) { // checks if fishing level is greater than 93 and less than 100
                  fishTries = rand.nextInt(4); // takes the instance of the Random class, 'rand', and sets it at a range of 4 (it will take 0-4 tries to fish something); this is assigned to the fishTries variable
               }
               break;
         }
      return true;
   }

You'll have to add the random fish tries for the rest of the fish, though.

In the startFishing() method, under the switch statement, under the case label that has the ID of '316', add:
Code:
randomFishTries(316);

Add this method:
Code:
public void fishAdd(int fishID) {
   int exp = 0; // declaration of 'exp' variable
   switch(fishID) { //creates switch statement for the fishID parameter variable
      case 317:
         exp = 80; // sets the variable 'exp' to 80
         sendMessage("You catch some " + getItemName(fishID)); // returns a message
         addItem(317, 1); // adds the item               
         addSkillXP(exp, playerFishing); // adds the experience
         randomFishTries(316); // sets fishTries var to a random number depending on your level once again
   }
}

Replace your fish() method with the below:
Code:
public void fish(int id) {
   if (!playerHasItem(-1)) {
         resetAction(true);
   }
   if(fishTries > 0) // checks if var fishTries is greater than 0, and if so, it'll decrease
      fishTries--;         
   required = -1;
   switch (fishId) {
      case 317:
         if(fishTries == 0) { // checks if var fishTries is equal to 0
            fishAdd(317); // invokes the fishAdd method, '317' corresponds with the case label in the switch statement in that method, so it will carry out that action.
         }
         break;
   }
}
Back to top Go down

Improving Fishing

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum: You cannot reply to topics in this forum
 :: Main Rsps :: Tutorial's / Config's Ect. -