//===== eAthena Script ======================================= 
//= Dungeon Teleport Service (Cool Event Corp and Kafra Corp competition)
//===== By: ================================================== 
//= Evera
//===== Current Version: ===================================== 
//= 1.9
//===== Compatible With: ===================================== 
//= eAthena
//===== Description: =========================================
//= All-included file of Cool Event Corp NPCs with Kafra voting system.
//===== Variables: ===========================================
//=Server - 	$dtsvote		= Variable for # of votes
//=					= Positive = Cool Corp winning
//=					= Negative = Kafra Corp winning
//=		$dts			= Variable for DTS status
//=					= (1<<0) Election
//=					= (1<<1) Cool Corp Enabled
//=					= (1<<2) Kafra Enabled
//=					= (1<<3) No winner last election
//=					= (1<<4) Cool Corp won last election
//=					= (1<<5) Kafra won last election
//=Character -	dtseligible 		= eligibility status, 0 not eligible yet, 1 eligible, 2 eligible & voted.
//=NPC Func. -	arg(0) 			= 0, Cool Event Corp Voting Staff; 1, Kafra Corp Voting Staff
//=		arg(1)			= Kafra only, Cool Corp script does not use. Changes illus for different sprites.
//=					= 0 = 4_f_kafra6 (yellow ponytail, classic outfit, spr 112)
//=					= 1 = 4_f_kafra5 (pink hair, classic outfit, spr 113)
//=					= 2 = 4_f_kafra4 (orange short hair, classic outfit, spr 114)
//=					= 3 = 4_f_kafra3 (brown bangs, classic outfit, spr 115)
//=					= 4 = 4_f_kafra2 (brown ponytale, classic outfit, spr 116)
//=					= 5 = 4_f_kafra1 (blue hair, classic outfit, spr 117)
//=					= 6 = 4_f_agentkafra (purp hair, black outfit, spr 859)
//=					= 7 = 4_f_kafra8 (blue hair, brown outfit, spr 860)
//=					= 8 = 4_f_kafra9 (red hair, brown outfit, spr 861)
//=Temporary - 	@dtstemp		= Temporary buffer, used in GM vote-fixing
//=		@dtstemps$		= Temporary buffer, like above, but a string.
//=		$@dtstempg		= Temporary buffer, but global
//===== Additional Comments: ================================= 
//= Some unofficial translations, need Dungeon maps/coords/prices
//= Also includes unofficial GM-enabled tweaking for script
//= Includes NPCs in Cool Event Corp headquarters
//= Also known as Zondaman in other languages (?)
//= Pretty sure there are more locations I didn't find.
//= Base level 60 required to vote
//===== Version History: ====================================
//= 1.9 Removed global eligibility option [Evera] (7/15/06)
//= 1.8	Changed requirement to lvl 60 [Evera] (7/03/06)
//= 1.7	Fixed bug of DTS_Admin not running by itself [Evera] (7/03/06)
//= 1.6 Removed Duplicates [Silent]
//= 1.5 Mushed voting varialbes into 1 variable. [Evera] (5/29/06)
//= 1.4 Changed global variables to read from 3 global variables, updated names,
//= fixed array bug [Evera] (5/28/06)
//= 1.3 Removed selfconfig [Evera] (5/20/06)
//= 1.2 Mushed some variables together, optimized a bit [Evera] (5/15/06)
//= 1.1	SVN release, removed from major town (found true info after research),
//=	put more arg(2) parameters, fixed a few bugs [Evera] (5/11/06)
//= 1.0	Initial release [Evera] (5/10/06)
//============================================================ 

//Yuno
yuno.gat,153,191,4	script	Cool Event Voting Staff#01	874,{
	callfunc "F_DTS_Warp",0,0;
}
yuno.gat,162,191,6	script	Kafra Voting Staff#01	861,{
	callfunc "F_DTS_Warp",1,8;
}
//Lighthalzen
lighthalzen.gat,154,60,6	script	Cool Event Voting Staff#02	874,{
	callfunc "F_DTS_Warp",0,0;
}
//Prontera
prontera.gat,147,125,4	script	Cool Event Voting Staff#03	874,{
	callfunc "F_DTS_Warp",0,0;
}
prontera.gat,164,125,6	script	Kafra Voting Staff#02	115,{
	callfunc "F_DTS_Warp",1,3;
}

