NOTE: for any .gsc file you find in \raw\maps\ for editing goes: it's probably best to make a copy of that .gsc and place it in 
\mods\yourmapname\maps\ folder and edit it there instead of editing .gsc files in your raw\map\ folder. 
If you edit file's in your \raw\ folder make a backup first!! 


1-First download the files and extract them. Copy the contents of the "copy to raw folder" into your \game_root\raw\ folder, 
and copy the contents of the "copy to mods mapname folder" into the \game_root\mods\name-of-the-map-to-install-to\ 
(example: nazi_zombie_factory ). It contains the models and animations and animtree, soundalias files. And the script ofcourse

2-Open your mapname.gsc file (you can find it in \raw\maps\), copy it into your mods\mapname\maps\ folder. Open it and find the line:
			maps\_zombiemode::main();

			
 above this line you add:
			maps\_soul_chest::PreCache_soul_chest();

			
 and below this line you add:
			thread maps\_soul_chest::main();

An example of how it should look (your mapname.gsc might look diffent, so don't copy this code!)

example before:
	/*--------------------
	 ZOMBIE MODE
	----------------------*/
	[[level.DLC3.weapons]]();
	[[level.DLC3.powerUps]]();
	maps\_zombiemode::main();
	
	/*--------------------
	 FUNCTION CALLS - POST _Load
	----------------------*/
	level.zone_manager_init_func = ::dlc3_zone_init;
	level thread DLC3_threadCalls2();

	
example after:
	/*--------------------
	 ZOMBIE MODE
	----------------------*/
	[[level.DLC3.weapons]]();
	[[level.DLC3.powerUps]]();
	maps\_soul_chest::PreCache_soul_chest();
	maps\_zombiemode::main();

	thread maps\_soul_chest::main();
	
	/*--------------------
	 FUNCTION CALLS - POST _Load
	----------------------*/
	level.zone_manager_init_func = ::dlc3_zone_init;
	level thread DLC3_threadCalls2();

	
3. Open (first copy or backup!) your _zombiemode_spawner and find the line:

	self.flame_damage_time = 0;

right below that line, add these:

if( level.chest_active == true )
	{
	self thread death_watch();
	}

	
next go all the way to the end of the file and add this:

death_watch()
{
	self waittill( "death" );
	last_origin = self.origin;
	area_radius = undefined;
	soul_chest_area = getentarray( "soul_chest_area" , "targetname") ;
	
	for(i=0;i<soul_chest_area.size;i++)
	{
	area_radius = soul_chest_area[i].radius;

		if( self IsTouching( soul_chest_area[i] ) )
		{
		 soul_chest_area[i] thread maps\_soul_chest::chest_death_count( last_origin, area_radius );
		 break;
		 }

		else
		{
		}
	wait 0.05;
	}
}


save and close the file.

4.	-go to your \game_root\zone_source\ folder and find yourmapname.csv Leave it where it is, so make a backup before editing. 
	Open it and at the end add the following:

//BluntStuffy's Soul Chest's
rawfile,maps/_soul_chest.gsc
rawfile,animtrees/blst_soul_chest.atr
sound,blst_soul_chest_1,,all_sp
sound,blst_soul_chest_2,,all_sp
fx,blst_custom/blst_fx_chest_soul
fx,blst_custom/blst_fx_chest_idle
xmodel,blst_soul_chest
xmodel,blst_soul_chest_active
xanim,blst_soul_chest_open
xanim,blst_soul_chest_close_notfull
xanim,blst_soul_chest_close_full
xanim,blst_soul_chest_idle01
xanim,blst_soul_chest_idle02
xanim,blst_soul_chest_idle03
xanim,blst_soul_chest_idle04
xanim,blst_soul_chest_idle05
xanim,blst_soul_chest_idle06

That should be the scripting part.

In radiant open your map. First make the chest locations:

create a trigger_radius and give that the KVP's:

targetname - soul_chest_area

Make sure it's flat on the floor. The chest will appear with it's center on the center of the trigger_radius. 
The arrow (when rotating the trigger) points to the front side of the chest. Adjust the radius and height for that trigger to suit your
needs. Every zombie that dies touching that trigger will feed the chest.


Next create a script-brushmodel and give it the "clip" texture. you want to make it about 104 units wide (x-axis) and 90 units 'long' 
(in the y-axis) make sure it's high enough so players can't get on top off it and MORE IMPORTANT: make it so the trigger_radius 
you created in the previous step is COMPLETELY INSIDE the clip-brush. Once you did all that give the clip-brush the KVP's:

targetname - soul_chest_clip

You can simply copy these two entities for all the chest's you want to make. The kvp's for all chests are the same. (the stock script
supports up to 6 chest locations without any editing, although you might want to set the amount of kills yourself. You can do this in
the _soul_chest.gsc file (i've marked where to edit stuff). Every chest can have it's own radius and height.

Next create 4 triggers (don't make more, that may cause issue's) where the players can pick up their reward when done (the ray-guns). 
Make those trigger_use and give the KVP's:

targetname - soul_chest_reward

The center of the trigger is where the ray-gun appears. The amount of players in the game is equal to the amount of ray-guns
that spawn. A player can only pick up a free ray-gun once, if they already have a raygun if refills the ammo for it, once.

Things you want to know:
When 2 or more chest's are activated at the same time, and one of them time's out and closes while other chest's are completed
the amount of kills needed when reactivating the timed-out chest could have increased one level. I'll explain: 
Say: you got 4 chest's
first one activated require's 4 kills
second one require's 8 kills
third require's 12 kills
fourth require's 16 kills

*when you activated chest 1 and 2 at the same time, and finished both of them without time-out's. it took you 12 kills, right!

*now when you activate chest 1 and 2 at the same time and let ONE of them time out: 
-In the case the first chest you activated times out, and you completed the second one, that one took you 8 kills. now when
you reactivate chest 1 (or another remaining chest) that one will also require 8 kills to fill instead of 4.
-When the second chest you activated timed out, nothing changes

That should be the worst case scenario, you might consider this a bug but i decided to keep it that way. It could add some difficulty
for players that are trying to fill multiple chest's at the same time and fail..

That's all, remember to select all new files in the MOD-Builder when compiling!

If you use this tutorial for your map credit is appreciated, would maybe even be more thankfull if you would send me 
a link or message if your level is released. Would love to check out other map's with my script in it!! ;)