Skip to content

nosoop/SM-TFCustomWeaponsX

Repository files navigation

Custom Weapons X

☕ fund my caffeine addiction ☕

A new iteration of Custom Weapons.

This was not a sponsored project.

Discuss this plugin on AlliedModders.

Features

Same as previous iterations of Custom Weapons:

  • A text-based configuration format for server operators to create new items with.
    • However, the format is different and not completely compatible.
  • A (newly localized) menu system for players to build their loadouts.
    • Know any languages? Please help localize by sending a pull request! Many of the localizations are copied straight from the game files, but there are custom messages that are not.
  • Support for equipping wearable weapons such as shields and boots.

New to CWX:

  • Dropped custom items can be picked up like any other item, and will retain their attributes (assuming the implementing plugins are written to spec).
  • Item exporting. You can dynamically add / update attributes, then run sm_cwx_export to export your item to a file once it's configured to your liking.
  • Weapon persistence. Custom items will not be dropped or reequipped on resupply, eliminating a whole class of related bugs and crummy workarounds.

More information is provided in the project wiki.

Installation

Dependencies

The SourceMod plugins / extensions listed below are required for Custom Weapons X to run:

  • Econ Data
    • Requires minimum version 0.18.0.
  • TF2Attributes
    • You must specifically use @nosoop's fork of TF2Attributes — it has additional features that are not available in the original upstream.
    • Requires minimum version 1.7.0 or newer.
  • TF2 Custom Attributes
  • TF2Utils
    • Requires minimum version 0.11.0.
  • DHooks2
    • The current stable version of SourceMod (1.11 or newer) now comes with this preinstalled. You only need to download this separately if you are using 1.10.

Additional software recommendations that aren't completely necessary:

  • The Attribute Support Fixes project, which is a no-configuration project that fixes certain attribute interactions.
  • CW3toX, which may allow attributes written for Custom Weapons 3 to run under this project.

Prebuilt Package

This repository is configured to have Github automatically compile the plugin and create a release whenever commits are pushed.

Download the package.zip from the releases section and unpack into your SourceMod directory.

This plugin can run alongside CW2/3, other than conflicting when weapons are applied. (As CW2/3 handles their logic later during spawn / resupply, their weapons will be the ones active.)

Upgrading

If you're upgrading an existing installation, please make sure to make a note of your currently installed version, then read over the Upgrade Notes section of the wiki to upgrade any changed dependencies between your current version and the latest.

Building

This project can be built in a consistent manner with Ninja, git, and Python 3.

  1. Clone the repository and its submodules: git clone --recurse-submodules ...
  2. Execute python3 configure.py --spcomp-dir ${PATH} within the repo, where ${PATH} is the path to the directory containing spcomp. This repository targets 1.10.
  3. Run ninja. Output will be available under build/.

(If you'd like to use a similar build system for your project, the template project is available here.)

Differences

Core design changes in TF2 necessitated a clean break from previous iterations of Custom Weapons. This means that attributes originally written for CW2 or CW3 are not compatible with CWX; they will need to be rewritten.

CWX is also not backwards-compatible with configuration files written for CW2 or CW3.

To keep the responsibilities of the core plugin to a minimum, a number of properties that were previously integral to CW2 / CW3 are delegated to attribute-implementing plugins in CWX.

This includes:

  • killfeed / log name
  • weapon model (view / world)
  • clip / ammo settings

For implementations of those, see the Core Attribute Implementations page on the project wiki.

For attribute developers

CWX has no unique format for attributes. Instead, it has first-class support for the following systems:

  • Native game attributes through TF2Attributes.
    • It'd be pretty dumb if you couldn't use built-in attributes.
    • New attribute classes can be injected using a plugin like Hidden Dev Attributes, and developers can then use TF2Attrib_HookValue* to calculate values like any other in-game attribute.
  • The Custom Attributes Framework.
    • These are basically KeyValues handles stored as an attribute value under a common interface. "Attributes" can be declared freely without an injection process, speeding up development iteration.
    • I'll be referring to these as CAF-based attributes.
    • Full disclosure: I made this.

By implementing your attribute in one of those two formats, they will interoperate with plugins that support those systems; they are not bound to specifically to CWX.

If you're coming from CW2 or CW3, native / CAF-based attributes are very different (though native / CAF-based attributes share similarities among themselves).

The main difference is the storage mechanism. Whereas CW2 / CW3 receive attribute information through forward functions and store them globally in-plugin, native / CAF-based ones retrieve the value from entities at runtime and are tied to the game's attribute system.