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 Tier | Script Logic Example | Tactical Function |
|---|---|---|
| Emergency Tier | Crew HP < 25% $\rightarrow$ Use Skill / Retreat | Protects crew from fatal focus fire and boarding |
| High Priority | Critical Room Damaged $\rightarrow$ Target Room | Initiates immediate damage control on vital systems |
| Tactical Action | Enemy Shields > 0 $\rightarrow$ Target Shield Room | Suppresses defensive barriers before hull attacks |
| Default Baseline | None $\rightarrow$ Target Reactor / Return to Station | Prevents 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.
- 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.
- 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.
- 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:
- 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.
- 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.
- 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.
Free Pixel Starships 2 Codes
Current active codes and how to redeem them.
COMMUNITY
Player Comments
100 players commented on this guide.
I tried this today and it worked better than my old setup.
The explanation is clear, especially for beginners.
This saved me time in the early game.
I wish I had read this before upgrading the wrong thing.