//===== Athena Script =======================================
//= Simple Adoption Script
//===== By ================================================
//= Fredzilla with help from Kamari,Acky
//===== Version ===========================================
//= 1.6 Removed call to function Is_Taekwon_Class in favor of baseClass == Job_Taekwon [Silentdragon]
//= 1.5 Added GM menu to reset current adoption [Lupus]
//= 1.4 Got rid of useless "event_adoptXXX" variables [Lupus]
//= 1.3c - Slightly rewrote the anti-taekwon protection to
//=        detect problems more easily [DracoRPG]
//= 1.3a - Added anti Taekwon Classes protection (they can't
//= be adopted) [Lupus]
//= 1.3 - Now it can teach parents/baby their missing skills.
//=	 Your old families should talk to these NPCs to get
//=  their family skills [Lupus]
//= 1.2b - More fixes + Added Acky's teacher to the end 
//=	  (stoped it from saying a particular word I thought
//=	  was inapropriate for a kids game)
//= 1.1 - Minor correction, replaced missing close; and mes :D
//= 1.0 - First Release, most likely going to have some bugs
//=	  Is using @adopt instead of proper NPC script command 
//===== Compatible With ===================================
//= eAthena Final (SVN), any version that contained the GM command @adopt
//= This is any version released after 03/29/05, dont know the number
//===== Description =======================================
//= A simple adoption script that lets couples adopt a 
//= lvl 1/1 novice without the help of a GM there
//===== Comments ==========================================
//= List or Variables used
//= $@AdoptionActive = Stops other people trying to use 
//= the adoption NPC's intill the currant one is over.
//= @AdoptionReady = Marks person that talks to first NPC, 
//= this person will end up being ParentOne.
//= $@ParentOne$ = Explains itself.
//= $@ParentTwo$ =    ""      ""  
//= $@Baby$	=    ""      ""
//= $@GenderBaby$ = Set so it can state boy or girl.
//= $@FinalQuestion = Lets the parents take one last chance 
//= to cancel the adoption before it is perminant.
//= $@CheckAll = Follow on from the last one, when this = 3, 
//= the adoption will take place and will be perminant.
//= @regged = Stops the same person being counted twice 
//= before the adoption is completed.
//= Lupus removed:
//= 	*event_adopt = Put on the parents so they cannot adopt again.
//= 	*event_adopted = Put on baby so it cant be adopted again.
//= 	Use "getchildid()>0" insread of event_adopt
//= 	Use "Upper==2" insread of event_adopted
//=========================================================

prt_church.gat,115,122,0	warp	prtch03	1,2,prt_church.gat,164,171
prt_church.gat,162,171,0	warp	prtch01-3	1,2,prt_church.gat,113,122

prt_church.gat,166,176,3	script	Adoption Man	61,{

//GM Menu: Start
//If u're a GM you can always reset current Adoption process
	if(getgmlevel(99)<90) goto L_SKIP;
	mes "[GM Menu]";
	mes "Would you like to reset curent adoption?";
	next;
	menu "Yes",-,"No",L_SKIP;	
	callfunc "AdoptReset","GM reset";
	close;
L_SKIP:
//GM Menu: End

	if($@AdoptionActive == 1) goto A_Cannot;
	mes "[Oliver]";
	if (Upper==2) goto A_YouBaby;
	if (getchildid()>0 && getskilllv(410)<=0) goto A_GetSkill;
	if (getchildid()>0) goto A_Already;
	mes "Would you like to adopt someone?";
	next;
	menu "Yes",A_Yes,"No",-;
A_No:
	mes "[Oliver]";
	mes "I am sorry to hear that, please come back when you believe you are ready.";
	close;
A_Cannot:
	mes "[Oliver]";
	mes "There is currentally an adoption inprogress, come back when it has finished.";
	close;
A_Yes:
	mes "[Oliver]";
	mes "Good to hear it!";
	mes "But do you meet the requirments for adoption?";
	next;
	mes "[Oliver]";
	mes "We cant just give out babies at the drop of a hat.";
	mes "Before we can let you leave with a baby we have to know you are strong enough to take care of it.";
	next;
	mes "[Oliver]";
	mes "We also need to know you have a partner you are married to.";
	mes "We wont give a baby to an un-married couple.";
	next;
	mes "[Oliver]";
	mes "Do you think you meet these criteria?";
	next;
	menu "Yes, I would love to adopt?",-,"No, I dont think I can",A_No;
	mes "[Oliver]";
	mes "Well you seem set on this.";
	next;
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	if ($@AdoptionActive == 1) goto A_Cannot;
	set $@AdoptionActive,1;
	set @AdoptionReady,1;
	mes "[Oliver]";
	mes "I will refer you to my coleage over there.";
	close;

A_GetSkill:
	mes "You have just adopted a baby. I'll teach you a useful skill CALL BABY !";
	next;
	emotion 46;
	skill 410,1,0;
	mes "[Oliver]";
	mes "Done! Tell your partner to call me, too.";
	mes "Our children are our future!";
	close;
A_Already:
	emotion 1;
	mes "How is your baby today?";
	close;
A_YouBaby:
	emotion 2;
	mes "Say HI to your parents! Be cool!";
	if (getskilllv(408)<=0 || getskilllv(409)<=0) mes "By the way, our Teacher's wanting to see you.";
	close;
}

