const int SCRIPTED_NPCD_FIELDS = 10;

//Set up special types.
const int NPCD_SCR1 = 0;
const int NPCD_SCR2 = 1;
const int NPCD_SCR3 = 2;
const int NPCD_SCR4 = 3;
const int NPCD_SCR5 = 4;
const int NPCD_SCR6 = 5;
const int NPCD_SCR7 = 6;
const int NPCD_SCR8 = 7;
const int NPCD_SCR9 = 8;
const int NPCD_SCR10 = 9;

//Set up special types for use with Script NPCD Table.
const int NPCD_SCRIPT1 = 0;
const int NPCD_FLAME = 0;
const int NPCD_HEAT = 0;

const int NPCD_SCRIPT2 = 1;
const int NPCD_ICE = 1;
const int NPCD_COLD = 1;
const int NPCD_WATER = 1;

const int NPCD_SCRIPT3 = 2;
const int NPCD_SCRIPT3 = 2;
const int NPCD_AIR = 2;
const int NPCD_ELECTRIC = 2;
const int NPCD_LIGHTNING = 2;

const int NPCD_SCRIPT4 = 3;
const int NPCD_EARTH = 3;
const int NPCD_ACID  = 3;
const int NPCD_QUAKE = 3;

const int NPCD_SCRIPT5 = 4;
const int NPCD_DARK = 4;
const int NPCD_DARKNESS = 4;
const int NPCD_HARM = 4;

const int NPCD_SCRIPT6 = 5;
const int NPCD_LIGHT = 5;
const int NPCD_HEAL = 5;

const int NPCD_SCRIPT7 = 6;
const int NPCD_SONIC = 6;
const int NPCD_SOUND = 6;

const int NPCD_SCRIPT8 = 7;
const int NPCD_BLUDG = 7;
const int NPCD_BLUDGEON = 7;

const int NPCD_SCRIPT9 = 8;
const int NPCD_ENERGY = 8;
const int NPCD_STAZER = 8;

const int NPCD_SCRIPT10 = 9;
const int NPCD_PROTON = 9;
const int NPCD_ATOMIC = 9;
const int NPCD_RADIATION = 9;
const int NPCD_NUKE = 9;

const int LW_FLAME		= 31;
const int LW_HEAT         	= 31;
const int LW_ICE            	= 32;
const int LW_COLD            	= 32;
const int LW_WATER            	= 32;
const int LW_AIR            	= 33;
const int LW_ELEC            	= 33;
const int LW_ELECTRIC           = 33;
const int LW_LIT            	= 33;
const int LW_EARTH            	= 34;
const int LW_ACID            	= 34;
const int LW_QUAKE            	= 34;
const int LW_DARK            	= 35;
const int LW_DARKNESS           = 35;
const int LW_HARM            	= 35;
const int LW_LIGHT            	= 36;
const int LW_HEAL            	= 36;
const int LW_SONIC            	= 37;
const int LW_SOUND            	= 37;
const int LW_BLUDG            	= 38;
const int LW_BLUDGEON           = 38;
const int LW_ENERGY            	= 39;
const int LW_STAZER            	= 39;
const int LW_NUKE           	= 40;
const int LW_ATOMIC           	= 40;
const int LW_RADIATION          = 40;
const int LW_PROTON          	= 40;


//For Loop Constants
const int MAX_COMBOS = 176;
const int MIN_COMBOS = 1;

const int MAX_NPCS = 256; //?
const int MIN_NPCS = 0;
const int MAX_ITEMS = 256; //?
const int MIN_ITEMS = 0;
const int MAX EW = 256; //?
const int MIN_EW = 0;
const int MIN_LW = = 256; //?
const int MAX_LW = 0;

int NumberNPCs(){
	return Screen->NumNPCs();
}

int NumberLWs(){
	return Screen->NumLWeapons();
}

int NumberEWs(){
	return Screen->NumEWeapons();
}

bool activeLW(){
	int num = NumberLWs();
	if ( num > 0 ) return true;
}

bool activeLW(int ofType){
	for ( int n = Screen->NumLWeapons(); n > 0; n-- ){
		lweapon lw = Screen->LoadLWeapon(n);
		if ( lw == ofType ) return true;
	}
}

bool activeEW(){
	int num = NumberEWs();
	if ( num > 0 ) return true;
}





bool activeEW(int ofType){
	for ( int n = Screen->NumEWeapons(); n > 0; n-- ){
		eweapon ew = Screen->LoadEWeapon(n);
		if ( ew == ofType ) return true;
	}
}

