summaryrefslogblamecommitdiff
path: root/npc/re/guild/invest_main.txt
blob: 0a9e4105bb8f9fbb88ff00da05daa64cc396f850 (plain) (tree)
1
2
3
4
5
6
7
8
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
                                                              



                                                              
       
                                                              
                         





                                                              
                                             












































                                                                                      
                                                              




































































































































































                                                                                                                                                                                                                               
                                                   
































































































































































                                                                                                                                                                                                                                      
                                                           
                            

                                            
                                               














                                                                                          
 






















































                                                                                                                                                                                                              
                                                                             
























































































                                                                                                                                                                    
                                                                             
















































































































                                                                                                                                                                   
                                                       





























































































































































































































































































































































































































































































                                                                                                                                                                                      
                                                  






































                                                                                                         
                                                  














































                                                                                                                          
                                                                   
























                                                                                                
                                                                          
































































                                                                                                                                                                                                                          
                                                                   










































































































































                                                                                                                                                                                                                             
                                                                            















































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                
//===== Hercules Script ======================================
//= Hall of Abyss - Core Scripts
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.1
//===== Description: =========================================
//= [Official Conversion]
//= Expansion for War of Emperium FE.
//= Invest in each realm to unlock new maps:
//= - Guild Dungeon F2, total 20,000,000z.
//= - Hall of Abyss, total 70,000,000z.
//===== Additional Comments: =================================
//= 1.0 First version. Missing official times. [Euphy]
//= 1.1 Added GM management function. [Euphy]
//============================================================

// Global Variables
//============================================================
// Note: an asterisk (*) represents any realm (prt, pay, gef, alde).
/*
$2011_agit_invest
-- 0: Inactive.
-- 1: Investment in progress.
-- 2: Investment results calculating.
-- 4: Investment calculations complete (only when at least one $*_invest_result is 3).
-- 11-21: Tie, revote required.

$agit_result_notice
-- 0: Inactive.
-- 1-12: Interim statements (displaying $@vfund_*x) available.

$agit_result_timer
-- 0: Inactive.
-- 0-59: Time elapsed during investment (in hours).

$agit_revoting_timer
-- 0: Inactive.
-- 0-29: Time elapsed during revote (in minutes).
-- 30: Revote closed.
-- 31: Revote results calculating.

$*_invest_result
-- 0: No data.
-- 1: Realm not connected.
-- 2: Guild Dungeon F2 open.
-- 3: Abyss Gate (Hall of Abyss and Gulid Dungeon F2) open.

$fund_*[01-05]
-- Investment units per guild castle.
$fund_*_extra
-- Investment units per realm.

$@vfund_*[01-05]
$@vfund_*_extra
-- Investment units, used in interim statements only.
*/

// Investment Functions & Controller
//============================================================
// Note: The times in this section are almost entirely custom.

-	script	#invest_timer	-1,{
OnClock0000:	// Open investments on Wed (1 hour after WoE)
	if (gettime(4) == 3 && !agitcheck()) {
		set $2011_agit_invest,1;
		donpcevent "#fund_master::OnInvest_start";
	}
	end;
OnClock1200:	// Close investments on Fri (60 hours after investments open)
	if (gettime(4) == 5 && !agitcheck()) {
		set $2011_agit_invest,2;
		donpcevent "#fund_master::OnInvest_stop";
	}
	end;
OnClock1235:	// Open dungeons on Fri (at least 31 minutes after investments close)
	if (gettime(4) == 5 && !agitcheck())
		donpcevent "#fund_master::OnResult";
	end;
OnClock2000:	// Close dungeons on Tues (1 hour before WoE)
	if (gettime(4) == 2)
		donpcevent "#fund_master::OnReset";
	end;
}

function	script	F_Invest_Status	{
	set .@day, gettime(4);
	set .@hour, gettime(3);
	set .@minute, gettime(2);

	// Inactive.
	if (agitcheck())
		return 0;

	// Open for investments.
	if (.@day >= 3 && (.@day < 5 || (.@day == 5 && .@hour <= 12)))
		return 1;

	// Investments closed, calculating results.
	if (.@day == 5 && .@hour == 12 && .@minute < 35)
		return 2;

	// Calculations complete, dungeons open.
	if ((.@day == 5 && (.@hour > 12 || (.@hour == 12 && .@minute >= 35))) || .@day > 5 ||
	    .@day < 2 || (.@day == 2 && .@hour < 20))
		return 3;

	// Dungeons closed.
	return 0;
}

//callfunc "F_Invest_Abyss","<variable>","<NPC name>"{,"<addon message>"};
function	script	F_Invest_Abyss	{
	mes "There are 2 ways to invest, by Zeny or the Investment Certificate given out by the Cat Paw Merchant Guild.";
	mes "Which way would you like to make your investment?";
	next;
	switch(select("Invest with Zeny.:Invest with Investment Certificates.:Cancel")) {
	case 1:
		mes getarg(1);
		mes "So you've decided to invest in Zeny.";
		mes "Minimum investment unit is ^4d4dff10,000 Zeny^000000.";
		mes "You can invest a maximum of 50 units which is ^4d4dff500,000 Zeny^000000.";
		next;
		switch(select("1 unit 10,000 Zeny:10 units 100,000 Zeny:50 units 500,000 Zeny:Another amount:Cancel")) {
		case 1:
			set .@units,1;
			break;
		case 2:
			set .@units,10;
			break;
		case 3:
			set .@units,50;
			break;
		case 4:
			mes getarg(1);
			mes "Please enter the amount you want to invest.";
			mes "Please choose between 1 to 200.";
			mes "Please enter 0 to cancel.";
			next;
			input .@units;
			if (.@units < 0 || .@units > 200) {
				mes getarg(1);
				mes "You've exceeded the amount per investment.";
				mes "Please try again.";
				close;
			} else if (.@units == 0) {
				mes getarg(1);
				mes "Canceled.";
				close;
			} else
				break;
		case 5:
			mes getarg(1);
			mes "Canceled.";
			close;
		}
		set .@zeny, .@units * 10000;
		if (Zeny < .@zeny) {
			mes getarg(1);
			mes "You do not have enough money.";
			close;
		}
		mes getarg(1);
		mes "You've invested "+.@units+" unit"+((.@units == 1)?"":"s")+" "+((.@units < 100)?.@units:insertchar(""+.@units,",",1))+"0,000 Zeny"+getarg(2,"")+".";
		mes "Not much but this is a small gift. You can exchange it with items in Malangdo.";
		set Zeny, Zeny-.@zeny;
		setd getarg(0), getd(getarg(0)) + .@units;
		getitem 6488,.@units; //Thanks_Invest_Ticket
		close;
	case 2:
		mes getarg(1);
		mes "Wow, you've brought Investment Certificates.";
		mes "How many certificates will you submit?";
		next;
		switch(select("1 Investment Certificate:5 Investment Certificates:Another amount:Cancel")) {
		case 1:
			set .@tickets,1;
			break;
		case 2:
			set .@tickets,5;
			break;
		case 3:
			mes getarg(1);
			mes "Please enter the number of Investment Certificates you want to submit.";
			mes "Please choose between 1 to 20.";
			mes "Please enter 0 to cancel.";
			next;
			input .@tickets;
			if (.@tickets < 0 || .@tickets > 20) {
				mes getarg(1);
				mes "You've exceeded the amount per investment.";
				mes "Please try again.";
				close;
			} else if (.@tickets == 0) {
				mes getarg(1);
				mes "Canceled.";
				close;
			} else
				break;
		case 4:
			mes getarg(1);
			mes "Canceled.";
			close;
		}
		if (countitem(6489) < .@tickets) {
			mes getarg(1);
			mes "Looks like you have fewer Investment Certificates than you want to submit.";
			close;
		}
		set .@units, .@tickets * 10;
		mes getarg(1);
		mes .@tickets+" Investment Certificate"+((.@tickets == 1)?" is":"s are")+" the same as an investment of "+.@units+" units ("+((.@units < 100)?.@units:insertchar(""+.@units,",",1))+"0,000z)"+getarg(2,"")+".";
		mes "Not much but this is a small gift. You can exchange it with items in Malangdo.";
		delitem 6489,.@tickets; //Cats_Invest_Certif
		setd getarg(0), getd(getarg(0)) + .@units;
		getitem 6488,.@units; //Thanks_Invest_Ticket
		close;
	case 3:
		mes getarg(1);
		mes "Canceled.";
		close;
	}
}

// Script Core
//============================================================
prt_gld,1,1,0	script	#fund_master	CLEAR_NPC,{
	end;
OnInit:
	set .@invest_status, callfunc("F_Invest_Status");
	if (.@invest_status == 1) {
		set $2011_agit_invest,1;
		end;
	}
	if ((.@invest_status == 2 && $2011_agit_invest == 1) ||
	    (.@invest_status == 3 && ($2011_agit_invest == 1 || $2011_agit_invest == 2))) {
		donpcevent "#fund_master::OnCalculate";
		end;
	}
	end;
OnCalculate_Election:
	set .@force_vote,1;
