# Ship Weapons

Accessed via the Weapons button in the Ship Editor.

Assigns weapons, starting ammo, and per-turret AI class to the ship's banks and turrets for this mission instance, overriding the ship class defaults.

All changes are buffered. Nothing is written to the mission until you click OK; Cancel and closing the dialog discard everything.

## Layout

Weapons are split across two tabs:

- Primary - primary weapon banks for the pilot and any turret with a primary slot.
- Secondary - secondary banks for the pilot and any turret with a secondary slot.

The dialog opens on whichever tab has banks first; if a ship has only secondaries, the Secondary tab is shown.

Each tab contains:

- A Weapons list on the left showing weapons valid for this bank type and ship size. Weapons that are not in the ship class's allowed loadout are shown in gray with a tooltip explaining why; you can still assign them in the editor.
- A Banks tree on the right showing Pilot and each turret as collapsible groups, with their bank slots and current ammo underneath.
- An AI selector beneath the tree for changing a turret's AI class.

## Assigning weapons

Several ways:

- Drag from the weapons list onto a bank slot. The slot is set to the dropped weapon, and ammo capacity is recalculated.
- Drag from one bank slot to another. By default the weapon is moved (the source slot becomes empty). Hold `Ctrl` while dropping to copy instead.
- Select one or more bank slots, pick a weapon from the list, and click Set Selected. The chosen weapon is assigned to every selected slot at once. Set Selected is enabled only when slot rows (not turret-group rows) are selected.

Selection within the Banks tree is restricted to one row type at a time: clicking a turret-group row clears any selected slot rows, and vice versa. This keeps the AI controls and Set Selected controls clearly applicable to whatever is currently highlighted.

## Editing ammo

Where a weapon uses ammo, the slot's row has a second column showing current/max. Click the value to edit; a spinbox appears, clamped to the maximum capacity for that weapon and bank. The display refreshes as soon as the edit is committed.

## View Table

With a weapon highlighted in the list, the View Table button opens a viewer for that weapon's `weapons.tbl` entry (including any modular `-wep.tbm` overrides). Useful for quickly checking damage, ammo capacity, or flags without leaving the dialog.

## AI class

Each turret has its own AI class, independent of the ship's overall AI class. Select one or more turret-group rows (the parent rows, not the individual slots), pick an AI class from the combo, and click Change AI. The new value is applied to every selected turret on every marked ship.

The combo reflects the selection:

- All selected turrets share the same AI - the combo shows that value.
- Selected turrets disagree (within one ship, or across ships in multi-edit) - the combo is blank; pick a value and click Change AI to set them all to that value.

The Pilot row is shown for context but its AI is owned by the Ship Editor and cannot be changed here. When only the Pilot row is selected the AI controls are disabled.

## Editing multiple ships at once

If multiple ships of the same class are marked when the dialog is opened, edits apply to all of them. The dialog reconciles per-slot state from the marked ships at open time:

- Slots where every marked ship has the same weapon and ammo are shown normally.
- Slots where ships disagree on the weapon show CONFLICT. Leaving the slot as CONFLICT preserves each ship's existing weapon on OK; assigning a weapon overwrites all of them.
- Slots where ships agree on the weapon but disagree on ammo show --/max. Leaving it preserves each ship's existing ammo; entering a value applies that value to all marked ships.
- Turret AI is reconciled similarly: matching AIs show in the combo, mixed AIs show as (Mixed AI) in the turret label and leave the combo blank.

Multi-edit is only available when every marked ship belongs to the same ship class. The Ship Editor's Weapons button is disabled otherwise.

## OK and Cancel

OK commits every change (weapons, ammo, and AI) to every relevant ship and closes the dialog. Cancel, closing the dialog window, or pressing `Esc` discards every change; no mission data is touched. If unsaved changes exist when closing, you are prompted to keep them.