Skip to content

Weapon System

Vladyslav Vytrykush edited this page Jul 14, 2026 · 1 revision

Weapon System

The Weapon System is one of the core gameplay mechanics in Adventure-Game. It defines how offensive equipment is created, stored, equipped, and used throughout the game.

Weapons are more than simple damage modifiers—they are fully featured objects containing their own statistics, durability, enchantment status, value, and usability state. Each weapon directly affects the player's combat capabilities by increasing attack power and, in some cases, providing additional defensive bonuses.

The system has been designed with scalability in mind, making it straightforward to introduce new weapon types, special abilities, crafting mechanics, or upgrade systems in future versions of the project.


Table of Contents


Overview

Weapons represent the player's primary offensive equipment.

Every weapon is implemented as an independent object derived from the abstract Item class. This allows weapons to be stored alongside armor and potions inside the inventory while still providing specialized behavior unique to weapons.

A weapon is responsible for:

  • Increasing attack power
  • Providing optional defensive bonuses
  • Tracking durability
  • Tracking enchantment status
  • Determining usability
  • Displaying weapon information

Weapons can be obtained through:

  • Starting equipment
  • Random generation
  • Loot chests
  • Special item generation

Weapon Architecture

The Weapon class inherits from the common Item base class.

classDiagram

Item <|-- Weapon

Character --> Weapon

MyInventory --> Weapon

Chest --> Weapon
Loading

This design allows every weapon to behave as an Item while still exposing weapon-specific functionality.


Weapon Properties

Each weapon contains several attributes that define its behavior.

Property Description
Name The weapon's display name.
Attack Offensive power added to the character.
Defense Bonus Additional defensive value provided by the weapon.
Durability Current condition of the weapon.
Value Gold value of the weapon.
Equipped Indicates whether the weapon is currently equipped.
Broken Indicates whether the weapon can still be used.
Enchanted Indicates whether the weapon has magical enhancements.

These properties determine how the weapon behaves during gameplay.


Weapon Types

Adventure-Game currently supports several categories of weapons.

Weapon Type Description
Sword Balanced attack and defense.
Axe High damage with lower defensive capabilities.
Bow Ranged weapon with offensive focus.
Wand Magic-oriented weapon intended for intelligence-based characters.
Spectacles Special equipment associated with intelligence-focused professions.

Additional weapon categories may be introduced in future updates.


Weapon Generation

Weapons can be generated in several different ways.

Starting Equipment

When a new character is created, the game generates a starting weapon based on the selected profession.

This ensures that each profession begins with equipment appropriate to its role.


Random Generation

The project includes functions that generate randomized weapons.

Randomly generated weapons may vary in:

  • Attack
  • Defense
  • Durability
  • Value
  • Enchantment status

This introduces variety and replayability.


Special Weapons

Special weapons are generated separately from standard equipment.

These weapons generally provide improved statistics and represent higher-value rewards.

Future versions may include unique legendary or named weapons.


Weapon Creation

Weapons are created using constructors that initialize all important properties.

Example:

Weapon(
    "Sword",
    attack,
    defense,
    durability,
    value,
    isEquipped,
    isBroken,
    isEnchanted
);

This allows each weapon to be fully customized during creation.


Weapon Lifecycle

The following diagram illustrates how weapons move through the game.

flowchart TD

GenerateWeapon --> Inventory

Inventory --> EquipWeapon

EquipWeapon --> Character

Character --> Gameplay

Gameplay --> DurabilityLoss

DurabilityLoss --> Broken

Broken --> Unequip

Unequip --> Inventory
Loading

Throughout gameplay, the weapon's state changes depending on player actions and durability.


Weapon Durability

Every weapon has a durability value representing its physical condition.

Durability decreases through gameplay and determines whether the weapon remains usable.

Possible states include:

State Description
New Full durability.
Worn Reduced durability but still usable.
Broken Cannot be used until repaired (future implementation).

The project currently includes functionality to:

  • Check if a weapon is usable
  • Mark a weapon as broken
  • Display durability information

Future versions may include durability loss during combat and repair mechanics.


Enchantments

Weapons may be generated with magical enchantments.

An enchanted weapon generally provides improved statistics compared to a standard version.

Current enchantment status is stored as a simple property of the weapon.

Future improvements may introduce enchantments that grant unique abilities such as:

  • Fire damage
  • Ice damage
  • Poison effects
  • Critical hit bonuses
  • Lifesteal
  • Increased durability
  • Bonus experience

Equipping Weapons

Players equip weapons directly from their inventory.

The general process is:

Select Weapon
      │
      ▼
Check Usability
      │
      ▼
Equip Weapon
      │
      ▼
Update Character Statistics

Only one weapon can be equipped at a time.

Equipping a new weapon automatically replaces the previously equipped one.


Combat Statistics

Weapons directly influence the player's offensive capabilities.

Current calculation:

Total Attack = Base Strength + Weapon Attack

Some weapons also contribute additional defense.

Total Defense = Base Defense + Weapon Defense Bonus + Armor Defense

Future combat mechanics may also consider:

  • Critical hits
  • Attack speed
  • Weapon class bonuses
  • Skill modifiers
  • Elemental damage

Displaying Weapon Information

Weapons provide detailed information when inspected.

Typical information includes:

  • Name
  • Weapon type
  • Attack value
  • Defense bonus
  • Durability
  • Gold value
  • Enchantment status
  • Equipped status
  • Broken status

This allows players to compare different weapons before equipping them.


Relationships with Other Systems

The Weapon System communicates with several other gameplay systems.

flowchart LR

Weapon --> Character

Weapon --> Inventory

Chest --> Weapon

Weapon --> Item

Character --> Equipment

Inventory --> Weapon
Loading

Weapons are generated, stored, equipped, and managed through these interconnected systems.


Design Decisions

Several architectural choices influenced the Weapon System.

Weapon Inherits from Item

Using inheritance allows weapons to share a common interface with every other collectible object.

This simplifies inventory management and enables polymorphic behavior.


Durability Stored Inside the Weapon

Each weapon independently manages its own durability.

This prevents external systems from needing to track weapon condition.


Random Generation

Rather than manually defining every weapon, randomized generation increases replayability while reducing duplicated content.


Modular Design

The Weapon class focuses only on weapon-related behavior.

Inventory management, character statistics, and loot generation remain the responsibility of their respective systems.


Future Improvements

The Weapon System has been designed to support many future additions.

Planned improvements include:

  • Additional weapon classes
  • Dual wielding
  • Shields
  • Critical hit mechanics
  • Weapon upgrades
  • Repair system
  • Elemental damage
  • Skill scaling
  • Weapon rarity colors
  • Legendary weapons
  • Named unique weapons
  • Weapon crafting
  • Socketed gems
  • Passive weapon abilities
  • Visual equipment representation (future graphical version)

The current architecture allows these features to be integrated without major redesign.


Summary

The Weapon System provides Adventure-Game with a flexible and extensible framework for offensive equipment. By combining randomized generation, durability, enchantments, equipment management, and object-oriented design, the system offers a solid foundation for both current gameplay and future expansion.

As the project continues to evolve, the Weapon System will support increasingly advanced RPG mechanics while maintaining a clean, modular architecture that reflects modern C++ programming practices.

Clone this wiki locally