public Buff doAddBuff(final CreatureObject creature, String buffName) { final Buff buff = new Buff(buffName, creature.getObjectID()); buff.setTotalPlayTime(((PlayerObject) creature.getSlottedObject("ghost")).getTotalPlayTime()); for (final Buff otherBuff : creature.getBuffList()) { if (buff.getGroup1().equals(otherBuff.getGroup1())) if (buff.getPriority() >= otherBuff.getPriority()) { if (buff.getBuffName().equals(otherBuff.getBuffName())) { if (otherBuff.getStacks() < otherBuff.getMaxStacks()) { buff.setStacks(otherBuff.getStacks() + 1); if (creature.getDotByBuff(otherBuff) != null) // reset duration when theres a dot stack creature.getDotByBuff(otherBuff).setStartTime(buff.getStartTime()); } if (otherBuff.getRemainingDuration() > buff.getDuration() && otherBuff.getStacks() >= otherBuff.getMaxStacks()) { return null; } } removeBuffFromCreature(creature, otherBuff); break; } else { System.out.println("buff not added:" + buffName); return null; } } if (FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) core.scriptService.callScript("scripts/buffs/", "setup", buffName, core, creature, buff); creature.addBuff(buff); if (buff.getDuration() > 0) { ScheduledFuture<?> task = scheduler.schedule( new Runnable() { @Override public void run() { removeBuffFromCreature(creature, buff); } }, (long) buff.getDuration(), TimeUnit.SECONDS); buff.setRemovalTask(task); } return buff; }
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; }
public IoBuffer buildBaseline6() { CreatureObject creature = (CreatureObject) object; IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); buffer.putShort((short) 0x23); buffer.putInt(0x43); // serverId buffer.putShort((short) 0); // detaiLStfFilename buffer.putInt(0); // detailStfSpacer buffer.putShort((short) 0); // detailStfName // TANO 6 lists TODO: research buffer.put(creature.getCombatFlag()); buffer.putLong(0); // List<Long> possibly defenders list 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 (SWGObject obj : creature.getEquipmentList().get()) { 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 (SWGObject obj : creature.getAppearanceEquipmentList().get()) { 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; }
public IoBuffer buildBaseline6() { CreatureObject creature = (CreatureObject) object; IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); buffer.putShort((short) 0x23); buffer.putInt(0x4E); buffer.putInt(0); // defenders list unused in NGE buffer.putInt(0); buffer.put(creature.getCombatFlag()); buffer.putLong(0); buffer.putLong(0); buffer.putLong(0); // Vehicle vars or TANO 6 vars TODO: research buffer.putLong(0); buffer.putInt(0); // buffer.putShort(creature.getLevel()); buffer.putShort((short) 90); buffer.putInt(0xD007); // unk 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.getTargetId()); buffer.put(creature.getMoodId()); buffer.putInt(creature.getPerformanceCounter()); buffer.putInt(creature.getPerformanceId()); buffer.putInt(0); // unks buffer.putInt(0); buffer.putInt(6); // Current HAM buffer.putInt(creature.getHamListCounter()); buffer.putInt(creature.getHealth()); buffer.putInt(0); buffer.putInt(creature.getAction()); buffer.putInt(0); buffer.putInt(0x2C01); buffer.putInt(0); buffer.putInt(6); // Max HAM buffer.putInt(0); 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(0); } else { buffer.putInt(creature.getEquipmentList().size()); buffer.putInt(0); for (SWGObject obj : creature.getEquipmentList().get()) { 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 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); // buffer.put(getAsciiString("appearance/gungan_m.sat")); buffer.put((byte) 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()) { buff.setTotalPlayTime( (int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000)); buffer.put((byte) 1); buffer.putInt(0); buffer.putInt(CRC.StringtoCRC(buff.getBuffName())); 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.putShort((short) 0); buffer.putInt(0xFFFFFFFF); buffer.put((byte) 1); buffer.putShort((short) 0); if (creature.getAppearanceEquipmentList().isEmpty()) { buffer.putInt(0); buffer.putInt(0); } else { buffer.putInt(creature.getAppearanceEquipmentList().size()); buffer.putInt(0); for (SWGObject obj : creature.getAppearanceEquipmentList().get()) { 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.putInt(0); buffer.putInt(0); 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; }