Custom NPCs script by Crystal Rain
Release Date: 30.08.2013


-- 0 - Contents --

0. Contents
1. Introduction
2. Installation
3. Adding new NPCs
4. Transferring required files to clients
5. Creating maps with custom NPCs
6. Console commands
7. Credits


-- 1 - Introduction --

I've made this script for users who wanted to use custom-made NPCs in CS2D. DC
rejected to implement custom NPCs in CS2D, and that's why I've made this script.
The behavior of NPCs made using this script is almost same as CS2D's NPCs,
but of course it needs some improvements.


-- 2 - 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)


-- 3 - 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.


-- 4 - 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)


-- 5 - 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.


-- 6 - Console commands --

Console commands:
cnpc_spawn <type> <x> <y> <rotation> -- Spawn an NPC
cnpc_damage <id> <health> -- Damage an NPC
cnpc_remove <id> -- Remove an NPC


-- 7 - Credits --

Big thanks to EngiN33R for solving the problems with angles and my grammar. :)