OnCalculate:
	setarray .@cas$[0],"prt","pay","gef","alde";
	for(set .@i,0; .@i<4; set .@i,.@i+1) {
		// All funds per realm are summed.
		set .@funds[.@i], getd("$fund_"+.@cas$[.@i]+"01")+getd("$fund_"+.@cas$[.@i]+"02")+getd("$fund_"+.@cas$[.@i]+"03")+getd("$fund_"+.@cas$[.@i]+"04")+getd("$fund_"+.@cas$[.@i]+"05")+getd("$fund_"+.@cas$[.@i]+"_extra");

		// 70,000,000z opens Hall of Abyss and F2.
		if (.@funds[.@i] >= 7000) {
			setd "$"+.@cas$[.@i]+"_invest_result",3;
			set .@total_7000,1;
		}
		// 20,000,000z opens F2 and a chance for Hall of Abyss.
		else if (.@funds[.@i] >= 2000) {
			setd "$"+.@cas$[.@i]+"_invest_result",2;
			set .@total_2000,1;
		}
		// Anything below that opens nothing.
		else
			setd "$"+.@cas$[.@i]+"_invest_result",1;
	}
	// No further actions if 20,000,000z isn't reached.
	if (!.@total_2000)
		end;
	// No further actions if any realm hits 70,000,000z.
	if (.@total_7000) {
		set $2011_agit_invest,4;
		end;
	}
	// Otherwise, highest investment above 20,000,000z opens Hall of Abyss.
	set .@max, .@funds[0];
	for(set .@i,1; .@i<4; set .@i,.@i+1) {
		if (.@funds[.@i] > .@max) {
			set .@max, .@funds[.@i];
			set .@ele, .@i;
			deletearray .@rand$[0], getarraysize(.@rand$);
		} else if (.@funds[.@i] == .@max && .@funds[.@i] >= 2000) {
			if (!getarraysize(.@rand$))
				set .@rand$[0], .@cas$[.@ele];
			set .@rand$[getarraysize(.@rand$)], .@cas$[.@i];
		}
	}
	if (.@max < 2000)
		end;
	if (getarraysize(.@rand$)) {

		// Tie: declare a random winner.
		if (!.@force_vote) {
			set .@i, rand(getarraysize(.@rand$));
			setd "$"+.@rand$[.@i]+"_invest_result",3;
			set $2011_agit_invest,4;
			end;
		}

		// Tie: initiate a 30-minute election.
		set .@str$, implode(.@rand$,"|");
		for(set .@i,0; .@i<4; set .@i,.@i+1) {
			if (compare(.@str$,.@cas$[.@i]))
				set .@election, .@election | (1<<.@i);
		}
		switch(.@election) {
			case 3:  set $2011_agit_invest,11; break; //Prontera|Payon
			case 9:  set $2011_agit_invest,12; break; //Prontera|Al De Baran
			case 5:  set $2011_agit_invest,13; break; //Prontera|Geffen
			case 10: set $2011_agit_invest,14; break; //Al De Baran|Payon
			case 6:  set $2011_agit_invest,15; break; //Geffen|Payon
			case 12: set $2011_agit_invest,16; break; //Al De Baran|Geffen
			case 11: set $2011_agit_invest,17; break; //Prontera|Payon|Al De Baran
			case 7:  set $2011_agit_invest,18; break; //Prontera|Payon|Geffen
			case 13: set $2011_agit_invest,19; break; //Prontera|Al De Baran|Geffen
			case 14: set $2011_agit_invest,20; break; //Al De Baran|Payon|Geffen
			case 15: set $2011_agit_invest,21; break; //Prontera|Payon|Al De Baran|Geffen
		}
		if ($2011_agit_invest >= 11)
			donpcevent "Revoting Manager#Invest1::OnStart";
		end;
	} else {
		setd "$"+.@cas$[.@ele]+"_invest_result",3;
		set $2011_agit_invest,4;
		end;
	}
	end;
OnInvest_start:
	announce "From now on, we are going to start the investments to connect the 'Abyss Gate' in the WOE areas: Valkyrie Realm, Greenwood Lake, Luina, Britoniah.",bc_all,0xFF0000; //FW_NORMAL 10
	set $fund_prt01,0;
	set $fund_prt02,0;
	set $fund_prt03,0;
	set $fund_prt04,0;
	set $fund_prt05,0;
	set $fund_pay01,0;
	set $fund_pay02,0;
	set $fund_pay03,0;
	set $fund_pay04,0;
	set $fund_pay05,0;
	set $fund_gef01,0;
	set $fund_gef02,0;
	set $fund_gef03,0;
	set $fund_gef04,0;
	set $fund_gef05,0;
	set $fund_alde01,0;
	set $fund_alde02,0;
	set $fund_alde03,0;
	set $fund_alde04,0;
	set $fund_alde05,0;
	donpcevent "Investment_total#fund00::OnEnable";
	end;
OnInvest_stop:
	announce "We've finished the investments to connect the 'Abyss Gate'.",bc_all,0xFF0000; //FW_NORMAL 10
	donpcevent "Investment_total#fund00::OnReset";
	donpcevent "#fund_master::OnCalculate_Election";
	end;
OnResult:
	announce "We've got the results of the investments for the 'Abyss Gate'. You can check through the Investment Status Board in each WOE area.",bc_all,0xFF0000; //FW_NORMAL 10
	if ($2011_agit_invest == 4) {
		set $fund_prt01,0;
		set $fund_prt02,0;
		set $fund_prt03,0;
		set $fund_prt04,0;
		set $fund_prt05,0;
		set $fund_prt_extra,0;
		set $fund_pay01,0;
		set $fund_pay02,0;
		set $fund_pay03,0;
		set $fund_pay04,0;
		set $fund_pay05,0;
		set $fund_pay_extra,0;
		set $fund_gef01,0;
		set $fund_gef02,0;
		set $fund_gef03,0;
		set $fund_gef04,0;
		set $fund_gef05,0;
		set $fund_gef_extra,0;
		set $fund_alde01,0;
		set $fund_alde02,0;
		set $fund_alde03,0;
		set $fund_alde04,0;
		set $fund_alde05,0;
		set $fund_alde_extra,0;
	} else if ($2011_agit_invest == 2)
		donpcevent "#fund_master::OnCalculate";
	end;
OnReset:
	set $2011_agit_invest,0;
	donpcevent "Investment_total#fund00::OnReset";
	end;
}

prt_gld,2,2,0	script	Investment_total#fund00	CLEAR_NPC,{
	callfunc "F_GM_NPC";
	mes "Is this not working properly?";
	next;
	if (callfunc("F_GM_NPC",1854,0) == 1) {
		mes "If you think the investment timer is dead, please adjust the timer.";
		next;
		switch(select("Turn on the timer:Cancel")) {
		case 1:
			donpcevent "Investment_total#fund00::OnTimerReset";
			mes "You've turned on the timer.";
			close;
		case 2:
			mes "Canceled.";
			close;
		}
	} else {
		mes "I don't need to adjust anything now.";
		close;
	}

OnInit:
	if (callfunc("F_Invest_Status") == 1) {
		initnpctimer;
		donpcevent "Investment_total#fund00::OnVarInit";
	} else {
		set $agit_result_timer,0;
		set $agit_result_notice,0;
	}
	end;
OnVarInit:
	setarray .@cas$[0],"prt","pay","gef","alde";
	for(set .@i,0; .@i<4; set .@i,.@i+1) {
		setd "$@vfund_"+.@cas$[.@i]+"01", getd("$fund_"+.@cas$[.@i]+"01");
		setd "$@vfund_"+.@cas$[.@i]+"02", getd("$fund_"+.@cas$[.@i]+"02");
		setd "$@vfund_"+.@cas$[.@i]+"03", getd("$fund_"+.@cas$[.@i]+"03");
		setd "$@vfund_"+.@cas$[.@i]+"04", getd("$fund_"+.@cas$[.@i]+"04");
		setd "$@vfund_"+.@cas$[.@i]+"05", getd("$fund_"+.@cas$[.@i]+"05");
		setd "$@vfund_"+.@cas$[.@i]+"_extra", getd("$fund_"+.@cas$[.@i]+"_extra");
	}
	end;
OnEnable:
	set $agit_result_timer,0;
	set $agit_result_notice,0;
	initnpctimer;
	end;
OnReset:
	set $agit_result_timer,0;
	set $agit_result_notice,0;
	stopnpctimer;
	end;
OnTimerReset:
	initnpctimer;
	end;
OnTimer3600000:
	if (callfunc("F_Invest_Status") == 1) {
		if ($agit_result_timer < 59) {
			set $agit_result_timer, $agit_result_timer+1;

			// Trigger on multiples of 5 up to 55, and 58.
			if ($agit_result_timer % 10 == 5 || $agit_result_timer % 10 == 0 || $agit_result_timer == 58) {
				set $agit_result_notice, $agit_result_notice+1;
				donpcevent "Investment_total#fund00::OnVarInit";
				announce "No. "+$agit_result_notice+" Interim statement is now available. You can check through the Investment Status Board in each WOE area.",bc_all,0xFF0000; //FW_NORMAL 10
			}

			donpcevent "Investment_total#fund00::OnTimerReset";
		} else
			stopnpctimer;
		end;
	} else {
		donpcevent "Investment_total#fund00::OnReset";
		end;
	}
}

prt_gld,164,98,3	script	Revoting Manager#Invest1	4_M_BOSSCAT,{
	mes "[Revoting Manager]";
	mes "We are not accepting additional votes.";
	mes "Please wait for our results announcement.";
	close;
OnInit:
	set .@invest_status, callfunc("F_Invest_Status");
	if (.@invest_status == 2 && $2011_agit_invest >= 11 && $agit_revoting_timer < 30) {
		donpcevent "Revoting Manager#Invest2::OnEnable";
		initnpctimer;
	} else if (.@invest_status == 3 && $2011_agit_invest >= 11)
		donpcevent "Revoting Manager#Invest1::OnCalculate";
	donpcevent "Revoting Manager#Invest1::OnDisable";
	end;
OnCalculate:
	switch($2011_agit_invest) {
		case 11: setarray.@cas$[0],"prt","pay"; break;
		case 12: setarray.@cas$[0],"prt","alde"; break;
		case 13: setarray.@cas$[0],"prt","gef"; break;
		case 14: setarray.@cas$[0],"alde","pay"; break;
		case 15: setarray.@cas$[0],"gef","pay"; break;
		case 16: setarray.@cas$[0],"alde","gef"; break;
		case 17: setarray.@cas$[0],"prt","pay","alde"; break;
		case 18: setarray.@cas$[0],"prt","pay","gef"; break;
		case 19: setarray.@cas$[0],"prt","alde","gef"; break;
		case 20: setarray.@cas$[0],"alde","pay","gef"; break;
		case 21: setarray.@cas$[0],"prt","pay","alde","gef"; break;
		default: end;
	}
	set .@max, getd("$fund_"+.@cas$[0]+"_extra");
	for(set .@i,1; .@i<getarraysize(.@cas$); set .@i,.@i+1) {
		set .@funds, getd("$fund_"+.@cas$[.@i]+"_extra");
		if (.@funds > .@max) {
			set .@max, .@funds;
			set .@ele, .@i;
			deletearray .@rand$[0], getarraysize(.@rand$);
		} else if (.@funds == .@max) {
			if (!getarraysize(.@rand$))
				set .@rand$[0], .@cas$[.@ele];
			set .@rand$[getarraysize(.@rand$)], .@cas$[.@i];
		}
	}
	if (getarraysize(.@rand$)) {
		set .@i, rand(getarraysize(.@rand$));
		setd "$"+.@rand$[.@i]+"_invest_result",3;
	} else
		setd "$"+.@cas$[.@ele]+"_invest_result",3;
	set $2011_agit_invest,4;
	set $agit_revoting_timer,0;
	end;
