[Mapping Guide] Model Index (modelindex) Replacement

Yaki

aa
Sep 3, 2018
418
256
NOTE: This guide assumes you know about...
  1. How to use CompilePal
  2. How to use an AddOutput and Instances
  3. How to use Notepad, the TF2 Console, the basics of Hammer
  4. How to set a launch parameter in your TF2's bootup
NOTE: I'm still working on this guide (need to add pictures, clarifications, etc...) Please feel free to post questions or comments here or on Discord.

[Mapping Guide] Model Index (modelindex) Replacement​


Ever wanted to replace the models for the skeletons in your map like pd_Farmageddon did?

Well now you can! This guide is here to help you on your way to make new and spooky skeletons.

Essentially, this guide is a step-by-step how-to on using the addoutput "modelindex" for your map.

Step 0: Explanation

To break it into bite-sized chunks, here's a bird's eye view of what we are doing:
  1. Packing two files inside your map ( using CompilePal ) to add your models onto a "precachelist",
  2. Using the TF2 console and an external txt file, we look at this precache list to find your replacement model,
  3. We go into Hammer and set up I/O logic to change the index of a model (in this case, a skeleton) to your replacement model.

Please understand: The model indexes update every time you add or remove things from your map. This means you need to repeat these steps every time you recompile your map.


And with that, here we go!

Step 1: Packing propdata.txt and propdata_original.txt

The main file we are replacing is called propdata.txt. It is under the directory of /tf/scripts/ . It is loaded on every map bootup and is used for breakable debris from HL2.
  • What I did was pack two files.
    1. The first is a list of all my models,
    2. The second is the original propdata.txt from HL2.
Code:
#base "PropData_original.txt"    //points to the second file you pack into your map

"PropData.txt"
{
    "BreakableModels"    // Required
    {
        "ModelPrecache.Skeleton.ReplacementModelo0o0o"    //Name can be anything
        {
            "models/props_ninfa/yeti_cutout.mdl"    "0"    //List your model replacement here, like this (include the "0").
            "models/props_medieval/medieval_scroll.mdl"    "0"    //List your model replacement here, like this (include the "0").
        }
    }
}

It is crucial to have it listed like this. For this to work, the model's directory must be within brackets, within "BreakableModels", within "PropData.txt". (like above)

Find the original propdata.txt in through GCFScape, or download it at the foot of this thread post.

Step 2: TF2 Console and console.txt

We need the list of all the model indexes to find the correct one for our skeleton.

After compiling the propdata files into my map, in the TF2 Console I typed
  • cl_precacheinfo modelprecache
This loads all the model indexes into the console.

However, because the list is so long, the full list doesn't show up in the console. You have to tell the game to output the console echo into a separate txt file.

For this part, place these launch parameters into your TF2 bootup:
  • -condebug -conclearlog
The first one, -condebug, is the main one that logs the file. -conclearlog deletes the file's contents after TF2 shuts down.

This file is found under /tf/ , with the name console.txt .

So... once you have those in order, you should be able to get to the beginning of the list.
  • The models I needed for my mod appear after all the map geometry. Sometimes they're in range of 10-15, or sometimes 200-205, etc. Easiest way to find them--ctrl+F to search in your favorite txt application (I use Notepad++). Find your replacement model's directory, and copy the index # for the next step.

Step 3: Hammer, I/O Logic, and AddOutput "modelindex #"

The last step, we open Hammer and setup the logic.

All we are doing is targetting the skeleton, then using output
  • AddOutput
  • modelindex #
With the model index number in hand, this above setup will do.

When the skeletons spawn, target them like any other entity with a name. Or, a neat trick I learned was:
  • Place a logic_relay inside the skeleton template with the name of the skeleton. Set the relay's flag to delete itself on execution and use OnSpawn output.
 

Attachments

  • propdata.txt
    531 bytes · Views: 82
  • propdata_original.txt
    11.9 KB · Views: 72
Last edited:

Yaki

aa
Sep 3, 2018
418
256

Bonus: Using Instances with Modelindex​

Also see: https://tf2maps.net/threads/guide-instances-and-you.24784/

One trick I've been using is setting up an instance with my modelindex stuff and changing the modelindex' # in as a parameter by the instance.

This makes changes to the model index value much simpler, and reduces complication by the changes you make.