bool activeNPC(int ofType){
	int num = NumberNPCs();
	if ( num > 0 ) return true;
}

bool activeNPC(){
	for ( int n = Screen->NumNPCs(); n > 0; n-- ){
		npc enem = Screen->LoadNPC(n);
		if ( enem == ofType ) return true;
	}
}

int ScriptTypes[10]={0,0,0,0,0,0,0,0,0,0}; //Probably not needed.

const int ENEMBASE = 0;
const int NPCDROW = 20; //?

//int ScripedWeapondNPCDs[2560]={ //Replaced with "RPG_NPCDs_Table.zlib"
//	0,0,0,0,0,0,0,0,0,0,};

	
	
	
const int LW_SCRIPT_BASE = 31; //First LW Script Type
const int LW_SCRIPT_ADJUST = -31; //Adjust for number of Ltypes before LW_SCRIPT1
	
void SetScriptNPCDs(){ //Call before Waitdraw() every frame.
	for ( int i = Screen->NumNPCs(); i > 0; i-- ){ //Read Enemies on Screen
		npc enem = Screen->LoadNPC(i);
		int base = enem->ID * 10;
		for ( int j = Screen->NumLWeapons(); j > 0; j-- ){ //for loop reads all lweapons
			lweapon wpn = Screen->LoadLWeapon(j);
			int ltype = wpn->ID;
			if ( ltype > 30 ) {
				///....ifr it is a Script Weapon
				if ( Collision(enem,wpn){ ///...and collides with the NPC
					enem->Defense[NPCD_SCRIPT] = 
						EnemyNPCD_Table[base + (ltype - LW_SCRIPT_ADJUST)]; // (Enem ID Number * 10) + Script NPCD Slot in Table
				}
			}
		}
	}
}

void chanceDefTable(int enemy, int defLType, int defType){
	EnemyNPCD_Table[enemy*SCRIPTED_NPCD_FIELDS + def] = defType;
}

void changeDefTableRow(int enemy, int newSet[]){
	for ( int 0; i < SCRIPTED_NPCD_FIELDS; i++){
		EnemyNPCD_Table[enemy+i] = array[i];
	}
}

	
////////////////////////
/// Reference Charts ///
/////////////////////////////////////
/// Standard NPCD Sources (LTypes)
//////////////////////////////////////
/// NPCD_ARROW			= 3;
/// NPCD_BEAM			= 10;
/// NPCD_BRANG			= 0;
/// NPCD_BOMB			= 1;
/// NPCD_BYRNA			= 16;
/// NPCD_FIRE			= 4;
/// NPCD_HAMMER			= 8;
/// NPCD_HOOKSHOT		= 7;
/// NPCD_MAGIC			= 6;
/// NPCD_REFBEAM		= 11;
/// NPCD_REFMAGIC		= 12;
/// NPCD_REFFIREBALL		= 13;
/// NPCD_REFROCK		= 14;
/// NPCD_SBOMB			= 2;
/// NPCD_SCRIPT			= 17;
/// NPCD_STOMP			= 15;
/// NPCD_SWORD			= 9;
/// NPCD_WAND			= 5;
///
/// NPC Defense types. Use with npc->Defense[].
/// NPCDT_NONE			= 0;  //No def.
/// NPCDT_HALFDAMAGE		= 1;  //Half damage.
/// NPCDT_QUARTERDAMAGE		= 2;  //Quarter damage.
/// NPCDT_STUN			= 3;  //Stuns enemy for duration of npc enem->Stun
/// NPCDT_STUNORBLOCK		= 4;  // ?
/// NPCDT_STUNORIGNORE		= 5;  // ?
/// NPCDT_BLOCK1		= 6;  //Block if 1-power or greater. Otherwise, ignore.
/// NPCDT_BLOCK2		= 7;  //Block if 2-power or greater. Otherwise, ignore.
/// NPCDT_BLOCK4		= 8;  //Block if 4-power or greater. Otherwise, ignore.
/// NPCDT_BLOCK6		= 9;  //Block if 2-power or greater. Otherwise, ignore.
/// NPCDT_BLOCK8		= 10; //Block if 2-power or greater. Otherwise, ignore.
/// NPCDT_BLOCK			= 11; //Block at all times, as if shielded.
/// NPCDT_IGNORE1		= 12; //Weapon passes through NPC without reporting with sound, unless???
/// NPCDT_IGNORE		= 13; //Weapon passes through NPC without reporting with sound?
/// NPCDT_ONEHITKILL		= 14; //Enemy dies ON COLLISION.

import "RPG_NPCDs_Table.zlib"
