//@unloadnpc arealoot
//@loadnpc npc/valhalla/arealoot.txt

-	script	arealoot	-1,{
end;
OnPCLoginEvent:
	atcommand "@arealoot";
	arealoot = 1;
	if(!#VIP && atype){
		atype = 0;
		end;
	}
	switch(atype){
		case 1: 
			atcommand("@autoloottype reset");
			atcommand("@autoloot 0");
			break;
		case 2: 
			atcommand("@autoloottype reset");
			atcommand("@autoloot 100");
			break;
		case 3: 
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +healing");
			break;
		case 4:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +usable");
			break;					
		case 5:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +etc");
			break;
		case 6:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +weapon");
			break;
		case 7:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +armor");
			break;
		case 8:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +card");
			break;
		case 9:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +petegg");
			break;
		case 10:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +petarmor");
			break;
		case 11:
			atcommand("@autoloot 0");
			atcommand("@autoloottype reset");
			atcommand("@autoloottype +ammo");
			break;
		default:
			atcommand("@autoloottype reset");
			atcommand("@autoloot 0");
			break;
		}
		end;
OnEnable:
	if(#VIP){	
		while(1){
			switch(select(
			"Arealoot [ "+((arealoot) ? "^28bf00Yes^000000" : "^ff0000No^000000")+" ]:"+
			"Autoloot Type [ ^00cc00"+.atype$[atype]+"^000000 ]:"+
			"^777777Close^000000"
			)) {
			case 1:
				if (arealoot == 1){
					atcommand("@arealoot");
					arealoot = 0;
					dispbottom "Area loot is now disabled";
				} else {
					atcommand("@arealoot");
					arealoot = 1;
					dispbottom "Area loot is now enabled";
				}
				break;
			case 2:
				switch(select(
				"Disable:"+
				"All:"+
				"Healing:"+
				"Usable:"+
				"Etc:"+
				"Weapon:"+
				"Armor:"+
				"Card:"+
				"PetEgg:"+
				"PetArmor:"+
				"Ammo"
				)) {
				case 1: 
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloot reset");
					atype = 1;
					break;
				case 2: 
					atcommand("@autoloottype reset");
					atcommand("@autoloot");
					atype = 2;
					break;

				case 3: 
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +healing");
					atype = 3;
					break;
				case 4:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +usable");
					atype = 4;
					break;					
				case 5:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +etc");
					atype = 5;
					break;
				case 6:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +weapon");
					atype = 6;
					break;
				case 7:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +armor");
					atype = 7;
					break;
				case 8:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +card");
					atype = 8;
					break;
				case 9:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +petegg");
					atype = 9;
					break;
				case 10:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +petarmor");
					atype = 10;
					break;
				case 11:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atcommand("@autoloottype +ammo");
					atype = 11;
					break;
				default:
					atcommand("@autoloot 0");
					atcommand("@autoloottype reset");
					atype = 0;
					break;
				}
				break;
			default:
				close;
			}
			if(atype == 1){
				dispbottom "Your autoloot is now disabled";
			} else if(atype == 2){
				dispbottom "You will now autoloot all items";
			} else {	
				dispbottom "You will now autoloot all "+.atype$[atype]+" items";
			}
		}
	} else {
		while(1){
			switch(select(
			"Arealoot [ "+((arealoot) ? "^28bf00Yes^000000" : "^ff0000No^000000")+" ]:"+
			"^777777Close^000000"
			)) {
			case 1:
			default:
				if (arealoot == 1){
					atcommand("@arealoot");
					arealoot = 0;
					dispbottom "Area loot is now disabled";
				} else {
					atcommand("@arealoot");
					arealoot = 1;
					dispbottom "Area loot is now enabled";
				}
			}
		}
		close; 	
		
	}	
OnInit:
	setarray .atype$[1],"Disable","All","Healing","Usable","Etc","Weapon","Armor","Card","Pet Eggs","Pet Armors","Ammonition";
	bindatcmd("aloot","arealoot::OnEnable",0,99);
	end;

}