summaryrefslogtreecommitdiff
path: root/npc/events/whiteday.txt
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-10-19 00:47:39 +0200
committerHaru <haru@dotalux.com>2014-10-27 01:06:10 +0100
commitbf9e067bf1e5c6bc15d313e0a197fd8f4b2ec131 (patch)
tree6a24e8f20a33f08dbbf6bba185e6842d650fcd50 /npc/events/whiteday.txt
parent8bb00782225e2f04f61863832a6c27d512b551b5 (diff)
downloadhercules-bf9e067bf1e5c6bc15d313e0a197fd8f4b2ec131.tar.gz
hercules-bf9e067bf1e5c6bc15d313e0a197fd8f4b2ec131.tar.bz2
hercules-bf9e067bf1e5c6bc15d313e0a197fd8f4b2ec131.tar.xz
hercules-bf9e067bf1e5c6bc15d313e0a197fd8f4b2ec131.zip
Removed use of 'menu' from official (non-custom) scripts
- Some scripts were partly refactored/rewritten to use a more modern coding style (and to fix some issues) - Note: the 'menu' command will be deprecated soon in favor of 'select' and 'prompt'. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'npc/events/whiteday.txt')
-rw-r--r--npc/events/whiteday.txt181
1 files changed, 94 insertions, 87 deletions
diff --git a/npc/events/whiteday.txt b/npc/events/whiteday.txt
index ac76c52a5..d90f7c491 100644
--- a/npc/events/whiteday.txt
+++ b/npc/events/whiteday.txt
@@ -12,10 +12,6 @@
//============================================================
alberta,188,64,4 script Sugar 4_F_02,{
- set @maplenum,0;
- set @mapleItemID,0;
- set @maplePrice,0;
- set @maplePriceT,0;
mes "[Sugar]";
mes "Welcome!";
mes "How delicious are sweets?";
@@ -29,51 +25,102 @@ alberta,188,64,4 script Sugar 4_F_02,{
mes "heartfelt like";
mes "the sweetness of the present some how.";
next;
- menu "Please give me!",-,"I don't need it.",M_End,"The teacher.",M_L1;
-
- mes "[Sugar]";
- mes "Yes!";
- mes "Select from menu here.";
- mes "Since there is a limitation in numbers";
- mes "Not more than ^ff0000 5 pieces^000000.";
- mes "are allowed to carry out?";
- next;
- menu "Candy",-,"Candy Cane",L0_2,"Well baked cookie",L0_3;
-
- set @maplePrice,3000;
- set @mapleItemID,529;
- mes "[Sugar]";
- mes "It is a candy, and the price is";
- mes "3000 Zeny each.";
- mes "How many do you like to purchase?";
- next;
- goto L_INPUT;
-L0_2:
- set @maplePrice,4000;
- set @mapleItemID,530;
- mes "[Sugar]";
- mes "It is a candy cane, and the price is";
- mes "4000 Zeny each.";
- mes "How many do you like to purchase?";
- next;
- goto L_INPUT;
-L0_3:
- set @maplePrice,2000;
- set @mapleItemID,538;
+ switch (select("Please give me!","I don't need it.","The teacher.")) {
+ case 1: // Please give me
+ mes "[Sugar]";
+ mes "Yes!";
+ mes "Select from menu here.";
+ mes "Since there is a limitation in numbers";
+ mes "Not more than ^ff0000 5 pieces^000000.";
+ mes "are allowed to carry out?";
+ next;
+ switch (select("Candy","Candy Cane","Well baked cookie")) {
+ case 1: // Candy
+ mes "[Sugar]";
+ mes "It is a candy, and the price is";
+ mes "3000 Zeny each.";
+ mes "How many do you like to purchase?";
+ next;
+ callsub(S_Purchase, 3000, Candy);
+ break;
+ case 2: // Candy Cane
+ mes "[Sugar]";
+ mes "It is a candy cane, and the price is";
+ mes "4000 Zeny each.";
+ mes "How many do you like to purchase?";
+ next;
+ callsub(S_Purchase, 4000, Candy_Striper);
+ break;
+ case 3: // Well baked cookie
+ mes "[Sugar]";
+ mes "It is a well baked cookie, and the price is";
+ mes "2000 Zeny each.";
+ mes "How many do you like to purchase?";
+ next;
+ callsub(S_Purchase, 2000, Well_Baked_Cookie);
+ break;
+ }
+ break;
+ case 3: // The teacher
+ mes "[Sugar]";
+ mes "Yes";
+ mes "The teacher of mine";
+ mes "is Mr. Kuberu, a sweets craftsman.";
+ mes "Making sweets under two persons.";
+ mes "which is allowed to self-train.";
+ next;
+ mes "[Sugar]";
+ mes "Although selling is seemingly to carried out ....";
+ mes "Where he is now?";
+ mes "Which I don't know.";
+ close;
+ case 2: // I don't need it
+ break;
+ }
mes "[Sugar]";
- mes "It is a well baked cookie, and the price is";
- mes "2000 Zeny each.";
- mes "How many do you like to purchase?";
- next;
+ mes "Really .... You might regret it..";
+ mes "If you change your mind.";
+ mes "I am just here ok.";
+ mes "Have a nice day!";
+ close;
-L_INPUT:
- input @maplenum;
- if (@maplenum > 5) goto L_ERROR;
- if (@maplenum == 0) goto M_End;
- set @maplePriceT,@maplePrice*@maplenum;
- if (Zeny < @maplePriceT) goto L_ERROR2;
- Zeny -= @maplePriceT;
- getitem @mapleItemID,@maplenum;
+/**
+ * Attempts to purchase an item, after asking the desired quantity.
+ *
+ * Arguments:
+ * 0 : price
+ * 1 : item ID
+ *
+ * Returns on user cancel. Closes on successful purchase or error.
+ */
+S_Purchase:
+ .@price = getarg(0);
+ .@item_id = getarg(1);
+ while (true) {
+ input .@amount;
+ if (.@amount <= 5)
+ break;
+ mes "[Sugar]";
+ mes "???";
+ mes "You seem to have a failure on hearing.";
+ mes "I will tell you once again?";
+ mes "You can only purchase";
+ mes "^ff0000 5 pieces^000000 at once.";
+ next;
+ }
+ if (.@amount == 0) // Cancel
+ return;
+ .@totalPrice = .@price * .@amount;
+ if (Zeny < .@totalPrice) {
+ mes "[Sugar]";
+ mes "???";
+ mes "Hmmm it seems you don't have enough money";
+ mes "to make that purchase.";
+ mes "I will ask you to check your money first.";
+ close;
+ }
+ Zeny -= .@totalPrice;
+ getitem .@item_id, .@amount;
mes "[Sugar]";
mes "Thank you!!!";
mes "These sweets are really delicious.";
@@ -82,44 +129,4 @@ L_INPUT:
mes "don't eat so much or you'll grow fat.";
mes "Please take care!!!";
close;
-
-M_L1:
- mes "[Sugar]";
- mes "Yes";
- mes "The teacher of mine";
- mes "is Mr. Kuberu, a sweets craftsman.";
- mes "Making sweets under two persons.";
- mes "which is allowed to self-train.";
- next;
- mes "[Sugar]";
- mes "Although selling is seemingly to carried out ....";
- mes "Where he is now?";
- mes "Which I don't know.";
- close;
-
-L_ERROR:
- mes "[Sugar]";
- mes "???";
- mes "You seem to have a failure on hearing.";
- mes "I will tell you once again?";
- mes "You can only purchase";
- mes "^ff0000 5 pieces^000000 at once.";
- next;
- goto L_INPUT;
-
-L_ERROR2:
- mes "[Sugar]";
- mes "???";
- mes "Hmmm it seems you don't have enough money";
- mes "to make that purchase.";
- mes "I will ask you to check your money first.";
- close;
-
-M_End:
- mes "[Sugar]";
- mes "Really .... You might regret it..";
- mes "If you change your mind.";
- mes "I am just here ok.";
- mes "Have a nice day!";
- close;
}