Example #1
0
  private byte[] getCustomizationBytes() {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();

    try {
      IDManagerVisitor visitor =
          ClientFileManager.loadFile(
              "customization/customization_id_manager.iff", IDManagerVisitor.class);

      stream.write((byte) 0x02); // Unk
      stream.write((byte) customizationVariables.size()); // Number of customization attributes

      for (String type : customizationVariables.keySet()) {
        stream.write(
            visitor.getAttributeIndex(
                type)); // Index of palette type within "customization/customization_id_manager.iff"
        stream.write(customizationVariables.get(type)); // Value/Index within palette

        // Seperator/Footer
        stream.write((byte) 0xC3);
        stream.write((byte) 0xBF);
        stream.write((byte) 0x03);
      }

      return stream.toByteArray();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
Example #2
0
  public BaseSWGCommand getCommandByName(String name) {
    Vector<BaseSWGCommand> commands = new Vector<BaseSWGCommand>(commandLookup);

    name = name.toLowerCase();

    for (BaseSWGCommand command : commands) {
      if (command.getCommandName().equalsIgnoreCase(name)) {
        return command;
      }
    }

    try {
      String[] tableArray =
          new String[] {
            "client_command_table",
            "command_table",
            "client_command_table_ground",
            "command_table_ground",
            "client_command_table_space",
            "command_table_space"
          };

      for (int n = 0; n < tableArray.length; n++) {
        DatatableVisitor visitor =
            ClientFileManager.loadFile(
                "datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class);

        for (int i = 0; i < visitor.getRowCount(); i++) {
          if (visitor.getObject(i, 0) != null) {
            String commandName = ((String) visitor.getObject(i, 0)).toLowerCase();

            if (commandName.equalsIgnoreCase(name)) {
              if (isCombatCommand(commandName)) {
                CombatCommand command = new CombatCommand(commandName);
                commandLookup.add(command);
                return command;
              } else {
                BaseSWGCommand command = new BaseSWGCommand(commandName);
                commandLookup.add(command);
                return command;
              }
            }
          }
        }
      }
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }

    return null;
  }
Example #3
0
  public boolean isCombatCommand(String commandName) {
    try {
      DatatableVisitor visitor =
          ClientFileManager.loadFile("datatables/combat/combat_data.iff", DatatableVisitor.class);

      for (int i = 0; i < visitor.getRowCount(); i++) {
        if (visitor.getObject(i, 0) != null
            && ((String) (visitor.getObject(i, 0))).equalsIgnoreCase(commandName)) {
          return true;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }
Example #4
0
  public Buff(String buffName, long ownerId) {

    this.buffName = buffName;
    this.ownerId = ownerId;

    DatatableVisitor visitor;

    try {

      visitor = ClientFileManager.loadFile("datatables/buff/buff.iff", DatatableVisitor.class);
      for (int i = 0; i < visitor.getRowCount(); i++) {

        if (visitor.getObject(i, 0) != null)
          if (((String) visitor.getObject(i, 0)).equalsIgnoreCase(buffName)) {

            group1 = (String) visitor.getObject(i, 1);
            priority = (int) visitor.getObject(i, 4);
            duration = (Float) visitor.getObject(i, 6);
            effect1Name = (String) visitor.getObject(i, 7);
            effect1Value = (Float) visitor.getObject(i, 8);
            effect2Name = (String) visitor.getObject(i, 9);
            effect2Value = (Float) visitor.getObject(i, 10);
            effect3Name = (String) visitor.getObject(i, 11);
            effect3Value = (Float) visitor.getObject(i, 12);
            effect4Name = (String) visitor.getObject(i, 13);
            effect4Value = (Float) visitor.getObject(i, 14);
            effect5Name = (String) visitor.getObject(i, 15);
            effect5Value = (Float) visitor.getObject(i, 16);
            particleEffect = (String) visitor.getObject(i, 19);
            isDebuff = (Boolean) visitor.getObject(i, 22);
            removeOnDeath = (Integer) visitor.getObject(i, 25) != 0;
            isRemovableByPlayer = (Integer) visitor.getObject(i, 26) != 0;
            maxStacks = (Integer) visitor.getObject(i, 28);
            isPersistent = (Integer) visitor.getObject(i, 29) != 0;
            removeOnRespec = (Integer) visitor.getObject(i, 31) != 0;
            aiRemoveOnEndCombat = (Integer) visitor.getObject(i, 32) != 0;
            decayOnPvPDeath = (Integer) visitor.getObject(i, 33) != 0;
          }
      }

    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }
  }
  private void createStarterClothing(
      CreatureObject creature, String raceTemplate, String profession) {
    try {
      ProfessionTemplateVisitor visitor =
          ClientFileManager.loadFile(
              "creation/profession_defaults_" + profession + ".iff",
              ProfessionTemplateVisitor.class);
      TangibleObject inventory = (TangibleObject) creature.getSlottedObject("inventory");

      if (inventory == null) return;

      for (String item : visitor.getItems(raceTemplate)) {
        TangibleObject createdItem =
            (TangibleObject) core.objectService.createObject(item, creature.getPlanet());

        if (createdItem == null) return;

        creature._add(createdItem);
        creature.addObjectToEquipList(createdItem);
      }
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }
  }