Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- } else if (ship.getHullSpec().getHullId().equals("exigency_cruiser")) {
- // Super CIGEN
- if (!canUseAltSystemThisFrame(ship)) {
- return;
- }
- boolean shouldUseSystem = false;
- WeaponAPI weap = null;
- List<WeaponAPI> allWeapons = ship.getAllWeapons();
- for (WeaponAPI weapon : allWeapons) {
- if (weapon.getId().equals("exigency_rr")) {
- if (weapon.getAmmo() > 2 && !weapon.isDisabled()) {
- weap = weapon;
- }
- }
- }
- if (weap == null) {
- return;
- }
- float range = ship.getMutableStats().getBallisticWeaponRangeBonus().computeEffective(CIGEN_RANGE);
- ShipAPI target = null;
- List<ShipAPI> directTargets = CombatUtils.getShipsWithinRange(weap.getLocation(), range);
- directTargets.remove(ship);
- if (!directTargets.isEmpty()) {
- Collections.sort(directTargets, new CollectionUtils.SortEntitiesByDistance(weap.getLocation()));
- ListIterator<ShipAPI> iter = directTargets.listIterator();
- while (iter.hasNext()) {
- ShipAPI tmp = iter.next();
- if (!tmp.isFighter() && !tmp.isDrone()) {
- Vector2f endpoint = new Vector2f(range, 0f);
- VectorUtils.rotate(endpoint, ship.getFacing(), endpoint);
- Vector2f.add(endpoint, ship.getLocation(), endpoint);
- float speed = CIGEN_PROJECTILE_SPEED * ship.getMutableStats().getProjectileSpeedMult().getModifiedValue();
- Vector2f relativeVelocity = Vector2f.sub(tmp.getVelocity(), ship.getVelocity(), null);
- Vector2f loc = intercept(weap.getLocation(), speed, tmp.getLocation(), relativeVelocity);
- if (loc == null) {
- Vector2f projection = new Vector2f(tmp.getVelocity());
- float scalar = MathUtils.getDistance(tmp.getLocation(), weap.getLocation()) / speed;
- projection.scale(scalar);
- Vector2f.add(tmp.getLocation(), projection, loc);
- }
- if (loc != null && weap.getLocation() != null) {
- if (CollisionUtils.getCollides(weap.getLocation(), endpoint, loc, tmp.getCollisionRadius() * 0.75f)) {
- target = tmp;
- break;
- }
- }
- }
- }
- }
- if (target == null || target.getOwner() != ship.getOwner() || target.isHulk()) {
- return;
- }
- float decisionLevel;
- if (target.isFrigate()) {
- decisionLevel = 0.25f;
- } else if (target.isDestroyer()) {
- decisionLevel = 0.5f;
- } else if (target.isCruiser()) {
- decisionLevel = 0.75f;
- } else {
- decisionLevel = 1f;
- }
- for (ShipAPI tmp : directTargets) {
- if (tmp.getOwner() == ship.getOwner() && !tmp.isFighter() && !tmp.isDrone()) {
- Vector2f safetyRectA = new Vector2f(-100f, 100f);
- VectorUtils.rotate(safetyRectA, ship.getFacing(), safetyRectA);
- Vector2f.add(safetyRectA, ship.getLocation(), safetyRectA);
- Vector2f safetyRectB = new Vector2f(-100f, -100f);
- VectorUtils.rotate(safetyRectB, ship.getFacing(), safetyRectB);
- Vector2f.add(safetyRectB, ship.getLocation(), safetyRectB);
- Vector2f safetyRectC = new Vector2f(1000f, -100f);
- VectorUtils.rotate(safetyRectC, ship.getFacing(), safetyRectC);
- Vector2f.add(safetyRectC, ship.getLocation(), safetyRectC);
- Vector2f safetyRectD = new Vector2f(1000f, 100f);
- VectorUtils.rotate(safetyRectD, ship.getFacing(), safetyRectD);
- Vector2f.add(safetyRectD, ship.getLocation(), safetyRectD);
- Vector2f pointA = CollisionUtils.getCollisionPoint(safetyRectA, safetyRectD, tmp);
- Vector2f pointB = CollisionUtils.getCollisionPoint(safetyRectB, safetyRectC, tmp);
- if (pointA != null || pointB != null) {
- float distance = MathUtils.getDistance(ship, tmp);
- decisionLevel -= 0.75f * (1f - distance / 1000f);
- }
- }
- }
- FleetMemberAPI member = CombatUtils.getFleetMember(target);
- if (member != null) {
- decisionLevel *= (float) member.getFleetPointCost() / 10f;
- }
- decisionLevel *= (float) Math.sqrt((double) weap.getAmmo() / 5.0);
- decisionLevel *= 2f - (ship.getFluxTracker().getCurrFlux() + ship.getFluxTracker().getHardFlux()) / ship.getFluxTracker().getMaxFlux();
- ShipwideAIFlags flags = exigency_RepulsorAI.getFlags(ship);
- if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.PURSUING)) {
- decisionLevel *= CIGEN_PURSUING_DECISION_FACTOR;
- }
- if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.BACK_OFF)) {
- decisionLevel *= CIGEN_BACK_OFF_DECISION_FACTOR;
- }
- if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.DO_NOT_USE_FLUX)) {
- decisionLevel *= CIGEN_DO_NOT_USE_FLUX_DECISION_FACTOR;
- }
- if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.RUN_QUICKLY)) {
- decisionLevel *= CIGEN_RUN_QUICKLY_DECISION_FACTOR;
- }
- if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.HAS_INCOMING_DAMAGE)) {
- decisionLevel *= CIGEN_HAS_INCOMING_DAMAGE_DECISION_FACTOR;
- }
- if (decisionLevel >= 0.5f) {
- shouldUseSystem = true;
- }
- if (shouldUseSystem && ship.getFluxTracker().getCurrFlux() + exigency_superCIGENStats.FLUX_COST * ship.getHullSpec().getFluxCapacity() < ship.getFluxTracker().getMaxFlux() * HIGH_FLUX_THRESHOLD) {
- systemAllowance.put(ship, Float.valueOf(0.1f));
- ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK, null, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement