Advanced scripting: Spawning NPCs with custom models!
Spawning Custom NPCs
Alright, you can spawn vehciles, NPCs, props and ragdolls but something is still missing. Ah right, custom NPCs such as military soldiers, gman, barney and kleiner with weapons and anime girls.
But JBMod can’t spawn them right? Well, with console commands you can even spawn NPCs with custom models. Here I will show you how to do that.
How to Spawn
Load any map and then open console. Type “ent_create npc_combine_s model models/kleiner.mdl additionalequipment weapon_smg1” in the console.
Now let’s explain everything:
- With “ent_create” console command you are able to spawn any entities from the game and you can change some of their ingame values such as model, health etc.
- “npc_combine_s” – Specific NPC class name used by developers. It will spawn NPC that uses combine soldier AI. Unfortunately only 4 NPCs work right now: npc_combine_s, npc_turret_floor, npc_vortigaunt, npc_citizen (it has different method though).
- “model models/kleiner.mdl” – Path name to game models. You can change it to “models/gman.mdl” (Spawns NPC with Gman’s model instead of Kleiner) and vice versa to use desired default or custom model. Example: models/mycustomcoolmodelfolder/mycustomcoolmodel.mdl
- “additionalequipment weapon_smg1” – Sets NPCs weapon to specified weapon. Example: “additionalequipment weapon_pistol” – spawns custom NPC with pistol instead of smg1.
- Gman with smg1:
- “ent_create npc_combine_s model models/gman.mdl additionalequipment weapon_smg1“
- Kleiner with shotgun:
- “ent_create npc_combine_s model models/kleiner.mdl additionalequipment weapon_shotgun“
- Alyx with alyxgun:
- “ent_create npc_combine_s model models/alyx.mdl additionalequipment weapon_alyxgun“
- Breen with AR2:
- “ent_create npc_combine_s model models/breen.mdl additionalequipment weapon_ar2“
- Eli with pistol:
- “ent_create npc_combine_s model models/eli.mdl additionalequipment weapon_pistol“
- Grigori with rifle:
- “ent_create npc_combine_s model models/monk.mdl additionalequipment weapon_annabelle“
- Barney with stunstick:
- “ent_create npc_combine_s model models/barney.mdl additionalequipment weapon_stunstick“
Portal’s turret has the same AI as npc_turret_floor that means you can set npc_turret_floor model to portal turret model. Btw I don’t remember where it is located. You can use Garry’s Mod’s spawnmenu to get model’s directory.
Combine Soldier NPC with custom model has good functionality with melee weapons such as Crowbar and Stunstick. They will chase you and try to hit you with their weapons, but default combine soldier doesn’t have animations for that.