//Cool Event Staff Headquarters NPCs
//Kudiuu (Maintenance Guy)
lhz_in02.gat,20,274,6	script	Maintenance Guy	851,{
	mes "[Kudiuu]";
	mes "Holy...!";
	mes "Will this place";
	mes "ever get cleaned up?!";
	mes "*Cough cough* There's";
	mes "so much dust here, it's";
	mes "almost a health hazard!";
	close;
}
//Cesuna (Zondaman at desk)
lhz_in02.gat,36,284,1	script	Cool Event Staff#01	874,{
	mes "[Cesuna]";
	mes "Ack! I'm totally";
	mes "swamped with all this";
	mes "work! But I don't wannna";
	mes "do any of it. That's it!";
	mes "I totally need a break";
	next;
	mes "[Cesuna]";
	mes "*Sigh...*";
	mes "I wonder if Saera";
	mes "would ever consider";
	mes "going out with me?";
	mes "That would be nice~";
	close;
}
//Jellarin (Event planner)
lhz_in02.gat,40,279,3	script	Event Planner	833,{
	mes "[Jellarin]";
	mes "I don't like this.";
	mes "But I don't like that";
	mes "idea either. What will";
	mes "I do for a new event, eh?";
	next;
	mes "[Jellarin]";
	mes "I need something";
	mes "major, something that'll";
	mes "really shake up the world,";
	mes "something epochal, but what?";
	mes "Hey, do you have any ideas";
	close;
}
//Baoto (Cool Event Manager)
lhz_in02.gat,110,283,5	script	Cool Event Manager	853,{
	mes "[Baoto]";
	mes "Hmmm...";
	mes "The employees seem";
	mes "to be having too much";
	mes "fun amongst themselves";
	mes "recently. This does not";
	mes "bode well at all...";
	next;
	mes "[Baoto]";
	mes "It looks like I'm";
	mes "just going to have to";
	mes "start cracking that whip";
	mes "more often and much";
	mes "harder. Ha ha ha ha!";
	close;
}
//Saera (Secretary), contains GM menu
lhz_in02.gat,36,274,3	script	Cool Event Staff#02	831,{
	if($dts == 0){
		set $dts,$dts|(1<<0);				//Sets NPCs to election mode if first time running
		set $dts,$dts|(1<<3);
	}
	mes "[Saera]";
	mes "Welcome to the";
	mes "temporary headquarters";
	mes "of Cool Event Corporation";
	mes "How may I help you today?";
	next;
	if(getgmlevel()>=40){ 						//Unofficial Text, GM-configurable settings for Event (GM level above 40 required)
		mes "[Saera]";
		mes "Why, I didn't even";
		mes "notice you there,";
		mes strcharinfo(0)+". What would";
		mes "you like to do today?";
		next;
		menu "Fix Vote",Lfixvote,
		"Set current teleporter",Lsettele,
		"Set last election winner",Lsetlast,
		"Manually run vote check",Lmanuvotecheck,
		"Normal menu please",-;
		mes "[Saera]";
		mes "Ok";
		next;
	}
	menu "Temporary headquarters?",Ltemphead,
	"Voting",Lvoting,"No, thanks.",Lnothx;

	Ltemphead:
		mes "[Saera]";
		mes "Our headquarters building";
		mes "is currently undergoing";
		mes "reconstruction, so we are";
		mes "basing our operations in";
		mes "this place for the meantime";
		close;

	Lvoting:
		mes "[Saera]";
		mes "Currently, Kafra Corporation";
		mes "and Cool Event Corp are working";
		mes "on a collaborative program that";
		mes "will provide direct teleport";
		mes "services to dungeons.";
		next;
		mes "[Saera]";
		mes "Due to technical issues,";
		mes "both companies cannot provide";
		mes "teleport services to the same";
		mes "dungeon. Therefore, we will be";
		mes "selecting our valued customers";
		mes "to choose the company they want.";
		next;
		if(dtseligible == 0 && baselevel >= 60 || dtseligible == 3 && baselevel >= 60) set dtseligible,1;	//Clear previous var of dtseligible,3 being tried for eligibility already
		switch(dtseligible){
			default:
				mes "[Saera]";
				mes "Only a limited number of";
				mes "voters will be chosen, so";
				mes "you can check your voting";
				mes "eligibility at the headquarters";
				mes "of both participating companies.";
				mes "Thank you for your patronage~";
				set dtseligible,3;
				close;
				break;
			case 1:
				mes "[Saera]";
				mes "It appears that you are";
				mes "eligible to vote";
				mes "so please cast your";
				mes "vote at any Voting Staff";
				mes "representative. Thank you~";
				close;
				break;
			case 2:
				mes "[Saera]";
				mes "You are eligible to vote, but";
				mes "you have already voted. Thank";
				mes "you for your participation";
				close;
				break;
		}

	Lnothx:
		mes "[Saera]";
		mes "Thank you.";
		mes "Have a good day.";
		close;
									//GM options start
	Lfixvote:							//Fix Vote
		mes "[Saera]";
		mes "Umm, sure..";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		mes "To who would you like to give votes to?";
		next;
		menu "Kafra",-,"Cool Event Corp",Lfixcool;

	Lfixkafra:							//Fixing vote for Kafra
		mes "[Saera]";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";	//multiplied by -1 because var is negative
		if($dtsv == 0) mes "The vote is currently tied.";
		mes "Please input the amount you wish to give to Kafra Corp";
		input @dtstemp;					//Set buffer for Kafra vote
		next;
		mes "[Saera]";
		mes "You inputted "+@dtstemp+" for Kafra";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		mes "Are you sure you would like to";
		mes "make these changes?";
		next;
		menu "Yes",-,"No",Lnothx;
		set $dtsv,$dtsv-@dtstemp;				//Set buffer to Kafra vote
		mes "[Saera]";
		mes "Okay, you fixed the vote";
		mes "of Kafra Corp.";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		close;

	Lfixcool:						//Fixing vote for cool corp
		mes "[Saera]";
		mes "Let me find the papers...";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		mes "Please input new vote for Cool Event Corp";
		input @dtstemp;					//Set buffer for Cool vote
		next;
		mes "[Saera]";
		mes "You inputted "+@dtstemp+" for Cool Event Corp";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		mes "Are you sure you would like to";
		mes "make these changes?";
		next;
		menu "Yes",-,"No",Lnothx;			//Confirmaiton
		set $dtsv,@dtsv+@dtstemp;			//Set buffer to Cool vote
		mes "[Saera]";
		mes "Okay, you fixed the vote";
		mes "of Cool Event Corp.";
		if($dtsv > 0) mes "Cool Event Corp is currently winning by "+$dtsv+" votes.";
		if($dtsv < 0) mes "Kafra Corp is currently winning by "+$dtsv*-1+" votes.";
		if($dtsv == 0) mes "The vote is currently tied.";
		close;

	Lsettele:							//Set current DTS tele
		mes "[Saera]";
		mes "Type Kafra for Kafra-enabled warp,";
		mes "Cool for Cool Event Corp-enabled";
		mes "warp ,Election for election mode,";
		mes "or Cancel to cancel.";
		if($dts&(1<<0)) mes "The election is currently in election mode.";
		if($dts&(1<<1)) mes "Cool Event Corp is currently the DTS warper.";
		if($dts&(1<<2)) mes "Kafra Corp is currently the DTS warper.";
		next;
		input @dtstemps$;					//Typed in choices to prevent mistakes
		mes "Let me find the papers...";
		next;
		if(@dtstemps$ == "Election" || @dtstemps$ == "election"){
			if($dts&(1<<1)){
				set $dts,$dts&~(1<<1);			//Removes previous winner
				set $dts,$dts|(1<<0);			//Changes status to election
			}
			if($dts&(1<<2)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<0);
			}
			mes "[Saera]";
			mes "Set to election mode.";
			close;
		}
		if(@dtstemps$ == "Cool" || @dtstemps$ == "cool"){
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);
				set $dts,$dts|(1<<1);
			}
			if($dts&(1<<2)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<1);
			}
			mes "[Saera]";
			mes "Cool Event Corp. is now the DTS warper.";
			close;
		}
		if(@dtstemps$ == "Kafra" || @dtstemps$ == "kafra"){
			if($dts&(1<<1)){
				set $dts,$dts&~(1<<1);
				set $dts,$dts|(1<<2);
			}
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);
				set $dts,$dts|(1<<2);
			}
			mes "[Saera]";
			mes "Kafra Corp. is now the DTS warper.";
			close;
		}
		if(@dtstemps$ == "Cancel" || @dtstemps$ == "cancel") goto Lnothx;
		mes "[Saera]";
		mes "Please input a correct name for the election";
		next;
		goto Lsettele;

	Lsetlast:							//Set last winner
		mes "[Saera]";
		mes "Type Kafra for election records to show Kafra,";
		mes "Cool for Cool for election records to show Cool Event Corp,";
		mes "None for no winner in election records,";
		mes "or Cancel to cancel.";
		if($dts&(1<<3)) mes "There was no previous winner";
		if($dts&(1<<4)) mes "Cool Event Corp was the last winner";
		if($dts&(1<<5)) mes "Kafra Corp was the last winner";
		next;
		input @dtstemps$;
		mes "[Saera]";
		mes "Let me find the papers...";
		next;
		if(@dtstemps$ == "None" || @dtstemps$ == "none"){
			if($dts&(1<<4)){
				set $dts,$dts&~(1<<4);			//removes last winner
				set $dts,$dts|(1<<3);			//sets current last winner
			}
			if($dts&(1<<5)){
				set $dts,$dts&~(1<<5);
				set $dts,$dts|(1<<3);
			}
			mes "[Saera]";
			mes "Set records to show no previous winner.";
			close;
		}
		if(@dtstemps$ == "Cool" || @dtstemps$ == "cool"){
			if($dts&(1<<3)){
				set $dts,$dts&~(1<<3);
				set $dts,$dts|(1<<4);
			}
			if($dts&(1<<5)){
				set $dts,$dts&~(1<<5);
				set $dts,$dts|(1<<4);
			}
			mes "[Saera]";
			mes "Cool Event Corp. is now the previous winner.";
			close;
		}
		if(@dtstemps$ == "Kafra" || @dtstemps$ == "kafra"){
			if($dts&(1<<3)){
				set $dts,$dts&~(1<<3);
				set $dts,$dts|(1<<5);
			}
			if($dts&(1<<4)){
				set $dts,$dts&~(1<<4);
				set $dts,$dts|(1<<5);
			}
			mes "[Saera]";
			mes "Kafra Corp. is now the previous winner.";
			close;
		}
		if(@dtstemps$ == "Cancel" || @dtstemps$ == "cancel") goto Lnothx;
		mes "[Saera]";
		mes "Please input a correct name";
		mes "for previous winner";
		next;
		goto Lsetlast;

	Lmanuvotecheck:
		mes "[Saera]";
		mes "Are you sure you would like to run";
		mes "the vote check again?";
		next;
		menu "Yes",Lmanuvoteyes,"No",Lnothx;

	Lmanuvoteyes:
		if($dtsv == 0){
			set $@dtstemp,rand(1,2);
			if($@dtstemp == 1) set $dtsv,$dtsv+100;
			else set $dtsv,$dtsv-100;
		}
		if($dtsv > 0){
			if($dts&(1<<3)) set $dts,$dts&~(1<<3);			//removes last winner varialbes
			if($dts&(1<<4)) set $dts,$dts&~(1<<4);
			if($dts&(1<<5)) set $dts,$dts&~(1<<5);
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);				//removes winner variable
				set $dts,$dts|(1<<1);				//sets last winner varialbe
				set $dts,$dts|(1<<3);				//sets current winner variable
			}
			if($dts&(1<<1)) set $dts,$dts|(1<<4);
			if($dts&(1<<2)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<1);
				set $dts,$dts|(1<<5);
			}
			set $dtsv,0;
		}
		else{
			if($dts&(1<<3)) set $dts,$dts&~(1<<3);
			if($dts&(1<<4)) set $dts,$dts&~(1<<4);
			if($dts&(1<<5)) set $dts,$dts&~(1<<5);
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);
				set $dts,$dts|(1<<2);
				set $dts,$dts|(1<<3);
			}
			if($dts&(1<<1)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<2);
				set $dts,$dts|(1<<4);
			}
			if($dts&(1<<2)) set $dts,$dts|(1<<5);
			set $dtsv,0;
		}
		mes "[Saera]";
		mes "Vote check run again.";
		if($dts&(1<<0)) mes "The election is currently in election mode.";
		if($dts&(1<<1)) mes "Cool Event Corp is currently the DTS warper.";
		if($dts&(1<<2)) mes "Kafra Corp is currently the DTS warper.";
		close;
}

