• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Add-on]MoopleDev Gain Items on Level

Newbie Spellweaver
Joined
Dec 4, 2010
Messages
48
Reaction score
8
This is my first release, and quite simple. Please don't flame.



This code will make it so that every few levels of your designation the player will receive an item / some items.
Open MapleCharacter.java.

In between
Code:
public void levelUp(boolean takeexp) {
        ISkill improvingMaxHP = null;
        ISkill improvingMaxMP = null;
        int improvingMaxHPLevel = 0;
        int improvingMaxMPLevel = 0;
and
Code:
 if (isBeginnerJob()) {
            remainingAp = 0;
            if (getLevel() < 6) {
                str += 5;
            } else {
                str += 4;
                dex += 1;
            }
        } else {
            remainingAp += 5;
            if (isCygnus() && level < 70) {
                remainingAp++;
            }
        }
        if (job == MapleJob.BEGINNER || job == MapleJob.NOBLESSE || job == MapleJob.LEGEND) {
            maxhp += Randomizer.rand(12, 16);
            maxmp += Randomizer.rand(10, 12);
        } else if (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.DAWNWARRIOR1)) {
            improvingMaxHP = isCygnus() ? SkillFactory.getSkill(DawnWarrior.MAX_HP_INCREASE) : SkillFactory.getSkill(Swordsman.IMPROVED_MAX_HP_INCREASE);
            if (job.isA(MapleJob.CRUSADER)) {
                improvingMaxMP = SkillFactory.getSkill(1210000);
            } else if (job.isA(MapleJob.DAWNWARRIOR2)) {
                improvingMaxMP = SkillFactory.getSkill(11110000);
            }
            improvingMaxHPLevel = getSkillLevel(improvingMaxHP);
            maxhp += Randomizer.rand(24, 28);
            maxmp += Randomizer.rand(4, 6);
        } else if (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.BLAZEWIZARD1)) {
            improvingMaxMP = isCygnus() ? SkillFactory.getSkill(BlazeWizard.INCREASING_MAX_MP) : SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE);
            improvingMaxMPLevel = getSkillLevel(improvingMaxMP);
            maxhp += Randomizer.rand(10, 14);
            maxmp += Randomizer.rand(22, 24);
        } else if (job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.THIEF) || (job.getId() > 1299 && job.getId() < 1500)) {
            maxhp += Randomizer.rand(20, 24);
            maxmp += Randomizer.rand(14, 16);
        } else if (job.isA(MapleJob.GM)) {
            maxhp = 30000;
            maxmp = 30000;
        } else if (job.isA(MapleJob.PIRATE) || job.isA(MapleJob.THUNDERBREAKER1)) {
            improvingMaxHP = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.IMPROVE_MAX_HP) : SkillFactory.getSkill(5100000);
            improvingMaxHPLevel = getSkillLevel(improvingMaxHP);
            maxhp += Randomizer.rand(22, 28);
            maxmp += Randomizer.rand(18, 23);
        } else if (job.isA(MapleJob.ARAN1)) {
            maxhp += Randomizer.rand(44, 48);
            int aids = Randomizer.rand(4, 8);
            maxmp += aids + Math.floor(aids * 0.1);
        }
        if (improvingMaxHPLevel > 0 && (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.PIRATE) || job.isA(MapleJob.DAWNWARRIOR1))) {
            maxhp += improvingMaxHP.getEffect(improvingMaxHPLevel).getX();
        }
        if (improvingMaxMPLevel > 0 && (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.CRUSADER) || job.isA(MapleJob.BLAZEWIZARD1))) {
            maxmp += improvingMaxMP.getEffect(improvingMaxMPLevel).getX();
        }
        maxmp += localint_ / 10;
        if (takeexp) {
            exp.addAndGet(-ExpTable.getExpNeededForLevel(level));
            if (exp.get() < 0) {
                exp.set(0);
            }
        }
        level++;
        if (level >= getMaxLevel()) {
            exp.set(0);
        }
        maxhp = Math.min(30000, maxhp);
        maxmp = Math.min(30000, maxmp);
        if (level == 200) {
            exp.set(0);
        }
        hp = maxhp;
        mp = maxmp;
        recalcLocalStats();
        List<Pair<MapleStat, Integer>> statup = new ArrayList<Pair<MapleStat, Integer>>(10);
        statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, remainingAp));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.HP, localmaxhp));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.MP, localmaxmp));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.EXP, exp.get()));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, level));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXHP, maxhp));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXMP, maxmp));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.STR, str));
        statup.add(new Pair<MapleStat, Integer>(MapleStat.DEX, dex));
        if (job.getId() % 1000 > 0) {
            remainingSp += 3;
            statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLESP, remainingSp));
        }
        client.announce(MaplePacketCreator.updatePlayerStats(statup));
        getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 0), false);
        recalcLocalStats();
        silentPartyUpdate();
        if (this.guildid > 0) {
            getGuild().broadcast(MaplePacketCreator.levelUpMessage(2, level, name), this.getId());
        }
        if (MapleInventoryManipulator.checkSpace(client, 4310000, (short) 1, "")) MapleInventoryManipulator.addById(client, 4310000, (short) 1);
        guildUpdate();
        if (ServerConstants.GMS_LIKE) saveToDB(true);
    }