prt_church.gat,172,177,3	script	Adoption Lady	103,{
	if (Upper==2) goto A_YouBaby;
	if (getchildid()>0 && getskilllv(410)<=0) goto A_GetSkill;
	if (getchildid()>0) goto A_Already;
	if ($@FinalQuestion==1 && $@ParentOne$==strcharinfo(0)) goto A_ParentOneEnd;
	if ($@FinalQuestion==1 && $@ParentTwo$==strcharinfo(0)) goto A_ParentTwoEnd;
	if ($@FinalQuestion==1 && $@Baby$==strcharinfo(0)) goto A_BabyEnd;
	if (strcharinfo(0)==$@Baby$) goto A_FinalTest;
	if (strcharinfo(0)==$@ParentTwo$) goto A_SecondReg;
	if (@AdoptionReady==0 || $@AdoptionActive==0) goto A_SeeFriend;
	mes "[Inanna]";
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	mes "So you think you meet our strict requirments?";
	mes "Let's see here, are you over level 70?";
	next;
	menu "Yes, I am over level 70",A_lvl,"No, sorry to bother you",-;
	mes "[Inanna]";
	mes "Oh, I am sorry to hear that, please return when you meet this requirment.";
	callfunc "AdoptReset","the parent didnt meet level requirments";
	close;
A_SeeFriend:
	mes "[Inanna]";
	mes "Seems you havent talked to my friend here.";
	mes "He will refer you to me, when he thinks you are ready.";
	close;
A_lvl:
	if(BaseLevel >= 70) goto A_lvlpassed;
	mes "[Inanna]";
	mes "Not only should I fail you on being a low level, but you also lied to me.";
	next;
 	mes "[Inanna]";
	mes "I cant give a baby to you";
	callfunc "AdoptReset","the parent didnt meet level requirments";
	close;
A_lvlpassed:
	mes "[Inanna]";
	mes "WOW, you have passed the test of strength.";
	next;
	mes "[Inanna]";
	mes "But lets see if you are happily married.";
	mes "For this I will need to see your wedding ring.";
	next;
	mes "[Inanna]";
	mes "Do you have you wedding ring on you now?";
	next;
	menu "Yes, here you go",A_Wedring,"No, Sorry I dont",A_Noring,"I am not married",-;
	mes "[Inanna]";
	mes "Well, as my fried said here, we will not give a baby to a family that is not married";
	callfunc "AdoptReset","the parent isnt married";
	close;
A_Noring:
	mes "[Inanna]";
	mes "I cant believe you are in a loving marrige when you dont have your ring on you at all times!!!";
	next;
	mes "[Inanna]";
	mes "I dont believe you deserve a baby.";
	callfunc "AdoptReset","the parent hasnt got a wedding ring as proof of marriage.";
	close;
A_Wedring:
	if ( countitem(2634)>0 || countitem(2635)>0 ) goto A_Wedringpassed;
	goto A_Noring;
A_Wedringpassed:
	mes "[Inanna]";
	mes "Awwwww, such a lovely ring, you must love your partner.";
	next;
	if (getchildid()>0) goto A_AlreadyHaveBaby;
	mes "[Inanna]";
	mes "I need to see them, please tell me their name.";
	next;
	input $@ParentTwo$;
	set $@ParentOne$, strcharinfo(0);
	mes "[Inanna]";
	mes "Your partner now has 5 min to talk to me before the adoption is canceled.";
	next;
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	areaannounce "prt_church.gat",0,0,350,350,"Can I please see "+$@ParentTwo$+" please",0; 
	mes "[Inanna]";
	mes "Can you now please wait for me to call you again, thank you.";
	close;
A_AlreadyHaveBaby:
	mes "Now lets look at the inscription on your ring, oh it seems you already have a baby.";
	next;
	mes "[Inanna]";
	mes "I am sorry, you can only ever adopt once.";
	mes "Please take care of you baby.";
	callfunc "AdoptReset","the parent has already adopted once before";
	close;
A_SecondReg:
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	mes "[Inanna]";
	mes "You must be "+$@ParentTwo$+", I just talked to your partner "+$@ParentOne$+", they mentioned you want to adopt baby.";
	next;
	mes "[Inanna]";
	mes "Do you agree with "+$@ParentOne$+", do you want to adopt?";
	next;
	menu "Yes, I agree with them",A_agree,"No, I dont want to adopt",-;
	mes "[Inanna]";
	mes "This is bad news, I am very sorry to hear this.";
	callfunc "AdoptReset","the 2nd parent does not want to adopt"; 
	close;
A_agree:
	mes "[Inanna]";
	mes "Now I will put you through the same test as your partner.";
	next;
	if(BaseLevel >= 70) goto A_lvltwo;
	mes "[Inanna]";
	mes "Sorry you are not over level 70.";
	callfunc "AdoptReset","the 2nd parent didnt meet the level requirments";
	close;
A_lvltwo:
	if ( countitem(2634)>0 || countitem(2635)>0 ) goto A_Wedringtwo;
	mes "[Inanna]";
	mes "Sorry you dont have a wedding ring on you as proof of marriage.";
	callfunc "AdoptReset","the 2nd parent hasnt got a wedding ring as proof of marriage";
	close;
A_Wedringtwo:
	if (getchildid()>0) goto A_AlreadyHaveBaby;
	mes "[Inanna]";
	mes "You have checked out, and have passed all the requirments.";
	mes "All you need is a novice to adopt.";
	next;
	mes "[Inanna]";
	mes "Do you have a novice to adopt?";
	next;
	menu "Yes, right here",A_YesBaby,"No, I'm sorry",-;
	mes "[Inanna]";
	mes "I suggest you find one, remember to get your parent to talk to my friend first when you return.";
	callfunc "AdoptReset","there is no novice present to be adopted";
	close;
A_YesBaby:
	mes "[Inanna]";
	mes "Can I please know thier name?";
	next;
	input $@Baby$;
	mes "[Inanna]";
	mes "The novice now has 5min to come and talk to me, or the adopt will be canceled.";
	next;
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	mes "[Inanna]";
	mes "Thank you, can you please wait with your partner, and wait to be called back.";
	areaannounce "prt_church.gat",0,0,350,350,"Can I please see "+$@Baby$+", please",0;
	close;
A_FinalTest:
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	if(Upper==2) goto A_AlreadyAdopted;
	if(baseClass == Job_Taekwon) goto A_CantBeAdopted;
	mes "[Inanna]";
	mes "You must be "+$@Baby$+", its very nice to meet you.";
	mes "Some very nice people, "+$@ParentOne$+" and "+$@ParentTwo$+", have asked to adopt you.";
	next;
	if(sex!=0) set $@GenderBaby$,"boy";
	if(sex==0) set $@GenderBaby$,"girl";

	mes "[Inanna]";
	mes "Now can you be a good "+$@GenderBaby$+" and go with these nice people?";
	next;
	menu "Yes, me would luv too",A_BabyYes,"NOOOOO!!!",-;
	mes "[Inanna]";
	mes "Please calm down.";
	mes "I will try and find better parents for you next time.";
	callfunc "AdoptReset","the novice didnt want to be adopted";
	close;
A_BabyYes:
	mes "[Inanna]";
	mes "Awwww, so cute, good to hear it.";
	mes "Now lets see here.";
	next;
	mes "[Inanna]";
	mes "I need to do a check on your level to prove you are a novice, stand still.";
	next;
	if (BaseLevel == 1 && JobLevel == 1) goto A_Ready;
	mes "[Inanna]";
	mes "Sorry but you are higher than level one, and cause of this you are a true novice.";
	callfunc "AdoptReset","the person that would be adopted, is over level 1";
	close;
A_Ready:
	mes "[Inanna]";
	mes "You are just as sweet an inocent as the day our lord made you.";
	next;
	mes "[Inanna]";
	mes "I have no objections to you being adopted.";
	mes "Before you can be adopted I will need to see your parents, and you, one last time.";
	set $@FinalQuestion,1;
	areaannounce "prt_church.gat",0,0,350,350,"Can I please see all people involved with this adoption please",0;
	deltimer "timeadopt";
	addtimer 300000,"timeadopt";
	close;
A_AlreadyAdopted:
	mes "[Inanna]";
	mes "Oh you are already adopted, so you cant be adopted again.";
	callfunc "AdoptReset","the person that would be adopted has already been adopted before";
	close;
A_CantBeAdopted:
	mes "[Inanna]";
	mes "Sorry, but your job does not allow adoption.";
	callfunc "AdoptReset","the person that would be adopted has a job that can't be adopted";
	close;
A_ParentOneEnd:
	if (@regged>1) goto AlreadyReged;
	if ($@ParentOne$==$@ParentTwo$) goto A_SameFail;
	mes "[Inanna]";
	mes "Nice to talk to you again "+$@ParentOne$;
	mes "This is you last chance to back out";
	next;
	mes "[Inanna]";
	mes "You can only ever adopt once, so if you adopt "+$@Baby$+", you can never adopt any one else ever"; 
	next;
	mes "[Inanna]";
	mes "Are you sure you want to proceed";
	next;
	menu "Yes",A_FinalYesP,"No",-;
	mes "[Inanna]";
	mes "I cannot believe you would come this far to say no!";
	mes "Are you sure you want to stop now?";
	next;
	menu "Yes, I dont want to adopt",-,"No, I made a mistake",A_ParentOneEnd;
A_Failend:
	mes "[Inanna]";
	mes "Well if you are sure";
	callfunc "AdoptReset","a parent or the novice pulled out";
	close;
A_FinalYesP:
	mes "[Inanna]";
	mes "OK everything is ready to start this adoption";
	mes "I will announce to everyone when it is complete";
	set @regged,1;
	set $@checkall,$@checkall+1;
	if ($@checkall==3) goto THEEND;
	close;
A_ParentTwoEnd:
	if (@regged>1) goto AlreadyReged;
	mes "[Inanna]";
	mes "Nice to talk to you again "+$@ParentTwo$;
	mes "This is you last chance to back out";
	next;
	mes "[Inanna]";
	mes "You can only ever adopt once, so if you adopt "+$@Baby$+", you can never adopt any one else ever"; 
	next;
	mes "[Inanna]";
	mes "Are you sure you want to proceed";
	next;
	menu "Yes",A_FinalYesP,"No",-;
	mes "[Inanna]";
	mes "I cannot believe you would come this far to say no!";
	mes "Are you sure you want to stop now?";
	next;
	menu "Yes, I dont want to adopt",A_Failend,"No, I made a mistake",A_ParentTwoEnd;
A_AlreadyReged:
	mes "[Inanna]";
	mes "Please wait for the others to talk to me";
	close;
A_BabyEnd:
	if (@regged>1) goto AlreadyReged;
	mes "[Inanna]";
	mes "Nice to talk to you again "+$@Baby$;
	mes "This is you last chance to back out";
	next;
	mes "[Inanna]";
	mes "You can only ever be adopted once, so if you are adopted by "+$@ParentOne$+" and "+$@ParentTwo$+", you can never be adopted again"; 
	next;
	mes "[Inanna]";
	mes "Are you sure you want to proceed";
	next;
	menu "Yes",A_FinalYesB,"No",-;
	mes "[Inanna]";
	mes "I cannot believe you would come this far to say no!";
	mes "Are you sure you want to stop now?";
	next;
	menu "Yes, I dont want to adopt",A_Failend,"No, I made a mistake",A_BabyEnd;
A_FinalYesB:
	mes "[Inanna]";
	mes "OK everything is ready to start this adoption";
	mes "I will announce to everyone when it is complete";
	set @regged,1;
	set $@checkall,$@checkall+1;
	if ($@checkall==3) goto THEEND;
	close;
A_SameFail:
	mes "[Inanna]";
	mes "Sorry, it seems you have registerd as both parents, this isnt allowed";
	callfunc "AdoptReset","both parents are the same person";
	close;

A_GetSkill:
	emotion 20;
	mes "[Inanna]";
	mes "You can't see your baby often?.. I'll try to teach you one skil... Where's my skills manual?";
	next;
	mes "[Oliver]";
	mes "Hey, Inanna! This is my job. Pass them to me!";
	close;
A_Already:
	mes "[Inanna]";
	emotion 21;
	mes "How is your baby now?";
	close;
A_YouBaby:
	mes "[Inanna]";
	emotion 30;
	mes "Tell your father he's a good father!";
	if (getskilllv(408)<=0 || getskilllv(409)<=0) mes "You should talk to our Teacher.";
	close;

THEEND:
	logmes "Adoption: "+$@Baby$+" adopted by "+$@ParentOne$+" and "+$@ParentTwo$+".";
	adopt $@ParentOne$,$@ParentTwo$,$@Baby$;
	announce $@ParentOne$+" and "+$@ParentTwo$+" has just adopted a new baby "+$@GenderBaby$+", called "+$@Baby$,5;
	deltimer "timeadopt";
	set $@AdoptionActive, 0;
	set $@ParentOne$, null;
	set $@ParentTwo$, null;
	set $@Baby$, null;
	set $@GenderBaby$, null;
	set $@FinalQuestion, 0;
	set $@CheckAll, 0;
	close;
	end;
}