OnEnable:
	enablenpc "Revoting Manager#Invest1";
	end;
OnDisable:
	disablenpc "Revoting Manager#Invest1";
	end;
OnStart:
	initnpctimer;
	donpcevent "Revoting Manager#Invest2::OnNotice_on";
	end;
OnEnd:
	stopnpctimer;
	disablenpc "Revoting Manager#Invest1";
	end;
OnTimerReset:
	initnpctimer;
	end;
OnTimer60000:
	set .@revote, $agit_revoting_timer;
	if (.@revote < 30) {
		set $agit_revoting_timer, $agit_revoting_timer+1;
		donpcevent "Revoting Manager#Invest1::OnTimerReset";
	} else if (.@revote == 30) {
		announce "Cat Paw Merchant Guild: Now we are going to close the additional vote. We will announce the results soon.",bc_all,0xFF0000; //FW_NORMAL 10
		donpcevent "Revoting Manager#Invest2::OnDisable";
		donpcevent "Revoting Manager#Invest1::OnEnable";
		set $agit_revoting_timer, $agit_revoting_timer+1;
		donpcevent "Revoting Manager#Invest1::OnTimerReset";
	} else if (.@revote == 31) {
		donpcevent "Revoting Manager#Invest1::OnCalculate";
		donpcevent "Revoting Manager#Invest1::OnDisable";
		stopnpctimer;
		end;
	} else {
		donpcevent "Revoting Manager#Invest1::OnDisable";
		stopnpctimer;
	}
	end;
}

prt_gld,164,98,3	script	Revoting Manager#Invest2	4_M_BOSSCAT,{
	set .@invest, $2011_agit_invest;
	if (.@invest < 11) {
		mes "[Revoting Manager]";
		mes "No! This is not the time to take a revote.";
		close2;
		disablenpc "Revoting Manager#Invest2";
		end;
	}
	set .@playtime, checkquest(7349,PLAYTIME);
	if (.@playtime == 0 || .@playtime == 1) {
		mes "[Revoting Manager]";
		mes "You've already participated in the vote.";
		mes "Please relax and wait for the results.";
		close;
	} else if (.@playtime == 2)
		erasequest 7349;
	mes "[Revoting Manager]";
	mes "Would you like to participate in the vote for choosing where to connect the 'Abyss Gate'?";
	next;
	if(select("Participate in the vote.:Skip for now.") == 2) {
		mes "[Revoting Manager]";
		mes "You've canceled the vote.";
		close;
	}
	mes "[Revoting Manager]";
	mes "You can vote once and won't need to invest for your choice.";
	mes "Plesae choose one WOE area.";
	next;

	// Create menu.
	explode(.@candidates$, callsub(OnGetCandidates, .@invest),"|");
	for(set .@i,0; .@i<getarraysize(.@candidates$); set .@i,.@i+1) {
		if (.@candidates$[.@i] == "alde")
			set .@menu$[.@i],"Luina";
		else if (.@candidates$[.@i] == "gef")
			set .@menu$[.@i],"Britoniah";
		else if (.@candidates$[.@i] == "pay")
			set .@menu$[.@i],"Greenwood Lake";
		else if (.@candidates$[.@i] == "prt")
			set .@menu$[.@i],"Valkyrie Realm";
	}
	set .@vote, select(implode(.@menu$,":"))-1;

	mes "[Revoting Manager]";
	mes "You've voted for "+.@menu$[.@vote]+".";
	mes "Thanks for voting.";
	setquest 7349;
	setd "$fund_"+.@candidates$[.@vote]+"_extra", getd("$fund_"+.@candidates$[.@vote]+"_extra") + 1;
	close;
OnGetCandidates:
	switch(getarg(0)) {
		case 11: return "prt|pay";
		case 12: return "prt|alde";
		case 13: return "prt|gef";
		case 14: return "alde|pay";
		case 15: return "gef|pay";
		case 16: return "alde|gef";
		case 17: return "prt|pay|alde";
		case 18: return "prt|pay|gef";
		case 19: return "prt|alde|gef";
		case 20: return "alde|pay|gef";
		case 21: return "prt|pay|alde|gef";
	}
	return "";
OnInit:
	disablenpc "Revoting Manager#Invest2";
	end;
OnEnable:
	enablenpc "Revoting Manager#Invest2";
	end;
OnDisable:
	disablenpc "Revoting Manager#Invest2";
	stopnpctimer;
	end;
OnNotice_on:
	initnpctimer;
	end;
OnTimer5000:
	announce "Cat Paw Merchant Guild: As no WOE area has reached the maximum investment level to connect the 'Abyss Gate'...",bc_all,0xFF0000; //FW_NORMAL 10
	end;
OnTimer8000:
	announce "Cat Paw Merchant Guild: We were about to connect the 'Abyss Gate' to the WOE area which invested most.",bc_all,0xFF0000; //FW_NORMAL 10
	end;
OnTimer11000:
	announce "Cat Paw Merchant Guild: However, there were areas which invested the same amount. So we will put them to a vote.",bc_all,0xFF0000; //FW_NORMAL 10
	end;
OnTimer14000:
	announce "Cat Paw Merchant Guild: Additional votes will be available for 30 minutes. You can vote in Valkyrie Realm.",bc_all,0xFF0000; //FW_NORMAL 10
	end;
OnTimer20000:
	explode(.@candidates$, callsub(OnGetCandidates, $2011_agit_invest),"|");
	for(set .@i,0; .@i<getarraysize(.@candidates$); set .@i,.@i+1) {
		if (.@candidates$[.@i] == "alde")
			set .@choices$[.@i],"Luina";
		else if (.@candidates$[.@i] == "gef")
			set .@choices$[.@i],"Britoniah";
		else if (.@candidates$[.@i] == "pay")
			set .@choices$[.@i],"Greenwood Lake";
		else if (.@candidates$[.@i] == "prt")
			set .@choices$[.@i],"Valkyrie Realm";
	}
	announce "Cat Paw Merchant Guild: The candidates for the additional vote are... "+implode(.@choices$," vs. ")+".",bc_all,0xFF0000; //FW_NORMAL 10
	set $fund_prt_extra,0;
	set $fund_pay_extra,0;
	set $fund_gef_extra,0;
	set $fund_alde_extra,0;
	set $agit_revoting_timer,0;
	donpcevent "Revoting Manager#Invest2::OnEnable";
	stopnpctimer;
	end;
}

/*
prtg_cas01,2,2,0	script	Abrai	1_M_JOBTESTER,{
	mes "I should quit my steward job.";
	close;
OnAgitInvest:
	switch(callfunc("F_Invest_Status")) {
	case 0:
		set $2011_agit_invest,0;
		donpcevent "#fund_master::OnReset";
		break;
	case 1:
		set $2011_agit_invest,1;
		donpcevent "#fund_master::OnInvest_start";
		break;
	case 2:
		set $2011_agit_invest,2;
		donpcevent "#fund_master::OnInvest_stop";
		break;
	case 3:
		donpcevent "#fund_master::OnResult";
		break;
	}
	end;
}
*/

// Realms - Merchant Guilds, Gate Managers, Status Boards
//============================================================
-	script	Cat Paw Merchant Guild	-1,{

	if (compare(strnpcinfo(4),"alde")) {
		set .@npc$,"alde";
		set .@name$,"Megrez";
		set .@realm$,"Luina";
		set .@intro$,"Luina Branch Manager in Al De Baran";
	} else if (compare(strnpcinfo(4),"gef")) {
		set .@npc$,"gef";
		set .@name$,"Meraq";
		set .@realm$,"Britoniah";
		set .@intro$,"Britoniah Branch Manager";
	} else if (compare(strnpcinfo(4),"pay")) {
		set .@npc$,"pay";
		set .@name$,"Phecda";
		set .@realm$,"Greenwood Lake";
		set .@intro$,"Payon Greenwood Lake Branch Manager";
	} else if (compare(strnpcinfo(4),"prt")) {
		set .@npc$,"prt";
		set .@name$,"Dubae";
		set .@realm$,"Valkyrie Realm";
		set .@intro$,"Prontera Valkyrie Realm Branch Manager";
	}
	set .@n$,"["+.@name$+"]";

	mes .@n$;
	mes "I'm "+.@name$+", the "+.@intro$+" of the Cat Paw Merchant Guild.";
	mes "I consult about investments for the Abyss Gate development.";
	mes "How may I help you?";
	next;
	switch(select("What is the Abyss Gate?:Investing in the gate development?:I want to invest in this area.:Cancel")) {
	case 1:
		mes .@n$;
		mes "It is only called the Abyss Gate for convenience but it's simply a ^4d4dffgap to another dimension^000000.";
		next;
		mes .@n$;
		mes "More of these gaps are found here and there after Morocc created the Crack of Dimension.";
		mes "I personally think that the Abyss Gate found recently is part of the past or even from the future.";
		next;
		mes .@n$;
		mes "It is said that the Abyss Gate forcefully connects to another dimension beyond our world.";
		mes "Probably because there are those that follow the Emperium's power.";
		next;
		mes .@n$;
		mes "There are a total of 4 Abyss Gates found so far. They all connect to the Agit region overflowing with the Emperium's force.";
		next;
		mes .@n$;
		mes "We named each by dimension beyond the gap.";
		mes "^4d4dffWay of the Warrior, Hill of the Dead, Winds of the Ancient, and the Hero's Tears.^000000";
		mes "And all these four gaps are called the ^4d4dffAbyss Gate^000000.";
		next;
		mes .@n$;
		mes "The gap may lead to the past, future or even an unknown world.";
		mes "The power the Abyss Gate holds is both fearful but sweet";
		next;
		mes .@n$;
		mes "Are you also interested in exploring the Abyss Gate?";
		mes "Ha ha. You'll need to go through several steps before exploring.";
		next;
		mes .@n$;
		mes "If you are interested,";
		mes "will you take the time to sit down and talk about investing in maintaining the Abyss Gate?";
		close;
	case 2:
		mes .@n$;
		mes "Are you curious about investing in the Gate development?";
		mes "What do you want to know about?";
		next;
		switch(select("About the Gate?:About investments?:How to invest?:Benefits from investing?")) {
		case 1:
			mes .@n$;
			mes "The Gate is what it is named after, a door.";
			mes "A dimensional passageway that connects here to there.";
			next;
			mes .@n$;
			mes "The Abyss Gate was created as a very unstable path from beyond the dimensional gap,";
			mes "therefore traveling through the Gate will need an artificial dimension connection.";
			next;
			mes .@n$;
			mes "Humans are far from having the advanced technology that's needed";
			mes "but our Cat Paw Merchant Guild holds the high technology to use the Crack of Dimension.";
			next;
			mes .@n$;
			mes "So we made a proposal.";
			mes "With the promise of support the Cat Paw Merchant Guild and paying for the immense expense for maintaining the connection with the Gate,";
			mes "we will make the connection to the Crack of Dimension.";
			next;
			mes .@n$;
			mes "Of course working on the Crack of Dimension is no easy job and it does come with risks.";
			mes "There are cases where people go missing from traveling between.";
			next;
			mes .@n$;
			mes "The best maintaining duration is about 4 days";
			mes "You invest in us and we create the door that connects to the dimensional gap.";
			next;
			mes .@n$;
			mes "Doesn't this sound like the perfect win-win proposal?";
			close;
		case 2:
			mes .@n$;
			mes "Forcing through the unstable dimensional gap and creating a passageway is very dangerous.";
			mes "Not to mention the huge resources needed.";
			next;
			mes .@n$;
			mes "If you take care of the charges and also the danger pay by investing in the Cat Paw Merchant Guild,";
			mes "we'll create and maintain the gate regardless of the risks.";
			next;
			mes .@n$;
			mes "But then of course the money involved for the gate costs will be extreme.";
			mes "It will be easy if you can find investors to share the amount.";
			next;
			mes .@n$;
			mes "There is a basic charge to start connecting the gate.";
			mes "Results depend on the how much investment money is collected.";
			next;
			mes .@n$;
			mes "The Abyss Gate exists in each Agit region.";
			mes "Can you imagine how much money and sacrifice our guild will have to go through to develop in all areas?";
			next;
			mes .@n$;
			mes "This explains the regional competition in investments.";
			mes "If not enough gate maintenance costs are collected then it is obvious the region with the most investments will receive the benefits";
			next;
			mes .@n$;
			mes "If ^4d4dffthe Abyss Gate is successfully connected then the dungeon of the hideout area";
			mes "will be open to others instead of being guild exclusive^000000 which will be very attractive for investment.";
			next;
			mes .@n$;
			mes "But then again, this is only for when the gate is connected.";
			close;
		case 3:
			mes .@n$;
			mes "It's simple.";
			mes "Visit the branch manager of the ^4d4dffregion you want to invest in during the investment duration^000000 and make your investment.";
			next;
			mes .@n$;
			mes "We usually receive ^4d4dffthe common currency here, Zeny^000000.";
			mes "But since we're talking about supporting our Cat Paw Merchant Guild, you can also invest with items in demand in Malangdo.";
			next;
			mes .@n$;
			mes "Provide the items in need to Namis in Malangdo who is in charge of general affairs in our guild.";
			mes "Bring back your Investment Certificate to add it to the investment tribute.";
			next;
			mes .@n$;
			mes "You must visit and invest at the region you want in order for your investment to be counted as a tribute.";
			close;
		case 4:
			mes .@n$;
			mes "The Abyss Gate is basically contracting and connecting with the castle that owns the Agit;";
			mes "therefore, we will provide all we have once the costs for connecting and maintaining the gate are sufficient.";
			next;
			mes .@n$;
			mes "In terms of the minimum and maximum costs for the whole work,";
			mes "if the collected investment ^4d4dffexceeds the minimum costs^000000, we can connect you to the ^4d4dffdeepest layer of an unknown guild dungeon^000000.";
			next;
			mes .@n$;
			mes "If investments exceed the maximum costs, that region will be connected to the";
			mes "^4d4dffAbyss Gate^000000 regardless of the investment rank which includes the deepest layer of the guild dungeon.";
			next;
			mes .@n$;
			mes "^ff0000If there is no Agit region that reached the maximum investment, then the region with the";
			mes "highest investment participation will get the Abyss Gate connected with the investment collected from all regions.^000000";
			next;
			mes .@n$;
			mes "Once the Abyss Gate is connected, the deepest layer (2F) of the guild dungeon";
			mes "will be open to all adventurers that participated in the regional investment.";
			next;
			mes .@n$;
			mes "Visits to the dungeon will be counted for the next investment for the Agit region";
			mes "so being in good terms with the guild that claims the Agit castle will be a bonus.";
			next;
			mes .@n$;
			mes "By the way, it isn't easy to maintain the connection with the Abyss Gate and investments and reconnection is needed weekly";
			mes "so please continue your support and investment if you want the power of the unknown.";
			close;
		}
	case 3:
		if (checkweight(1201,1) == 0 || MaxWeight - Weight < 1000) {
			mes "- Currently you're carrying -";
			mes "- too many items with you. -";
			mes "- Please try again after you -";
			mes "- lose some weight. -";
			close;
		}
		if (countitem(6488) >= 4800) {
			mes .@n$;
			mes "You have too many Thank You Tickets to receive any more.";
			mes "Cannot give you any more tickets. Please use your ticket and come back.";
			mes "The ticket can be exchanged with various items in Malangdo.";
			close;
		}
		if (callfunc("F_Invest_Status") != 1) {
			mes .@n$;
			mes "We do not receive investments now.";
			mes "Please come back during the investment duration.";
			close;
		}
		set .@guild, getcharid(2);
		for(set .@i,1; .@i<=5; set .@i,.@i+1) {
			set .@castle_name$[.@i], getcastlename(.@npc$+"g_cas0"+.@i);
			set .@owner_id[.@i], getcastledata(.@npc$+"g_cas0"+.@i,1);
			set .@owner_name$[.@i], getguildname(.@owner_id[.@i]);
			if (.@guild == .@owner_id[.@i]) {
				set .@menu$, .@menu$+.@castle_name$[.@i]+" ["+.@owner_name$[.@i]+"] Guild:";
				set .@castles_owned, .@castles_owned | (1<<.@i);
			} else
				set .@menu$, .@menu$+"^aaaaaaNot the guild that claimed "+.@castle_name$[.@i]+"^000000:";
		}
		mes .@n$;
		mes "Would you like to invest in the ^4d4dff"+.@realm$+"^000000 region?";
		mes "If there is a castle occupied already, you will invest in the castle and the guild that is occupying it.";
		next;
		if (.@castles_owned) {
			set .@i, select(.@menu$+"Cancel");
			if (.@i == 6) {
				mes .@n$;
				mes "Canceled.";
				close;
			}
			if (.@guild != .@owner_id[.@i]) {
				mes .@n$;
				mes "The guild that is occupying "+.@castle_name$[.@i]+" is "+.@owner_name$[.@i]+".";
				mes "Doesn't look like your guild.";
				close;
			}
			mes .@n$;
			mes "Invest under "+.@castle_name$[.@i]+"'s"+.@owner_name$[.@i]+" guild name.";
			callfunc "F_Invest_Abyss","$fund_"+.@npc$+"0"+.@i,.@n$;
			end;
		} else {
			mes .@n$;
			callfunc "F_Invest_Abyss","$fund_"+.@npc$+"_extra",.@n$," for "+.@realm$;
			end;
		}
	case 4:
		mes .@n$;
		mes "Is that so?";
		mes "Please come back whenever you are interested in investing in the Abyss Gate development.";
		close;
	}
}

-	script	Gate Manager#realm	-1,{

	if (compare(strnpcinfo(4),"alde")) {
		set .@npc$,"alde";
		set .@name$,"Alkor";
		set .@gate$,"Hero's Tears";
		set .@realm$,"Luina";
	} else if (compare(strnpcinfo(4),"gef")) {
		set .@npc$,"gef";
		set .@name$,"Mizar";
		set .@gate$,"Hill of the Dead";
		set .@realm$,"Britoniah";
	} else if (compare(strnpcinfo(4),"pay")) {
		set .@npc$,"pay";
		set .@name$,"Alkaid";
		set .@gate$,"Winds of the Ancient";
		set .@realm$,"Greenwood Lake";
	} else if (compare(strnpcinfo(4),"prt")) {
		set .@npc$,"prt";
		set .@name$,"Arios";
		set .@gate$,"Way of the Warrior";
		set .@realm$,"Valkyrie Realm";
	}
	set .@n$,"["+.@name$+"]";

	if (callfunc("F_Invest_Status") != 3) {
		mes .@n$;
		mes "There are currently no connected dungeon gates.";
		close;
	}
	set .@status, getd("$"+.@npc$+"_invest_result");
	if (.@status == 3) {
		mes .@n$;
		mes "We've successfully connected the Abyss Gate ["+.@gate$+"] with the help from your investment.";
		mes "The Agit dungeon will be open to everyone with a small entrance fee in "+.@realm$+".";
		next;
		mes .@n$;
		mes "Please visit as often as possible since the entrance fee is saved as an investment for the region.";
		mes "Do you want to enter the Agit dungeon?";
		next;
		set .@i, select(.@realm$+" Dungeon 1F - 10000z:"+.@realm$+" Dungeon 2F - 10000z:Cancel");
		if (.@i == 3) {
			mes .@n$;
			mes "Canceled.";
			close;
		}
		if (Zeny < 10000) {
			mes .@n$;
			mes "I'm collecting a small entrance fee.";
			mes "Your contribution will be saved for the next investment.";
			mes "Entrance fee is 10000z.";
			close;
		}
		mes .@n$;
		mes "I'm sending you to the "+.@realm$+" Agit Dungeon "+.@i+"F.";
		set Zeny, Zeny-10000;
		setd "$fund_"+.@npc$+"_extra", getd("$fund_"+.@npc$+"_extra") + 1;
		close2;
		if (compare(strnpcinfo(2),"alde"))
			warp "gld_dun02"+((.@i == 2)?"_2":""),32,122;
		else if (compare(strnpcinfo(2),"gef"))
			warp "gld_dun04"+((.@i == 2)?"_2":""),39,258;
		else if (compare(strnpcinfo(2),"pay"))
			warp "gld_dun01"+((.@i == 2)?"_2":""),186,165;
		else if (compare(strnpcinfo(2),"prt"))
			warp "gld_dun03"+((.@i == 2)?"_2":""),164,268;
		end;
	} else if (.@status == 2) {
		mes .@n$;
		mes "The "+.@realm$+" Agit Dungeon 2F is now available but since it is not connected with the Abyss Gate,";
		mes "the Agit dungeon is only accessible to the Agit guild.";
		close;
	} else {
		mes .@n$;
		mes .@realm$+" was not chosen to be connected with a gate this time.";
		mes "Please wait for the next investment duration.";
		close;
	}
	end;
}

