# 5 · Weapon Workbench

Configure the 3D preview, component recipes, compatibility rules and server-side weapon crafting validations.

# Weapon Workbench Overview

A bench with type:

```text
weapon
```

uses the dedicated weapon crafting interface and validation path.

The workflow can:

- Inspect weapon items in the player's inventory.
- Preview a weapon in a configured 3D location.
- Preview/attach/detach selected components in the interface.
- Validate component recipes assigned to the bench.
- Validate player level.
- Validate ingredients.
- Process multiple selected component recipes as one selection.

The server rejects weapon-component requests sent to a non-weapon bench.


# Weapon Preview Shell

The preview environment is configured in `config/config.lua`.

```lua
Config.WeaponPreviewShell = {
    coords = vector3(1048.34, -3107.5, -39.0),
    heading = 0.0,
    mode = 'wall', -- wall | center
    wallOffset = 0.06,
    heightOffset = 1.10,
    cameraDistance = 2.65,
    cameraHeight = 0.08,
    spin = false
}
```

## Important

Nord Crafting does **not** create the preview shell/interior. The configured coordinates must already be a suitable location on your server.

### Wall mode

Place the coordinates at the desired wall position. `heading` should point from the wall toward the camera. If the weapon faces the wrong direction, adjust the heading by 180 degrees.

### Center mode

Use a free central preview point where the weapon can be displayed without a wall offset.


# Weapon Component Recipes

Component recipes use the same database/config recipe model but are classified as component recipes.

The weapon callback validates:

- Bench type is `weapon`.
- Recipe is assigned to that bench.
- Recipe exists.
- Recipe type resolves to `component`.
- Player meets required level.
- Player has required ingredients.

For multi-selection, ingredient totals are combined before removal so the full selected set must be affordable.


# Compatibility Validation

The weapon system groups weapons into families such as:

- pistol
- smg
- rifle
- shotgun
- sniper
- other

Component compatibility is validated against the weapon/component profile data used by the workbench.

When a selected component is not compatible with the target weapon, the server rejects the selection before consuming the combined materials.

This prevents a client from forcing an arbitrary component recipe onto an incompatible weapon through NUI manipulation.


# Weapon Craft Security

Weapon callbacks perform the same trust-boundary checks expected from standard crafting, plus weapon-specific checks.

## Server checks

- Valid request structure.
- Existing bench ID.
- Player distance.
- Access policy.
- Weapon bench type.
- Allowed recipe list.
- Recipe type.
- Weapon item ownership when required by the selected workflow.
- Component compatibility.
- Level requirements.
- Total ingredient requirements.

XP is applied after a valid weapon/component craft, and bench usage analytics are updated.