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 ... 3 4 [5] 6 7 ... 11

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Random Code Mistakes Thread
« Reply #60 on: April 22, 2016, 09:32:40 PM »

Ahh, I see. Fixed.

The fix sure got ugly... problem was that dpsDuration is being reset every frame (by the beam), while a fast-time ship's beam effect plugin might run several times per frame. Normally dpsDuration would be something like 0, 0, 0, 0, 0.1, 0, 0, etc (beams doing damage at 0.1 second intervals), but for a fast-time ship it'd do a bunch of the .1 frames in a row. Which would be fine, except the beam is also running 3x faster, sort of mimicking ship-time in engine-time, to ensure it does the right amount of damage, i.e. based on ship-time.

Can't fix it by advancing beams in ship-time due to the order of calls being important. And advancing beams multiple times in fast-time - instead of once in engine-time, but with a ship-time multiplier - would get pretty involved too, on the engine side - that's the "right" fix, and doable, but would take a while to make sure it was right. Hence this abomination. Sigh.

In conclusion, messing with time messes with my mind.

Spoiler
Code: java
public class TachyonLanceEffect implements BeamEffectPlugin {

private IntervalUtil fireInterval = new IntervalUtil(0.2f, 0.3f);
private boolean wasZero = true;

public void advance(float amount, CombatEngineAPI engine, BeamAPI beam) {
CombatEntityAPI target = beam.getDamageTarget();
if (target instanceof ShipAPI && beam.getBrightness() >= 1f) {
float dur = beam.getDamage().getDpsDuration();
// needed because when the ship is in fast-time, dpsDuration will not be reset every frame as it should be
if (!wasZero) dur = 0;
wasZero = beam.getDamage().getDpsDuration() <= 0;
fireInterval.advance(dur);
if (fireInterval.intervalElapsed()) {
ShipAPI ship = (ShipAPI) target;
boolean hitShield = target.getShield() != null && target.getShield().isWithinArc(beam.getTo());
float pierceChance = ((ShipAPI)target).getHardFluxLevel() - 0.1f;
pierceChance *= ship.getMutableStats().getDynamic().getValue(Stats.SHIELD_PIERCED_MULT);

boolean piercedShield = hitShield && (float) Math.random() < pierceChance;
//piercedShield = true;

if (!hitShield || piercedShield) {
Vector2f dir = Vector2f.sub(beam.getTo(), beam.getFrom(), new Vector2f());
if (dir.lengthSquared() > 0) dir.normalise();
dir.scale(50f);
Vector2f point = Vector2f.sub(beam.getTo(), dir, new Vector2f());
float emp = beam.getWeapon().getDamage().getFluxComponent() * 0.5f;
float dam = beam.getWeapon().getDamage().getDamage() * 0.25f;
engine.spawnEmpArcPierceShields(
  beam.getSource(), point, beam.getDamageTarget(), beam.getDamageTarget(),
  DamageType.ENERGY,
  dam, // damage
  emp, // emp
  100000f, // max range
  "tachyon_lance_emp_impact",
  beam.getWidth() + 5f,
  beam.getFringeColor(),
  beam.getCoreColor()
  );
}
}
}

}
}
[close]

Edit: and, I almost forgot to undo one of the Scarab's slots being large to test this. That would be a really fun one to completely forget about and make the next release with.
« Last Edit: April 22, 2016, 09:34:16 PM by Alex »
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Random Code Mistakes Thread
« Reply #61 on: April 22, 2016, 09:55:57 PM »

Hopefully people don't get used to the Ion Beam and Tachyon Lance being grossly overpowered on a couple mod ships...
Logged

Midnight Kitsune

  • Admiral
  • *****
  • Posts: 2846
  • Your Friendly Forum Friend
    • View Profile
Re: Random Code Mistakes Thread
« Reply #62 on: September 25, 2016, 10:46:57 PM »

This seems like the best place to put this:
The Plasma Cannon has no weapon hints at all, making it shoot (and waste flux) firing at fighters and sometimes frigs. Is this supposed to be like this?
Logged
Help out MesoTroniK, a modder in need

2021 is 2020 won
2022 is 2020 too

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Random Code Mistakes Thread
« Reply #63 on: September 26, 2016, 08:47:24 AM »

Plasma Cannon, I'd argue, is effective against frigates.  If you actually hit, they die, and you're not ammo limited.

Hitting fighters with that charge-up delay is basically impossible though.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #64 on: December 17, 2016, 07:53:35 AM »

The factionPicker arg in BaseSubmarketPlugin.getWeaponsOnRolePick() (line 347) does nothing!!
Code: java
protected List<WeaponSpecAPI> getWeaponsOnRolePick(String role, WeightedRandomPicker<FactionAPI> factionPicker) {
float qf = market.getShipQualityFactor();

List<WeaponSpecAPI> result = new ArrayList<WeaponSpecAPI>();

FactionAPI faction = submarket.getFaction();
if (factionPicker != null && !factionPicker.isEmpty()) {
faction = factionPicker.pick(); // it picks a faction
}
List<ShipRolePick> picks = submarket.getFaction().pickShip(role, qf, itemGenRandom); // but then just uses the submarket faction
// [...]
}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Random Code Mistakes Thread
« Reply #65 on: December 17, 2016, 10:16:16 AM »