-	script	Investment Status Board	-1,{
	set .@invest_status, callfunc("F_Invest_Status");
	if (.@invest_status == 1) {
		if (compare(strnpcinfo(4),"alde")) {
			set .@npc$,"alde";
			set .@realm$,"Luina";
		} else if (compare(strnpcinfo(4),"gef")) {
			set .@npc$,"gef";
			set .@realm$,"Britoniah";
		} else if (compare(strnpcinfo(4),"pay")) {
			set .@npc$,"pay";
			set .@realm$,"Greenwood Lake";
		} else if (compare(strnpcinfo(4),"prt")) {
			set .@npc$,"prt";
			set .@realm$,"Valkyrie Realm";
		}
		set .@notice, $agit_result_notice;
		if (.@notice < 1 || .@notice > 12) {
			mes "There are currently no investment sums available.";
			close;
		} else if (.@notice == 1)
			set .@str$,"1st";
		else if (.@notice == 2)
			set .@str$,"2nd";
		else if (.@notice == 3)
			set .@str$,"3rd";
		else
			set .@str$,.@notice+"th";
		mes .@str$+" total (unit in 10,000z)";
		for(set .@i,1; .@i<=5; set .@i,.@i+1) {
			set .@map$, .@npc$+"g_cas0"+.@i;
			set .@fund[.@i], getd("$@vfund_"+.@npc$+"0"+.@i);
			mes getcastlename(.@map$)+" "+getguildname(getcastledata(.@map$,1))+" Guild: "+.@fund[.@i];
		}
		set .@fund[0], getd("$@vfund_"+.@npc$+"_extra");
		mes .@realm$+" normal: "+.@fund[0];
		mes .@realm$+" Investment Grand Total: "+(.@fund[0]+.@fund[1]+.@fund[2]+.@fund[3]+.@fund[4]+.@fund[5]);
		close;
	} else if (.@invest_status == 2) {
		mes "!- Notice -!";
		mes "No sums are available because the total investment amount is currently being calculated.";
		mes "Please wait for the announcement of the results.";
		close;
	} else if (.@invest_status == 3) {
		setarray .@invest_result[0], $prt_invest_result,$pay_invest_result,$gef_invest_result,$alde_invest_result;
		setarray .@invest_region$[0],  "Valkyrie Realm",  "Greenwood Lake",       "Britoniah",            "Luina";
		mes "!- Investment Results of All Agit Regions -!";
		for(set .@i,0; .@i<4; set .@i,.@i+1) {
			if (.@invest_result[.@i] == 1)
				mes "^aaaaaa["+.@invest_region$[.@i]+"] below minimum^000000";
			else if (.@invest_result[.@i] == 2) {
				mes "["+.@invest_region$[.@i]+"] minimum achieved";
				mes "-> Guild Dungeon Deepest Layer (2F) available";
			} else if (.@invest_result[.@i] == 3) {
				mes "^4d4dff["+.@invest_region$[.@i]+"] maximum achieved^000000";
				mes "-> Abyss Gate available";
			} else
				mes "No data for ["+.@invest_region$[.@i]+"].";
		}
		close;
	} else {
		mes "!- Notice -!";
		mes "No investment information will be announced now.";
		close;
	}
}

// Inside Castles - Gate Managers
//============================================================
-	script	Gate Manager#castle	-1,{

	set .@id, atoi(charat(strnpcinfo(2),getstrlen(strnpcinfo(2))-1));
	if (compare(strnpcinfo(2),"alde")) {
		set .@npc$,"alde";
		set .@realm$,"Luina";
	} else if (compare(strnpcinfo(2),"gef")) {
		set .@npc$,"gef";
		set .@realm$,"Britoniah";
	} else if (compare(strnpcinfo(2),"pay")) {
		set .@npc$,"pay";
		set .@realm$,"Greenwood Lake";
	} else if (compare(strnpcinfo(2),"prt")) {
		set .@npc$,"prt";
		set .@realm$,"Valkyrie Realm";
	}

	set .@GID, getcastledata(strnpcinfo(4),1);
	if (getcharid(2) != .@GID) {
		mes "[Gate Manager]";
		mes "You don't seem to be the member of guild owning this castle.";
		mes "If you need any help, please visit any of our guild members at "+.@realm$+" Square.";
		close;
	}
	mes "[Gate Manager]";
	mes "Hello, I am the Gate Manager from Cat Paw Merchant Guild warp department.";
	mes "How may I help you today?";
	next;
	switch(select("Invest for gate connection:Deepest Layer Dungeon Access:Abyss Gate Access:Cancel")) {
	case 1:
		if (checkweight(1201,1) == 0 || MaxWeight - Weight < 1000) {
			mes "[Gate Manager]";
			mes "You have too many items to receive the Thank You Ticket as a small gift for your investment.";
			mes "Please come back after making room in your inventory.";
			close;
		}
		if (countitem(6488) >= 4800) {
			mes "[Gate Manager]";
			mes "You have too many Thank You Tickets to receive any more.";
			mes "Cannot give you any more tickets. Please use your ticket and come back.";
			mes "The ticket can be exchanged with various items in Malangdo.";
			close;
		}
		if (callfunc("F_Invest_Status") != 1) {
			mes "[Gate Manager]";
			mes "We do not receive investments now.";
			mes "Please come back during the investment duration.";
			close;
		}
		if (getcharid(2) != .@GID) {
			mes "[Gate Manager]";
			mes "You don't seem to be the member of the guild owning this castle.";
			mes "Please use the normal investment from "+.@realm$+" Square.";
			close;
		}
		mes "[Gate Manager]";
		mes "Proceed investing under your guild name.";
		callfunc "F_Invest_Abyss","$fund_"+.@npc$+"0"+.@id,"[Gate Manager]";
		end;
	case 2:
		callsub L_Enter,1,.@realm$,.@npc$;
		mes "[Gate Manager]";
		mes "You are interested in exploring the "+.@realm$+" Guild Dungeon Deepest Layer (2F).";
		mes "Let me guide you. Good luck.";
		close2;
		if (compare(strnpcinfo(2),"alde")) {
			switch(.@id) {
				case 1: warp "gld_dun02_2",32,122; end;
				case 2: warp "gld_dun02_2",79,30; end;
				case 3: warp "gld_dun02_2",165,38; end;
				case 4: warp "gld_dun02_2",160,148; end;
				case 5: warp "gld_dun02_2",103,169; end;
			}
		} else if (compare(strnpcinfo(2),"gef")) {
			switch(.@id) {
				case 1: warp "gld_dun04_2",39,258; end;
				case 2: warp "gld_dun04_2",125,270; end;
				case 3: warp "gld_dun04_2",268,251; end;
				case 4: warp "gld_dun04_2",268,108; end;
				case 5: warp "gld_dun04_2",230,35; end;
			}
		} else if (compare(strnpcinfo(2),"pay")) {
			switch(.@id) {
				case 1: warp "gld_dun01_2",186,165; end;
				case 2: warp "gld_dun01_2",54,165; end;
				case 3: warp "gld_dun01_2",54,39; end;
				case 4: warp "gld_dun01_2",186,39; end;
				case 5: warp "gld_dun01_2",223,202; end;
			}
		} else if (compare(strnpcinfo(2),"prt")) {
			switch(.@id) {
				case 1: warp "gld_dun03_2",28,251; end;
				case 2: warp "gld_dun03_2",164,268; end;
				case 3: warp "gld_dun03_2",164,179; end;
				case 4: warp "gld_dun03_2",268,203; end;
				case 5: warp "gld_dun03_2",199,28; end;
			}
		}
		end;
	case 3:
		callsub L_Enter,2,.@realm$,.@npc$;
		mes "[Gate Manager]";
		mes "Let me guide you to the Abyss Gap connected with "+.@realm$+", the Abyss Gate 'Way of the Warrior'.";
		close2;
		if (compare(strnpcinfo(2),"alde")) {
			switch(.@id) {
				case 1: warp "gld2_ald",175,41; end;
				case 2: warp "gld2_ald",77,64; end;
				case 3: warp "gld2_ald",46,127; end;
				case 4: warp "gld2_ald",104,246; end;
				case 5: warp "gld2_ald",241,156; end;
			}
		} else if (compare(strnpcinfo(2),"gef")) {
			switch(.@id) {
				case 1: warp "gld2_gef",28,199; end;
				case 2: warp "gld2_gef",217,46; end;
				case 3: warp "gld2_gef",171,195; end;
				case 4: warp "gld2_gef",30,67; end;
				case 5: warp "gld2_gef",115,40; end;
			}
		} else if (compare(strnpcinfo(2),"pay")) {
			switch(.@id) {
				case 1: warp "gld2_pay",33,112; end;
				case 2: warp "gld2_pay",119,27; end;
				case 3: warp "gld2_pay",205,111; end;
				case 4: warp "gld2_pay",175,221; end;
				case 5: warp "gld2_pay",61,221; end;
			}
		} else if (compare(strnpcinfo(2),"prt")) {
			switch(.@id) {
				case 1: warp "gld2_prt",10,27; end;
				case 2: warp "gld2_prt",14,247; end;
				case 3: warp "gld2_prt",259,236; end;
				case 4: warp "gld2_prt",226,25; end;
				case 5: warp "gld2_prt",97,11; end;
			}
		}
		end;
	case 4:
		mes "[Gate Manager]";
		mes "Canceled.";
		close;
	}
	end;