paste this:
Code:
        if (getLevel() == 24) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)75);
            
        } else if (getLevel() == 49) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)125);
           
        }
to customize the item ID, just change
Code:
4030002
in
Code:
server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)75);
to whatever you want. change the last number (75 in this case) to the amount you want.

if you want more consecutive levels, just copy and paste the else if and modify the values. example:
Code:
        if (getLevel() == 24) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)75);
            
        } else if (getLevel() == 49) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)125);
           
        } else if (getLevel() == 74) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)200);
            
        } else if (getLevel() == 99) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)300);
           
        } else if (getLevel() == 124) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)425);
           
        } else if (getLevel() == 149) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)550);
            
        } else if (getLevel() == 174) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)700);
            
        } else if (getLevel() == 199) {
            server.MapleInventoryManipulator.addById(getClient(), 4030002, (short)850);
        }
Edit:
actually, where i put it, you have to put the level before. 24 to gain it on level 25, 74 on 75, etc.

Credits:
Me (barely)
BloodAngel13 & NemesisToKill for helping me
RpViet for trying to help, but giving inaccurate info
 
Last edited:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
PHP:
int[] levels = {24, 19, 74, 99, 124, 149, 174, 199};
short[] amount = {75, 125, 200, 300, 425, 550, 700, 850};
for (int i = 0; i < levels.length; i++) {  
  if (getLevel() == levels[i]) {
     server.MapleInventoryManipulator.addById(getClient(), 4030002, amount[i]);
  }
}
You can use map but I still trying to figure that poop out..(I only know how to use it a bit)
 
Newbie Spellweaver
Joined
Aug 28, 2009
Messages
80
Reaction score
50
nice release :D

---------- Post added at 01:43 PM ---------- Previous post was at 01:42 PM ----------

PHP:
int[] levels = {24, 19, 74, 99, 124, 149, 174, 199};
short[] amount = {75, 125, 200, 300, 425, 550, 700, 850};
for (int i = 0; i < levels.length; i++) {  
  if (getLevel() == levels[i]) {
     server.MapleInventoryManipulator.addById(getClient(), 4030002, amount[i]);
  }
}
You can use map but I still trying to figure that poop out..(I only know how to use it a bit)

You could add a break statement if the level == levels :)
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
You could add a break statement if the level == levels :)


lmao forgot about that, never tested, anyways to busy to edit, working on NPCs
 
Last edited:
Newbie Spellweaver
Joined
Dec 4, 2010
Messages
48
Reaction score
8
thanks guys! :)

@bloodangel13, you mentioned using maplecharacter.java, which I am too much of a noob to think of.
 
Interesting...
Loyal Member
Joined
Oct 25, 2008
Messages
1,372
Reaction score
604
Sorry, just realized a problem with my release. I found that actually this only works with the !levelup command, at least in Nakedstory repack. Sorry. :/

If it's in the levelUp() method it should work with all types of leveling, normal or forced.

I haven't tried it, but I'm pretty sure.
 
Newbie Spellweaver
Joined
Jan 30, 2011
Messages
5
Reaction score
0
Whats the short after the itemID? The quantity or something?

EDIT: Oh wow, I actually got mentioned. o_o

Yes it is the quantity of that item you get per level up.
This should already be in MoopleDEV for perfect pitches. All you had to do was change the ID but w/e a release is a release. :eek:tt1:

& of course it works with !levelup, I'm not sure how that is a flaw at all though ;_; But you could add an exception to GMs if you don't want to get spammed items.
 
Last edited:
Newbie Spellweaver
Joined
Apr 10, 2009
Messages
91
Reaction score
195
Using HashMap (For constant time lookups)
and static (For less memory usage):


Code:
//If extensibility is wanted (IE. Giving out multiple items), change Pair<Integer, Integer> into an ArrayList<Pair<Integer, Integer>>.
public static final HashMap<Integer, Pair<Integer,Integer>> GainItemOnLevel = new HashMap<Integer, Pair<Integer, Integer>>();

static {
  int[][] LevelItemStuff = {
    {24, 4030002, 75},
    {49, 4030002, 125},
    {74, 4030002, 200},
    {99, 4030002, 300},
    {124, 4030002, 425},
    {149, 4030002, 550},
    {174, 4030002, 700},
    {199, 4030002, 850}
  };
  for (int i = 0;i < LevelItemStuff.length;i++) {
    GainItemOnLevel.put(LevelItemStuff[i][0], new Pair<Integer, Integer>(LevelItemStuff[i][1], LevelItemStuff[i][2]));
  }

}

Usage:
Code:
if (GainItemOnLevel.containsKey(getLevel())) {
  Pair<Integer, Integer> Info = GainItemOnLevel.get(getLevel());
  server.MapleInventoryManipulator.addById(getClient(), Info.getLeft(), (short) Info.getRight());
}
 
Last edited:
Skilled Illusionist
Joined
Dec 16, 2010
Messages
304
Reaction score
164
Using HashMap (For constant time lookups)
and static (For less memory usage):


Code:
//If extensibility is wanted (IE. Giving out multiple items), change Pair<Integer, Integer> into an ArrayList<Pair<Integer, Integer>>.
public static final HashMap<Integer, Pair<Integer,Integer>> GainItemOnLevel = new HashMap<Integer, Pair<Integer, Integer>>();

static {
  int[][] LevelItemStuff = {
    {24, 4030002, 75},
    {49, 4030002, 125},
    {74, 4030002, 200},
    {99, 4030002, 300},
    {124, 4030002, 425},
    {149, 4030002, 550},
    {174, 4030002, 700},
    {199, 4030002, 850}
  };
  for (int i = 0;i < LevelItemStuff.length;i++) {
    GainItemOnLevel.put(LevelItemStuff[i][0], new Pair<Integer, Integer>(LevelItemStuff[i][1], LevelItemStuff[i][2]));
  }

}

Usage:
Code:
if (GainItemOnLevel.containsKey(getLevel())) {
  Pair<Integer, Integer> Info = GainItemOnLevel.get(getLevel());
  server.MapleInventoryManipulator.addById(getClient(), Info.getLeft(), (short) Info.getRight());
}
Not to sound noob.... but why is GainItemOnLevel final if you're adding things to it? o-o
 
Newbie Spellweaver
Joined
Apr 10, 2009
Messages
91
Reaction score
195
Not to sound noob.... but why is GainItemOnLevel final if you're adding things to it? o-o

Final makes the reference to the object immutable, the object itself may still be mutable.

Ideally, after you're done initializing the HashMap, you'll wrap it with Collections.unmodifiableMap() to make it fully immutable. (I didn't do this because I forgot, but w/e it's not needed unless you have are really pissy about proper coding style).
 
Back
Top