Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 ... 8 9 [10] 11

Author Topic: Random Code Mistakes Thread  (Read 36144 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #135 on: October 28, 2021, 08:25:39 AM »

Thank you for the report, fixed this up!
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #136 on: November 05, 2021, 10:25:09 PM »

If you buy security codes in a bar or from a contact, a complication pirate fleet may appear and demand the codes. But handing the codes over doesn't end the mission, and I'm not sure the game makes any attempt at doing so.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #137 on: November 06, 2021, 08:57:11 AM »

Thank you! But, IIRC this is intentional.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Random Code Mistakes Thread
« Reply #138 on: December 01, 2021, 08:42:16 AM »

Line 29 of GravityConditionGenerator causes the chance of Low Gravity to be inverted for planets with radius < 100.

Can be fixed by changing "100 - radius" to "radius - min".
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #139 on: December 01, 2021, 08:59:08 AM »

Ah, thank you! Fixed by removing "1f - " from:
chance = 0.2f + 0.8f * (1f - (100 - radius) / range);

And the other similar expression in that file.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Random Code Mistakes Thread
« Reply #140 on: December 17, 2021, 04:41:39 AM »

The High Grav one is supposed to be inverted... :-[
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #141 on: December 17, 2021, 10:42:06 AM »

I know :( Fixed this a couple of days ago; that's what I get for trying to do some things too fast.
Logged

PureTilt

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Random Code Mistakes Thread
« Reply #142 on: February 03, 2022, 02:19:28 AM »

Entropy amplifier targeting code checks if target ally ship or not only if target is null which never can happen, so you can use entropy amplifier on your own ships.
Logged




Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #143 on: February 03, 2022, 06:46:28 AM »

Hmm, could you clarify where that is? I'm not seeing it.
Logged

PureTilt

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: Random Code Mistakes Thread
« Reply #144 on: February 03, 2022, 02:50:12 PM »

Code: java
	protected ShipAPI findTarget(ShipAPI ship) {
float range = getMaxRange(ship);
boolean player = ship == Global.getCombatEngine().getPlayerShip();
ShipAPI target = ship.getShipTarget();
if (target != null) {
float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
if (dist > range + radSum) target = null;
/* no ally check if have target */
} else {
/* ally check only if target is null */
if (target == null || target.getOwner() == ship.getOwner()) {
if (player) {
target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true);
} else {
Object test = ship.getAIFlags().getCustom(AIFlags.MANEUVER_TARGET);
if (test instanceof ShipAPI) {
target = (ShipAPI) test;
float dist = Misc.getDistance(ship.getLocation(), target.getLocation());
float radSum = ship.getCollisionRadius() + target.getCollisionRadius();
if (dist > range + radSum) target = null;
}
}
}
if (target == null) {
target = Misc.findClosestShipEnemyOf(ship, ship.getLocation(), HullSize.FIGHTER, range, true);
}
}

return target;
}
if target is not null its never check if target is on same side or not
Logged




Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #145 on: February 03, 2022, 02:58:49 PM »

Ah, thank you for clarifying! This looks fine, it's just an extraneous check left over due to some refactoring, probably, but I don't think it's a problem. The AI is not going to target friendlies with it (at least, as far as I can tell; it involves more code than just the system - i.e. actually deciding to use it) and the system *is* mechanically usable on allied ships.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #146 on: July 04, 2022, 07:59:31 AM »

Remnant station custom bounty (CBRemnantStation) can pick an undamaged station even on difficulty 7-8, when it's supposed to pick damaged ones.

Lines 159-164:
Code: java
	boolean damaged = fleet.getMemoryWithoutUpdate().getBoolean("$damagedStation");
if ((difficulty == 7 || difficulty == 8) && damaged) {
stations.add(fleet);
} else if (!damaged) {
stations.add(fleet);
}
An undamaged station on difficulty 7 will fail the first if check (due to not being damaged) and then pass the else if.

My alternative formulation:
Code: java
	boolean isDamaged = fleet.getMemoryWithoutUpdate().getBoolean("$damagedStation");
boolean wantDamaged = difficulty <= 8;
if (isDamaged == wantDamaged) {
stations.add(fleet);
}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #147 on: July 04, 2022, 08:05:27 AM »

Thank you! Fixed that up.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #148 on: July 05, 2022, 03:44:49 AM »

Great!

Unrelatedly, where do custom bounty creators mark their target as important? Because I noticed the CBEnemyStation target wasn't made important, but couldn't find where the other bounty types do it.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Random Code Mistakes Thread
« Reply #149 on: July 05, 2022, 07:15:28 AM »

In BaseCustomBounty.accept(), I believe - that seems like that should kick in for CBEnemyStation, too. ... ah, I bet what's happening is it's flagging the station "fleet" as important (which works for e.g. Remnant stations) but that doesn't do anything for regular colony-stations since the fleet is hidden and what's visible in the campaign is a custom entity. Let me make a note about that!
Logged
Pages: 1 ... 8 9 [10] 11