L_Enter:
	set .@invest_status, callfunc("F_Invest_Status");
	if (.@invest_status == 3) {
		set .@status, getd("$"+getarg(2)+"_invest_result");
		if ((getarg(0) == 1 && .@status == 2) || .@status == 3)
			return;
		else {
			mes "[Gate Manager]";
			mes getarg(1)+" was not chosen to be connected with a gate this time.";
			mes "Please wait for the next investment duration.";
			close;
		}
	} else if (.@invest_status < 3) {
		mes "[Gate Manager]";
		mes "There are currently no connected dungeon gates.";
		mes "A gate will be connected as soon as the investment results are available.";
		mes "Please wait.";
		close;
	} else {
		mes "[Gate Manager]";
		mes "The gate will disappear soon.";
		mes "The dungeon is no longer accessible.";
		mes "Please try again next time.";
		close;
	}
}

// Item Investments
//============================================================
malangdo,218,126,4	script	Cat Paw Merchants Notice	4_BOARD3,{
	mes "<< Cat Paw Merchants Notice >>";
	mes "'^C379CEInvest Unused Items for Prizes!^000000'";
	next;
	switch(select("Read Notice:Check Event 1:Check Event 2")) {
	case 1:
		mes "- Notice -";
		mes "Hello all Cat Paw Merchants customers! With your love, we Cat Paw Merchants are growing every day. All executives and staff members promise to do our best to further our frontier and development.";
		next;
		mes "- Event Notice! -";
		mes " An Event called '^C379CEInvest Unused Items for Prizes!^000000' is under way, where you could exchange unused items in your storage for Investment Certificate of the Cat Paw Merchants.";
		next;
		mes "Exchangeable items will be announced on a separate sheet. Thank you for your time.";
		mes "- From all the employees of Cat Paw Merchants -";
		next;
		mes "There is a small warning at the bottom.";
		mes " ";
		mes "^FF0000This event could be changed or repealed due to the Merchants' situation.^000000";
		close;
	case 2:
		mes "'^C379CEInvest Unused Items for Prizes!^000000'";
		mes "There are details of Event 1.";
		next;
		setarray .@event1$[0],
			"Wings of the Insect Queen","Crown of the Fly King","I hear Dragon Scales are tough 01","The Meaning of the Mother's Nightmare",
			"To refine ore","Hekekek Orcs, Orcs!!","Study of Yin-Yang","Secrets of the Pyramid King","Tick-tock the time goes",
			"Planting trees on Mellow Island","Ancient language research","Weapons made of sharp teeth","Toy boss doll 01",
			"A tiger is just a cat after all","The shattered spear and shield?","Toy boss doll 02","Best in summer! Cold scales",
			"Piece of Thanatos' armor","I hear Dragon Scales are tough 02","The identity of the creepy eye","If only I could see!";
		set .@menu$, "Quit:"+implode(.@event1$[0],":");
		while(1) {
			set .@i, select(.@menu$)-1;
			switch(.@i) {
				case 0: close;
				case 1: set .@str$,"2 Pieces of Queen's Wing"; break;
				case 2: set .@str$,"2 Broken Crowns"; break;
				case 3: set .@str$,"2 Fire Dragon Scales"; break;
				case 4: set .@str$,"3 Mother's Nightmares"; break;
				case 5: set .@str$,"5 Gemstones"; break;
				case 6: set .@str$,"5 Heroic Emblems"; break;
				case 7: set .@str$,"3 Taeguk Plates"; break;
				case 8: set .@str$,"3 Broken Pharaoh Symbols and 3 Tutankhamen's Masks"; break;
				case 9: set .@str$,"2 Pocket Watches"; break;
				case 10: set .@str$,"3 Young Twigs"; break;
				case 11: set .@str$,"5 Rossata Pieces"; break;
				case 12: set .@str$,"5 Fangs of Garm"; break;
				case 13: set .@str$,"3 Baphomet Dolls"; break;
				case 14: set .@str$,"1 Tiger's Footskin and 5 Tiger Skins"; break;
				case 15: set .@str$,"3 Broken Shield Pieces and 3 Shining Spear Blades"; break;
				case 16: set .@str$,"3 Osiris Dolls"; break;
				case 17: set .@str$,"1 Ice Scale"; break;
				case 18: set .@str$,"1 Skeletal Armor Piece"; break;
				case 19: set .@str$,"1 Darkred Scale Piece"; break;
				case 20: set .@str$,"2 Wills of Red Darkness"; break;
				case 21: set .@str$,"2 Foolishness of the Blind"; break;
			}
			mes "["+.@event1$[.@i-1]+"]";
			mes .@str$+" for one Cat Paw Merchants Investment Certificate.";
			next;
		}
	case 3:
		mes "Look out for the next '^C379CEInvest Unused Items for Prizes!^000000' Event 2!! Coming up real soon!";
		close;
	}
}

malangdo,218,123,1	script	Namis#invest	4_CAT_SAILOR2,4,4,{
	if (checkweight(1201,1) == 0 || MaxWeight - Weight < 1000) {
		mes "- Currently you're carrying -";
		mes "- too many items with you. -";
		mes "- Please try again after you -";
		mes "- lose some weight. -";
		close;
	}
	emotion e_omg;
	emotion e_an;
	emotion e_ag;
	mes "[Namis]";
	mes "Purr-Purr-Purrr-Purrrr-Pur~ Meow!!";
	mes "Wh-- What? How rude. You scared me.";
	next;
	switch(select("What do you need? I'll invest!:What's the purpose of this event?:Were you asleep?")) {
	case 1:
		break;
	case 2:
		mes "[Namis]";
		mes "So, another pushover in contract with the Cat Paw Merchants?";
		next;
		select("Huh? What! You calling me a pushover?");
		mes "[Namis]";
		mes "I'll say this just once, so you listen good!";
		mes "We, the Cat Paw Merchants have planned an event for loyal workers like yourself.";
		next;
		mes "[Namis]";
		mes "Run along to your storage and bring back rotting antiques to us and we'll exchange them for the oh-so valuable 'Cat Paw Merchants Investment Certificate'.";
		next;
		mes "[Namis]";
		mes "It will be wise for you to do so because the Cat Paw Merchants are doing this at a loss!";
		next;
		mes "[Namis]";
		mes "Details are on the notice.";
		close;
	case 3:
		mes "[Namis]";
		mes "Hick- Slurp-";
		mes "Remember, human! There's no other cat who works as hard as I do.";
		close;
	}
	mes "[Namis]";
	mes "You must be here to participate in the '^C379CEInvest Unused Items for Prizes!^000000' event of the Cat Paw Merchants.";
	next;
	mes "[Namis]";
	mes "So, which event do you wish to participate in?";
	next;
	switch(select("Not interested:Event 1 Items:Event 2 Items")) {
	case 1:
		mes "[Namis]";
		mes "Don't you mess with a busy cat!";
		close;
	case 2:
		mes "[Namis]";
		mes "So you're in for Event 1.";
		mes "Choose from the shown list.";
		next;
		setarray .@event1$[0],
			"Wings of the Insect Queen","Crown of the Fly King","I hear Dragon Scales are tough 01","The Meaning of the Mother's Nightmare",
			"To refine ore","Hekekek Orcs, Orcs!!","Study of Yin-Yang","Secrets of the Pyramid King","Tick-tock the time goes",
			"Planting trees on Mellow Island","Ancient language research","Weapons made of sharp teeth","Toy boss doll 01",
			"A tiger is just a cat after all","The shattered spear and shield?","Toy boss doll 02","Best in summer! Cold scales",
			"Piece of Thanatos' armor","I hear Dragon Scales are tough 02","The identity of the creepy eye","If only I could see!";
		set .@i, select(implode(.@event1$[0],":"))-1;
		switch(.@i+1) {
			case 1: callsub L_Check,"2 Pieces of Queen's Wing",6326,2,"Wings of the Insect Queen? What a pitiful name. I would've given some cool names!",.@event1$[.@i];
			case 2: callsub L_Check,"2 Broken Crowns",7754,2,"For crying out loud! Those cats working on these events must be playing around. Can't they think of a better name?",.@event1$[.@i];
			case 3: callsub L_Check,"2 Fire Dragon Scales",7451,2,"Dragon scales? Well... I guess they are tough. But what are they going to use them for?",.@event1$[.@i];
			case 4: callsub L_Check,"3 Mother's Nightmares",7020,3,"Even though I don't have the authority to find out, I wonder what they're doing with the collected items?",.@event1$[.@i];
			case 5: callsub L_Check,"5 Gemstones",7300,5,"Something useful for a change. The ore will end up as nice pieces of jewelry.",.@event1$[.@i];
			case 6: callsub L_Check,"5 Heroic Emblems",968,5,"Good, good. This is the kind of name I wanted!",.@event1$[.@i];
			case 7: callsub L_Check,"3 Taeguk Plates",7169,3,"Taking in something like this, maybe they're up to something dangerous.",.@event1$[.@i];
			case 8: callsub L_Check,"3 Broken Pharaoh Symbols and 3 Tutankhamen's Masks",7113,3,"I hear the pyramids are in Morroc, but I've never been there. Some humans call it Morco.",.@event1$[.@i],7114,3;
			case 9: callsub L_Check,"2 Pocket Watches",7513,2,"Those lazy merchants, why do they need pocket watches they don't even use?",.@event1$[.@i];
			case 10: callsub L_Check,"3 Young Twigs",7018,3,"Mellow Island has a climate like with where we cats used to live. But the trees die out sometimes due to it being an island.",.@event1$[.@i];
			case 11: callsub L_Check,"5 Rossata Pieces",7211,5,"I guess they collect these because humans have them, but what's the use of researching ancient languages?",.@event1$[.@i];
			case 12: callsub L_Check,"5 Fangs of Garm",7036,5,"Weak humans need sharp weapons, but cats already have nice and sharp claws, so why are we collecting these!!",.@event1$[.@i];
			case 13: callsub L_Check,"3 Baphomet Dolls",750,3,"Baphomet dolls are great for playing around with.",.@event1$[.@i];
			case 14: callsub L_Check,"1 Tiger's Footskin and 5 Tiger Skins",1030,1,"Did you know that tigers are cats too? Therefore, cats are better than tigers.",.@event1$[.@i],1029,5;
			case 15: callsub L_Check,"3 Broken Shield Pieces and 3 Shining Spear Blades",7108,3,"I don't know what they want with these.",.@event1$[.@i],7109,3;
			case 16: callsub L_Check,"3 Osiris Dolls",751,3,"Shame~ I never got to play with an Osiris doll.",.@event1$[.@i];
			case 17: callsub L_Check,"1 Ice Scale",7562,1,"Mellow Island is a fabulous place to live. But the ships are too hot.",.@event1$[.@i];
			case 18: callsub L_Check,"1 Skeletal Armor Piece",7450,1,"Ewww... Why would they collect something so creepy?",.@event1$[.@i];
			case 19: callsub L_Check,"1 Darkred Scale Piece",6091,1,"Dragon scales? Well... I guess they are tough. But what are they going to use them for?",.@event1$[.@i];
			case 20: callsub L_Check,"2 Wills of Red Darkness",7566,2,"Interesting! Does it scream or something when I poke it in the eye?",.@event1$[.@i];
			case 21: callsub L_Check,"2 Foolishness of the Blind",7021,2,"This blind man is foolish in not knowing that gathering 300 cats cures blindness...",.@event1$[.@i];
		}
	case 3:
		mes "[Namis]";
		mes "Participate in Event 2?";
		mes "It is not yet in motion. Wait for it!";
		close;
	}
	end;
