Skip to content

Creating new NPC portraits

Wouter Koppenol edited this page Dec 5, 2023 · 2 revisions

How does it work?

There's a set of scripts that you can use to generate a Lua script which you can run in-game, which will then render the NPC portraits on your screen. Screenshots will be taken and a Python scripts then crossreferences an NPC list with the icons in the screenshot, and extracts the correct icon for the correct NPC ID and saves the result to a .png file.

Prerequisites

  • WoW subscription (should be easy)
  • Python (I have v3.9.19)

Script files

The script files are located in this private repo: https://github.com/Wotuu/keystone.guru.npcportraits. Gain access through me and clone the repo.

Fetch NPC IDs

Grab a CSV file of just a list of NPC IDs that you want to generate NPC portraits for. You can import NPCs from WoWhead (@TODO add link to page that details how to do this), or you can insert them manually through the NPC admin pages. Then, either export them from the database (PhpStorm makes this easy) or build the CSV file yourself. There's a checked in npcs.csv file that you can look at as an example.

I keep the amount of NPCs under 100 since the script doesn't seem to handle more than 100 very well for some reason that I haven't found out yet. Just repeating these steps once per new dungeon isn't that much effort so I split it up per dungeon.

Fetching display IDs

For each NPC ID exists a display ID. This display ID is actually what the game needs to render the portrait. Run the following in a Powershell terminal:

.\get_display_info_ids.py

This will convert your npcs.csv and output a display_ids.csv. Don't edit either file from this point onward.

display_ids.lua

Copy the contents of this file.

display_portraits.lua

Paste at the top of the file (replacing any local displayIds variable you see). Then, there's some variables at the top of the script which you may need to adjust. I calibrated it for my setup which is a 1440p screen. You may need to edit the values there to make it match for 1080p or 4k if that's what you're running.

Copy the contents of this file.

Running it in-game

Download the addon https://www.curseforge.com/wow/addons/wowlua. Open it in-game using /lua. Paste the above script. Hit run. Images will appear oin the top of your screen. A screenshot will be taken.

Generating the NPC icons

Open your screenshots folder. Find the file that contains your screenshot. Go to crop_screenshots.py and edit it. On line 20 where it says

    screenshots_folder = Path(r"H:\Games\World of Warcraft\_retail_\Screenshots")
    screenshots_glob = screenshots_folder.glob("WoWScrnShot_040423_104041.tga")

Edit this as necessary. Then:

.\crop_screenshots.py

This will generate a list of .png files for all NPCs and save it in the portraits/ folder.

Saving the generated icons in the correct location

Take the NPC icons that were generated and store them in resources/assets/images/enemyportaits. Add to Git. Commit. Push. Done!

Clone this wiki locally