@Override
  public void advance(float amount) {
    if (Global.getCombatEngine() == null) return;

    float t = Global.getCombatEngine().getTotalElapsedTime(false);
    if (t > timeOfNextUpdate) {
      timeOfNextUpdate = t + UPDATE_FREQUENCY;

      if (findTarget() == null) return;

      float selfOverloadTime = IceUtils.getBaseOverloadDuration(ship);
      float targetOverloadTime =
          IceUtils.estimateOverloadDurationOnHit(
              target, weapon.getDerivedStats().getDamagePerShot(), weapon.getDamageType());
      float incomingMissileDamage = IceUtils.estimateIncomingMissileDamage(ship);
      float fpOfSupport = IceUtils.getFPWorthOfSupport(ship, 2000);
      float fpOfEnemies = IceUtils.getFPWorthOfHostility(ship, 2000);
      fpOfEnemies = Math.max(0, fpOfEnemies - IceUtils.getFP(target) / 2);

      hitChance = IceUtils.getHitChance(weapon, target);
      targetWillDieSoonAnyway = (IceUtils.getLifeExpectancy(ship) < 3);
      overloadBalance = targetOverloadTime - selfOverloadTime;
      fpRatio = IceUtils.getFPStrength(target) / IceUtils.getFPStrength(ship);
      danger = Math.max(0, fpOfEnemies - fpOfSupport + incomingMissileDamage / 100f);
    }
  }
Пример #2
0
  @Override
  public void advance(float amount) {
    if (!missile.getSource().isAlive()) {
      IceUtils.destroy(missile);
      return;
    }

    super.advance(amount);

    weaponCooldown = Math.max(0, weaponCooldown - amount);

    if (target == null) return;

    Vector2f.add(destOffset, target.getLocation(), dest);

    accelerate();
    turnToward(dest);

    if (ammo > 0 && weaponCooldown == 0) {
      CombatEntityAPI nearest = null;
      float record = Float.MAX_VALUE;

      for (int i = 0; i < potentialTargets.size(); ++i) {
        CombatEntityAPI m = (CombatEntityAPI) potentialTargets.get(i);

        float dist2 = MathUtils.getDistanceSquared(missile, m);

        if (dist2 < record && dist2 <= WEAPON_RANGE_SQUARED) {
          record = dist2;
          nearest = m;
        }
      }

      if (nearest != null) {
        Global.getCombatEngine()
            .spawnProjectile(
                missile.getSource(),
                null,
                WEAPON_ID,
                missile.getLocation(),
                VectorUtils.getAngle(missile.getLocation(), nearest.getLocation()),
                new Vector2f());

        --ammo;
        weaponCooldown = WEAPON_COOLDOWN;
      }
    }
  }
Пример #3
0
  public PdDroneMissileAI(MissileAPI missile) {
    super(missile);

    findTarget();
    this.circumstanceEvaluationTimer.setInterval(0.6f, 1.4f);

    int count = 0;

    Object[] missiles = Global.getCombatEngine().getMissiles().toArray();

    for (int i = missiles.length - 1; i >= 0; --i) {
      MissileAPI m = (MissileAPI) missiles[i];

      if (m.getProjectileSpecId().equals(MISSILE_ID) && m.getWeapon() == missile.getWeapon()) {
        ++count;

        if (count >= MAX_ACTIVE_DRONES) {
          IceUtils.destroy(m);
        }
      }
    }

    // missile.setCollisionClass(CollisionClass.FIGHTER);
  }
  @Override
  public void forceOff() {
    if (Global.getCombatEngine() == null) return;

    findTarget();
  }
 /**
  * create a dummy location the access the item and fleet exchange UI, user should quickly remove
  * it to prevent AI do some strange actions.
  *
  * @return
  */
 private OrbitalStationAPI createDummyStation(String name) {
   SectorAPI sector = Global.getSector();
   LocationAPI sys = sector.getCurrentLocation();
   return (OrbitalStationAPI)
       sys.addOrbitalStation(sector.getPlayerFleet(), 0, 100, 100, name, "neutral");
 }
Пример #6
0
  public void generate(SectorAPI sector) {
    StarSystemAPI system = sector.createStarSystem("Cocytus");
    system.getLocation().set(-5000, -11500);
    system.setBackgroundTextureFilename("graphics/backgrounds/hyperspace1.jpg");

    PlanetAPI cocytus =
        system.initStar(
            "cocytus", // unique id for this star
            "star_red", // id in planets.json
            500f, // radius (in pixels at default zoom)
            500, // corona radius, from star edge
            10f, // solar wind burn level
            1f, // flare probability
            3f); // cr loss mult

    system.setLightColor(
        new Color(255, 0, 0)); // light color in entire system, affects all entities

    PlanetAPI enkidu = system.addPlanet("enkidu", cocytus, "Enkidu", "lava", 300, 200, 3400, 215);
    enkidu.getSpec().setGlowTexture(Global.getSettings().getSpriteName("hab_glows", "volturn"));
    enkidu.getSpec().setGlowColor(new Color(255, 200, 150, 255));
    enkidu.getSpec().setUseReverseLightForGlow(true);
    enkidu.applySpecChanges();
    enkidu.setCustomDescriptionId("fs_enkidu");

    // Shivan Jumppoint
    JumpPointAPI enkidu_jumppoint =
        Global.getFactory().createJumpPoint("enkidu_jump", "Enkidu Jumppoint");
    enkidu_jumppoint.setCircularOrbit(system.getEntityById("enkidu"), 100, 300, 215);
    enkidu_jumppoint.setRelatedPlanet(enkidu);

    enkidu_jumppoint.setStandardWormholeToHyperspaceVisual();
    system.addEntity(enkidu_jumppoint);

    // Shivan Station
    SectorEntityToken shivanStation =
        system.addCustomEntity(
            "fs_shivan_base", "Shivan Origin", "station_jangala_type", "fs_shivan");
    shivanStation.setCircularOrbitPointingDown(system.getEntityById("enkidu"), 45 + 180, 300, 50);
    shivanStation.setCustomDescriptionId("fs_shivan_base");

    addMarketplace.addMarketplace(
        "fs_shivan",
        enkidu,
        new ArrayList<>(Arrays.asList(shivanStation)),
        "Shivan Origin",
        10,
        new ArrayList<>(
            Arrays.asList(
                Conditions.UNINHABITABLE,
                Conditions.AUTOFAC_HEAVY_INDUSTRY,
                Conditions.MILITARY_BASE,
                Conditions.POPULATION_10,
                Conditions.HEADQUARTERS,
                Conditions.SPACEPORT,
                Conditions.ORE_COMPLEX,
                Conditions.ORE_REFINING_COMPLEX)),
        new ArrayList<>(Arrays.asList(Submarkets.SUBMARKET_STORAGE, Submarkets.GENERIC_MILITARY)),
        0f);

    system.autogenerateHyperspaceJumpPoints(true, true);
  }