public TangibleObject( long objectID, Planet planet, String template, Point3D position, Quaternion orientation) { super(objectID, planet, position, orientation, template); messageBuilder = new TangibleMessageBuilder(this); spawnCoordinates = position.clone(); if (this.getClass().getSimpleName().equals("TangibleObject")) setIntAttribute("volume", 1); }
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); } } }