drop eligibility works

chest stores tier + quality
ground chest path is guarded
space chest menu/open path exists
reward table lookup moved to open time
quality matching supports all and pipe lists
item-type dispatch stubs are ready
This commit is contained in:
Heron
2026-05-14 23:08:07 -04:00
parent 182349536a
commit d550f14830
13 changed files with 1889 additions and 49 deletions
@@ -70,54 +70,59 @@ public class space_crafting extends script.base_script
public static final float MK4_ENERGY_MAX = 20318.80f;
public static final string_id SID_COLLECTION_REACTOR_REPLACED = new string_id("player_structure", "collection_reactor_replaced");
public static final string_id SID_INCORRECTLY_CONFIGURED_ITEM = new string_id("space/space_interaction", "incorrectly_configured_item");
public static final String STARSHIP_DROID_TABLE = "datatables/space_combat/ship_droid_assignments.iff";
public static final String SHIP_COMPONENT_TABLE = "datatables/space/ship_components.iff";
public static final String SHIP_WEAPON_TABLE = "datatables/ship/components/weapon.iff";
public static double randBell(double avg, double var)
{
//This looks like the Marsagila polar form of a Box-Muller
//Distributes a value over a bell curve, giving a result in standard deviations
//Needs to be clamped to avoid insane values
var = var / 2;
double r, v1, v2;
do
{
v1 = 2.0 * rand() - 1.0;
v2 = 2.0 * rand() - 1.0;
r = v1 * v1 + v2 * v2;
} while (r >= 1.0 || r == 0.0);
double fac = Math.sqrt(-2.0 * StrictMath.log(r) / r);
double deviations = (v1 * fac);
//Now we are going to clamp to +/- 3 standard deviations
deviations = utils.clamp(deviations, -3.0, 3.0);
double value = (avg + deviations * (avg * var));
if (value < 0)
{
return 0;
}
else
{
return value;
}
}
public static float getBellValue(float fltValue, float fltModifier)
{
return (float)(randBell(fltValue, fltModifier));
}
public static final String STARSHIP_DROID_TABLE = "datatables/space_combat/ship_droid_assignments.iff";
public static final String SHIP_COMPONENT_TABLE = "datatables/space/ship_components.iff";
public static final String SHIP_WEAPON_TABLE = "datatables/ship/components/weapon.iff";
public static double randBell(double avg, double var)
{
return applyBellModifier(avg, var, getRandomBellDeviation());
}
public static double getRandomBellDeviation()
{
double r, v1, v2;
do
{
v1 = 2.0 * rand() - 1.0;
v2 = 2.0 * rand() - 1.0;
r = v1 * v1 + v2 * v2;
} while (r >= 1.0 || r == 0.0);
double fac = Math.sqrt(-2.0 * StrictMath.log(r) / r);
double deviations = v1 * fac;
return utils.clamp(deviations, -3.0, 3.0);
}
public static double applyBellModifier(double avg, double var, double deviations)
{
var = var / 2;
double value = avg + deviations * (avg * var);
if (value < 0)
{
return 0;
}
return value;
}
public static double applyDirectedBellModifier(double avg, double var, double deviations, boolean lowerIsBetter)
{
deviations = Math.abs(deviations);
if (lowerIsBetter)
{
deviations = -deviations;
}
return applyBellModifier(avg, var, deviations);
}
public static float getBellValue(float fltValue, float fltModifier)
{
return (float)(randBell(fltValue, fltModifier));
}
public static float getDirectedBellValue(float fltValue, float fltModifier, double deviations, boolean lowerIsBetter)
{
return (float)(applyDirectedBellModifier(fltValue, fltModifier, deviations, lowerIsBetter));
}
public static float getModifiedValue(float fltValue, float fltModifier)
{
fltValue = fltValue + rand(-1 * fltModifier, fltModifier);