Installation
In order to install this script, you have to extract the .zip archive in your CS2D folder. Make sure that there are "cnpc" folders in both "gfx" and "sys/lua". Open the "sys/lua/server.lua" file with standard notepad and add this line: "dofile('sys/lua/cnpc/main.lua')" (without quotes)
Adding new NPCs
In order to add new NPCs you have to open "list.lua" file that is located in "sys/lua/cnpc". You can open it using standard notepad. Other instructions are written in that file.
Transferring required files to clients
In order to make clients see the NPCs and hear sounds they make, you have to transfer the files to them. To make that possible you have to include paths to the required files in "sys/lua/servertransfer.txt". You also have to include this path in order to make clients see the bullets: "gfx/cnpc/1x1.png".
(one path per line)
Creating maps with custom NPCs
In order to spawn NPCs using entities in the map editor you have to trigger an "Env_Item" entity, which has the special command in its trigger field. The pattern of command is this: "cnpc <type> <health> <rotation> <spawn on start>"
Explanation: First word "cnpc" is letting the script know that we want to spawn an NPC on that entity. The <type> field is letting the script know the type (ID) of the NPC we want to spawn. The <health> field is letting the script know the health we want to spawn the NPC with. If the <health> field is 0, then NPC will be spawned with its default health. The <rotation> field is letting the script know the rotation we want to spawn the NPC with. And last but not least, the <spawn on start> field can only be number 0 (false) or 1 (true). This field lets the script know whether or not we want the NPC to spawn right at the round start. (Replace everything that is between "<" and ">" with number and don't put "<" and ">" around the number))
Examples:
1) cnpc 1 100 180 0
Will spawn NPC with type 1, with 100 health, and with rotation of 180. It won't be spawned at the round start, but only when entity is triggered.
2) cnpc 2 0 90 1
Will spawn NPC with type 2, with its default health, and with rotation of 90. It will be spawned at the round start, and when the entity is triggered.
Console commands
Console commands are:
cnpc_spawn <type> <x> <y> <rotation> -- Spawn an NPC
cnpc_damage <id> <health> -- Damage an NPC
cnpc_remove <id> -- Remove an NPC