To program effective ship automation in Pixel Starships 2, order every command list strictly by urgency from top to bottom. Combat runs in real time, and during each evaluation cycle, the game parses an entity’s command list starting at line one. The parser executes the first command whose condition is met and immediately terminates evaluation for that tick. To prevent combat loops and dead code, place self-preservation and critical damage triggers at the top of a script, tactical adjustments in the middle, and unconditional default routines at the bottom.

Top-Down AI Execution Rules

Because the parser halts evaluation as soon as it encounters a valid condition, vertical positioning determines priority:

  • Conditional lines belong at the top: High-urgency checks—such as low crew health, damaged critical rooms, or incoming missile fire—must be evaluated first. If these conditions are not met, the parser passes down to the next instruction.
  • Unconditional lines belong at the bottom: Commands without conditions (such as targeting an enemy reactor or holding an assigned room) will always evaluate as true. Placing an unconditional line near the top creates dead code, permanently preventing the script from reading any command beneath it.
Priority TierScript Logic ExampleTactical Function
Emergency TierCrew HP < 25% $\rightarrow$ Use Skill / RetreatProtects crew from fatal focus fire and boarding
High PriorityCritical Room Damaged $\rightarrow$ Target RoomInitiates immediate damage control on vital systems
Tactical ActionEnemy Shields > 0 $\rightarrow$ Target Shield RoomSuppresses defensive barriers before hull attacks
Default BaselineNone $\rightarrow$ Target Reactor / Return to StationPrevents idling when no priority triggers are active

Crew AI Setup for Repair and Survival

Crew members should prioritize personal survival and local damage control over distant ship travel. Global repair commands often cause crew to waste time traversing lifts and corridors, exposing them to enemy fire while leaving damaged rooms unattended.

  1. Set personal survivability first: Place low-health conditions at the top of the script (such as using an active defensive skill or retreating to a safe room when health drops below a set threshold). A crew member lost in transit provides no repair utility for the rest of the battle.
  2. Assign localized room repair: Direct specific crew to repair nearby high-value compartments, such as Shield Generators or primary Reactors. Restricting crew to specific sectors prevents pathfinding thrashing, where crew members endlessly run between distant damaged rooms without finishing repairs on either.
  3. End with an idle station order: Conclude the script with an unconditional command directing the crew member to man their assigned room. This keeps crew stationed to provide module buffs whenever repairs are complete.

Weapon Room AI and Target Prioritization

Weapon scripts must coordinate offensive fire to remove defenses before attacking vulnerable hull compartments:

  1. Strip active shields: Set high-rate-of-fire weapons and laser batteries to target the enemy Shield Generator while enemy shield points remain above zero.
  2. Focus-fire primary subsystems: Once shields drop, direct primary weapons toward a single critical module—such as enemy weapon bays or reactor rooms. Concentrating fire suppresses incoming damage and forces the opponent's crew into repair loops.
  3. Include an unconditional fallback: Conclude every weapon script with a default target line (such as targeting the enemy Reactor or hull). If the primary target room is completely destroyed, this baseline instruction ensures the weapon continues cycling damage rather than going idle.

Reactor Power Allocation Logic

Power distribution scripts allow a ship to operate within a finite reactor budget by shifting energy to active modules dynamically:

  • Draw power on demand: Program situational utility rooms, such as evasion engines or secondary defenses, to draw power only when specific threats (such as incoming projectiles or missiles) are detected.
  • Depower destroyed compartments: Script power allocation to drop immediately if a module is destroyed in combat. This frees trapped power from disabled rooms and automatically redirects electricity to functional shields and offensive weapons.
Pixel Starships 2 icon

Free Pixel Starships 2 Codes

Current active codes and how to redeem them.

View Codes
Michael Smith

Michael Smith

Michael covers live-service games, events, reward systems, and efficient daily routines, turning frequent updates into clear actions for players.