npc_weapon_randomize.txt

Overview Source Syntax Convars


Overview

npc_weapon_randomize.txt is an SMOD script used to mix up NPCs' use of weapons. You might wish to give the rebels on a map with zombies a greater chance of wielding shotguns, as one example.

Source

WeaponRandomizeData
{
    "default_map" {
        "default_npc" {
            "weapon_pistol"        "10"
            "weapon_smg1"        "10"
            "weapon_shotgun"    "10"
            "weapon_ar2"        "10"
            "weapon_lasergun"    "10"
            "weapon_ak47"        "10"
            "weapon_kar98"        "10"
            "weapon_grease"        "10"
            "weapon_mp5"        "10"
            "weapon_svd"        "10"
            "weapon_rpg"        "10"
        }
    }
}


Syntax

1
2
3
4
5
6
7
8
9
    "default_map"
        {
        "npc_combine_s"
            {
            "weapon_ar2"        "4"
            "weapon_smg1"        "2"
            "weapon_mp5"        "1"
            }
        }

Line 1 names the map that the next few lines will apply to. In this case, default_map is used to affect an NPC type's equipment on any map that doesn't have its own weapon settings for that NPC.

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 NPC we want to change the equipment of. In this case, the run-of-the-mill Combine soldier. default_npc can be used to affect all NPCs capable of carrying a weapon.

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

Lines 5, 6, and 7 set the names of possible weapons and their chances of being that NPCs' weapon of choice.
Because their values total up to 7, their chances are as follows:

AR2:
SMG1:
MP5:

4 / 7
2 / 7
1 / 7

Lines 8 and 9 are closing braces for the default_map and npc_combine_s 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.

Convars

  • npc_randomize_weapon <boolean> ( Default: 0 )
    When enabled, NPCs' weapons are randomized as specified by npc_weapon_randomize.txt.


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