/* 
	PScript by Peter Pon
	
	scene23
*/
#include "..\PScriptLib\Def.h"

#include "..\PScriptLib\box.pst"
#include "..\PScriptLib\desk.pst"
#include "..\PScriptLib\chair.pst"
#include "..\PScriptLib\jug.pst"

int g_CharacterArena[99];
int g_ArenaCharacters[99];
int g_TeamAArenaCharacters[16];
int g_TeamBArenaCharacters[16];

Scene_OnInit()
{
	InitBoxes(g_iNumBoxes);
	InitBBoxes(g_iNumBBoxes);
	InitChairs(g_iNumChairs);
	InitDeskes(g_iNumDeskes);
	InitJugs(g_iNumJugs);
	
	int i;
	string itemname;
	for (i=0; i<16; i=i+1)
	{	
		MakeString(itemname, "D_tpEC", i+1);
		SetSceneItem(itemname, "name", "machine");
		SetSceneItem(itemname, "attribute", "collision", 0);
		SetSceneItem(itemname, "attribute", "interactive", 1);

		MakeString(itemname, "D_tpEC", i+17);
		SetSceneItem(itemname, "name", "machine");
		SetSceneItem(itemname, "attribute", "collision", 0);
		SetSceneItem(itemname, "attribute", "interactive", 1);
	}
}

TransferToArena(int characterid, int tpid)
{
    string arenaname;
    int arena = tpid/2;
    Output("arena characters", g_ArenaCharacters[arena]);
    if ( g_ArenaCharacters[arena]<99)
    {
          g_ArenaCharacters[arena]=g_ArenaCharacters[arena];
          g_CharacterArena[characterid] = arena;
          MakeString(arenaname, "D_tpED", tpid+1);
          Misc("transfer", characterid, arenaname);
          Output("transfer", characterid, "to", tpid);
    }
}

TransferFromArena(int characterid, int tpid)
{
    string arenaname;
    int arena = tpid/2;
    if ( g_ArenaCharacters[arena]<99)
    {
          g_ArenaCharacters[arena]=g_ArenaCharacters[arena];
          g_CharacterArena[characterid] = -1;
          MakeString(arenaname, "D_tpED", tpid+17);
          Misc("transfer", characterid, arenaname);
          Output("transfer", characterid, "from", tpid);
    }
} 
Scene_OnLoad() 
{
SetScene("snow", 1);
SetScene("snowdensity", 3000);
SetScene("winddir", 0, 0, 0);
SetScene("snowspeed", 50, 2500);
SetScene("snowsize", 2, 3);
}
D_tpEC01_OnTouch(int id, int characterid)
{
    Output("EC01 Touched");
    TransferToArena(characterid, 0);
}
D_tpEC02_OnTouch(int id, int characterid)
{
    Output("EC02 Touched");
    TransferToArena(characterid, 1);
}
D_tpEC03_OnTouch(int id, int characterid)
{
    Output("EC03 Touched");
    TransferToArena(characterid, 2);
}
D_tpEC04_OnTouch(int id, int characterid)
{
    Output("EC04 Touched");
    TransferToArena(characterid, 3);
}
D_tpEC05_OnTouch(int id, int characterid)
{
    Output("EC05 Touched");
    TransferToArena(characterid, 4);
}