Thread: Coding question RS2HD 562

Results 1 to 4 of 4
  1. #1 Coding question RS2HD 562 
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Sup guys! I know the basics with Java, however i'm stuck right now I can't figure out how to type and code what I have in mind lol.

    So let me explain quickly, I am editing ways to train Dungeoneering. I did arrays to separate npcs. I'll use Bathusfor example.

    Code:
    // This list contains ids of Bathus NPCs
    final int BathusList[] = {10418,	10419,	10420,	10421,	10422,	10423};
    
    // My whole function isn't there, but this code is located in NPC.java after "public void npcDied(Player p, int npcID) ", so you know where the npcID come from.
    
    for (int i = 0; i < BathusList.length; i++) {
    	if (npcID == BathusList[i]) {
    		p.DungTokens += 20;
    		p.getSkills().addXp(Skills.DUNGEONEERING, 1);
    		p.sm("You have defeated a Bathus Forggoten Warrior and gained 20 Tokens.");
    		return;
    	}
    }
    Is there a way to make BathusList[] Return the XP gained and the number of "DungTokens" from each kill?

    I'd like to do it another way than using a "Switch(npcID)" with cases for every npc, because it takes so much space and don't like it lol.

    If you miss some infos or need me to explain myself another way, let me know I'd really appreciate your help guys!

    Thanks in advance,
    Alex
    Currently working on my 562/659 Server project! Server will probably be online soon
    Reply With Quote  
     

  2. #2  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Addict View Post
    Sup guys! I know the basics with Java, however i'm stuck right now I can't figure out how to type and code what I have in mind lol.

    So let me explain quickly, I am editing ways to train Dungeoneering. I did arrays to separate npcs. I'll use Bathusfor example.

    Code:
    // This list contains ids of Bathus NPCs
    final int BathusList[] = {10418,	10419,	10420,	10421,	10422,	10423};
    
    // My whole function isn't there, but this code is located in NPC.java after "public void npcDied(Player p, int npcID) ", so you know where the npcID come from.
    
    for (int i = 0; i < BathusList.length; i++) {
    	if (npcID == BathusList[i]) {
    		p.DungTokens += 20;
    		p.getSkills().addXp(Skills.DUNGEONEERING, 1);
    		p.sm("You have defeated a Bathus Forggoten Warrior and gained 20 Tokens.");
    		return;
    	}
    }
    Is there a way to make BathusList[] Return the XP gained and the number of "DungTokens" from each kill?

    I'd like to do it another way than using a "Switch(npcID)" with cases for every npc, because it takes so much space and don't like it lol.

    If you miss some infos or need me to explain myself another way, let me know I'd really appreciate your help guys!

    Thanks in advance,
    Alex
    Switch would be the easiest way to do what you're asking for. There isn't an magical ways that would be cleaner.
    Project thread
    Reply With Quote  
     

  3. #3  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,819
    Thanks received
    1,767
    Rep Power
    2438
    use an enum or a 2d array
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Nov 2012
    Age
    27
    Posts
    30
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by clem585 View Post
    Switch would be the easiest way to do what you're asking for. There isn't an magical ways that would be cleaner.
    Yeah I know, but switch are too common loll I'd like to learn other ways

    Quote Originally Posted by Tyluur View Post
    use an enum or a 2d array
    Could you explain a bit more? Or i'll find if I google
    Currently working on my 562/659 Server project! Server will probably be online soon
    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. rs2hd 562 Help please rep!
    By Propane in forum Help
    Replies: 3
    Last Post: 11-15-2009, 04:24 AM
  2. rs2hd 562 updated.
    By _slam in forum Downloads
    Replies: 26
    Last Post: 10-28-2009, 07:31 PM
  3. [Rs2hd][562]NpcCombat Files
    By Sir Tom in forum Snippets
    Replies: 10
    Last Post: 10-24-2009, 06:13 PM
  4. Replies: 7
    Last Post: 07-16-2009, 04:39 PM
  5. Coding Question
    By coolguyon in forum Help
    Replies: 0
    Last Post: 04-27-2009, 03:36 AM
Tags for this Thread

View Tag Cloud

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