Exemplo n.º 1
0
  @Override
  public ItemStack applyEffectByID(ItemStack artifact, int id, String trigger) {
    if (artifact.stackTagCompound == null) {
      artifact.stackTagCompound = this.createDefault();
    }
    int[] a = artifact.stackTagCompound.getIntArray("allComponents");
    Vector effectsOnItem = new Vector();
    for (int i = 0; i < 5; ++i) {
      if (a[i] != 0) {
        effectsOnItem.add(a[i]);
      }
    }
    int numEff = 0;

    IArtifactComponent c = getComponent(id);
    if (!effectsOnItem.contains(c)) {
      if (trigger == null || trigger.equals("")) trigger = c.getRandomTrigger(rand);
      if (!artifact.stackTagCompound.hasKey(trigger)) {
        effectsOnItem.add(c);
        if (id == 9) {
          int bonus = a.length * 5;
          if (numEff == a.length) {
            numEff = 1;
            bonus = 0;
            artifact.stackSize = 10;
          }
          artifact.stackTagCompound.setInteger("cashBonus", bonus);
        }
        if (id == 7) {
          if (numEff == a.length) {
            if (trigger == "onDropped") {
              numEff = 1;
              artifact.stackSize = 10;
            }
          }
        }
        artifact.stackTagCompound.setInteger(trigger, id);
        for (int i = 0; i < 5; ++i) {
          if (a[i] == 0) {
            a[i] = id;
            i = 99;
          }
        }
        artifact.stackTagCompound.setIntArray("allComponents", a);
      }
    }
    return artifact;
  }