Weeeeell, that would explain why the black market weapons were all pirate stuff. Thank you, fixed!
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Random Code Mistakes Thread
« Reply #66 on: April 22, 2017, 01:46:34 AM »

Drover is worth 0 fleet points, throwing off some fleetbuilding calculations.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Random Code Mistakes Thread
« Reply #67 on: April 22, 2017, 03:39:31 AM »



We have ship damage effects sticking out on the external boundary, but not the internal boundary of splits.  Don't mind the weird screenshot; it's just a way to visualize it.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Random Code Mistakes Thread
« Reply #68 on: April 23, 2017, 12:02:25 AM »

Aquaculture.java:

Code: java
package com.fs.starfarer.api.impl.campaign.econ;


public class Aquaculture extends BaseMarketConditionPlugin {

public void apply(String id) {

// float pop = getPopulation(market);
// float foodProduced = pop * ConditionData.AQUACULTURE_FOOD_MULT;
// float organicsProduced = foodProduced * ConditionData.FARMING_ORGANICS_FRACTION;
// market.getCommodityData(Commodities.ORGANICS).getSupply().modifyFlat(id, organicsProduced);
// market.getCommodityData(Commodities.FOOD).getSupply().modifyFlat(id, foodProduced);
// market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id,
// foodProduced * ConditionData.AQUACULTURE_MACHINERY_MULT);
}

public void unapply(String id) {
// market.getCommodityData(Commodities.ORGANICS).getSupply().unmodify(id);
// market.getCommodityData(Commodities.FOOD).getSupply().unmodify(id);
// market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().unmodify(id);
}

}

Probably a mistake?
Logged
 

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #69 on: April 30, 2017, 06:40:04 AM »

The factionPicker arg in BaseSubmarketPlugin.getWeaponsOnRolePick() (line 347) does nothing!!
Code: java
protected List<WeaponSpecAPI> getWeaponsOnRolePick(String role, WeightedRandomPicker<FactionAPI> factionPicker) {
float qf = market.getShipQualityFactor();

List<WeaponSpecAPI> result = new ArrayList<WeaponSpecAPI>();

FactionAPI faction = submarket.getFaction();
if (factionPicker != null && !factionPicker.isEmpty()) {
faction = factionPicker.pick(); // it picks a faction
}
List<ShipRolePick> picks = submarket.getFaction().pickShip(role, qf, itemGenRandom); // but then just uses the submarket faction
// [...]
}
getWingsOnRolePick() has the same issue (line 433).
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Random Code Mistakes Thread
« Reply #70 on: April 30, 2017, 11:45:22 AM »

Drover is worth 0 fleet points, throwing off some fleetbuilding calculations.

Thank you, fixed.

Spoiler

[close]
We have ship damage effects sticking out on the external boundary, but not the internal boundary of splits.  Don't mind the weird screenshot; it's just a way to visualize it.

Been meaning to get back to this - not actually quite sure what I'm looking at here. A quick "this is how to see it in-game with a half-decent probability of it happening" would be really helpful.

Aquaculture: iirc intentional, but ty.

Re: fighter LPC picking: oops, fixed, thank you. Explains some things.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Random Code Mistakes Thread
« Reply #71 on: April 30, 2017, 01:27:56 PM »

Normally the damage overlay texture is stencil-checked such that it doesn't render over where the ship texture is fully transparent.  When a ship splits into chunks, the damage overlay texture stops doing that and only uses the visual render bounds as the stencil, not the ship transparency.  As a result, the damage texture sticks outside of the actual sprite when a ship is chunkified.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Random Code Mistakes Thread
« Reply #72 on: April 30, 2017, 01:39:37 PM »

Aha - meaning, this happens if the visual bounds of the chunks happen to go outside the ship sprite, correct? If so, this is more or less intended; the chunk boundaries aren't necessarily going to match the sprite.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Random Code Mistakes Thread
« Reply #73 on: May 31, 2017, 07:44:31 AM »

A large number of market conditions (OrbitalStation, Spaceport, LargeRefugeePopulation being the potentially most dangerous) still use getPopulation() (the 10^size one) instead of getBaseSizeMult() for their supply/demand values. Is this desirable?

EDIT: Also Fuel Production uses sizemult for everything except its heavy machinery demand, which is constant.

EDIT 2: Okay, turns out a lot of the population references are commented out or otherwise unused, and the ones that aren't are often capped. Still seems wrong...
« Last Edit: May 31, 2017, 08:14:15 AM by Histidine »
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Random Code Mistakes Thread
« Reply #74 on: June 01, 2017, 11:15:02 AM »

Mistake string method:

Interface FleetAssignmentDataAPI:

isExipred()  => isExpired()
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.
Pages: 1 ... 3 4 [5] 6 7 ... 11