Skip to main content

Spellscript Refactor Tool for AzerothCore

Python tool to convert spellscript(s) to use registry macros (see official wiki https://www.azerothcore.org/wiki/core-scripts)

The acore_spellscript_refactor tool provides modules to refactor spellscripts to use registry macros (see official wiki https://www.azerothcore.org/wiki/core-scripts).

Disclaimer: This tool is dumb. It finds the first SpellScript by searching for public SpellScriptLoader in a file and converts it. It does not add enums for magic numbers, and may remove variables; some manual work is required, but it is a good first pass

Features

  • convert AuraScript
  • convert SpellScript
  • convert Spell- and Aurascript Pairs
  • add bool Validate... if it does not exist already
  • read/write to file
  • create skeleton update statement spell_script_names to script_name.sql if type is _aura
  • fill in spell_ids skeleton update with spell_ids from table acore_world spell_script_names
  • --skip to specify line number to search for SpellScript
  • --verbose/-v to output debug info
  • --sql-file to write script_name updates to specific file
  • discover runs repeatedly on all *cpp in directory
  • spell scripts with args
  • magic numbers to Enum

See sample log./refactor.log

Install

The acore-spellscript-refactor package is published on Test PyPI for testing and development purposes. Follow the steps below to install it.

Installation Steps

  1. Clone the Repository (Optional)
    If you want to work with the source code, clone the repository to your local machine:

    git clone https://github.com/your-username/acore-spellscript-refactor.git
    cd acore-spellscript-refactor
    pip install -e .
    
  2. Install from Test PyPI
    To install the latest version of acore-spellscript-refactor from Test PyPI, use the following command:

    pip install acore-spellscript-refactor
    

    This installs the package and all required dependencies from the Test PyPI repository.

  3. Verify the Installation
    Confirm the installation by running:

    python3 -m acore_spellscript_refactor.main --help
    

For more information, visit the acore-spellscript-refactor page on Test PyPI.

Usage

This covers basic usage, command options, and examples for the main and discover modules.

To create a rev_*.sql file, use create_sql.sh

./data/sql/updates/pending_db_world/create_sql.sh

In the sections below $REV_SQL refers to absolute path of this created rev_*.sql.

REV_SQL="/azerothcore-wotlk/data/sql/updates/pending_db_world/rev_1730477106741869456.sql"

note: for file arguments, use absolute paths

Examples

Using main

The main module refactors a single script file at a time or all scripts within a directory.

Refactoring a Single Script with Line Offset

To refactor a single script file and specify an offset (e.g., skip the first 950 lines):

python3 -m acore_spellscript_refactor.main "/azerothcore-wotlk/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp" --skip 950
python3 -m acore_spellscript_refactor.main `realpath boss_xt002.cpp` --skip 950
python3 -m acore_spellscript_refactor.main `realpath boss_xt002.cpp` --skip 950 --verbose
Refactoring All Scripts in a Directory

To refactor all .cpp files in a directory, use xargs to iterate through each file:

ls *cpp | xargs -n 1 -I {} python3 -m acore_spellscript_refactor.main `realpath {}`
Command Options
  1. Specify input and output files:

    • Provide an input_file and output_file to save results to a specific file.
    python3 -m acore_spellscript_refactor.main input_file output_file
    
  2. Overwrite input file:

    • Use the same file for both input_file and output_file to overwrite.
    python3 -m acore_spellscript_refactor.main input_file input_file
    
  3. Default single file refactor:

    • Refactor a single file without specifying an output, defaults to overwriting the input_file.
    python3 -m acore_spellscript_refactor.main input_file
    
  4. Skip a specified number of lines:

    • Use --skip to ignore a set number of lines.
    python3 -m acore_spellscript_refactor.main input_file output_file --skip 1200
    
  5. Use with SQL file generation:

    • Refactor with associated SQL queries stored in a specified file.
    python3 -m acore_spellscript_refactor.main input_file output_file --skip 1200 --sql_file $REV_SQL
    
  6. Commit changes:

    • Add the --commit flag to save changes with an optional SQL file for database updates.
    python3 -m acore_spellscript_refactor.main input_file --commit --sql_file $REV_SQL
    

Using discover

The discover module finds .cpp files and creates commits and SQL files as necessary.

Example Usage
  1. Commit all discovered files:

    • Specify a .sql file for database changes, or allow discover to auto-create one by omitting --sql_file
    python3 -m acore_spellscript_refactor.discover --commit --sql_file $REV_SQL
    
  2. Run on all scripts in a directory:

    • Set the working directory to azerothcore-wotlk/src/server/scripts/***/scripts_folder and recursively discover .cpp files.
    python3 -m acore_spellscript_refactor.discover --commit --recursive --sql_file $REV_SQL
    
  3. Run on all scripts:

    • Set the working directory to azerothcore-wotlk/src/server/scripts and recursively discover .cpp files.
    python3 -m acore_spellscript_refactor.discover --commit --recursive --sql_file $REV_SQL
    

Development

Run tests

pytest .

Development

pip install -e .

Metadata

Release files for acore-spellscript-refactor 1.8.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for acore-spellscript-refactor 1.8.4
File Size Uploaded Provenance Actions
acore_spellscript_refactor-1.8.4.tar.gz 224.6 kB Without provenance Details for acore_spellscript_refactor-1.8.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for acore-spellscript-refactor 1.8.4
File Interpreter ABI Platform Actions
acore_spellscript_refactor-1.8.4-py3-none-any.whl Python 3 none any Details for acore_spellscript_refactor-1.8.4-py3-none-any.whl

Total release size: 235.5 kB

Release files / acore_spellscript_refactor-1.8.4.tar.gz

Download URL acore_spellscript_refactor-1.8.4.tar.gz
Size 224.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fcba7194afcb1ba63543de999a368d919cedfffdf5dfa81c28d14186cc51e5a2
BLAKE2b-256 checksum
How to use checksums
749696bd307fa00841861ba7a677dfeb3daab43fac8c2c0b1037605031b1c678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / acore_spellscript_refactor-1.8.4-py3-none-any.whl

Download URL acore_spellscript_refactor-1.8.4-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03c2c7585d6ec0248a7f4e3b7302053e4de99b290152b2d119d7aab6b4025c1a
BLAKE2b-256 checksum
How to use checksums
53099742e7ad6f2d5e9dccf8304315e57100bfb4fd0b9f38605a415e1b8508f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for acore-spellscript-refactor 1.8.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.8.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page