L_Check:
	set .@args, getargcount();
	if (.@args > 5) {
		if (countitem(getarg(5)) < getarg(6))
			set .@items,1; //incomplete
		else
			set .@items,2; //complete
	}
	if (countitem(getarg(1)) < getarg(2) || .@items == 1) {
		mes "[Namis]";
		mes "You don't have the items?";
		mes getarg(0)+" exchange for one Cat Paw Merchants Investment Certificate.";
		next;
		mes "[Namis]";
		mes "Don't bother me and look up the details on the board over there!";
		close;
	}
	mes "[Namis]";
	mes "'^8E5601"+getarg(4)+" Event^000000'";
	mes "Seems to be the right items.";
	mes getarg(3);
	mes "Oh! Almost forgot. Will you invest?";
	next;
	if(select("Invest:Don't Invest") == 2) {
		mes "[Namis]";
		mes "Don't you mess with a busy cat!";
		close;
	}
	delitem getarg(1),getarg(2);
	if (.@items == 2)
		delitem getarg(5),getarg(6);
	getitem 6489,1; //Cats_Invest_Certif
	mes "[Namis]";
	mes "Here's your Certificate. Always be grateful to the Merchants for these events!";
	close;
OnTouch:
	if (rand(2))
		emotion e_yawn;
	else
		specialeffect EF_SLEEPATTACK;
	end;
}