Exemplo n.º 2
0
  public ItemStack applyRandomEffects(ItemStack artifact) {
    artifact.stackTagCompound = createDefault();
    String nameChunk = "";
    Amulet = 1;
    Dagger = 1;
    Figurine = 1;
    Ring = 1;
    Staff = 1;
    Sword = 1;
    Trinket = 1;
    Wand = 1;
    Armor = 1;
    Boots = 1;
    Chestplate = 1;
    Helm = 1;
    Leggings = 1;
    int flags, effID;
    String artiName = "";
    Vector effectsOnItem = new Vector();
    IArtifactComponent c;
    int count = 0, a[];
    int numEff = rand.nextInt(5) + 1;
    a = new int[numEff];
    for (; numEff > 0; numEff--) {
      effID = rand.nextInt(effects.size()) + 1;
      if (effID == 17 && a.length < 3) {
        numEff++;
        a = new int[numEff];
      }
      c = getComponent(effID);
      if (effectsOnItem.contains(c)) {
        numEff++;
        continue;
      }
      String trigName = c.getRandomTrigger(rand);
      if (artifact.stackTagCompound.hasKey(trigName)) {
        // make NBTTagLists to remove this condition;
        numEff++;
        continue;
      }
      effectsOnItem.add(c);
      if (effID == 9) {
        int bonus = a.length * 5;
        if (numEff == a.length) {
          numEff = 1;
          bonus = 0;
          artifact.stackSize = 10;
        }
        artifact.stackTagCompound.setInteger("cashBonus", bonus);
      }
      if (effID == 7) {
        if (numEff == a.length) {
          if (trigName == "onDropped") {
            numEff = 1;
            artifact.stackSize = 10;
          }
        }
      }
      // System.out.println(c.getName());
      artifact.stackTagCompound.setInteger(trigName, effID);
      if (trigName == "onHeld") {
        artifact = c.attached(artifact, rand);
      }
      a[numEff - 1] = effID;
      flags = c.getTextureBitflags();
      Amulet += flags % 2;
      flags >>= 1;
      Dagger += flags % 2;
      flags >>= 1;
      Figurine += flags % 2;
      flags >>= 1;
      Ring += flags % 2;
      flags >>= 1;
      Staff += flags % 2;
      flags >>= 1;
      Sword += flags % 2;
      flags >>= 1;
      Trinket += flags % 2;
      flags >>= 1;
      Wand += flags % 2;
      flags >>= 1;
      // Armor += flags % 2;
      flags >>= 1;
      Boots += flags % 2;
      flags >>= 1;
      Chestplate += flags % 2;
      flags >>= 1;
      Helm += flags % 2;
      flags >>= 1;
      Leggings += flags % 2;

      flags = c.getNegTextureBitflags();
      Amulet -= flags % 2;
      flags >>= 1;
      Dagger -= flags % 2;
      flags >>= 1;
      Figurine -= flags % 2;
      flags >>= 1;
      Ring -= flags % 2;
      flags >>= 1;
      Staff -= flags % 2;
      flags >>= 1;
      Sword -= flags % 2;
      flags >>= 1;
      Trinket -= flags % 2;
      flags >>= 1;
      Wand -= flags % 2;
      flags >>= 1;
      Armor -= flags % 2;
      flags >>= 1;
      Boots -= flags % 2;
      flags >>= 1;
      Chestplate -= flags % 2;
      flags >>= 1;
      Helm -= flags % 2;
      flags >>= 1;
      Leggings -= flags % 2;
      if (rand.nextInt(4) == 0) {
        numEff--;
        if (numEff > 0) a[numEff - 1] = 0;
      }
    }
    Amulet = Math.max(Amulet, 0);
    Dagger = Math.max(Dagger, 0);
    Figurine = Math.max(Figurine, 0);
    Ring = Math.max(Ring, 0);
    Staff = Math.max(Staff, 0);
    Sword = Math.max(Sword, 0);
    Trinket = Math.max(Trinket, 0);
    Wand = Math.max(Wand, 0);
    Armor = Math.max(Armor * 4, 0);
    Boots = Math.max(Boots, 0);
    Chestplate = Math.max(Chestplate, 0);
    Helm = Math.max(Helm, 0);
    Leggings = Math.max(Leggings, 0);
    // end loop
    int t = Amulet + Dagger + Figurine + Ring + Staff + Sword + Trinket + Wand;
    int r = 0;
    String iconType;
    artifact.stackTagCompound.setInteger("armorType", -1);
    if (t > 0) {
      r = rand.nextInt(t);
      if ((r -= Amulet) < 0) {
        iconType = "Amulet";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberAmulets;
      } else if ((r -= Dagger) < 0) {
        iconType = "Dagger";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberDaggers;
        if (!effectsOnItem.contains(2)) {
          artifact = baseDamage.attached(artifact, rand);
        }
      } else if ((r -= Figurine) < 0) {
        iconType = "Figurine";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberFigurines;
      } else if ((r -= Ring) < 0) {
        iconType = "Ring";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberRings;
      } else if ((r -= Staff) < 0) {
        iconType = "Staff";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberStaffs;
      } else if ((r -= Sword) < 0) {
        iconType = "Sword";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberSwords;
        if (!effectsOnItem.contains(2)) {
          artifact = baseDamage.attached(artifact, rand);
        }
      } else if ((r -= Trinket) < 0) {
        iconType = "Trinket";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberTrinkets;
      } else if ((r -= Wand) < 0) {
        iconType = "Wand";
        t = ((FactoryItemIcons) (ArtifactsAPI.itemicons)).numberWands;
      } else if ((r -= Armor) < 0) {
        /*t = Boots+Chestplate+Helm+Leggings;
        if(t < 1)
        	t = 1;
        r = rand.nextInt(t);
        if((r -= Boots) < 0) {
        	iconType = "Boots";
        	t = 1;
        	artifact.stackTagCompound.setInteger("armorType", 3);
        }
        else if((r -= Chestplate) < 0) {
        	iconType = "Chestplate";
        	t = 1;
        	artifact.stackTagCompound.setInteger("armorType", 1);
        }
        else if((r -= Helm) < 0) {
        	iconType = "Helm";
        	t = 1;
        	artifact.stackTagCompound.setInteger("armorType", 0);
        }
        else if((r -= Leggings) < 0) {
        	iconType = "Leggings";
        	t = 1;
        	artifact.stackTagCompound.setInteger("armorType", 2);
        }
        else {*/
        iconType = "Artifact";
        t = 1;
        // }
      } else {
        iconType = "Artifact";
        t = 1;
      }
    } else {
      iconType = "Artifact";
      t = 1;
    }
    int r2 = -1, r3 = -1, r4 = rand.nextInt(10);
    String matName = "[Material]";
    switch (r4) {
      case 0:
        matName = "Wood";
        r4 = 0;
        break;
      case 1:
      case 8:
        r4 = 1;
        matName = "Stone";
        break;
      case 2:
      case 7:
      case 9:
        r4 = 2;
        matName = "Iron";
        break;
      case 4:
        r4 = 4;
        matName = "Diamond";
        break;
      case 3:
      case 5:
      case 6:
      case 10:
        r4 = 3;
        matName = "Gold";
        break;
    }
    artifact.stackTagCompound.setString("iconName", iconType);
    artifact.stackTagCompound.setString("matName", matName);
    if (effectsOnItem.size() > 1) {
      r2 = rand.nextInt(effectsOnItem.size());
      c = (IArtifactComponent) effectsOnItem.get(r2);
      // System.out.println("Pre: " + c.getPreAdj(rand));
      nameChunk = c.getPreAdj(rand);
      artifact.stackTagCompound.setString("preadj", nameChunk);
      artiName = nameChunk + " ";
      artiName += matName + " " + iconType;
      do {
        r3 = rand.nextInt(effectsOnItem.size());
      } while (r2 == r3);
      c = (IArtifactComponent) effectsOnItem.get(r3);
      nameChunk = c.getPostAdj(rand);
      artifact.stackTagCompound.setString("postadj", nameChunk);
      artiName += " " + nameChunk;
    } else {
      // System.out.println("Singular");
      if (rand.nextBoolean()) {
        r2 = rand.nextInt(effectsOnItem.size());
        c = (IArtifactComponent) effectsOnItem.get(r2);
        nameChunk = c.getPreAdj(rand);
        artifact.stackTagCompound.setString("preadj", nameChunk);
        artifact.stackTagCompound.setString("postadj", "");
        artiName = nameChunk + " " + matName + " " + iconType;
      } else {
        r3 = rand.nextInt(effectsOnItem.size());
        c = (IArtifactComponent) effectsOnItem.get(r3);
        nameChunk = c.getPostAdj(rand);
        artifact.stackTagCompound.setString("preadj", "");
        artifact.stackTagCompound.setString("postadj", nameChunk);
        artiName = matName + " " + iconType + " " + nameChunk;
      }
    }
    r = rand.nextInt(t);
    artifact.stackTagCompound.setString("name", artiName);
    artifact.stackTagCompound.setString("icon", iconType + (r + 1));
    int col = Color.HSBtoRGB((float) (rand.nextInt(360) / 360F), .8f, 1);
    artifact.stackTagCompound.setLong("overlay_color", col);
    artiName = "";
    artifact.stackTagCompound.setInteger("material", r4);

    artifact.stackTagCompound.setIntArray("allComponents", a);
    if (rand.nextInt(8) == 0) {
      artifact =
          enchantArtifact(artifact, effectsOnItem, (iconType == "Sword" || iconType == "Dagger"));
    }
    return artifact;
  }