prt_church.gat,165,175,0	script	timeadopt	-1,{
	callfunc "AdoptReset","too much time has passed between steps";
	end;
}
function	script	AdoptReset	{
	deltimer "timeadopt";
	set $@AdoptionActive, 0;
	set $@ParentOne$, null;
	set $@ParentTwo$, null;
	set $@Baby$, null;
	set $@GenderBaby$, null;
	set $@FinalQuestion, 0;
	set $@CheckAll, 0;
	areaannounce "prt_church.gat",0,0,350,350,"The adoption has been canceled because "+getarg(0),0;
	return;
}

prt_church.gat,165,166,6	script	Teacher	97,{
	mes "[Mario]";
	if (Upper==2 && (getskilllv(408)<=0 || getskilllv(409)<=0)) goto L_Teach;
	if (Upper==2) mes "Hello, baby! How are you?";
	if (Upper!=2) mes "How are you?";
	next;
	menu "Great!",-,"Fine.",-,"So-so...",-,"Shoot me, please.",-;
	mes "[Mario]";
	mes "So nice!";
	emotion rand(19,21);
	close;

L_Teach:
	skill 408,1,0;
	skill 409,1,0;
	mes "Ta-da! Now you know 2 quite useful skills!";
	mes "1. Call your Parents (when you're in a danger).";
	mes "2. Protect your parents' EXP with yor love!";
	emotion 41;
	next;
	mes "[Mario]";
	mes "On seeing a baby tell them to visit me.";
	next;

L_Cancel:
	mes "[Mario]";
	mes "Bye bye!";
	close;
}