//Function for Voting Staff NPC
function	script	F_DTS_Warp	{
	if($dts == 0){ 						//Sets NPCs to election mode if first time running
		set $dts,$dts|(1<<0);
		set $dts,$dts|(1<<3);
	}
	if(dtseligible == 0 && baselevel >= 60 || dtseligible == 3 && baselevel >= 60) set dtseligible,1;	//Clear previous var of dtseligible,3 being tried for eligibility already
	switch(getarg(0)){
	case 0:
		cutin "zonda_01",2;
		mes "[Cool Event Corp. Voting Staff]";
		mes "Hello! Don't forget to make";
		mes "your voice be heard and make";
		mes "sure you vote in the elections";
		mes "between Cool Event Corp. and";
		mes "Kafra Corporation for control of";
		mes "the Dungeon Teleport Service!";
		break;
	case 1:
		switch(getarg(1)){
		case 0: cutin "kafra_06",2; break;			//Finding arguments to find which illust to use
		case 1: cutin "kafra_05",2; break;			//Used Red hair "kafra_09" for black outfit kafra
		case 2: cutin "kafra_04",2; break;			//because I couldn't find a suitable illust
		case 3: cutin "kafra_03",2; break;
		case 4: cutin "kafra_02",2; break;
		case 5: cutin "kafra_01",2; break;
		case 6: cutin "kafra_09",2; break;
		case 7: cutin "kafra_08",2; break;
		case 8: cutin "kafra_09",2; break;
		default: cutin "kafra_09",2; break;
		}
		mes "[Kafra Voting Staff]";
		mes "Greetings, adventurer.";
		mes "As you may be aware, we";
		mes "are holding an election to";
		mes "provide the Dungeon Teleport";
		mes "Service. How may I help you?";
		break;
	}
	next;
	menu "Reason for Election",Lelection,"Cast a Vote",Lvote,
	"Use Teleport Service",Lteleport,"Cancel",Lcancel;

	Lelection: 							//Reason for election explanation
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]";
			mes "Cool Event Corp. has been";
			mes "planning to provide a new";
			mes "Dungeon Teleport Service to";	
			mes "its customers, a service not";
			mes "already provided by the Kafra";
			mes "Corporation. However...";
			next;
			mes "[Cool Event Corp. Voting Staff]";
			mes "Kafra Corporation, which";
			mes "already monopolizes the";
			mes "public teleportation market,";
			mes "actually also had plans to";
			mes "provide a similar service.";
			next;
			mes "[Cool Event Corp. Voting Staff]";
			mes "Because of technological";
			mes "limitations, only one company";
			mes "can be chosen as the provider";
			mes "of this Dungeon Teleport Service.";
			mes "Hence, we will let the customers";
			mes "decide through these elections.";
			next;
			mes "[Cool Event Corp. Voting Staff]";
			mes "Multiple elections will be";
			mes "held so that our customers";
			mes "can test out the special services";
			mes "of each company for themselves.";
			mes "However, keep in mind that you";
			mes "must be eligible in order to vote.";
			next;
			mes "[Cool Event Corp. Voting Staff]";
			mes "For voter eligibility";
			mes "details, please visit our";
			mes "headquarters in the city of";
			mes "Lighthalzen located in the";
			mes "Schwaltzvalt Republic.";
			mes "Thank you for your time.";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "Cool Event Corp and the";
			mes "Kafra Corporation have both";
			mes "been planning to provide a";
			mes "Teleport Service to dungeons.";
			next;
			mes "[Kafra Voting Staff]";
			mes "But due to technological";
			mes "limitations, only one company";
			mes "can serve as provider for this";
			mes "Dungeon Teleport Service at a";
			mes "time. There, both companies have";
			mes "agreed to hold special elections";
			next;
			mes "[Kafra Voting Staff]";
			mes "Each company has its own";
			mes "policies and guarantees in";
			mes "regards to the Dungeon Teleport";
			mes "Service, and in this election, the";
			mes "customers will ultimately decide";
			mes "and choose what's best for them.";
			next;
			mes "[Kafra Voting Staff]";
			mes "For now, the Dungeon";
			mes "Teleport Service will be";
			mes "provided in a series of trial";
			mes "periods. This way, customers can";
			mes "see the benefits of both companies";
			mes "before making the final decision";
			next;
			mes "[Kafra Voting Staff]";
			mes "If you are qualified,";
			mes "please vote in each election";
			mes "to decide which company will";
			mes "provide the Dungeon Teleport";
			mes "Service for the next trial period.";
			mes "Thank you for your support~";
			break;
		}
		goto Lend;

	Lvote: //If you clicked you wanted to vote
		if(dtseligible == 1) goto Leligible; 			//Var check if eligible

	Lnoteligible: 							//Text displayed if wanted to vote, but not eligible/voted
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]";
			mes "I'm sorry, but you are not";
			mes "eligible to vote at this time.";
			mes "Please visit our headquarters";
			mes "in Lighthalzen for information";
			mes "related to acquiring voting";
			mes "rights. Thank you for your time.";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "Oh, I'm so sorry, but you";
			mes "are currently not qualified to";
			mes "vote. For voting qualification";
			mes "information, please visit the";
			mes "Al De Baran Kafra Headquarters.";
			mes "Thank you and have a nice day.";
			break;
		}
		goto Lend;

	Leligible: 							//Text displayed if eligible to vote
		if(dtseligible == 2) goto Lnoteligible; //Var check if voted
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]"; 		//Unofficial text
			mes "Checking your credentials, you";
			mes "are able to vote for the";
			mes "Dungeon Teleport Service";
			mes "elections. Who would you like";
			mes "to vote for?";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "It appears that you qualify";
			mes "to vote for the Dungeon";
			mes "Teleport Service elections.";
			mes "Who would you like to vote for";		//End Unofficial text
			break;
		}
		next;
		menu "Cool Event Corp.",Lvotecool,"Kafra Corp.",Lvotekafra;
	
	Lvotecool:
		set $dtsv,$dtsv+1;				//Adds 1 to cool count
		set dtseligible,2;						//Sets var so that you can't vote over and over
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]";
			mes "Thank you for voting for us.";
			mes "Your vote has been counted,";
			mes "and we appreciate your input";
			mes "Thank you and have a good day.";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "We thank you for your vote.";
			mes "Your opinion matters very much";
			mes "and has been counted for Cool";
			mes "Event Corp.";
			break;
		}
		goto Lend;

	Lvotekafra:
		setd $dtsv,$dtsv-1; 				//Adds 1 to kafra count
		set dtseligible,2; 					//Sets var to prevent cheating
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]";		//Unofficial Text
			mes "Thank you for your opinion.";
			mes "Your vote for Kafra corp.";
			mes "has been counted. Thank";
			mes "you and have a good day.";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "Your vote for us has been";
			mes "counted. We thank you very";
			mes "much for your input, and";
			mes "we hope that we meet your";
			mes "adventuring needs and";
			mes "standards of excellence.";
			break;
		}
		goto Lend;						//End Unofficial text

	Lteleport: 							//Selected Teleport
		switch(getarg(0)){
		case 0:
			if($dts&(1<<0)){
				mes "[Cool Event Corp. Voting Staff]";
				mes "I'm sorry, but the";
				mes "Dungeon Teleport Service is";
				mes "unavailable during elections";
				mes "and will be reactivated after the";
				mes "election results are announced.";
				mes "Thank you and have a nice day.";
				goto Lend;
			}
			if($dts&(1<<1)) goto Lteleenabled;
			mes "[Cool Event Corp. Voting Staff]";		//Text if Kafra won DTS elect.
			mes "I'm sorry, but Cool Event";
			mes "Corp. does not currently offer";
			mes "the Dungeon Teleport Service";
			mes "due to the results of the last";
			mes "election. Please vote for us";
			mes "next time, alright? Good day~";
			break;
		case 1:
			if($dts&(1<<0)){
				mes "[Kafra Voting Staff]";
				mes "Sorry, but the elections for";
				mes "which Dungeon Teleport System";
				mes "to use is currently going on";
				mes "right now. We are unable to";
				mes "vote until results are announced";
				goto Lend;
			}
			if($dts&(1<<2)) goto Lteleenabled;
			mes "[Kafra Voting Staff]";
			mes "We're sorry, but Kafra Corp";
			mes "doesn't currently offer the";
			mes "Dungeon Teleport System due";
			mes "to last election's results,";
			mes "Please vote for Kafra Corp";
			mes "next time~";
			break;
		}
		goto Lend;

	Lteleenabled: 							//Shows DTS tele selections
	cleararray @dtswarpmap$[0],"",getarraysize(@dtswarpmap$);
	cleararray @dtswarp$[0],"",getarraysize(@dtswarp$);
	switch(getarg(0)){
	case 0:
		mes "[Cool Event Corp. Voting Staff]";
		mes "Please remember that we";
		mes "cannot accept Free Warp Tickets";
		mes "or award Special Reserve Points";
		mes "for this service. Now, please";
		mes "choose your destination.";
		setarray @dtswarpmap$[0],"Bailand, Level 4","Clock Tower, Basement 3";
		setarray @dtswarp$[0],@dtswarpmap$[0]+" -> 4,000z",
		@dtswarpmap$[1]+" -> 4,000z","Cancel";
		if($dts&(1<<4)){ 
			set @dtswarpmap$[2],"Glastheim Entrance";
			setarray @dtswarp$[2],@dtswarpmap$[2]+" -> 4,000z","Cancel";
		}
		break;
	case 1:
		mes "[Kafra Voting Staff]";
		mes "Thank you for choosing the";
		mes "Dungeon Teleport Service";
		mes "Please keep in mind that the";
		mes "Free Warp Tickets and Kafra";
		mes "Special Reserve Points do not";
		mes "apply in this special service.";
		setarray @dtswarpmap$[0],"Toy Factory, Level 2","Clock Tower, Level 3";
		setarray @dtswarp$[0],@dtswarpmap$[0]+" -> 4,000z",
		@dtswarpmap$[1]+" -> 4,000z","Cancel";
		if($dts&(1<<5)){ 
			set @dtswarpmap$[2],"Lava Dungeon, Level 2";
			setarray @dtswarp$[2],@dtswarpmap$[2]+" -> 4,000z","Cancel";
		}
		break;
	}
	next;
	switch(select(@dtswarp$[0],@dtswarp$[1],@dtswarp$[2],@dtswarp$[3])){
		case 1:
			set @num, 0;
			break;
		case 2:
			set @num, 1;
			break;
		case 3:
			set @num, 2;
			break;
		case 4:
			set @num, 3;
			break;
	}
	Lwarp:
		if (@dtswarp$[@num] == "Cancel") goto Lcancel;
		if (Zeny<4000) goto Lnomoney;
		set Zeny, Zeny-@dtswarpcost[@num];
		if (@dtswarpmap$[@num] == "Toy Factory, Level 2") warp "xmas_dun02.gat",130,123;
 //Maps to warp to
		if (@dtswarpmap$[@num] == "Clock Tower, Level 3") warp "alde_dun03.gat",265,22;

		if (@dtswarpmap$[@num] == "Lava Dungeon, Level 2") warp "mag_dun02.gat",47,40;

		if (@dtswarpmap$[@num] == "Bailand, Level 4") warp "iz_dun03.gat",32,63;

		if (@dtswarpmap$[@num] == "Clock Tower, Basement 3") warp "alde_dun03.gat",277,178;

		if (@dtswarpmap$[@num] == "Glastheim Entrance") warp "glast_01.gat",375,304;

		cutin "", 255;
		end;
	Lnomoney:
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]"; 		//Unofficial Text
			mes "Umm, apparently you don't have";
			mes "adequate funds for your";
			mes "selected warp. Please check";
			mes "that you have the correct amount";
			mes "of money, and try again later";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "It appears as if you don't";
			mes "have enough zeny for the warp";
			mes "Please check your funds and";
			mes "try again.";
			break;
		}
		goto Lend;						//End unofficial text

	Lcancel: 							//Selected Cancel on first menu
		switch(getarg(0)){
		case 0:
			mes "[Cool Event Corp. Voting Staff]";	
			mes "Cool Event Corp. is always";
			mes "working to make sure that";
			mes "not only are our customers";
			mes "satisfied, but that we also";
			mes "exceed your utmost standards.";
			mes "Thank you and have a good day.";
			break;
		case 1:
			mes "[Kafra Voting Staff]";
			mes "We, here at Kafra Corporation,";
			mes "are alwyas endeavoring to provide";
			mes "you with the best services. We hope";
			mes "that we meet your adventuring needs";
			mes "and the standards of excellence.";
			break;
		}
		goto Lend;
	Lend:
		close2;
		cutin "", 255;
		end;

}

