Skip to content

Feature/modern Weapon Trait System - #42

Open
Plateaus wants to merge 55 commits into
jonradoff:mainfrom
Plateaus:feature/modern-weapons
Open

Plateaus wants to merge 55 commits into
jonradoff:mainfrom
Plateaus:feature/modern-weapons

Conversation

@Plateaus

@Plateaus Plateaus commented Sep 1, 2026

Copy link
Copy Markdown

Modern Weapon Trait System

This branch introduces a reusable trait system for weapons and begins moving weapon-specific behavior into a new set of modern LOFP script files.

Why

The original LOFP item scripts often combine an item's basic definition, descriptive text, interaction behavior, magical effects, special attacks, and other logic into a single INUMBER definition.

For complex weapons this becomes extremely difficult to maintain. The original Long Sword definition, for example, grew to more than 500 lines of script. Much of that code represents behavior that could be shared by an entire class of weapons rather than duplicated on every individual item.

That makes the original scripts valuable as a record of how LOFP worked, but increasingly difficult to use as the foundation for new development.

The goal of this work is not to replace LOFP's script-driven design with hard-coded Go behavior. Instead, it gives the scripting system a cleaner way to express reusable behavior.

Trait system

Weapons can now attach reusable traits:

INUMBER 45
NAME 201
SLASH_WEAPON
WEIGHT 10
VOLUME 5
PARAMETER1 8
SUBSTANCE HARDMETAL
CRAFTABLE
ENCRUSTABLE

TRAIT GENERIC_SWORD
TRAIT SWORD_SHORT

Traits themselves remain scripts:

TRAITDEF GENERIC_SWORD

    IFVERB WIELD -1
        ...
    ENDIF

    IFPREVERB TURN -1
        ...
    ENDIF

ENDTRAIT

This allows common behavior such as wielding, unwielding, turning, examining, magical effects, and eventually other weapon abilities to be implemented once and reused across many weapons.

Traits can exist on the base item archetype or on an individual item instance, allowing otherwise identical weapons to acquire unique properties.

Trait order also provides simple specialization: later traits can override an earlier trait's implementation of the same event while retaining unrelated behavior from the earlier trait.

Script organization

Modern weapon behavior is being separated from the original scripts:

original/scripts-modern/
    MODERN_WEAPON_TRAITS.SCR
    MODERN_WEAPON_EXAMINE.SCR
    MODERN_WEAPONS.SCR

The original scripts remain available as the historical source of truth while the modern scripts provide a substantially more readable and maintainable representation of the same game concepts.

Generic weapon-family behavior is separated from individual weapon descriptions. For example, swords can share GENERIC_SWORD behavior while Short Sword, Long Sword, Rapier, Greatsword, etc. provide their own EXAMINE traits.

Magic and item state

The trait system is also designed to work with LOFP's existing weapon ItemVals rather than replacing them with a parallel set of mechanics.

Current investigation has identified the original weapon fields as including:

  • PARAMETER1 — base weapon damage
  • ITEMVAL2 — magical weapon bonus / WeaponPlus
  • ITEMVAL3 — elemental critical, slayer, and other special weapon types
  • ITEMVAL5 — weapon damage modifier used by special/critical weapon effects

This means modern traits can eventually expose existing LOFP mechanics such as magical weapons, elemental weapons, slayers, temporary blade spells, and other special properties while retaining compatibility with the original data model.

Going forward

This branch establishes the infrastructure rather than attempting to redesign the entire weapon system at once.

The next steps are to:

  • Continue converting ordinary weapons into concise modern definitions.
  • Preserve original weapon statistics and mechanics wherever they can be determined.
  • Move shared interactions into reusable weapon-family traits.
  • Keep unique weapon behavior in specialized traits rather than enormous item definitions.
  • Connect the existing ITEMVAL2 / WEAPONPLUS magic bonus to combat.
  • Use trait POWER as a basis for magical-item strength and treasure-generation limits.
  • Allow generated and dropped weapons to receive instance-level traits.
  • Add identification so magical traits can function without necessarily being visible to the player until identified.
  • Gradually represent elemental, slayer, enchanted, and unique weapons through composable traits.
  • Continue consulting the original scripts, manuals, and captured game behavior before recreating mechanics whose original meaning is uncertain.

The larger goal is to make LOFP's item system readable, composable, and extensible without moving gameplay into hard-coded Go.

Instead of another 500-line Long Sword definition, a weapon should increasingly be expressible as a small base definition plus the handful of traits that make that particular weapon interesting.

New in this update

  • Added Identify spell support for weapon items.
  • Identify now persists on the specific item instance.
  • Magical traits can add identification adjectives via ADJDEF.
  • Multiple enchantments stack correctly when identified.
  • Identified weapons now show enchantment details in EXAMINE.
  • Weapon condition now appears in EXAMINE as Undamaged or Damaged.
  • Identify scrolls use the spell ID stored in VAL3.

csanburn1966 and others added 30 commits May 1, 2026 07:52
Run item preverb scripts for GET and DROP
Run item preverb scripts for equipment commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants