Generated ships carry the crates their weapons reload from; Missiles gets a cargo shape; comment and lore fixes
LoadoutGenerator.GenerateShipLoadout, the one owner of NPC and generated-scenario fitting, now stocks AmmunitionCrates (3) of every distinct AmmoType the ship's weapons draw, after the consumable roll and without touching the random stream; it logs and goes on if no hold takes them. Missiles is authored with Ammo's 1x1 shape and a stack of 5 (a shapeless commodity cannot be stored at all). Tests: generated ships hold exactly the crates they draw and none of an ammunition they do not; a magazine weapon with no AmmoType still reloads free. weapon-ammo moves so RangeFalloff keeps its doc comment; the Munitions comment and lore now match the recipe (warhead and motor, magazines 2 to 288). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fdbf0b6851
commit
386f29bf0d
5 changed files with 85 additions and 12 deletions
|
|
@ -24,6 +24,10 @@ public class LoadoutGenerator
|
|||
public const float ShipConsumableChance = .1f;
|
||||
public const int ShipConsumableUnits = 1;
|
||||
|
||||
// Ammunition-fed weapons reload from cargo (ruling ballistics-real-ammo), so a generated ship carries this many crates of every
|
||||
// distinct AmmoType its weapons draw: enough to fight on past the first magazine, few enough to leave the rest of the hold.
|
||||
public const int AmmunitionCrates = 3;
|
||||
|
||||
public LoadoutGenerator(
|
||||
ref Random random,
|
||||
ItemManager itemManager,
|
||||
|
|
@ -56,6 +60,7 @@ public class LoadoutGenerator
|
|||
OutfitEntity(entity);
|
||||
EquipPickup(entity);
|
||||
StockConsumables(entity, ShipConsumableChance, ShipConsumableUnits);
|
||||
StockAmmunition(entity);
|
||||
return EntitySerializer.Pack(entity);
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +167,18 @@ public class LoadoutGenerator
|
|||
}
|
||||
}
|
||||
|
||||
// The crates the ship's weapons reload from: AmmunitionCrates of each distinct AmmoType, stopping when no hold takes another.
|
||||
// Draws nothing from the random stream, so adding it moves no other roll.
|
||||
private void StockAmmunition(Entity entity)
|
||||
{
|
||||
foreach (var key in entity.Weapons.Select(weapon => weapon.WeaponData.AmmoType).Where(type => type.IsSet()).Select(type => type.Key).Distinct())
|
||||
{
|
||||
var crates = new SimpleCommodity { Data = new CultRecordRef<ItemData>(key), Quantity = AmmunitionCrates };
|
||||
if (!entity.CargoBays.Any(bay => bay.TryStore(crates)))
|
||||
ItemManager.Log($"{entity.Name}: no room for {AmmunitionCrates} crates of {key.Value}.");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsHeater(GearData item) =>
|
||||
item.HardpointType == HardpointType.Tool &&
|
||||
item.Behaviors.Any(b => b is ThermotoggleData { HighPass: false }) &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue