Skip to content

Asteroid

An Asteroid is a natural mining target — a floating rock in a Sector that mining ships can extract resources from. Vanilla uses class.asteroid as the catch-all for mining-eligible rocks; class.miningnode, class.crystal, and class.recyclable are related class labels with slightly different gameplay roles.

No dedicated datatype. Asteroids are class.asteroid but scriptproperties.xml has no asteroid datatype — the class is a label, properties come from inherited object and from per-macro .wares. Same shape as Bomb, Checkpoint, Welfare module.

ClassPurposeDistinction
class.asteroidCatch-all for “minable rock”Most mineable objects qualify
class.miningnodeSpecific asteroid types that mining drones targetA subtype within mining-targetable rocks
class.crystalCrystal asteroids (rare; Terran/special crystal fields)Distinct visual + ware content
class.recyclableScrap cubes / derelict hulls for Processing modulesNot technically asteroids — but adjacent

class.recyclable is what the Processing module consumes via process_recyclable_object; the others are mined via drilling weapons.

There are no asteroid-specific datatype properties. Useful inherited:

PropertySourceDescription
.wares(per-macro)Contained ware(s) — what mining extracts
.sector / .zone / .positionobjectLocation
.macrocomponentAsteroid macro variant
.hulldestructibleDamage state — mining drills reduce hull, exhausting yields fragments

The .wares accessor is the most-used asteroid-specific check:

<do_if value="@player.target.isclass.asteroid
and @player.target.wares.count">
<!-- mining-targetable asteroid with ware content -->
</do_if>

Pattern from vanilla scenario_tutorials.xml:15113, 15124.

”Detect asteroid attacked (mining started)”

Section titled “”Detect asteroid attacked (mining started)””

Pattern from vanilla cinematiccamera.xml:73:

<do_if value="event.name == 'event_object_attacked_object'
and event.param.isclass.asteroid
or event.name == 'event_object_miningdrones_armed'">
<!-- mining activity -->
</do_if>

The event_object_miningdrones_armed is the alternative trigger for drone-mining.

Pattern from vanilla tutorial_mining.xml:682, 708:

<event_object_attacked_object/>
<check_value value="event.param.isclass.asteroid"/>

Used to detect the moment the player’s drill hits a rock — event.param is the asteroid, event.object is the attacker (the player’s ship/drill).

Pattern from scenario_tutorials.xml:15187:

<check_value value="event.param.isclass.miningnode"/>

When the tutorial needs to specifically detect the drone-targetable node type rather than a generic asteroid.

”Find asteroid shards (mining output, collectablewares)”

Section titled “”Find asteroid shards (mining output, collectablewares)””

Pattern from vanilla scenario_advanced.xml:1561-1570:

<check_value value="event.param.isclass.asteroid"/>
<!-- ... later ... -->
<find_object
groupname="$asteroidshards"
class="[class.collectablewares]"
space="$ResourceSector"
multiple="true"/>
<do_for_each name="$shard" in="$asteroidshards">
<do_if value="not $shard.isdroppedcontainer">
<!-- this is an asteroid shard, not a dropped cargo container -->
</do_if>
</do_for_each>

See also Collectablewares .isdroppedcontainer=false for asteroid shards.

There is no event_asteroid_X family. Mining activity is observed via:

EventWhenNotes
event_object_attacked_objectAsteroid attacked (drill hit)event.param.isclass.asteroid filter
event_object_miningdrones_armedMining drones activatedVanilla cinematiccamera.xml:73
event_object_destroyedAsteroid exhausted / depletedStandard
  • No asteroid datatype. Class label only. Properties come from inherited object + per-macro .wares.
  • class.asteroid is a category, not a specific type. Mining nodes, crystals, and certain Terran-specific rocks all qualify. Use class.miningnode / class.crystal for narrower checks.
  • .wares.count may be 0 for depleted asteroids. Always check before assuming mining yield. Vanilla scenario_tutorials.xml:15113 uses @player.target.wares.count for the truthy/non-zero check.
  • Recyclables are NOT asteroids. class.recyclable is a separate class for Processing modules, even though scrap cubes look similar to asteroids visually.
  • NPC miners read sector-level yield, not per-asteroid .wares. NPC mining decisions use Sector.yieldrating.{ware} — see Region. Don’t expect NPCs to iterate asteroids.
  • Asteroid shards (post-mining) are class.collectablewares, not class.asteroid. They drop into the pickup graph — see Collectablewares isdroppedcontainer=false for the distinction.

Example 1: Count silicon asteroids in a sector

Section titled “Example 1: Count silicon asteroids in a sector”
<find_object
name="$Asteroids"
space="$Sector"
class="class.asteroid"
multiple="true"/>
<set_value name="$SiliconRocks" exact="0"/>
<do_for_each name="$rock" in="$Asteroids">
<do_if value="$rock.wares.indexof.{ware.silicon} gt 0">
<set_value name="$SiliconRocks"
operation="add" exact="1"/>
</do_if>
</do_for_each>
<write_to_logbook
text="$Sector.knownname + ' has '
+ $SiliconRocks + ' silicon asteroids'"/>
<cue name="WatchPlayerMining" instantiate="true">
<conditions>
<event_object_attacked_object/>
<check_value
value="event.param.isclass.asteroid
and event.object.isplayerowned"/>
</conditions>
<actions>
<write_to_logbook
text="'Player mining: '
+ event.param.macro.knownname"/>
</actions>
</cue>
<find_object
name="$Crystals"
space="player.galaxy"
class="class.crystal"
multiple="true"/>
<set_value name="$best" exact="null"/>
<set_value name="$bestRating" exact="0"/>
<do_for_each name="$c" in="$Crystals">
<set_value name="$rating"
exact="$c.sector.bestyieldrating.{ware.silicon}"/>
<do_if value="$rating gt $bestRating">
<set_value name="$best" exact="$c"/>
<set_value name="$bestRating" exact="$rating"/>
</do_if>
</do_for_each>
  • Mining gameplay loop: Architectural overview Mining — drill ↔ asteroid ↔ shard ↔ cargo flow.
  • Resource region seeding: Architectural overview Resource regions — how asteroid spawn density is driven by region definitions in libraries/regions.xml.
  • NPC mining decisions: Architectural overview NPC miners — sector-level yield-rating reads, not per-asteroid iteration.
  • Sector — host; .yieldrating.{ware} is the sector-level analog.
  • Region — region definitions drive asteroid spawn.
  • Ship — what mines (with mining drills / mining drones).
  • Weapon.ismining=true drills.
  • Collectablewares — asteroid shards land here (isdroppedcontainer=false).
  • Processing module — consumes class.recyclable (sibling category).
  • Ware — silicon / ore / methane / nividium / etc.