override_class.txt

Overview Source Syntax Usage Notes


Overview

override_class.txt is an SMOD script used to replace certain entities in the game with others. As an example, the script is typically used to easily introduce custom weapons into SMOD mods by giving the normal weapons a set chance to change into custom ones.

overridecon.png

Source

//    SMOD class override data (sample)
OverrideClasses
{
    "default_map" {
        "weapon_crowbar" {
            "weapon_custom1"    "100"
            "weapon_custom10"    "100"
        }
        "weapon_pistol"    {
            "weapon_custom2"    "80"
        }
        "weapon_ak47"    {
            "weapon_custom3"    "80"
            "weapon_custom4"    "80"
        }
        "weapon_smg1"    {
            "weapon_custom3"    "80"
            "weapon_custom4"    "80"
        }
        "weapon_grease"    {
            "weapon_custom3"    "80"
            "weapon_custom4"    "80"
        }
        "weapon_mp5"    {
            "weapon_custom3"    "80"
            "weapon_custom4"    "80"
        }
        "weapon_ar2"    {
            "weapon_custom3"    "80"
            "weapon_custom4"    "80"
        }
        "weapon_shotgun"    {
            "weapon_custom5"    "70"
        }
        "weapon_crossbow"    {
            "weapon_custom7"    "50"
        }
        "weapon_kar98"    {
            "weapon_custom3"    "80"
        }
        "weapon_rpg"    {
            "weapon_custom8"    "100"
        }
        "weapon_frag"    {
            "weapon_custom9"    "100"
        }
    }
}


Syntax

1
2
3
4
5
6
7
8
9
    "default_map"
        {
        "weapon_pistol"
            {
            "weapon_custom1"    "1"
            "weapon_custom2"    "2"
            "weapon_custom3"    "4"
            }
        }

Line 1 names the map that the next few lines will apply to. It's possible, for instance, to replace all the fast headcrabs in the Ravenholm chapters with kamikaze crabs. In this case, default_map is used to set the override behavior for any map that isn't defined elsewhere in the script.

Line 2 has an opening brace, {. This signals the start of a code block, which will continue until we hit its closing brace, }. Anything within these braces will apply to the map named in line 1.

Line 3 is an entity we want to replace with this script. In this case, the 9mm pistol.

Line 4 is an opening brace for another code block. Anything within this block will apply to the entity named in line 3.

Lines 5, 6, and 7 set the name of possible replacement entities and their chances of being the replacement.
Because their values total up to 7, their chances are as follows:
weapon_custom1: 1 / 7
weapon_custom2: 2 / 7
weapon_custom3: 4 / 7

Mind that there is no chance of the overridden entity remaining. It will be replaced by something.

Lines 8 and 9 are closing braces for the default_map and weapon_pistol blocks, respectively. You must match every opening brace with a closing brace or you'll have problems. Most commonly, the entire script won't run or some code blocks will be skipped over and won't do anything.

Usage Notes

  • Fake entity names can be used with smodaclist.txt to create new spawn commands. A case where this is useful is making some coherent names for custom weapons; an entry for weapon_shredder can be created that will always be overridden to weapon_custom17.
  • It is highly recommended that developers don't use this. While testing this feature, general game load increased 5+ms, SpawnBuffer load increased 5+ to 10+ms, and FileSystem load increased 10+ms, for one entity. If more than 1 entity is overrode, initial map load, and in game performance will be impacted. It's best to use an FGD file for Hammer that already includes all new entities when making custom maps, and to simply call on all entities by their original class name, instead of a fake one like in the method above. If you wish to remove default (weapon) entities, simply use excludeweapons.txt.

Convars

  • smod_override_classname <boolean> ( Default: 0 )
    When enabled, this script can replace certain entities with others.


Customization

Mapadd Command Reference (Non-LUA)Command Reference (LUA)Getting StartedPorts 'n' Doors
Alarm, Alarm!Color Correction in SMODDoor BreachingMobile APCsWorking With Dropships
Supply Drop (LUA)Countdown (LUA)
kh0rn3's Mapadd Generator
Scripts addcontentsoverride_classsmod_custom_explosivesmodaclistSMOD Soundscripts

npc_gib_modelnpc_replace_modelnpc_shieldsetnpc_weapon_randomizenpc_weaponweight

excludeweaponsweapon_categoryweapon_customConsole Command List
Other Crosshair CustomizationGenerating AI NodesUsing the NodemakerSubViewCam
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License