Making an SNPC

From Valve Developer Community
Jump to: navigation, search

what is a SNPC

an SNPC is like an NPC but it is much smarter for example it has weapon switching healing etc.
so if you have played GMOD you probably know what Im talking about.

making an NPC pickup weapons + ammo

to start off you want to make a normal npc (I recommend a citizen/rebel)and name it something like example_npc to make into the SNPC.
so now that you have your npc in we want to make it pickup stuff right well we want to make a weapon and some ammo so it can shoot I will be using the SMG wepon and ammo also name the weapon and ammo something like smg_ammo and smg_weapon.
the smg ammo and weapon
so now we want to add triggers so that the NPC will go to pickup the weapon or ammo the first one we want to add is to pickup the ammo to do this simply make a trigger_once surounding the ammo and check the flag NPCs and uncheck the flag Clients we also want to make the outputs.
My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger smg_ammo Kill 0.00 No
Io11.png OnTrigger example_npc SetAmmoResupplierOn 0.00 No
Io11.png OnTrigger example_npc SetAmmoResupplierOff 30.00 No

then comes the pickup for the smg you want to add a trigger_once and make it surround the gun so the NPC will pick it up and set the same flags after that set the outputs to.

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger smg_weapon Kill 0.00 No
Io11.png OnTrigger example_npc kill 0.00 No
next you want to create another npc that will be used after the pickup animation to make the pickup animation create a prop dynamic and make sure it looks like the NPC you used earlier call it pickup_model.
then add one more output to the smg pickup trigger.
My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger smg_weapon Kill 0.00 No
Io11.png OnTrigger example_npc kill 0.00 No
Io11.png Ontrigger pickup_model Enable 0.00 No

then we want to make another npc out of bounds called example_npc2 and if you are doing this make sure to swap the ammo trigger Target entity to example_npc2, then we want to add a logic_auto to disable pickup on the map spawn. then make a point teleport called npc_teleport and modify the prop dynamic so that example_npc2 can teleport to the game. also add an output to pickup_model.

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnAnimationDone npc_teleport teleport 0.00 No

after that your done! enjoy your SNPC(more could be added in the future)