Weapon Damage

Discussion in 'Plugin Development' started by Taien, Jun 15, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Taien

    Hey all, I'm pretty new to this but I've done a fair bit of searching and come up empty-handed for the most part.

    I'm trying to create a bit of code that damages a weapon ten times as much when it is used to damage a certain kind of mob. The problem is the durability is not being read or something. I have the following as my code (notice the printing to console for debugging this):

    Code:
    if ((weapon.getTypeId() >= 256 && weapon.getTypeId() <= 258) ||
                (weapon.getTypeId() >= 267 && weapon.getTypeId() <= 279) ||
                (weapon.getTypeId() >= 290 && weapon.getTypeId() <= 293))
                {
                    System.out.println("Meltable Weapon Hit Detected.");
                    System.out.println("Weapon Durability: " + weapon.getDurability());
                    if(weapon.getDurability() > plugin.weaponDamage){
                        weapon.setDurability((short) (weapon.getDurability() - plugin.weaponDamage));
                    }
                    else{
                        weapon.setDurability((short) 0);
                    }
                    System.out.println("New Durability: " + weapon.getDurability());
                }
    As you can see the plugin detects what weapon was used to damage the monster, and then is SUPPOSED to damage it. (Btw, plugin.weaponDamage is a short from the main plugin class) But when it appears in console, I get this:

    15:24:48 [INFO] Meltable Weapon Hit Detected.
    15:24:48 [INFO] Weapon Durability: 0
    15:24:48 [INFO] New Durability: 0

    Any help? :(
     
  2. Offline

    CptSausage

    It looks like the durability works the other way round.

    weapon.setDurability((short) (weapon.getDurability() + plugin.weaponDamage));
     
    jeffadkins51 likes this.
  3. Offline

    nisovin

    Yes, it's more of a damage counter than a durability measurement. As it's used, the number gets bigger until it exceeds a certain hard-coded number (which can be found on the wiki if you're curious).
     
    CptSausage likes this.
  4. Offline

    Taien

    WOW. So my problem is I've been HEALING the weapon? LMAO. Thanks guys :)
     
Thread Status:
Not open for further replies.

Share This Page