//Elections administration NPC (hidden)
-	script DTS_Admin -1,{
	OnSun0100:					//Works only at 1am on sunday
		if($dtsv == 0){				//If tied, gives random side 100 votes
			set $@dtstemp,rand(1,2);
			if($@dtstemp == 1) set $dtsv,$dtsv+100;
			else set $dtsv,$dtsv-100;
		}
		if($dtsv > 0){
			if($dts&(1<<3)) set $dts,$dts&~(1<<3);
			if($dts&(1<<4)) set $dts,$dts&~(1<<4);
			if($dts&(1<<5)) set $dts,$dts&~(1<<5);
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);
				set $dts,$dts|(1<<1);
				set $dts,$dts|(1<<3);
			}
			if($dts&(1<<1)) set $dts,$dts|(1<<4);
			if($dts&(1<<2)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<1);
				set $dts,$dts|(1<<5);
			}
			set $dtsv,0;
		}
		else{
			if($dts&(1<<3)) set $dts,$dts&~(1<<3);
			if($dts&(1<<4)) set $dts,$dts&~(1<<4);
			if($dts&(1<<5)) set $dts,$dts&~(1<<5);
			if($dts&(1<<0)){
				set $dts,$dts&~(1<<0);
				set $dts,$dts|(1<<2);
				set $dts,$dts|(1<<3);
			}
			if($dts&(1<<1)){
				set $dts,$dts&~(1<<2);
				set $dts,$dts|(1<<2);
				set $dts,$dts|(1<<4);
			}
			if($dts&(1<<2)) set $dts,$dts|(1<<5);
			set $dtsv,0;
		}
		end;
}