Ejemplo n.º 1
0
 public Buff getBuffByName(String buffName) {
   synchronized (objectMutex) {
     for (Buff buff : buffList.get()) {
       if (buff.getBuffName().equals(buffName)) return buff;
     }
   }
   return null;
 }
Ejemplo n.º 2
0
 public Buff getBuffByCRC(int crc) {
   synchronized (objectMutex) {
     for (Buff buff : buffList.get()) {
       if (buff.getBuffCRC() == crc) {
         return buff;
       }
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 public void updateBuff(Buff buff) {
   buff.updateRemovalTask();
   synchronized (objectMutex) {
     setBuffListCounter(getBuffListCounter() + 1);
     notifyObservers(messageBuilder.buildUpdateBuffDelta(buff), true);
   }
 }
Ejemplo n.º 4
0
 public void addBuff(Buff buff) {
   synchronized (objectMutex) {
     buffList.get().add(buff);
     setBuffListCounter(getBuffListCounter() + 1);
   }
   buff.setStartTime();
   notifyObservers(messageBuilder.buildAddBuffDelta(buff), true);
 }
Ejemplo n.º 5
0
  public IoBuffer buildUpdateBuffDelta(Buff buff) {

    CreatureObject creature = (CreatureObject) object;
    PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");

    IoBuffer buffer = bufferPool.allocate(37, false).order(ByteOrder.LITTLE_ENDIAN);
    buffer.putInt(1);
    buffer.putInt(creature.getBuffListCounter());
    if (player != null)
      buff.setTotalPlayTime(
          (int)
              (player.getTotalPlayTime()
                  + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
    else buff.setTotalPlayTime(0);
    buffer.put((byte) 2);
    buffer.put(buff.getBytes());
    int size = buffer.position();
    buffer.flip();
    buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1A, buffer, size + 4);

    return buffer;
  }
Ejemplo n.º 6
0
  public IoBuffer buildRemoveBuffDelta(Buff buff) {

    CreatureObject creature = (CreatureObject) object;

    IoBuffer buffer = bufferPool.allocate(37, false).order(ByteOrder.LITTLE_ENDIAN);
    buffer.putInt(1);
    buffer.putInt(creature.getBuffListCounter());
    buffer.put((byte) 1);
    buffer.put(buff.getBytes());
    int size = buffer.position();
    buffer.flip();
    buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1A, buffer, size + 4);

    return buffer;
  }
Ejemplo n.º 7
0
  public IoBuffer buildBaseline6() {
    CreatureObject creature = (CreatureObject) object;

    IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
    buffer.setAutoExpand(true);
    buffer.putShort((short) 0x23);

    // BaseObject
    buffer.putInt(0x43); // serverId

    buffer.putShort((short) 0); // detaiLStfFilename
    buffer.putInt(0); // detailStfSpacer
    buffer.putShort((short) 0); // detailStfName

    // TangibleObject
    buffer.put(creature.getCombatFlag());

    buffer.putLong(0); // Set<Long> cloakViewers (set of objectIds of who can see a cloaked spy)
    buffer.putInt(0); // Int
    buffer.putLong(0); // List<Long>
    buffer.putLong(0); // List<Int>
    buffer.putLong(0); // List<Unknown>

    buffer.putShort(creature.getLevel());
    buffer.putInt(
        creature
            .getGrantedHealth()); // From player_level.iff.  Ranges from 0-2000 as you level,
                                  // consistent with that table.

    // 0A
    if (creature.getCurrentAnimation() == null || creature.getCurrentAnimation().length() == 0)
      buffer.putShort((short) 0);
    else buffer.put(getAsciiString(creature.getCurrentAnimation()));

    if (creature.getMoodAnimation() == null || creature.getMoodAnimation().length() == 0)
      buffer.put(getAsciiString("neutral"));
    else buffer.put(getAsciiString(creature.getMoodAnimation()));

    buffer.putLong(creature.getWeaponId());

    buffer.putLong(creature.getGroupId());
    buffer.putLong(creature.getInviteSenderId());
    if (creature.getInviteSenderName() == null || creature.getInviteSenderName().length() == 0)
      buffer.putShort((short) 0);
    else buffer.put(getAsciiString(creature.getInviteSenderName()));

    buffer.putLong(creature.getInviteCounter());

    buffer.putInt(creature.getGuildId());

    buffer.putLong(creature.getLookAtTarget()); // lookAtTarget 0x10
    buffer.putLong(creature.getIntendedTarget()); // intendedTarget 0x11
    buffer.put(creature.getMoodId());
    buffer.putInt(creature.getPerformanceCounter());
    /*
     * minor dilemma: performance ID is needed for XP calculation, but it can't be sent
     * in the CREO, otherwise the evul note bubbles appear
     */
    buffer.putInt((creature.getPerformanceType()) ? 0 : creature.getPerformanceId());

    buffer.putInt(6); // Current HAM
    buffer.putInt(creature.getHamListCounter());

    buffer.putInt(creature.getHealth());
    // 1A
    buffer.putInt(0);
    buffer.putInt(creature.getAction());
    buffer.putInt(0);
    buffer.putInt(0x2C01);
    buffer.putInt(0);

    buffer.putInt(6); // Max HAM
    buffer.putInt(creature.getMaxHAMListCounter());

    buffer.putInt(creature.getMaxHealth());
    buffer.putInt(0);
    buffer.putInt(creature.getMaxAction());
    buffer.putInt(0);
    buffer.putInt(0x2C01);
    buffer.putInt(0);

    if (creature.getEquipmentList().isEmpty()) {
      buffer.putInt(0);
      buffer.putInt(creature.getEquipmentListUpdateCounter());
    } else {
      buffer.putInt(creature.getEquipmentList().size());
      buffer.putInt(creature.getEquipmentListUpdateCounter());

      for (Long objId : creature.getEquipmentList().get()) {

        SWGObject obj = NGECore.getInstance().objectService.getObject(objId);

        if (obj == null) {
          System.err.println("Cant find obj for obj id in equip list!!!");
          continue;
        }

        if (obj instanceof TangibleObject && !(obj instanceof WeaponObject)) {
          TangibleObject tangible = (TangibleObject) obj;
          if (tangible.getCustomization() == null || tangible.getCustomization().length == 0) {
            buffer.putShort((short) 0);
          } else {
            buffer.putShort((short) tangible.getCustomization().length);
            buffer.put(tangible.getCustomization());
          }
          buffer.putInt(tangible.getArrangementId());
          buffer.putLong(tangible.getObjectID());
          buffer.putInt(CRC.StringtoCRC(tangible.getTemplate()));
          buffer.put((byte) 0);
        } else if (obj instanceof WeaponObject) {
          WeaponObject weapon = (WeaponObject) obj;
          if (weapon.getCustomization() == null || weapon.getCustomization().length == 0) {
            buffer.putShort((short) 0);
          } else {
            buffer.putShort((short) weapon.getCustomization().length);
            buffer.put(weapon.getCustomization());
          }
          buffer.putInt(weapon.getArrangementId());
          buffer.putLong(weapon.getObjectID());
          buffer.putInt(CRC.StringtoCRC(weapon.getTemplate()));

          buffer.put((byte) 1);
          buffer.put(weapon.getMessageBuilder().buildBaseline3());
          buffer.put(weapon.getMessageBuilder().buildBaseline6());
        } else {
          System.out.println("Bad equipment object");
        }
      }
    }

    buffer.putShort((short) 0); // costume
    // buffer.put(getAsciiString("appearance/gungan_m.sat"));
    buffer.put((byte) (creature.isInStealth() ? 0 : 1));

    if (creature.getBuffList().isEmpty()) {
      buffer.putInt(0);
      buffer.putInt(creature.getBuffListCounter());
    } else {
      buffer.putInt(creature.getBuffList().size() + 1);
      buffer.putInt(creature.getBuffListCounter());

      buffer.put((byte) 0);
      // buffer.putInt(0x2098793D);
      buffer.putInt(0);
      buffer.putInt(-1);
      buffer.putInt(0);
      buffer.putInt(0);
      buffer.putLong(creature.getObjectID());

      PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");

      for (Buff buff : creature.getBuffList().get()) {

        if (player != null)
          buff.setTotalPlayTime(
              (int)
                  (player.getTotalPlayTime()
                      + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
        else buff.setTotalPlayTime(0);
        buffer.put((byte) 1);
        buffer.putInt(0);
        buffer.putInt(CRC.StringtoCRC(buff.getBuffName().toLowerCase()));
        if (buff.getDuration() > 0) {
          buffer.putInt((int) (buff.getTotalPlayTime() + buff.getRemainingDuration()));
          buffer.putInt(0);
          buffer.putInt((int) buff.getDuration());
        } else {
          buffer.putInt(-1);
          buffer.putInt(0);
          buffer.putInt(0);
        }

        buffer.putLong(creature.getObjectID());
      }

      buffer.putInt(1);
    }

    buffer.put(
        (byte)
            (creature.isStationary() ? 1 : 0)); // if the server accepts transforms from the object
    buffer.put(creature.getDifficulty());

    if (creature.isHologram()) buffer.putInt(0);
    else buffer.putInt(0xFFFFFFFF);

    buffer.put((byte) (creature.isRadarVisible() ? 1 : 0));
    buffer.put((byte) 0); // no effect for 1?
    buffer.put((byte) 0); // no effect for 1?

    if (creature.getAppearanceEquipmentList().isEmpty()) {
      buffer.putInt(0);
      buffer.putInt(creature.getAppearanceEquipmentListUpdateCounter());
    } else {
      buffer.putInt(creature.getAppearanceEquipmentList().size());
      buffer.putInt(creature.getAppearanceEquipmentListUpdateCounter());

      for (Long objId : creature.getAppearanceEquipmentList().get()) {

        SWGObject obj = NGECore.getInstance().objectService.getObject(objId);

        if (obj == null) {
          System.err.println("Cant find obj for obj id in equip list!!!");
          continue;
        }

        if (obj instanceof TangibleObject) {
          TangibleObject tangible = (TangibleObject) obj;
          if (tangible.getCustomization() == null || tangible.getCustomization().length == 0) {
            buffer.putShort((short) 0);
          } else {
            buffer.putShort((short) tangible.getCustomization().length);
            buffer.put(tangible.getCustomization());
          }
          buffer.putInt(tangible.getArrangementId());
          buffer.putLong(tangible.getObjectID());
          buffer.putInt(CRC.StringtoCRC(tangible.getTemplate()));
          buffer.put((byte) 0);
        } else {
          System.out.println("Bad appearance equipment object");
        }
      }
    }

    buffer.putLong(0); // unk long

    int size = buffer.position();
    buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);

    buffer.flip();
    buffer = createBaseline("CREO", (byte) 6, buffer, size);

    return buffer;
  }