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 void removeBuffFromCreature(CreatureObject creature, Buff buff) { if (!creature.getBuffList().contains(buff)) return; DamageOverTime dot = creature.getDotByBuff(buff); if (dot != null) { dot.getTask().cancel(true); creature.removeDot(dot); } if (FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) core.scriptService.callScript( "scripts/buffs/", "removeBuff", buff.getBuffName(), core, creature, buff); creature.removeBuff(buff); }
public void processCommand( CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { if (command.getCooldown() > 0f) { actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); } if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { if (FileUtilities.doesFileExist( "scripts/commands/" + command.getCommandName().toLowerCase() + ".py")) { core.scriptService.callScript( "scripts/commands/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); } else if (FileUtilities.doesFileExist( "scripts/commands/combat/" + command.getCommandName().toLowerCase() + ".py")) { core.scriptService.callScript( "scripts/commands/combat/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); } } }
public void processCombatCommand( CreatureObject attacker, SWGObject target, CombatCommand command, int actionCounter, String commandArgs) { if (FileUtilities.doesFileExist( "scripts/commands/combat/" + command.getCommandName() + ".py")) { core.scriptService.callScript( "scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); } boolean success = true; // if((command.getHitType() == 5 || command.getHitType() == 7) && !(target instanceof // CreatureObject)) // success = false; if (!(command.getAttackType() == 2) && !(command.getHitType() == 5) && !(command.getHitType() == 0)) { if (target == null || !(target instanceof TangibleObject) || target == attacker) success = false; } else { if (target == null) target = attacker; else if (!(target instanceof TangibleObject)) return; } if (attacker.getPosture() == 13 || attacker.getPosture() == 14) success = false; if (target instanceof CreatureObject) { if (!(command.getHitType() == 5)) if (((CreatureObject) target).getPosture() == 13) success = false; if (!(command.getHitType() == 7)) if (((CreatureObject) target).getPosture() == 14) success = false; } if (command.getHitType() == 7 && target.getClient() == null) success = false; WeaponObject weapon; if (attacker.getWeaponId() == 0) weapon = (WeaponObject) attacker.getSlottedObject( "default_weapon"); // use unarmed/default weapon if no weapon is equipped else weapon = (WeaponObject) core.objectService.getObject(attacker.getWeaponId()); float maxRange = 0; if (command.getMaxRange() == 0) maxRange = weapon.getMaxRange(); else maxRange = command.getMaxRange(); Point3D attackerPos = attacker.getWorldPosition(); Point3D defenderPos = attacker.getWorldPosition(); if (attackerPos.getDistance(defenderPos) > maxRange && maxRange != 0) success = false; if (command.getMinRange() > 0) { if (attackerPos.getDistance(defenderPos) < command.getMinRange()) success = false; } if (target != attacker && success && !core.simulationService.checkLineOfSight(attacker, target)) { attacker.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true); success = false; } if (!success && attacker.getClient() != null) { IoSession session = attacker.getClient().getSession(); CommandEnqueueRemove commandRemove = new CommandEnqueueRemove(attacker.getObjectId(), actionCounter); session.write(new ObjControllerMessage(0x0B, commandRemove).serialize()); StartTask startTask = new StartTask( actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), -1); session.write(new ObjControllerMessage(0x0B, startTask).serialize()); } else { if (command.getHitType() == 5) { core.combatService.doHeal( attacker, (CreatureObject) target, weapon, command, actionCounter); return; } if (command.getHitType() == 7) { core.combatService.doRevive( attacker, (CreatureObject) target, weapon, command, actionCounter); return; } if (command.getHitType() == 0 && command.getBuffNameSelf() != null && command.getBuffNameSelf().length() > 0) { core.combatService.doSelfBuff(attacker, weapon, command, actionCounter); return; } for (int i = 0; i < command.getAttack_rolls(); i++) { core.combatService.doCombat( attacker, (TangibleObject) target, weapon, command, actionCounter); } } }