[Help] Occupation

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    [Help] Occupation

    I just need to know why my code won't work. I'm trying to give an occupation (Korean Gamer) more occupation EXP rate per occupation level. He will get +50 EXP rate every occupation level. I'm almost 100% positive my code is supposed to work but doesn't.

    PHP Code:
    public double getExpRate(MapleCharacter player) {
            
    int oriExp WorldConstants.Servers.Scania.getExp();
            switch (
    occupid) {
                case 
    0:
                    return (int) 
    oriExp player.getExpBoost();
                case 
    1:
                    return (int) 
    oriExp 2.5 getExpModByKoreanGamer(player); 
    PHP Code:
    public static double getExpModByKoreanGamer(MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            
    double occuexp chr.getOccupation().getExpRate(chr);
            if (
    level >= 1) {
                
    occuexp += 50;
            } else if (
    level >= 2) {
                
    occuexp += 50;
            }
            return 
    occuexp;
        } 
    I only did two levels for debugging purposes. I'm almost sure this is supposed to work and the occupation's EXP rate is supposed to add +50 to it's current EXP rate per rebirth. Any idea as to what's going on?


  2. #2
    I'm overrated. Fraysa is offline
    MemberRank
    Apr 2008 Join Date
    4,891Posts

    Re: [Help] Occupation

    How doesn't this work? Can you explain what happens? Also, why are you returning double on the getExpRate by casting everything as int?...

  3. #3
    Member Drum is offline
    MemberRank
    Jul 2013 Join Date
    80Posts

    Re: [Help] Occupation

    I agree, why are you casting?

    Also, instead of doing multiple checks, you could use their occupation level as a counter for the amount of times to add + 50 EXP.

    PHP Code:
    for (int i 0chr.getOccupationLevel(); i++) {
        
    occuexp += 50;


  4. #4
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Quote Originally Posted by Fraysa View Post
    How doesn't this work? Can you explain what happens? Also, why are you returning double on the getExpRate by casting everything as int?...
    The only int that's cast is the occupation level? Isn't that how it's supposed to be called? That's how I coded some occupation skills + features and they work 100% fine. I would really appreciate it if you could point out what's wrong and help me improve ^.^.
    Anyway the problem that occurs is that whenever I use my method and use "@checkme" to check my stats my EXP rate does not show meaning my character is bugged (using Netbeans java hotfix so i am running server in Netbeans fyi) which is odd.
    http://imgur.com/QsETMGX
    It doesn't show any of my rates or anything else upon using my method which should seem to work. But when I use another method to try and modify my exp rate is works just fine?
    http://imgur.com/2XklFI5

    - - - Updated - - -

    Quote Originally Posted by Drum View Post
    I agree, why are you casting?

    Also, instead of doing multiple checks, you could use their occupation level as a counter for the amount of times to add + 50 EXP.

    PHP Code:
    for (int i 0chr.getOccupationLevel(); i++) {
        
    occuexp += 50;

    I did not know that. Thank you very much. I will use your way which seems easier, cleaner, and looks efficient!

    - - - Updated - - -

    Edit: Got it working now for some dumb ass reason. Did the same exact method and it didn't work yesterday and it works now... Thanks for the tip and help guys +1. Thanks for teaching me a shorter way too, Drum! @Drum

    PHP Code:
    public static double getExpModByGamer(MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            
    double occuexp 0;
            for (
    int i 0leveli++) {
                
    occuexp += 50;
            }
            return 
    occuexp;
        } 
    This is what the finished version looks like.

  5. #5
    Account Upgraded | Title Enabled! NemesisToKill is offline
    MemberRank
    Nov 2009 Join Date
    874Posts

    Re: [Help] Occupation

    PHP Code:
    double occuexp chr.getOccupationLevel() * 50
    ?

  6. #6
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Another nice method ^.^.

    - - - Updated - - -

    Don't mean to spam this thread with useless posts, but i'm a little confused as to why this won't work? It was working fine yesterday when I was in a party but when i'm alone it throws null errors.

    PHP Code:
    public static double getSexyManPtyRates(final MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            final 
    int pty chr.getParty().getMembers().size();
            
    double sessi 0;
            if (
    chr.getParty().isDisbanded()) {
                
    leppy += 0;
            }
            if (
    level == && pty >= 1) {
                
    leppy += 50 2;
            }
            return 
    leppy;
        } 
    Last edited by BestSiteEvar; 12-02-14 at 02:10 AM.

  7. #7
    I'm overrated. Fraysa is offline
    MemberRank
    Apr 2008 Join Date
    4,891Posts

    Re: [Help] Occupation

    Quote Originally Posted by BestSiteEvar View Post
    Another nice method ^.^.

    - - - Updated - - -

    Don't mean to spam this thread with useless posts, but i'm a little confused as to why this won't work? It was working fine yesterday when I was in a party but when i'm alone it throws null errors.

    PHP Code:
    public static double getSexyManPtyRates(final MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            final 
    int pty chr.getParty().getMembers().size();
            
    double sessi 0;
            if (
    chr.getParty().isDisbanded()) {
                
    leppy += 0;
            }
            if (
    level == && pty >= 1) {
                
    leppy += 50 2;
            }
            return 
    leppy;
        } 
    It throws null because pty variable is null because getParty() returns null twice (on the variable set and on the statement). To make it better, check if the character has a party and then do whatever.

    Code:
    if (chr.getParty() != null) {
            // code with a party.
    } else {
           // code for solo player.
    }

  8. #8
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Quote Originally Posted by Fraysa View Post
    It throws null because pty variable is null because getParty() returns null twice (on the variable set and on the statement). To make it better, check if the character has a party and then do whatever.

    Code:
    if (chr.getParty() != null) {
            // code with a party.
    } else {
           // code for solo player.
    }
    Thanks for the method, can't believe I didn't notice that before ROFL. Didn't even know I was throwing like 3 null point errors with a fail method. It works but only for single players, like only the occupation's ID I specified gets boosted rates but everyone else in the party doesn't O_O. I'm trying to make it whereas if the "sexyman occupation" is present within the party members or party leader everyone gets their exp rate boosted. But there's so many null's being thrown and stuff.

    PHP Code:
    public static double getSexyManRates(final MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            
    double rates 0;
            if (
    chr.getParty() != null && chr.getOccupation().getId() == && level == && chr.getParty().getLeader() == chr.getOccupation().getId()==6) {
                
    rates += 50 2;
            }
            return 
    rates;
        } 
    I'm trying to make this work but there are a shit load of errors.

  9. #9
    I'm overrated. Fraysa is offline
    MemberRank
    Apr 2008 Join Date
    4,891Posts

    Re: [Help] Occupation

    Quote Originally Posted by BestSiteEvar View Post
    Thanks for the method, can't believe I didn't notice that before ROFL. Didn't even know I was throwing like 3 null point errors with a fail method. It works but only for single players, like only the occupation's ID I specified gets boosted rates but everyone else in the party doesn't O_O. I'm trying to make it whereas if the "sexyman occupation" is present within the party members or party leader everyone gets their exp rate boosted. But there's so many null's being thrown and stuff.

    PHP Code:
    public static double getSexyManRates(final MapleCharacter chr) {
            final 
    int level chr.getOccupationLevel();
            
    double rates 0;
            if (
    chr.getParty() != null && chr.getOccupation().getId() == && level == && chr.getParty().getLeader() == chr.getOccupation().getId()==6) {
                
    rates += 50 2;
            }
            return 
    rates;
        } 
    I'm trying to make this work but there are a shit load of errors.
    Again, why make it return double if you're working with ints? Nevermind that. What are you exactly comparing? Imagine as if you're the computer. You're trying to compare the party's leader with a statement. That won't work.I'm guessing you want to compare the leader to check if it's the occupation character. Do it like so:

    Code:
    public static int getSexyManRates(final MapleCharacter chr) {
    	int level = chr.getOccupationLevel();
    	int rates = 0;
    	
    	if ((chr.getOccupation().getId() == 6) && (chr.getParty() != null) && (level == 1) && (chr.getParty().getLeader().equals(chr)))
    		rates += 50 * 2;
    		
    	return rates;
    }
    I'm hoping getLeader().equals will work in that case. You have to first check if it's a sexy man occupation (it's the identifier, you don't want to check for anything unless they're sexy man occupation. Then, you check if their party is null or not. If it's not, you check if their occupation level is 1 and lastly you compare their party leader to see if it's matching the sexy man. If it is, you add 100 to the rates. Else it will return 0).

  10. #10
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Quote Originally Posted by Fraysa View Post
    Again, why make it return double if you're working with ints? Nevermind that. What are you exactly comparing? Imagine as if you're the computer. You're trying to compare the party's leader with a statement. That won't work.I'm guessing you want to compare the leader to check if it's the occupation character. Do it like so:

    Code:
    public static int getSexyManRates(final MapleCharacter chr) {
    	int level = chr.getOccupationLevel();
    	int rates = 0;
    	
    	if ((chr.getOccupation().getId() == 6) && (chr.getParty() != null) && (level == 1) && (chr.getParty().getLeader().equals(chr)))
    		rates += 50 * 2;
    		
    	return rates;
    }
    I'm hoping getLeader().equals will work in that case. You have to first check if it's a sexy man occupation (it's the identifier, you don't want to check for anything unless they're sexy man occupation. Then, you check if their party is null or not. If it's not, you check if their occupation level is 1 and lastly you compare their party leader to see if it's matching the sexy man. If it is, you add 100 to the rates. Else it will return 0).
    I was hoping it would as well, considering I have been stuck on this 1 cool feature for a while. It didn't work but it didn't throw any errors so meh. It was incompatible sadly. I'm just trying to make it where if the sexyman occupation is present in the party or is the party leader everyone in the party has their occupation rates boosted. Excluding himself or himself as well, whichever is easier to code. Could you also tell me why returning double seems to be bad with ints?

  11. #11
    I'm overrated. Fraysa is offline
    MemberRank
    Apr 2008 Join Date
    4,891Posts

    Re: [Help] Occupation

    Quote Originally Posted by BestSiteEvar View Post
    I was hoping it would as well, considering I have been stuck on this 1 cool feature for a while. It didn't work but it didn't throw any errors so meh. It was incompatible sadly. I'm just trying to make it where if the sexyman occupation is present in the party or is the party leader everyone in the party has their occupation rates boosted. Excluding himself or himself as well, whichever is easier to code. Could you also tell me why returning double seems to be bad with ints?
    Well, you can add a property "isBoosted" party which will be true if you set the leader and the leader is a sexyman occupation, or add a property in MaplePartyCharacter, or make the comparsion better somehow (between MaplePartyCharacter and MapleCharacter). Anyways, it's not bad, it's just not the same datatype. If you need to return double - do it. If you need to return int - do it. This will just save you a cast. Example:

    Code:
    public static int getWhat() {
           return 5;
    }
    
    public static double getWhat() {
            return 5.2;
    }
    
    public static double getWhat() {
             int a = 5;
      
             return (double)a;
    }
    You have to cast everything to double if your method returns double, it's just a waste. Of course, if your code requires double, use it.

  12. #12
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Quote Originally Posted by Fraysa View Post
    Well, you can add a property "isBoosted" party which will be true if you set the leader and the leader is a sexyman occupation, or add a property in MaplePartyCharacter, or make the comparsion better somehow (between MaplePartyCharacter and MapleCharacter). Anyways, it's not bad, it's just not the same datatype. If you need to return double - do it. If you need to return int - do it. This will just save you a cast. Example:

    Code:
    public static int getWhat() {
           return 5;
    }
    
    public static double getWhat() {
            return 5.2;
    }
    
    public static double getWhat() {
             int a = 5;
      
             return (double)a;
    }
    You have to cast everything to double if your method returns double, it's just a waste. Of course, if your code requires double, use it.
    I see if it will be possible. For the property method I did add one. I added it to some of my occupations for debug. It still didn't seem to work.
    PHP Code:
    public double getExpRate(MapleCharacter player) {
            
    int oriExp WorldConstants.Servers.Scania.getExp();
            switch (
    occupid) {
                case 
    0:
                    return (int) 
    oriExp player.getExpBoost();
                case 
    1:
                    return (int) 
    oriExp 2.5 getSexyManRates(player) + getExpModByGamer(player) + player.getExpBoost();
                case 
    6:
                    return (int) 
    oriExp 1.0 getSexyManRates(player) + player.getExpBoost();
                default:
                    return (int) 
    oriExp player.getExpBoost();
            }
        } 
    Is there no other way around it or will I need to try and add a method? Even if it boosts everyone's rates by a bit and the sexyman is among the party and not the leader? Btw I will keep the doubles and int's method in mind, thank you.

  13. #13
    Account Upgraded | Title Enabled! StripedCow is offline
    MemberRank
    Jun 2011 Join Date
    813Posts

    Re: [Help] Occupation

    why default if case 0 is just like default

  14. #14
    Account Upgraded | Title Enabled! BestSiteEvar is offline
    MemberRank
    Sep 2010 Join Date
    513Posts

    Re: [Help] Occupation

    Quote Originally Posted by StripedCow View Post
    why default if case 0 is just like default
    Very true indeed. Did not spot that. Ty.

    So what i'm getting from this thread is that I MIGHT need to implement a method to give everyone rate boosts if the sexyman is present in the party or party leader? There's no other way?

  15. #15
    Wut. QuietCrystal is offline
    MemberRank
    Aug 2010 Join Date
    SingaporeLocation
    346Posts

    Re: [Help] Occupation

    Quote Originally Posted by BestSiteEvar View Post
    Very true indeed. Did not spot that. Ty.

    So what i'm getting from this thread is that I MIGHT need to implement a method to give everyone rate boosts if the sexyman is present in the party or party leader? There's no other way?
    No? What exactly do you want anyway?



Page 1 of 2 12 LastLast

Advertisement