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.
Related class labels
Section titled “Related class labels”| Class | Purpose | Distinction |
|---|---|---|
class.asteroid | Catch-all for “minable rock” | Most mineable objects qualify |
class.miningnode | Specific asteroid types that mining drones target | A subtype within mining-targetable rocks |
class.crystal | Crystal asteroids (rare; Terran/special crystal fields) | Distinct visual + ware content |
class.recyclable | Scrap cubes / derelict hulls for Processing modules | Not technically asteroids — but adjacent |
class.recyclable is what the Processing module consumes via process_recyclable_object; the others are mined via drilling weapons.
Properties
Section titled “Properties”There are no asteroid-specific datatype properties. Useful inherited:
| Property | Source | Description |
|---|---|---|
.wares | (per-macro) | Contained ware(s) — what mining extracts |
.sector / .zone / .position | object | Location |
.macro | component | Asteroid macro variant |
.hull | destructible | Damage 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.
Common patterns
Section titled “Common patterns””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.
”Track player drilling an asteroid”
Section titled “”Track player drilling an asteroid””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).
”Detect mining node specifically”
Section titled “”Detect mining node specifically””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.
Events
Section titled “Events”There is no event_asteroid_X family. Mining activity is observed via:
| Event | When | Notes |
|---|---|---|
event_object_attacked_object | Asteroid attacked (drill hit) | event.param.isclass.asteroid filter |
event_object_miningdrones_armed | Mining drones activated | Vanilla cinematiccamera.xml:73 |
event_object_destroyed | Asteroid exhausted / depleted | Standard |
Common gotchas
Section titled “Common gotchas”- ⚠ No
asteroiddatatype. Class label only. Properties come from inherited object + per-macro.wares. - ⚠
class.asteroidis a category, not a specific type. Mining nodes, crystals, and certain Terran-specific rocks all qualify. Useclass.miningnode/class.crystalfor narrower checks. - ⚠
.wares.countmay be 0 for depleted asteroids. Always check before assuming mining yield. Vanillascenario_tutorials.xml:15113uses@player.target.wares.countfor the truthy/non-zero check. - ⚠ Recyclables are NOT asteroids.
class.recyclableis 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 useSector.yieldrating.{ware}— see Region. Don’t expect NPCs to iterate asteroids. - ⚠ Asteroid shards (post-mining) are
class.collectablewares, notclass.asteroid. They drop into the pickup graph — see Collectablewaresisdroppedcontainer=falsefor the distinction.
Examples
Section titled “Examples”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'"/>Example 2: Detect player asteroid mining
Section titled “Example 2: Detect player asteroid mining”<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>Example 3: Pick a richest crystal field
Section titled “Example 3: Pick a richest crystal field”<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>Architectural context
Section titled “Architectural context”- 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.
Related
Section titled “Related”- 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=truedrills. - Collectablewares — asteroid shards land here (
isdroppedcontainer=false). - Processing module — consumes
class.recyclable(sibling category). - Ware — silicon / ore / methane / nividium / etc.