summaryrefslogtreecommitdiff
path: root/npc/merchants/grandpa_pharmacist.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/merchants/grandpa_pharmacist.txt')
-rw-r--r--npc/merchants/grandpa_pharmacist.txt241
1 files changed, 109 insertions, 132 deletions
diff --git a/npc/merchants/grandpa_pharmacist.txt b/npc/merchants/grandpa_pharmacist.txt
index bbeaf97d0..055e9e53c 100644
--- a/npc/merchants/grandpa_pharmacist.txt
+++ b/npc/merchants/grandpa_pharmacist.txt
@@ -1,173 +1,86 @@
-//===== eAthena Script =======================================
+//===== eAthena Script =======================================
//= Grandpa Pharmacist
-//===== By: ==================================================
+//===== By: ==================================================
//= kobra_k88
-//===== Current Version: =====================================
-//= 1.1
-//===== Compatible With: =====================================
+//===== Current Version: =====================================
+//= 1.2
+//===== Compatible With: =====================================
//= eAthena 7.15 +
-//===== Description: =========================================
-//= trade in items for potions
-//===== Additional Comments: =================================
+//===== Description: =========================================
+//= Trade in items for potions
+//===============================
+//= Breakdown of arguments used
+//= arg(0): first item id#
+//= arg(1): 2nd item id# if needed, or else use 0
+//= arg(2): zeny cost
+//= arg(3): potion id#
+//= arg(4): potion name
+//===== Additional Comments: =================================
//= Fully working
//= 1.1 Negative input bug fixed [Lupus]
-//============================================================
-
-
+//= 1.2 Created a subfunc for the potion making part. Added more
+//= input/zeny exploit checks. Added Lupus's "loopless" technique.[kobra_k88]
+//============================================================
alberta_in.gat,16,28,4 script Grampa Pharmacist 61,
{
- set @count, 0;
-
mes "[Grampa Pharmacist]";
mes "Hmmm... what do you want...?";
next;
menu "Make Potion",M_Make, "Talk",M_Talk, "Information",M_Info, "Cancel",M_End;
M_Make:
- if(countitem(713) < 1) goto ssL_NdBottle;
mes "[Grampa Pharmacist]";
mes "Did you prepare all the items needed? If so what potion do you want?";
M_Menu:
next;
- menu "Red Potion",M_0, "Orange Potion",M_1, "Yellow Potion",M_2, "White Potion",M_3, "Blue Potion",M_4, "Green Potion",M_5,
- "Nah, I change my mind.",M_End;
+ menu "Red Potion",M_0, "Orange Potion",M_1, "Yellow Potion",M_2,
+ "White Potion",M_3, "Blue Potion",M_4, "Green Potion",M_5,
+ "Nah, I change my mind.",M_End;
M_0:
- set @pot$, "red";
- set @pot, 501;
- set @item1, 507;
- set @zeny, 3;
- goto sL_Make;
+ callsub sF_Make, 507, 0, 2, 501, "red";
+ goto M_Menu;
M_1:
- if(countitem(507)<1 || countitem(508)<1) goto ssL_NdHerbs;
- if(Zeny < 5) goto ssL_NdZeny;
- set @pot$, "orange";
- set @pot, 502;
- mes "[Grampa Pharmacist]";
- mes "How many?";
- next;
- menu "As many as possible.",sM_1a, "I will set the amount.",sM_1b, "Nah, forget about it",M_Menu;
-
- sM_1a:
- if(countitem(507)<1 || countitem(508)<1 || countitem(713)<1 || Zeny< 5) goto ssL_End;
- set @count, @count +1;
- delitem 507, 1;
- delitem 508, 1;
- delitem 713, 1;
- set Zeny, Zeny - 5;
- goto sM_1a;
-
- sM_1b:
- input @count;
- if(@count<1) goto ssL_NdNegative;
- if(countitem(507)<@count || countitem(508)<@count) goto ssL_NdHerbs;
- if(countitem(713) < @count) goto ssL_NdBottle;
- if(Zeny<(5*@count)) goto ssL_NdZeny;
- delitem 507, @count;
- delitem 508, @count;
- delitem 713, @count;
- set Zeny, Zeny - (@zeny*@count);
- goto ssL_End;
-
+ callsub sF_Make, 507, 508, 5, 502, "orange";
+ goto M_Menu;
M_2:
- set @pot$, "yellow";
- set @pot, 503;
- set @item1, 508;
- set @zeny, 10;
- goto sL_Make;
+ callsub sF_Make, 508, 0, 10, 503, "yellow";
+ goto M_Menu;
M_3:
- set @pot$, "white";
- set @pot, 504;
- set @item1, 509;
- set @zeny, 20;
- goto sL_Make;
+ callsub sF_Make, 509, 0, 20, 504, "white";
+ goto M_Menu;
M_4:
- set @pot$, "blue";
- set @pot, 505;
- set @item1, 510;
- set @zeny, 30;
- goto sL_Make;
+ callsub sF_Make, 510, 0, 30, 505, "blue";
+ goto M_Menu;
M_5:
- set @pot$, "green";
- set @pot, 506;
- set @item1, 511;
- set @zeny, 3;
-
- sL_Make:
- if(countitem(@item1) < 2) goto ssL_NdHerbs;
- if(Zeny < @zeny) goto ssL_NdZeny;
-
- mes "[Grampa Pharmacist]";
- mes "How many?";
- next;
- menu "As many as possible.",sM_0a, "I will set the amount.",sM_0b, "Nah, forget about it",M_Menu;
-
- sM_0a:
- if((countitem(@item1) < 2) || (countitem(713) < 1) || (Zeny < @zeny)) goto ssL_End;
- set @count, @count +1;
- delitem @item1, 2;
- delitem 713, 1;
- set Zeny, Zeny - @zeny;
- goto sM_0a;
-
- sM_0b:
- input @count;
- if(@count<1) goto ssL_NdNegative;
- if(countitem(@item1) < (2*@count)) goto ssL_NdHerbs;
- if(countitem(713) < @count) goto ssL_NdBottle;
- if(Zeny < (@zeny*@count)) goto ssL_NdZeny;
- delitem @item1, (2*@count);
- delitem 713, @count;
- set Zeny, Zeny - (@zeny*@count);
-
- ssL_End:
- mes "[Grampa Pharmacist]";
- mes "Here are your "+@pot$+" potions.";
- getitem @pot, @count;
- close;
-
- ssL_NdBottle:
- mes "[Grampa Pharmacist]";
- mes "You don't have enough empty tubes to put the medicine in you idiot!!";
- close;
-
- ssL_NdHerbs:
- mes "[Grampa Pharmacist]";
- mes "You rascal! What did you expect from me? You didn't even bring all of the right herbs!";
- mes "Get lost!";
- close;
-
- ssL_NdNegative:
- mes "[Grampa Pharmacist]";
- mes "You dirty cheater! What did you expect from me? Next time set positive amount of the potions!";
- mes "Get off!";
- close;
-
- ssL_NdZeny:
- mes "[Gramp Pharmacist]";
- mes "You don't have enough zeny for potions.";
- close;
+ callsub sF_Make, 511, 0, 3, 506, "green";
+ goto M_Menu;
M_Talk:
mes "[Grampa Pharmacist]";
- mes "The right type of medicinal Herbs can replenish a person's HP or SP.";
- mes "~Sigh~ I'm starting to reminisce about my youth.... a sign that I must be getting old.....";
+ mes "The right type of medicinal Herbs can replenish a person's HP or SP";
+ mes ". ~Sigh~ I'm starting to reminisce about my youth.... a sign that I";
+ mes "must be getting old.....";
next;
mes "[Grampa Pharmacist]";
- mes "Anyways, a potion is merely an, 'easy to use', form of medicinal Herbs..... nothing more and nothing less.";
+ mes "... A potion is merely an, 'easy to use', form of medicinal Herbs";
+ mes "..... nothing more and nothing less.";
close;
M_Info:
mes "[Grampa Pharmacist]";
- mes "~Sigh~... you young ones can be quite bothersome... Fine, I will explain to you how potions work....";
+ mes "~Sigh~... you young ones can be quite bothersome.. Fine, I will";
+ mes "explain to you how potions work....";
next;
mes "[Grampa Pharmacist]";
- mes "Though the bennefits from consuming the various Herbs found around Rune-Midgard are great......";
- mes "By refining them into potions, the effects of the Herbs are dramatically enhanced.";
+ mes "Though the bennefits from consuming the various Herbs found around";
+ mes "Rune-Midgard are great... by refining them into potions, the";
+ mes "effects of the Herbs are dramatically enhanced.";
next;
mes "[Grampa Pharmacist]";
- mes "The process of refining herbs into potions is a special one that I created. For a small fee I can make any potion you desire.";
+ mes "The process of refining herbs into potions is a special one that I";
+ mes "created. For a small fee I can make any potion you desire.";
next;
mes "[Grampa Pharmacist]";
mes "^FF5533Red Potion^000000 - 2 Red Herbs, 1 Empty Bottle, 2 Zeny fee.";
@@ -183,4 +96,68 @@ alberta_in.gat,16,28,4 script Grampa Pharmacist 61,
mes "[Grampa Pharmacist]";
mes "Didn't you have something to say?!";
close;
+
+// Subfunction for making potions
+//================================
+sF_Make:
+ set @herbnum, 2;
+ if(getarg(1) != 0) set @herbnum, 1;
+ if(countitem(getarg(0)) < @herbnum) goto L_NdHerbs;
+ if((countitem(getarg(1)) < @herbnum) && (getarg(1) != 0)) goto L_NdHerbs;
+ if(countitem(713) < 1) goto L_NdBottle;
+ if(Zeny < getarg(2)) goto L_NdZeny;
+
+ mes "[Grampa Pharmacist]";
+ mes "How many?";
+ next;
+ menu "As many as possible.",sM_0a, "I will set the amount.",sM_0b, "Nah, forget about it",M_End;
+
+ sM_0a:
+ set @amount, 1000;
+ if(zeny/getarg(2) < @amount) set @amount, zeny/getarg(2);
+ if(countitem(getarg(0))/@herbnum < @amount) set @amount, countitem(getarg(0))/@herbnum;
+ if((countitem(getarg(1))/@herbnum < @amount) && (countitem(getarg(1)) != 0)) set @amount, countitem(getarg(1))/@herbnum;
+ if(countitem(713) < @amount) set @amount, countitem(713);
+ if(@amount > 0) goto L_End;
+ mes "[Grampa Pharmacist]";
+ mes "Jeez... you don't even have the right items.....";
+ close;
+
+ sM_0b:
+ input @amount;
+ if(@amount<1 || @amount>1000) goto L_BadAmnt;
+ if(countitem(getarg(0))/@herbnum < @amount) goto L_NdHerbs;
+ if((countitem(getarg(1))/@herbnum < @amount) && (countitem(getarg(1)) != 0)) goto L_NdHerbs;
+ if(countitem(713) < @amount) goto L_NdBottle;
+ if(Zeny < (getarg(2)*@amount)) goto L_NdZeny;
+
+ L_End:
+ mes "[Grampa Pharmacist]";
+ mes "Here are your " +getarg(4)+ " potions.";
+ delitem getarg(0), (@amount*@herbnum);
+ if(getarg(1) != 0) delitem getarg(1), (@amount*@herbnum);
+ delitem 713, @amount;
+ set Zeny, Zeny - (getarg(2)*@amount);
+ getitem getarg(3), @amount;
+ close;
+
+ L_NdBottle:
+ mes "[Grampa Pharmacist]";
+ mes "You don't have enough empty bottles to put the medicine in you idiot!!";
+ return;
+
+ L_NdHerbs:
+ mes "[Grampa Pharmacist]";
+ mes "You rascal! What did you expect from me? You didn't even bring all of the right herbs!";
+ return;
+
+ L_NdZeny:
+ mes "[Grampa Pharmacist]";
+ mes "You don't have enough zeny for that many potions.";
+ return;
+
+ L_BadAmnt:
+ mes "[Grampa Pharmacist]";
+ mes "What?! That's not a valid amount!";
+ return;
}