Advertisement
DarkRevenant

Untitled

Jul 6th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.57 KB | None | 0 0
  1.         } else if (ship.getHullSpec().getHullId().equals("exigency_cruiser")) {
  2.             // Super CIGEN
  3.             if (!canUseAltSystemThisFrame(ship)) {
  4.                 return;
  5.             }
  6.  
  7.             boolean shouldUseSystem = false;
  8.  
  9.             WeaponAPI weap = null;
  10.             List<WeaponAPI> allWeapons = ship.getAllWeapons();
  11.             for (WeaponAPI weapon : allWeapons) {
  12.                 if (weapon.getId().equals("exigency_rr")) {
  13.                     if (weapon.getAmmo() > 2 && !weapon.isDisabled()) {
  14.                         weap = weapon;
  15.                     }
  16.                 }
  17.             }
  18.  
  19.             if (weap == null) {
  20.                 return;
  21.             }
  22.  
  23.             float range = ship.getMutableStats().getBallisticWeaponRangeBonus().computeEffective(CIGEN_RANGE);
  24.  
  25.             ShipAPI target = null;
  26.             List<ShipAPI> directTargets = CombatUtils.getShipsWithinRange(weap.getLocation(), range);
  27.             directTargets.remove(ship);
  28.             if (!directTargets.isEmpty()) {
  29.                 Collections.sort(directTargets, new CollectionUtils.SortEntitiesByDistance(weap.getLocation()));
  30.                 ListIterator<ShipAPI> iter = directTargets.listIterator();
  31.                 while (iter.hasNext()) {
  32.                     ShipAPI tmp = iter.next();
  33.                     if (!tmp.isFighter() && !tmp.isDrone()) {
  34.                         Vector2f endpoint = new Vector2f(range, 0f);
  35.                         VectorUtils.rotate(endpoint, ship.getFacing(), endpoint);
  36.                         Vector2f.add(endpoint, ship.getLocation(), endpoint);
  37.  
  38.                         float speed = CIGEN_PROJECTILE_SPEED * ship.getMutableStats().getProjectileSpeedMult().getModifiedValue();
  39.                         Vector2f relativeVelocity = Vector2f.sub(tmp.getVelocity(), ship.getVelocity(), null);
  40.                         Vector2f loc = intercept(weap.getLocation(), speed, tmp.getLocation(), relativeVelocity);
  41.  
  42.                         if (loc == null) {
  43.                             Vector2f projection = new Vector2f(tmp.getVelocity());
  44.                             float scalar = MathUtils.getDistance(tmp.getLocation(), weap.getLocation()) / speed;
  45.                             projection.scale(scalar);
  46.                             Vector2f.add(tmp.getLocation(), projection, loc);
  47.                         }
  48.  
  49.                         if (loc != null && weap.getLocation() != null) {
  50.                             if (CollisionUtils.getCollides(weap.getLocation(), endpoint, loc, tmp.getCollisionRadius() * 0.75f)) {
  51.                                 target = tmp;
  52.                                 break;
  53.                             }
  54.                         }
  55.                     }
  56.                 }
  57.             }
  58.  
  59.             if (target == null || target.getOwner() != ship.getOwner() || target.isHulk()) {
  60.                 return;
  61.             }
  62.  
  63.             float decisionLevel;
  64.             if (target.isFrigate()) {
  65.                 decisionLevel = 0.25f;
  66.             } else if (target.isDestroyer()) {
  67.                 decisionLevel = 0.5f;
  68.             } else if (target.isCruiser()) {
  69.                 decisionLevel = 0.75f;
  70.             } else {
  71.                 decisionLevel = 1f;
  72.             }
  73.  
  74.             for (ShipAPI tmp : directTargets) {
  75.                 if (tmp.getOwner() == ship.getOwner() && !tmp.isFighter() && !tmp.isDrone()) {
  76.                     Vector2f safetyRectA = new Vector2f(-100f, 100f);
  77.                     VectorUtils.rotate(safetyRectA, ship.getFacing(), safetyRectA);
  78.                     Vector2f.add(safetyRectA, ship.getLocation(), safetyRectA);
  79.                     Vector2f safetyRectB = new Vector2f(-100f, -100f);
  80.                     VectorUtils.rotate(safetyRectB, ship.getFacing(), safetyRectB);
  81.                     Vector2f.add(safetyRectB, ship.getLocation(), safetyRectB);
  82.                     Vector2f safetyRectC = new Vector2f(1000f, -100f);
  83.                     VectorUtils.rotate(safetyRectC, ship.getFacing(), safetyRectC);
  84.                     Vector2f.add(safetyRectC, ship.getLocation(), safetyRectC);
  85.                     Vector2f safetyRectD = new Vector2f(1000f, 100f);
  86.                     VectorUtils.rotate(safetyRectD, ship.getFacing(), safetyRectD);
  87.                     Vector2f.add(safetyRectD, ship.getLocation(), safetyRectD);
  88.  
  89.                     Vector2f pointA = CollisionUtils.getCollisionPoint(safetyRectA, safetyRectD, tmp);
  90.                     Vector2f pointB = CollisionUtils.getCollisionPoint(safetyRectB, safetyRectC, tmp);
  91.  
  92.                     if (pointA != null || pointB != null) {
  93.                         float distance = MathUtils.getDistance(ship, tmp);
  94.                         decisionLevel -= 0.75f * (1f - distance / 1000f);
  95.                     }
  96.                 }
  97.             }
  98.  
  99.             FleetMemberAPI member = CombatUtils.getFleetMember(target);
  100.             if (member != null) {
  101.                 decisionLevel *= (float) member.getFleetPointCost() / 10f;
  102.             }
  103.  
  104.             decisionLevel *= (float) Math.sqrt((double) weap.getAmmo() / 5.0);
  105.             decisionLevel *= 2f - (ship.getFluxTracker().getCurrFlux() + ship.getFluxTracker().getHardFlux()) / ship.getFluxTracker().getMaxFlux();
  106.             ShipwideAIFlags flags = exigency_RepulsorAI.getFlags(ship);
  107.             if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.PURSUING)) {
  108.                 decisionLevel *= CIGEN_PURSUING_DECISION_FACTOR;
  109.             }
  110.             if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.BACK_OFF)) {
  111.                 decisionLevel *= CIGEN_BACK_OFF_DECISION_FACTOR;
  112.             }
  113.             if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.DO_NOT_USE_FLUX)) {
  114.                 decisionLevel *= CIGEN_DO_NOT_USE_FLUX_DECISION_FACTOR;
  115.             }
  116.             if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.RUN_QUICKLY)) {
  117.                 decisionLevel *= CIGEN_RUN_QUICKLY_DECISION_FACTOR;
  118.             }
  119.             if (flags != null && flags.hasFlag(ShipwideAIFlags.AIFlags.HAS_INCOMING_DAMAGE)) {
  120.                 decisionLevel *= CIGEN_HAS_INCOMING_DAMAGE_DECISION_FACTOR;
  121.             }
  122.  
  123.             if (decisionLevel >= 0.5f) {
  124.                 shouldUseSystem = true;
  125.             }
  126.  
  127.             if (shouldUseSystem && ship.getFluxTracker().getCurrFlux() + exigency_superCIGENStats.FLUX_COST * ship.getHullSpec().getFluxCapacity() < ship.getFluxTracker().getMaxFlux() * HIGH_FLUX_THRESHOLD) {
  128.                 systemAllowance.put(ship, Float.valueOf(0.1f));
  129.                 ship.giveCommand(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK, null, 0);
  130.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement