Converting Int to Big Int (Mob HP)

Results 1 to 9 of 9
  1. #1
    Enthusiast Baymax is offline
    MemberRank
    Dec 2014 Join Date
    39Posts

    Converting Int to Big Int (Mob HP)

    Hi, can anyone guide me along on how to change the Integer on mob HP to biginteger/long? I tried changing errors keep popping up, also the "Spawner" for monster doesn't allow more than INT values, any way to change that?

    Thanks!


  2. #2
    Proficient Member ByCreator is offline
    MemberRank
    Mar 2012 Join Date
    154Posts

    Re: Converting Int to Big Int (Mob HP)

    Well this is what I know
    open with Notepad++ any mobID.img.xml (XML file) from YourSource\wz\Mob.wz
    for example green snail 100100.img.xml
    Spoiler:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <imgdir name="0100100.img"> (mob/moster ID)
    <imgdir name="info">
    <int name="level" value="1"/>
    <int name="bodyAttack" value="1"/>
    <int name="maxHP" value="15"/>
    <int name="speed" value="-65"/>
    <int name="PADamage" value="2"/>
    <int name="PDRate" value="10"/>
    <int name="MADamage" value="1"/>
    <int name="MDRate" value="10"/>
    <int name="acc" value="10"/>
    <int name="pushed" value="5"/>
    <float name="fs" value="10.0"/>
    <int name="exp" value="3"/>
    <int name="summonType" value="1"/>
    <int name="category" value="1"/>
    <string name="mobType" value="1N"/>
    </imgdir>
    <imgdir name="move">
    <int name="zigzag" value="1"/>
    <canvas name="0" width="37" height="26">
    <vector name="origin" x="18" y="26"/>
    <vector name="lt" x="-18" y="-26"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="180"/>
    </canvas>
    <canvas name="1" width="36" height="25">
    <vector name="origin" x="17" y="25"/>
    <vector name="lt" x="-17" y="-25"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-12" y="-24"/>
    <int name="delay" value="180"/>
    </canvas>
    <canvas name="2" width="36" height="25">
    <vector name="origin" x="17" y="25"/>
    <vector name="lt" x="-17" y="-25"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-11" y="-24"/>
    <int name="delay" value="180"/>
    </canvas>
    <canvas name="3" width="36" height="24">
    <vector name="origin" x="17" y="24"/>
    <vector name="lt" x="-17" y="-24"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-10" y="-24"/>
    <int name="delay" value="180"/>
    </canvas>
    <canvas name="4" width="37" height="24">
    <vector name="origin" x="18" y="24"/>
    <vector name="lt" x="-18" y="-24"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-9" y="-24"/>
    <int name="delay" value="180"/>
    </canvas>
    </imgdir>
    <imgdir name="stand">
    <canvas name="0" width="37" height="26">
    <vector name="origin" x="18" y="26"/>
    <vector name="lt" x="-18" y="-26"/>
    <vector name="rb" x="19" y="0"/>
    <vector name="head" x="-13" y="-24"/>
    </canvas>
    </imgdir>
    <imgdir name="hit1">
    <canvas name="0" width="43" height="33">
    <vector name="origin" x="21" y="33"/>
    <vector name="lt" x="-21" y="-33"/>
    <vector name="rb" x="22" y="0"/>
    <vector name="head" x="-10" y="-27"/>
    <int name="delay" value="600"/>
    </canvas>
    </imgdir>
    <imgdir name="die1">
    <canvas name="0" width="43" height="33">
    <vector name="origin" x="21" y="33"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    <string name="source" value="Mob/0100100.img/hit1/0"/>
    </canvas>
    <canvas name="1" width="44" height="31">
    <vector name="origin" x="22" y="31"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="2" width="36" height="24">
    <vector name="origin" x="14" y="24"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="3" width="36" height="24">
    <vector name="origin" x="14" y="24"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="4" width="35" height="23">
    <vector name="origin" x="13" y="23"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="5" width="35" height="18">
    <vector name="origin" x="13" y="18"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="6" width="33" height="14">
    <vector name="origin" x="13" y="14"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="7" width="33" height="10">
    <vector name="origin" x="13" y="10"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="120"/>
    </canvas>
    <canvas name="8" width="33" height="6">
    <vector name="origin" x="13" y="6"/>
    <vector name="head" x="-13" y="-24"/>
    <int name="delay" value="300"/>
    <int name="a0" value="255"/>
    <int name="a1" value="0"/>
    </canvas>
    </imgdir>
    </imgdir>


    now where you see this
    Spoiler:

    <imgdir name="0100100.img">
    <imgdir name="info">
    <int name="level" value="1"/> (here is MOB level)
    <int name="bodyAttack" value="1"/> (here is MOB attack , the DMG it do when its touch on Character)
    <int name="maxHP" value="15"/> (here is MOB HP)
    <int name="speed" value="-65"/> (here is MOB speed that he move)
    <int name="PADamage" value="2"/> (mob Weapon attack)
    <int name="PDRate" value="10"/>
    <int name="MADamage" value="1"/>(mod Magic attack)
    <int name="MDRate" value="10"/>
    <int name="acc" value="10"/>
    <int name="pushed" value="5"/>
    <float name="fs" value="10.0"/>
    <int name="exp" value="3"/>

    you can edit the HP , and save the file, then restart the SERVER and spawn the mob. (this modification will make that change for every one in the server.)

    and about the "Spanwer" :
    Spoiler:

    Code:
    cm.spawnMonster(MobID, HP, MP, level, EXP, boss, undead, amount, x, y);
    MobID - Monster ID
    HP - Custom HP, put in the amount you want.
    MP - Custom MP, put in the amount you want.
    Level - Level of the Mob
    EXP- Custom EXP, put in the amount you want.
    boss - If it is a boss put a 1. If not a 0.
    undead - If it's undead put a 1. If not a 0.
    amount - The number it spawns
    x - X coordinate
    y - Y coordinate


    code was taken from ThePack's mob spawner
    Code:
     cm.spawnMonster(8500001, 20000000, 2000000, 125, 700000, 1, 0, 1, 655, -146);

    Info about Spawner I took from

  3. #3
    Enthusiast Baymax is offline
    MemberRank
    Dec 2014 Join Date
    39Posts

    Re: Converting Int to Big Int (Mob HP)

    @ByCreator, what I'm trying to do is allow the HP of any monster to exceed 2.147b which is the limit for Integer.

  4. #4
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: Converting Int to Big Int (Mob HP)

    Quote Originally Posted by Baymax View Post
    @ByCreator, what I'm trying to do is allow the HP of any monster to exceed 2.147b which is the limit for Integer.
    Just modify "private int hp" in MapleMonster to a long and then check everywhere in your source and modify it all to a long. Most sources do checks if hp >= Int.MaxValue, just write Int.MaxValue, else write the current hp. This is because for things like packets you can't write along, so you have to cast it to an integer. You can follow this method or calculate the actual real percentage of health and display that. You'll have a lot of areas to edit, and you'll also have to realize that by the XML format's "int" usage, you cannot just edit it to a very high number that exceeds the max value of an int. You can use longs for !spawns and !pmob stuff which is what I usually use it for.

  5. #5
    Enthusiast Baymax is offline
    MemberRank
    Dec 2014 Join Date
    39Posts

    Re: Converting Int to Big Int (Mob HP)



    What about these kinds of error? Do I make it 'mob.setHp((int) (long) remainingHp);' or mob.setHp((int) remainingHp);

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

    Re: Converting Int to Big Int (Mob HP)

    Quote Originally Posted by Baymax View Post


    What about these kinds of error? Do I make it 'mob.setHp((int) (long) remainingHp);' or mob.setHp((int) remainingHp);
    Just change all the methods involving mobs' hp to take long as an argument. Obviously setHp takes an integer, so change that.

  7. #7
    Omega sunnyboy is offline
    MemberRank
    Mar 2010 Join Date
    6,109Posts

    Re: Converting Int to Big Int (Mob HP)

    If you're gonna change hp to a long or BigInteger, you'll have to do the same for every function dealing with mob HP

  8. #8
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: Converting Int to Big Int (Mob HP)

    Quote Originally Posted by Baymax View Post


    What about these kinds of error? Do I make it 'mob.setHp((int) (long) remainingHp);' or mob.setHp((int) remainingHp);
    I'm not sure what version you're using, but considering you have a writeInt and a writeLong, I'll assume you simply modified "writeInt" to "writeLong". This is what I said you were unable to do. For functions like mob.setHp(int hp), you'll modify it to mob.setHp(long hp), so that when you pass in mob.setHp(remainingHp), it will work.

    ...However, when it reaches things that are required to be of integer type, like your packets for example, this is where you can either make a formula to calculate overall percentage and display that, or just write Integer.MAX_VALUE if the HP > Integer.MAX_VALUE. If it's a valid int otherwise, just cast the long to an int. You can't just modify your packet's sizes from writeInt to writeLong, you'll just crash with error 38's or have many other things go wrong if you do that. It has to match the same data type in bytes as the client is expecting to receive (in this case, 4 bytes, not 8). Something like so would be how you can do it:
    Code:
    mplew.writeInt(remainingHp > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) remainingHp);

  9. #9
    Enthusiast Baymax is offline
    MemberRank
    Dec 2014 Join Date
    39Posts

    Re: Converting Int to Big Int (Mob HP)

    Thanks everyone!



Advertisement