// Investment Rewards
//============================================================
malangdo,215,119,4	script	Thanks Ticket Machine	2_VENDING_MACHINE1,{
	if (MaxWeight - Weight < 4500 || checkweight(1201,1) == 0) {
		mes "- Currently you're carrying -";
		mes "- too many items with you. -";
		mes "- Please try again after you -";
		mes "- lose some weight. -";
		close;
	}
	mes "[Vending Machine Notice]";
	mes "^6815EA1. Don't kick the machine please. @_@";
	mes "2. You can only insert Invest Thanks Ticket.";
	mes "3. About the Jelly Box, if you open it, it gives you a random item.";
	mes "4. Hope you enjoy~^000000";
	mes "- Mr. Cat, the Machine Owner -";
	next;
	switch(select("Finish:Purchase:Red Paw Jelly Bag (5 Tickets):Black Paw Jelly Bag (50 Tickets)")) {
	case 1:
		close;
	case 2:
		mes "The Vending Machine is selling items in the following list.";
		next;
		switch(select("Finish:1 Siege Arrow Quiver A (2 Tickets):1 Siege Arrow Quiver S (2 Tickets):30 White Potion (12 Tickets):30 White Slim Potion (14 Tickets):10 Dark Water (20 Tickets):20 Siege_Violet_Potion (30 Tickets):10 Coldproof Potion (30 Tickets):10 Thunderproof Potion (30 Tickets):10 Earthproof Potion (30 Tickets):10 Fireproof Potion (30 Tickets):10 Elemental Converter[Fire] (30 Tickets)")) {
			case 1: close;
			case 2: callsub L_Purchase,2,12678,1; //Siege_Arrow_Quiver_A
			case 3: callsub L_Purchase,2,12677,1; //Siege_Arrow_Quiver_S
			case 4: callsub L_Purchase,12,504,30; //White_Potion
			case 5: callsub L_Purchase,14,547,30; //White_Slim_Potion
			case 6: callsub L_Purchase,20,12020,10; //Water_Of_Darkness
			case 7: callsub L_Purchase,30,11547,20; //Woe_Violet_Potion
			case 8: callsub L_Purchase,30,12119,10; //Resist_Water
			case 9: callsub L_Purchase,30,12121,10; //Resist_Wind
			case 10: callsub L_Purchase,30,12120,10; //Resist_Earth
			case 11: callsub L_Purchase,30,12118,10; //Resist_Fire
			case 12: callsub L_Purchase,30,12114,10,"Elemental Converter[Fire]"; //Elemental_Fire
			case 13: callsub L_Purchase,30,12115,10,"Elemental Converter[Water]"; //Elemental_Water
			case 14: callsub L_Purchase,30,12117,10,"Elemental Converter[Wind]"; //Elemental_Wind
			case 15: callsub L_Purchase,30,12116,10,"Elemental Converter[Earth]"; //Elemental_Earth
		}
		end;
	case 3:
		mes "Red Paw Jelly Bag Button chosen. Need to insert 5 ^FF0000Invest Thanks Ticket^000000 and a random item will appear.";
		next;
		if (countitem(6488) < 5) {
			mes "You don't have enough ^FF0000Invest Thanks Ticket^000000 to proceed.";
			close;
		}
		delitem 6488,5; //Thanks_Invest_Ticket
		set .@i, rand(1,10000);
		     if (.@i <= 100) callsub L_Bag,12531,1; //White_Potion_Box
		else if (.@i <= 200) callsub L_Bag,12549,1; //White_Slim_Pot_Box2
		else if (.@i <= 250) callsub L_Bag,11549,10; //Woe_Blue_Potion
		else if (.@i <= 660) callsub L_Bag,617,1; //Old_Violet_Box
		else if (.@i <= 710) callsub L_Bag,12532,1; //Royal_Jelly_Box2
		else if (.@i <= 760) callsub L_Bag,12533,1; //Blue_Herb_Box2
		else if (.@i <= 810) callsub L_Bag,505,5; //Blue_Potion
		else if (.@i <= 1110) callsub L_Bag,644,1; //Gift_Box
		else if (.@i <= 1120) callsub L_Bag,607,1; //Yggdrasilberry
		else if (.@i <= 1130) callsub L_Bag,608,2; //Seed_Of_Yggdrasil
		else if (.@i <= 1140) callsub L_Bag,12292,5; //Unripe_Fruit
		else if (.@i <= 1150) callsub L_Bag,12293,5; //Dried_Yggdrasilberry
		else if (.@i <= 1250) callsub L_Bag,12679,1; //Sg_White_Potion_Box
		else if (.@i <= 1471) callsub L_Bag,603,1; //Old_Blue_Box
		else if (.@i <= 1571) callsub L_Bag,12550,1,"Poison Bottle Box(30)"; //Poison_Bottle_Box2
		else if (.@i <= 1671) callsub L_Bag,12020,10; //Water_Of_Darkness
		else if (.@i <= 1871) callsub L_Bag,12030,5; //Box_Of_Grudge
		else if (.@i <= 2071) callsub L_Bag,12031,5; //Sleepy_Box
		else if (.@i <= 2371) callsub L_Bag,12033,2; //Box_Of_Sunlight
		else if (.@i <= 2571) callsub L_Bag,12114,5,"Elemental Converter[Fire]"; //Elemental_Fire
		else if (.@i <= 2771) callsub L_Bag,12115,5,"Elemental Converter[Water]"; //Elemental_Water
		else if (.@i <= 2971) callsub L_Bag,12117,5,"Elemental Converter[Wind]"; //Elemental_Wind
		else if (.@i <= 3171) callsub L_Bag,12116,5,"Elemental Converter[Earth]"; //Elemental_Earth
		else if (.@i <= 3271) callsub L_Bag,12680,1; //Sg_Blue_Potion_Box
		else if (.@i <= 3471) callsub L_Bag,12118,5; //Resist_Fire
		else if (.@i <= 3671) callsub L_Bag,12119,5; //Resist_Water
		else if (.@i <= 3871) callsub L_Bag,12121,5; //Resist_Wind
		else if (.@i <= 4071) callsub L_Bag,12120,5; //Resist_Earth
		else if (.@i <= 4271) callsub L_Bag,929,20; //Immortal_Heart
		else if (.@i <= 4471) callsub L_Bag,1059,20; //Transparent_Cloth
		else if (.@i <= 4671) callsub L_Bag,905,20; //Stem
		else if (.@i <= 4871) callsub L_Bag,606,10; //Aloebera
		else if (.@i <= 5071) callsub L_Bag,609,10; //Amulet
		else if (.@i <= 5271) callsub L_Bag,710,2; //Illusion_Flower
		else if (.@i <= 5471) callsub L_Bag,576,20; //Prickly_Fruit
		else if (.@i <= 5671) callsub L_Bag,621,10; //Bitter_Herb
		else if (.@i <= 5871) callsub L_Bag,709,10; //Izidor
		else if (.@i <= 6071) callsub L_Bag,605,10; //Anodyne
		else if (.@i <= 6171) callsub L_Bag,11548,10; //Woe_White_Potion
		else if (.@i <= 6371) callsub L_Bag,706,10; //Four_Leaf_Clover
		else if (.@i <= 6571) callsub L_Bag,521,10; //Leaflet_Of_Aloe
		else if (.@i <= 6771) callsub L_Bag,707,10; //Singing_Plant
		else if (.@i <= 6971) callsub L_Bag,610,10; //Leaf_Of_Yggdrasil
		else if (.@i <= 7021) callsub L_Bag,12676,1; //Sg_Violet_Potion_Box
		else if (.@i <= 7171) callsub L_Bag,6249,10; //Savage_Meat
		else if (.@i <= 7321) callsub L_Bag,6252,10; //Wolf_Blood
		else if (.@i <= 7471) callsub L_Bag,6254,10; //Beef_Head_Meat
		else if (.@i <= 7621) callsub L_Bag,6253,10; //Cold_Ice
		else if (.@i <= 7771) callsub L_Bag,6256,10; //Ice_Fragment
		else if (.@i <= 7921) callsub L_Bag,6257,10; //Ice_Crystal
		else if (.@i <= 8071) callsub L_Bag,6260,10; //Petti_Tail
		else if (.@i <= 8309) callsub L_Bag,7932,20; //Poison_Herb_Nerium
		else if (.@i <= 8547) callsub L_Bag,7933,20; //Poison_Herb_Rantana
		else if (.@i <= 8785) callsub L_Bag,7934,20; //Poison_Herb_Makulata
		else if (.@i <= 9023) callsub L_Bag,7935,20; //Poison_Herb_Seratum
		else if (.@i <= 9261) callsub L_Bag,7936,20; //Poison_Herb_Scopolia
		else if (.@i <= 9499) callsub L_Bag,7937,20; //Poison_Herb_Amoena
		else if (.@i <= 9699) callsub L_Bag,6217,20; //Mandragora_Flowerpot
		else callsub L_Bag,12016,10; //Speed_Up_Potion
		end;
	case 4:
		mes "Black Paw Jelly Bag Button chosen. Need to insert 50 ^FF0000Invest Thanks Ticket^000000 and a random item will appear.";
		next;
		if (countitem(6488) < 50) {
			mes "You don't have enough ^FF0000Invest Thanks Ticket^000000 to proceed.";
			close;
		}
		delitem 6488,50; //Thanks_Invest_Ticket
		set .@i, rand(1,10000);
		     if (.@i <= 100) callsub L_Bag,12531,1; //White_Potion_Box
		else if (.@i <= 200) callsub L_Bag,12549,1; //White_Slim_Pot_Box2
		else if (.@i <= 250) callsub L_Bag,11549,20; //Woe_Blue_Potion
		else if (.@i <= 450) callsub L_Bag,617,1; //Old_Violet_Box
		else if (.@i <= 500) callsub L_Bag,12532,1; //Royal_Jelly_Box2
		else if (.@i <= 550) callsub L_Bag,12533,1; //Blue_Herb_Box2
		else if (.@i <= 600) callsub L_Bag,505,10; //Blue_Potion
		else if (.@i <= 800) callsub L_Bag,644,1; //Gift_Box
		else if (.@i <= 810) callsub L_Bag,607,2; //Yggdrasilberry
		else if (.@i <= 820) callsub L_Bag,608,3; //Seed_Of_Yggdrasil
		else if (.@i <= 830) callsub L_Bag,12292,10; //Unripe_Fruit
		else if (.@i <= 840) callsub L_Bag,12293,10; //Dried_Yggdrasilberry
		else if (.@i <= 940) callsub L_Bag,12679,1; //Sg_White_Potion_Box
		else if (.@i <= 1140) callsub L_Bag,603,1; //Old_Blue_Box
		else if (.@i <= 1240) callsub L_Bag,12550,1,"Poison Bottle Box(30)"; //Poison_Bottle_Box2
		else if (.@i <= 1340) callsub L_Bag,12020,20; //Water_Of_Darkness
		else if (.@i <= 1440) callsub L_Bag,12030,10; //Box_Of_Grudge
		else if (.@i <= 1540) callsub L_Bag,12031,10; //Sleepy_Box
		else if (.@i <= 1690) callsub L_Bag,12033,4; //Box_Of_Sunlight
		else if (.@i <= 1790) callsub L_Bag,12114,10,"Elemental Converter[Fire]"; //Elemental_Fire
		else if (.@i <= 1890) callsub L_Bag,12115,10,"Elemental Converter[Water]"; //Elemental_Water
		else if (.@i <= 1990) callsub L_Bag,12117,10,"Elemental Converter[Wind]"; //Elemental_Wind
		else if (.@i <= 2090) callsub L_Bag,12116,10,"Elemental Converter[Earth]"; //Elemental_Earth
		else if (.@i <= 2190) callsub L_Bag,12680,1; //Sg_Blue_Potion_Box
		else if (.@i <= 2290) callsub L_Bag,12118,10; //Resist_Fire
		else if (.@i <= 2390) callsub L_Bag,12119,10; //Resist_Water
		else if (.@i <= 2490) callsub L_Bag,12121,10; //Resist_Wind
		else if (.@i <= 2590) callsub L_Bag,12120,10; //Resist_Earth
		else if (.@i <= 2690) callsub L_Bag,929,40; //Immortal_Heart
		else if (.@i <= 2790) callsub L_Bag,1059,40; //Transparent_Cloth
		else if (.@i <= 2890) callsub L_Bag,905,40; //Stem
		else if (.@i <= 2990) callsub L_Bag,606,20; //Aloebera
		else if (.@i <= 3090) callsub L_Bag,609,20; //Amulet
		else if (.@i <= 3190) callsub L_Bag,710,4; //Illusion_Flower
		else if (.@i <= 3290) callsub L_Bag,576,40; //Prickly_Fruit
		else if (.@i <= 3390) callsub L_Bag,621,20; //Bitter_Herb
		else if (.@i <= 3490) callsub L_Bag,709,20; //Izidor
		else if (.@i <= 3590) callsub L_Bag,605,20; //Anodyne
		else if (.@i <= 3690) callsub L_Bag,11548,20; //Woe_White_Potion
		else if (.@i <= 3790) callsub L_Bag,706,20; //Four_Leaf_Clover
		else if (.@i <= 3890) callsub L_Bag,521,20; //Leaflet_Of_Aloe
		else if (.@i <= 3990) callsub L_Bag,707,20; //Singing_Plant
		else if (.@i <= 4090) callsub L_Bag,610,20; //Leaf_Of_Yggdrasil
		else if (.@i <= 4140) callsub L_Bag,12676,1; //Sg_Violet_Potion_Box
		else if (.@i <= 4240) callsub L_Bag,6249,20; //Savage_Meat
		else if (.@i <= 4340) callsub L_Bag,6252,20; //Wolf_Blood
		else if (.@i <= 4440) callsub L_Bag,6254,20; //Beef_Head_Meat
		else if (.@i <= 4540) callsub L_Bag,6253,20; //Cold_Ice
		else if (.@i <= 4640) callsub L_Bag,6256,20; //Ice_Fragment
		else if (.@i <= 4740) callsub L_Bag,6257,20; //Ice_Crystal
		else if (.@i <= 4840) callsub L_Bag,6260,20; //Petti_Tail
		else if (.@i <= 4940) callsub L_Bag,7932,40; //Poison_Herb_Nerium
		else if (.@i <= 5040) callsub L_Bag,7933,40; //Poison_Herb_Rantana
		else if (.@i <= 5140) callsub L_Bag,7934,40; //Poison_Herb_Makulata
		else if (.@i <= 5240) callsub L_Bag,7935,40; //Poison_Herb_Seratum
		else if (.@i <= 5340) callsub L_Bag,7936,40; //Poison_Herb_Scopolia
		else if (.@i <= 5440) callsub L_Bag,7937,40; //Poison_Herb_Amoena
		else if (.@i <= 5540) callsub L_Bag,6217,40; //Mandragora_Flowerpot
		else if (.@i <= 6000) callsub L_Bag,12016,20; //Speed_Up_Potion
		else if (.@i <= 6500) callsub L_Bag,2483,1; //Siege_Greave
		else if (.@i <= 7000) callsub L_Bag,2484,1; //Siege_Boots
		else if (.@i <= 7500) callsub L_Bag,2485,1; //Siege_Shoes
		else if (.@i <= 8000) callsub L_Bag,2586,1; //Siege_Manteau
		else if (.@i <= 8500) callsub L_Bag,2587,1; //Siege_Muffler
		else if (.@i <= 9000) callsub L_Bag,15046,1; //Siege_Plate
		else if (.@i <= 9500) callsub L_Bag,15047,1; //Siege_Suits
		else callsub L_Bag,15048,1; //Siege_Robe
		end;
	}
	end;

//callsub L_Purchase,<ticket cost>,<reward ID>,<reward amount>{,<reward name>};
L_Purchase:
	if (countitem(6488) < getarg(0)) {
		mes "You don't have enough ^FF0000Invest Thanks Ticket^000000 to proceed.";
		close;
	}
	delitem 6488,getarg(0); //Thanks_Invest_Ticket
	getitem getarg(1),getarg(2);
	mes "- Done! -";
	next;
	mes "The item ^0000FF"+((getargcount() > 3)?getarg(3,""):getitemname(getarg(1)))+"^000000 has been obtained.";
	close;

//callsub L_Bag,<reward ID>,<reward amount>{,<reward name>};
L_Bag:
	getitem getarg(0),getarg(1);
	mes "- Done! -";
	next;
	mes "The item ^0000FF"+((getargcount() > 2)?getarg(2,""):getitemname(getarg(0)))+"^000000 has been obtained.";
	close;
}