summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-02-01 12:48:43 -0600
committerWushin <pasekei@gmail.com>2015-02-01 12:48:43 -0600
commit63b4fdaaf3ebddf32a8e92890b5f13b81ff8150a (patch)
treef80779298c2bd7de325e1c3568e64dae333bcfb2 /world
parentbbd430fd6c76fe41e2145863820bbd358c31dc5e (diff)
parentaf5304828c259d500f7c6d93b5ffa735bc1695f5 (diff)
downloadserverdata-63b4fdaaf3ebddf32a8e92890b5f13b81ff8150a.tar.gz
serverdata-63b4fdaaf3ebddf32a8e92890b5f13b81ff8150a.tar.bz2
serverdata-63b4fdaaf3ebddf32a8e92890b5f13b81ff8150a.tar.xz
serverdata-63b4fdaaf3ebddf32a8e92890b5f13b81ff8150a.zip
Merge pull request #268 from mekolat/pauline
Add DynamicItemMenu, DynamicItemMenu$, Quiz and MultiQuiz frameworks
Diffstat (limited to 'world')
-rw-r--r--world/map/npc/001-2/pauline.txt19
-rw-r--r--world/map/npc/009-2/selim.txt299
-rw-r--r--world/map/npc/010-2/loratay.txt139
-rw-r--r--world/map/npc/functions/dynamic_menu.txt302
-rw-r--r--world/map/npc/functions/quiz.txt93
-rw-r--r--world/map/npc/scripts.conf2
6 files changed, 451 insertions, 403 deletions
diff --git a/world/map/npc/001-2/pauline.txt b/world/map/npc/001-2/pauline.txt
index b8833251..2c49bef6 100644
--- a/world/map/npc/001-2/pauline.txt
+++ b/world/map/npc/001-2/pauline.txt
@@ -122,13 +122,15 @@ L_KnowIngredientsMouboo:
"No.", L_ComeBackLater;
L_Next3:
+ setarray @items$, "AlizarinHerb", "GambogeHerb", "SilkCocoon", "PinkAntenna", "MaggotSlime", "BugLeg", "GrassSeeds", "ReedBundle", "RoastedAcorn", "Candy", "Milk", "BottleOfWater", "ChickenLeg", "Steak", "Root", "RawLog", "Beer", "CactusDrink", "MoubooFigurine", "Acorn", "Iten", "WarpedLog";
+ setarray @item_names$, "Alizarin Herb", "Gamboge Herb", "Silk Cocoon", "Pink Antenna", "Maggot Slime", "Bug Leg", "Grass Seeds", "Reed Bundle", "Roasted Acorn", "Candy", "Milk", "Bottle of Water", "Chicken Leg", "Steak", "Root", "Raw Log", "Beer", "Cactus Drink", "Mouboo Figurine", "Acorn", "Iten", "Warped Log";
mes "\"Then tell me the ingredients for the mouboo summoning spell and give them to me. Start with the first ingredient and then tell me the second one separately.\"";
next;
- mes "This is case sensitive. Also do not enter whitespaces.";
- next;
- input @pauline_ingredient1$;
+ callfunc "DynamicItemMenu$";
+ set @pauline_ingredient1$, @item$;
mes "Next ingredient.";
- input @pauline_ingredient2$;
+ callfunc "DynamicItemMenu$";
+ set @pauline_ingredient2$, @item$;
if (@pauline_ingredient1$ == "")
goto L_Wrong;
if (@pauline_ingredient2$ == "")
@@ -180,13 +182,16 @@ L_TrySpellMouboo:
goto L_Close;
L_KnowIngredientsPinkie:
+ setarray @items$, "AlizarinHerb", "GambogeHerb", "SilkCocoon", "PinkAntenna", "MaggotSlime", "BugLeg", "GrassSeeds", "ReedBundle", "RoastedAcorn", "Candy", "Milk", "BottleOfWater", "ChickenLeg", "Steak", "Root", "RawLog", "Beer", "CactusDrink", "MoubooFigurine", "Acorn", "Iten", "WarpedLog";
+ setarray @item_names$, "Alizarin Herb", "Gamboge Herb", "Silk Cocoon", "Pink Antenna", "Maggot Slime", "Bug Leg", "Grass Seeds", "Reed Bundle", "Roasted Acorn", "Candy", "Milk", "Bottle of Water", "Chicken Leg", "Steak", "Root", "Raw Log", "Beer", "Cactus Drink", "Mouboo Figurine", "Acorn", "Iten", "Warped Log";
mes "[Pauline]";
mes "\"Now give me the ingredients for the pinkie spell.\"";
next;
- mes "This is case sensitive. Also do not enter whitespaces.";
- input @pauline_ingredient1$;
+ callfunc "DynamicItemMenu$";
+ set @pauline_ingredient1$, @item$;
mes "Next ingredient.";
- input @pauline_ingredient2$;
+ callfunc "DynamicItemMenu$";
+ set @pauline_ingredient2$, @item$;
if (@pauline_ingredient1$ == "")
goto L_Wrong;
if (@pauline_ingredient2$ == "")
diff --git a/world/map/npc/009-2/selim.txt b/world/map/npc/009-2/selim.txt
index f936f2cc..c34f3968 100644
--- a/world/map/npc/009-2/selim.txt
+++ b/world/map/npc/009-2/selim.txt
@@ -9,255 +9,29 @@
{
setarray @all_colours$, "red", "green", "dark blue", "yellow", "light blue", "pink", "black", "orange", "purple", "dark green";
- mes "[Selim]";
- mes "\"What can I dye for you today?\"";
- next;
+ cleararray @items$, "", getarraysize(@items$);
+ cleararray @item_names$, "", getarraysize(@item_names$);
+ cleararray @items_new, "", getarraysize(@items_new);
+ setarray @items_new, 5131, 2250, 2060, 2070, 2110, 2180, 2100, 2170, 2090, 2120, 2080, 2140, 2130, 2150, 2160, 2190, 2200, 2210, 2230, 2240, 5131, 2220, 5000, 5011, 5022, 5033, 5044, 5055, 5066, 5077, 5088, 5099;
+ setarray @items$, "CottonShirt", "CottonCloth", "VNeckSweater", "TurtleneckSweater", "CottonShorts", "CottonTrousers", "CottonSkirt", "Miniskirt", "TankTop", "ShortTankTop", "SilkRobe", "CottonHeadband", "DesertHat", "CottonBoots", "CottonGloves", "WhiteRabbitEars", "WizardHat", "BowlerHat", "BowlerHatBrown", "FineDress", "ContributorShirt", "SorcererRobeRed", "SorcererRobeGreen", "SorcererRobeDarkBlue", "SorcererRobeYellow", "SorcererRobeLightBlue", "SorcererRobePink", "SorcererRobeBlack", "SorcererRobeOrange", "SorcererRobePurple", "SorcererRobeDarkGreen", "SorcererRobeWhite";
+ setarray @item_names$, "Cotton Shirt", "Cotton Cloth", "V-Neck Sweater", "Turtleneck Sweater", "Cotton Shorts", "Cotton Trousers", "Cotton Skirt", "Miniskirt", "Tank Top", "Short Tank Top", "Silk Robe", "Cotton Headband", "Desert Hat", "Cotton Boots", "Cotton Gloves", "White Rabbit Ears", "Wizard Hat", "Bowler Hat", "Bowler Hat (brown)", "Fine Dress", "Contributor Shirt", "Red lined Sorcerer Robe", "Green lined Sorcerer Robe", "Dark Blue lined Sorcerer Robe", "Yellow lined Sorcerer Robe", "Light Blue lined Sorcerer Robe", "Pink lined Sorcerer Robe", "Black lined Sorcerer Robe", "Orange lined Sorcerer Robe", "Purple lined Sorcerer Robe", "Dark Green lined Sorcerer Robe", "White lined Sorcerer Robe";
+ set @default_choice$, "About these sorcerer robes...";
goto L_clothes_choice;
L_clothes_choice:
- set @pronoun$, "it";
- set @is_verb$, "is";
- menu
- "Cotton shirt.", L_cottonshirt,
- "Cotton cloth.", L_cottoncloth,
- "V-Neck sweater.", L_vneck,
- "Turtleneck sweater.", L_tneck,
- "Cotton shorts.", L_shorts,
- "Cotton trousers.", L_trousers,
- "Cotton skirt.", L_skirt,
- "Miniskirt.", L_miniskirt,
- "Tank top.", L_tanktop,
- "Short tank top.", L_tanktop_short,
- "Silk robe.", L_robe,
- "Cotton headband.", L_headband,
- "Desert hat.", L_desert_hat,
- "Cotton boots.", L_cottonboots,
- "Cotton gloves.", L_cottongloves,
- "Rabbit ears.", L_rabbitears,
- "Wizard hat.", L_wizardhat,
- "Bowler hat.", L_bowlerhat,
- "Sorcerer robe.", L_sorcererrobe,
- "Bowler hat (brown).", L_bowlerhatbrown,
- "Fine dress.", L_finedress,
- "Contributor Shirt.", L_contributor,
- "About these sorcerer robes...", L_asksorcererrobe,
- "I'm fine for now, thanks.", L_Close;
-
-L_contributor:
- set @del, 1178;
- set @new, 5131;
- set @name$, "contributor shirt";
- goto L_picked_item;
-
-L_cottonshirt:
- set @del, 1202;
- set @new, 2050;
- set @name$, "cotton shirt";
- goto L_picked_item;
-
-L_vneck:
- set @del, 624;
- set @new, 2060;
- set @name$, "V-neck sweater";
- goto L_picked_item;
-
-L_tneck:
- set @del, 564;
- set @new, 2070;
- set @name$, "turtleneck sweater";
- goto L_picked_item;
-
-L_shorts:
- set @del, 586;
- set @new, 2110;
- set @name$, "cotton shorts";
- set @pronoun$, "them";
- set @is_verb$, "are";
- goto L_picked_item;
-
-L_trousers:
- set @del, 648;
- set @new, 2180;
- set @name$, "cotton trousers";
- set @pronoun$, "them";
- set @is_verb$, "are";
- goto L_picked_item;
-
-L_skirt:
- set @del, 632;
- set @new, 2100;
- set @name$, "cotton skirt";
- goto L_picked_item;
-
-L_miniskirt:
- set @del, 771;
- set @new, 2170;
- set @name$, "miniskirt";
- goto L_picked_item;
-
-L_tanktop:
- set @del, 688;
- set @new, 2090;
- set @name$, "tank top";
- goto L_picked_item;
-
-L_tanktop_short:
- set @del, 689;
- set @new, 2120;
- set @name$, "short tank top";
- goto L_picked_item;
-
-L_robe:
- set @del, 720;
- set @new, 2080;
- set @name$, "silk robe";
- goto L_picked_item;
-
-L_headband:
- set @del, 724;
- set @new, 2140;
- set @name$, "cotton headband";
- goto L_picked_item;
-
-L_desert_hat:
- set @del, 723;
- set @new, 2130;
- set @name$, "desert hat";
- goto L_picked_item;
-
-L_cottonboots:
- set @del, 735;
- set @new, 2150;
- set @name$, "cotton boots";
- goto L_picked_item;
-
-L_cottongloves:
- set @del, 741;
- set @new, 2160;
- set @name$, "cotton gloves";
- goto L_picked_item;
-
-L_rabbitears:
- set @del, 1255;
- set @new, 2190;
- set @name$, "rabbit ears";
- set @pronoun$, "them";
- set @is_verb$, "are";
- goto L_picked_item;
-
-L_wizardhat:
- set @del, 4028;
- set @new, 2200;
- set @name$, "wizard hat";
- goto L_picked_item;
-
-L_bowlerhat:
- set @del, 4030;
- set @new, 2210;
- set @name$, "bowler hat";
- goto L_picked_item;
-
-L_sorcererrobe:
mes "[Selim]";
- mes "\"Which one?\"";
+ mes "\"What can I dye for you today?\"";
next;
- menu
- "A red lined one.", L_redlinedsorcererrobe,
- "A green lined one.", L_greenlinedsorcererrobe,
- "A dark blue lined one.", L_darkbluelinedsorcererrobe,
- "A yellow lined one.", L_yellowlinedsorcererrobe,
- "A light blue lined one.", L_lightbluelinedsorcererrobe,
- "A pink lined one.", L_pinklinedsorcererrobe,
- "A black lined one.", L_blacklinedsorcererrobe,
- "An orange lined one.", L_orangelinedsorcererrobe,
- "A purple lined one.", L_purplelinedsorcererrobe,
- "A dark green lined one.", L_darkgreenlinedsorcererrobe,
- "A white lined one.", L_whitelinedsorcererrobe,
- "I'm fine for now, thanks.", L_Close;
-
-L_redlinedsorcererrobe:
- set @del, 798;
- set @new, 2220;
- set @name$, "red lined sorcerer robe";
- goto L_picked_item;
-
-L_greenlinedsorcererrobe:
- set @del, 5010;
- set @new, 5000;
- set @name$, "green lined sorcerer robe";
+ callfunc "DynamicItemMenu$";
+ set @default_choice$, "";
+ set @item_del$, @item$;
+ set @item_new, @items_new[@index];
+ set @name$, @item_names$[@index];
+ cleararray @items$, "", getarraysize(@items$);
+ cleararray @item_names$, "", getarraysize(@item_names$);
+ if(@item$ == "") goto L_asksorcererrobe;
goto L_picked_item;
-L_darkbluelinedsorcererrobe:
- set @del, 5021;
- set @new, 5011;
- set @name$, "dark blue lined sorcerer robe";
- goto L_picked_item;
-
-L_yellowlinedsorcererrobe:
- set @del, 5032;
- set @new, 5022;
- set @name$, "yellow lined sorcerer robe";
- goto L_picked_item;
-
-L_lightbluelinedsorcererrobe:
- set @del, 5043;
- set @new, 5033;
- set @name$, "light blue lined sorcerer robe";
- goto L_picked_item;
-
-L_pinklinedsorcererrobe:
- set @del, 5054;
- set @new, 5044;
- set @name$, "pink lined sorcerer robe";
- goto L_picked_item;
-
-L_blacklinedsorcererrobe:
- set @del, 5065;
- set @new, 5055;
- set @name$, "black lined sorcerer robe";
- goto L_picked_item;
-
-L_orangelinedsorcererrobe:
- set @del, 5076;
- set @new, 5066;
- set @name$, "orange lined sorcerer robe";
- goto L_picked_item;
-
-L_purplelinedsorcererrobe:
- set @del, 5087;
- set @new, 5077;
- set @name$, "purple lined sorcerer robe";
- goto L_picked_item;
-
-L_darkgreenlinedsorcererrobe:
- set @del, 5098;
- set @new, 5088;
- set @name$, "dark green lined sorcerer robe";
- goto L_picked_item;
-
-L_whitelinedsorcererrobe:
- set @del, 5109;
- set @new, 5099;
- set @name$, "white lined sorcerer robe";
- goto L_picked_item;
-
-L_bowlerhatbrown:
- set @del, 800;
- set @new, 2230;
- set @name$, "bowler hat (brown)";
- goto L_picked_item;
-
-L_finedress:
- set @del, 870;
- set @new, 2240;
- set @name$, "fine dress";
- goto L_picked_item;
-
-L_cottoncloth:
- set @del, 660;
- set @new, 2250;
- set @name$, "cotton cloth";
- goto L_picked_item;
L_asksorcererrobe:
mes "[Selim]";
@@ -278,43 +52,38 @@ L_Next:
mes "[Selim]";
mes "\"Of course I can help you by dyeing the materials your tailor will want.";
mes "All I need is a piece of Cotton Cloth.\"";
+ set @item_del$, "CottonCloth";
+ set @item_new, 2250;
menu
- "Sure. Here is one.", L_cottoncloth,
+ "Sure. Here is one.", L_picked_item,
"I have to go pick that.", L_Close;
L_picked_item:
- if (countitem(@del) == 0) goto L_havenone;
+ if (countitem(@item_del$) == 0) goto L_havenone;
goto L_colour;
L_colour:
mes "[Selim]";
mes "\"Excellent. Now, what color do you want?\"";
next;
- menu
- "Red.", L_MenuItems,
- "Green.", L_MenuItems,
- "Dark Blue.", L_MenuItems,
- "Yellow.", L_MenuItems,
- "Light Blue.", L_MenuItems,
- "Pink.", L_MenuItems,
- "Black.", L_MenuItems,
- "Orange.", L_MenuItems,
- "Purple.", L_MenuItems,
- "Dark Green.", L_MenuItems;
-
-L_MenuItems:
- set @colour, @menu - 1;
+ setarray @items$, "RedDye", "GreenDye", "DarkBlueDye", "YellowDye", "LightBlueDye", "PinkDye", "BlackDye", "OrangeDye", "PurpleDye", "DarkGreenDye";
+ setarray @item_names$, "red", "green", "dark blue", "yellow", "light blue", "pink", "black", "orange", "purple", "dark green";
+ set @default_choice$, "I have no dye.";
+ callfunc "DynamicItemMenu$";
+ cleararray @items$, "", getarraysize(@items$);
+ cleararray @item_names$, "", getarraysize(@item_names$);
+ set @default_choice$, "";
+ if (@item$ == "") goto L_no_dye;
+ set @colour, @index;
set @vial, 690 + @colour;
- if (countitem(@vial) == 0) goto L_no_dye;
goto L_finish;
L_no_dye:
mes "[Selim]";
- mes "\"I would love to dye your " + @name$ + " for you, but you will have to bring me some " + @all_colours$[@colour] + " dye first.";
+ mes "\"I would love to dye your " + @name$ + " for you, but you will have to bring me some dye first.";
mes "Those behind me are nearly empty and won't last for your item.\"";
next;
menu
- "Sorry, I meant a different color.", L_colour,
"I wanted to dye a different item anyway.", L_clothes_choice,
"What do you mean, `bring you dye'?", L_explain_dye,
"Where would I get dye?", L_explain_dye,
@@ -329,13 +98,11 @@ L_explain_dye:
close;
L_finish:
- if (countitem(@del) == 0)
- goto L_havenone;
delitem @vial, 1;
- delitem @del, 1;
- getitem @new + @colour, 1;
+ delitem @item_del$, 1;
+ getitem @item_new + @colour, 1;
mes "[Selim]";
- mes "\"Here " + @is_verb$ + " your " + @all_colours$[@colour] + " " + @name$ + "! Please let " + @pronoun$ + " dry for a minute before you put " + @pronoun$ + " on.\"";
+ mes "\"Here's your " + @all_colours$[@colour] + " " + @name$ + "! Please let dry for a minute.\"";
close;
L_havenone:
diff --git a/world/map/npc/010-2/loratay.txt b/world/map/npc/010-2/loratay.txt
index b8a00c28..324f953a 100644
--- a/world/map/npc/010-2/loratay.txt
+++ b/world/map/npc/010-2/loratay.txt
@@ -487,12 +487,12 @@ L_desert_hat:
mes "The seamstress sighs.";
mes "\"One of these days it would be nice to have an actual challenge... yes, of course I can make a desert hat. A Cotton Headband, three pieces of cotton cloth. Hmm. And let's add 300 GP to that.\"";
next;
- set @default_choice$, "Never mind.";
+ cleararray @items, 0, getarraysize(@items);
+ cleararray @item_names$, "", getarraysize(@item_names$);
setarray @items, 724, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149;
setarray @item_names$, "Here is a Cotton Headband.", "Here is a Red Cotton Headband.", "Here is a Green Cotton Headband.", "Here is a Dark Blue Cotton Headband.", "Here is a Yellow Cotton Headband.", "Here is a Light Blue Cotton Headband.", "Here is a Pink Cotton Headband.", "Here is a Black Cotton Headband.", "Here is an Orange Cotton Headband.", "Here is a Puple Cotton Headband.", "Here is a Dark Green Cotton Headband.";
- set @items_nr, 11;
- callsub S_pick_one_of_many_items;
+ callfunc "DynamicItemMenu";
if (@item == 0)
goto L_main_menu;
if (@item == 724)
@@ -544,11 +544,11 @@ L_trim:
mes "\"Alright. What is it that you want trimmed?\"";
next;
- set @default_choice$, "Never mind.";
+ cleararray @items, 0, getarraysize(@items);
+ cleararray @item_names$, "", getarraysize(@item_names$);
setarray @items, 1202, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 688, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 632, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 648, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189;
setarray @item_names$, "Cotton Shirt", "Red Cotton Shirt", "Green Cotton Shirt", "Dark Blue Cotton Shirt", "Yellow Cotton Shirt", "Light Blue Cotton Shirt", "Pink Cotton Shirt", "Black Cotton Shirt", "Orange Cotton Shirt", "Purple Cotton Shirt", "Dark Green Cotton Shirt", "Tank Top", "Red Tank Top", "Green Tank Top", "Dark Blue Tank Top", "Yellow Tank Top", "Light Blue Tank Top", "Pink Tank Top", "Black Tank Top", "Orange Tank Top", "Purple Tank Top", "Dark Green Tank Top", "Cotton Skirt", "Red Cotton Skirt", "Green Cotton Skirt", "Dark Blue Cotton Skirt", "Yellow Cotton Skirt", "Light Blue Cotton Skirt", "Pink Cotton Skirt", "Black Cotton Skirt", "Orange Cotton Skirt", "Purple Cotton Skirt", "Dark Green Cotton Skirt", "Cotton Trousers", "Red Cotton Trousers", "Green Cotton Trousers", "Dark Blue Cotton Trousers", "Yellow Cotton Trousers", "Light Blue Cotton Trousers", "Pink Cotton Trousers", "Black Cotton Trousers", "Orange Cotton Trousers", "Purple Cotton Trousers", "Dark Green Cotton Trousers";
- set @items_nr, 44;
- callsub S_pick_one_of_many_items;
+ callfunc "DynamicItemMenu";
if (@item == 0)
goto L_main_menu;
set @delitem, @item;
@@ -603,12 +603,12 @@ L_lengthen:
mes "\"Now, let me see. What is it that you want lengthened?\"";
next;
- set @default_choice$, "Never mind.";
+ cleararray @items, 0, getarraysize(@items);
+ cleararray @item_names$, "", getarraysize(@item_names$);
setarray @items, 688, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 689, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 771, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 586, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119;
setarray @item_names$, "Tank Top", "Red Tank Top", "Green Tank Top", "Dark Blue Tank Top", "Yellow Tank Top", "Light Blue Tank Top", "Pink Tank Top", "Black Tank Top", "Orange Tank Top", "Purple Tank Top", "Dark Green Tank Top", "Short Tank Top", "Red Short Tank Top", "Green Short Tank Top", "Dark Blue Short Tank Top", "Yellow Short Tank Top", "Light Blue Short Tank Top", "Pink Short Tank Top", "Black Short Tank Top", "Orange Short Tank Top", "Purple Short Tank Top", "Dark Green Short Tank Top", "Miniskirt", "Red Miniskirt", "Green Miniskirt", "Dark Blue Miniskirt", "Yellow Miniskirt", "Light Blue Miniskirt", "Pink Miniskirt", "Black Miniskirt", "Orange Miniskirt", "Purple Miniskirt", "Dark Green Miniskirt", "Cotton Shorts", "Red Cotton Shorts", "Green Cotton Shorts", "Dark Blue Cotton Shorts", "Yellow Cotton Shorts", "Light Blue Cotton Shorts", "Pink Cotton Shorts", "Black Cotton Shorts", "Orange Cotton Shorts", "Purple Cotton Shorts", "Dark Green Cotton Shorts";
- set @items_nr, 44;
- callsub S_pick_one_of_many_items;
+ callfunc "DynamicItemMenu";
if (@item == 0)
goto L_main_menu;
@@ -903,127 +903,6 @@ L_end:
set @Robe_with_sheets, 0;
goto L_Close;
-// Input: @items (array of items you want to choose from)
-// @item_names (names of the items in @items)
-// @items_nr (number of entries in @items)
-// @default_choice$ (default option)
-// Return: @item (The selected item, or 0 if the default/something invalid was chosen)
-S_pick_one_of_many_items:
- set @c, 0;
- set @i, 0;
-
- setarray @choice_n$, "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "";
- goto S_SUB_pick_choice_loop;
-
-S_SUB_pick_choice_loop:
- if (@i >= @items_nr)
- goto S_SUB_choice_init_done;
- set @current, @items[@i];
- set @current_name$, @item_names$[@i];
- set @i, @i + 1;
-
- if (countitem(@current) == 0)
- goto S_SUB_pick_choice_loop;
- set @choice_v[@c], @current;
- set @choice_n$[@c], @current_name$;
- set @c, @c + 1;
- goto S_SUB_pick_choice_loop;
-
-S_SUB_choice_init_done:
- set @choice_v[@c], 0;
- set @choice_n$[@c], @default_choice$;
- set @c, @c + 1;
-
- if (@c < 10)
- menu
- @choice_n$[0], L_MenuItems,
- @choice_n$[1], L_MenuItems,
- @choice_n$[2], L_MenuItems,
- @choice_n$[3], L_MenuItems,
- @choice_n$[4], L_MenuItems,
- @choice_n$[5], L_MenuItems,
- @choice_n$[6], L_MenuItems,
- @choice_n$[7], L_MenuItems,
- @choice_n$[8], L_MenuItems,
- @choice_n$[9], L_MenuItems;
- goto L_MenuItems;
-
-L_MenuItems:
- if (@c < 10)
- goto L_SUB_choice_join;
-
- if (@c < 20)
- menu
- @choice_n$[0], L_MenuItems1,
- @choice_n$[1], L_MenuItems1,
- @choice_n$[2], L_MenuItems1,
- @choice_n$[3], L_MenuItems1,
- @choice_n$[4], L_MenuItems1,
- @choice_n$[5], L_MenuItems1,
- @choice_n$[6], L_MenuItems1,
- @choice_n$[7], L_MenuItems1,
- @choice_n$[8], L_MenuItems1,
- @choice_n$[9], L_MenuItems1,
- @choice_n$[10], L_MenuItems1,
- @choice_n$[11], L_MenuItems1,
- @choice_n$[12], L_MenuItems1,
- @choice_n$[13], L_MenuItems1,
- @choice_n$[14], L_MenuItems1,
- @choice_n$[15], L_MenuItems1,
- @choice_n$[16], L_MenuItems1,
- @choice_n$[17], L_MenuItems1,
- @choice_n$[18], L_MenuItems1,
- @choice_n$[19], L_MenuItems1;
- goto L_MenuItems1;
-
-L_MenuItems1:
- if (@c < 20)
- goto L_SUB_choice_join;
-
- menu
- @choice_n$[0], L_SUB_choice_join,
- @choice_n$[1], L_SUB_choice_join,
- @choice_n$[2], L_SUB_choice_join,
- @choice_n$[3], L_SUB_choice_join,
- @choice_n$[4], L_SUB_choice_join,
- @choice_n$[5], L_SUB_choice_join,
- @choice_n$[6], L_SUB_choice_join,
- @choice_n$[7], L_SUB_choice_join,
- @choice_n$[8], L_SUB_choice_join,
- @choice_n$[9], L_SUB_choice_join,
- @choice_n$[10], L_SUB_choice_join,
- @choice_n$[11], L_SUB_choice_join,
- @choice_n$[12], L_SUB_choice_join,
- @choice_n$[13], L_SUB_choice_join,
- @choice_n$[14], L_SUB_choice_join,
- @choice_n$[15], L_SUB_choice_join,
- @choice_n$[16], L_SUB_choice_join,
- @choice_n$[17], L_SUB_choice_join,
- @choice_n$[18], L_SUB_choice_join,
- @choice_n$[19], L_SUB_choice_join,
- @choice_n$[20], L_SUB_choice_join,
- @choice_n$[21], L_SUB_choice_join,
- @choice_n$[22], L_SUB_choice_join,
- @choice_n$[23], L_SUB_choice_join,
- @choice_n$[24], L_SUB_choice_join,
- @choice_n$[25], L_SUB_choice_join,
- @choice_n$[26], L_SUB_choice_join,
- @choice_n$[27], L_SUB_choice_join,
- @choice_n$[28], L_SUB_choice_join,
- @choice_n$[29], L_SUB_choice_join,
- @choice_n$[30], L_SUB_choice_join,
- @choice_n$[31], L_SUB_choice_join;
-
-L_SUB_choice_join:
- set @menu, @menu - 1;
- set @item, @choice_v[@menu];
- if (@menu >= @c)
- set @item, 0;
- return;
-
L_TooMany:
mes "[Lora Tay the Seamstress]";
mes "\"You don't have anywhere to put this. Come back when you have more room.\"";
diff --git a/world/map/npc/functions/dynamic_menu.txt b/world/map/npc/functions/dynamic_menu.txt
new file mode 100644
index 00000000..a2a735d6
--- /dev/null
+++ b/world/map/npc/functions/dynamic_menu.txt
@@ -0,0 +1,302 @@
+// Input: @items (array of items you want to choose from)
+// @item_names$ (names of the items in @items)
+// @default_choice$ (default option)
+// Return: @item (The selected item, or 0 if the default/something invalid was chosen)
+//
+// NOTE: DynamicItemMenu is ONLY used for scripts that need to do math with @item like tailor, dyer, bleacher
+// All other scripts should use DynamicItemMenu$
+
+function|script|DynamicItemMenu
+{
+set @items_nr, getarraysize(@items);
+if(@items_nr != getarraysize(@item_names$)) goto L_ArrayLengthMismatch;
+if(@default_choice$ == "") set @default_choice$, "Never mind.";
+goto L_pick_one_of_many_items;
+
+L_pick_one_of_many_items:
+ set @c, 0;
+ set @i, 0;
+
+ setarray @choice_n$, "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "";
+ goto L_pick_choice_loop;
+
+L_pick_choice_loop:
+ if (@i >= @items_nr)
+ goto L_choice_init_done;
+ set @current, @items[@i];
+ set @current_name$, @item_names$[@i];
+ set @current_index, @i;
+ set @i, @i + 1;
+
+ if (countitem(@current) == 0)
+ goto L_pick_choice_loop;
+ set @choice_v[@c], @current;
+ set @choice_n$[@c], @current_name$;
+ set @choice_i[@c], @current_index;
+ set @c, @c + 1;
+ goto L_pick_choice_loop;
+
+L_choice_init_done:
+ set @choice_v[@c], 0;
+ set @choice_n$[@c], @default_choice$;
+ set @c, @c + 1;
+
+ if (@c < 10)
+ menu
+ @choice_n$[0], L_MenuItems,
+ @choice_n$[1], L_MenuItems,
+ @choice_n$[2], L_MenuItems,
+ @choice_n$[3], L_MenuItems,
+ @choice_n$[4], L_MenuItems,
+ @choice_n$[5], L_MenuItems,
+ @choice_n$[6], L_MenuItems,
+ @choice_n$[7], L_MenuItems,
+ @choice_n$[8], L_MenuItems,
+ @choice_n$[9], L_MenuItems;
+ goto L_MenuItems;
+
+L_MenuItems:
+ if (@c < 10)
+ goto L_choice_join;
+
+ if (@c < 20)
+ menu
+ @choice_n$[0], L_MenuItems1,
+ @choice_n$[1], L_MenuItems1,
+ @choice_n$[2], L_MenuItems1,
+ @choice_n$[3], L_MenuItems1,
+ @choice_n$[4], L_MenuItems1,
+ @choice_n$[5], L_MenuItems1,
+ @choice_n$[6], L_MenuItems1,
+ @choice_n$[7], L_MenuItems1,
+ @choice_n$[8], L_MenuItems1,
+ @choice_n$[9], L_MenuItems1,
+ @choice_n$[10], L_MenuItems1,
+ @choice_n$[11], L_MenuItems1,
+ @choice_n$[12], L_MenuItems1,
+ @choice_n$[13], L_MenuItems1,
+ @choice_n$[14], L_MenuItems1,
+ @choice_n$[15], L_MenuItems1,
+ @choice_n$[16], L_MenuItems1,
+ @choice_n$[17], L_MenuItems1,
+ @choice_n$[18], L_MenuItems1,
+ @choice_n$[19], L_MenuItems1;
+ goto L_MenuItems1;
+
+L_MenuItems1:
+ if (@c < 20)
+ goto L_choice_join;
+
+ menu
+ @choice_n$[0], L_choice_join,
+ @choice_n$[1], L_choice_join,
+ @choice_n$[2], L_choice_join,
+ @choice_n$[3], L_choice_join,
+ @choice_n$[4], L_choice_join,
+ @choice_n$[5], L_choice_join,
+ @choice_n$[6], L_choice_join,
+ @choice_n$[7], L_choice_join,
+ @choice_n$[8], L_choice_join,
+ @choice_n$[9], L_choice_join,
+ @choice_n$[10], L_choice_join,
+ @choice_n$[11], L_choice_join,
+ @choice_n$[12], L_choice_join,
+ @choice_n$[13], L_choice_join,
+ @choice_n$[14], L_choice_join,
+ @choice_n$[15], L_choice_join,
+ @choice_n$[16], L_choice_join,
+ @choice_n$[17], L_choice_join,
+ @choice_n$[18], L_choice_join,
+ @choice_n$[19], L_choice_join,
+ @choice_n$[20], L_choice_join,
+ @choice_n$[21], L_choice_join,
+ @choice_n$[22], L_choice_join,
+ @choice_n$[23], L_choice_join,
+ @choice_n$[24], L_choice_join,
+ @choice_n$[25], L_choice_join,
+ @choice_n$[26], L_choice_join,
+ @choice_n$[27], L_choice_join,
+ @choice_n$[28], L_choice_join,
+ @choice_n$[29], L_choice_join,
+ @choice_n$[30], L_choice_join,
+ @choice_n$[31], L_choice_join;
+
+L_choice_join:
+ set @menu, @menu - 1;
+ set @item, @choice_v[@menu];
+ set @index, @choice_i[@menu];
+ if (@menu >= @c)
+ set @item, 0;
+ goto L_Clean;
+
+L_Clean:
+ set @menu, 0;
+ set @items_nr, 0;
+ set @c, 0;
+ set @i, 0;
+ set @current, 0;
+ set @current_name$, "";
+ cleararray @choice_v, 0, getarraysize(@choice_v);
+ cleararray @choice_n$, "", getarraysize(@choice_n$);
+ cleararray @choice_i, 0, getarraysize(@choice_i);
+ return;
+
+L_ArrayLengthMismatch:
+ debugmes "@items and @item_names$ array length mismatch";
+ mapexit;
+}
+
+
+
+
+// Input: @items$ (array of items you want to choose from)
+// @item_names$ (names of the items in @items)
+// @default_choice$ (default option)
+// Return: @item$ (The selected item, or 0 if the default/something invalid was chosen)
+
+function|script|DynamicItemMenu$
+{
+set @items_nr, getarraysize(@items$);
+if(@items_nr != getarraysize(@item_names$)) goto L_ArrayLengthMismatch;
+if(@default_choice$ == "") set @default_choice$, "Never mind.";
+goto L_pick_one_of_many_items;
+
+L_pick_one_of_many_items:
+ set @c, 0;
+ set @i, 0;
+
+ setarray @choice_n$, "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "";
+ goto L_pick_choice_loop;
+
+L_pick_choice_loop:
+ if (@i >= @items_nr)
+ goto L_choice_init_done;
+ set @current$, @items$[@i];
+ set @current_name$, @item_names$[@i];
+ set @current_index, @i;
+ set @i, @i + 1;
+
+ if (countitem(@current$) == 0)
+ goto L_pick_choice_loop;
+ set @choice_v$[@c], @current$;
+ set @choice_n$[@c], @current_name$;
+ set @choice_i[@c], @current_index;
+ set @c, @c + 1;
+ goto L_pick_choice_loop;
+
+L_choice_init_done:
+ set @choice_v$[@c], "";
+ set @choice_n$[@c], @default_choice$;
+ set @c, @c + 1;
+
+ if (@c < 10)
+ menu
+ @choice_n$[0], L_MenuItems,
+ @choice_n$[1], L_MenuItems,
+ @choice_n$[2], L_MenuItems,
+ @choice_n$[3], L_MenuItems,
+ @choice_n$[4], L_MenuItems,
+ @choice_n$[5], L_MenuItems,
+ @choice_n$[6], L_MenuItems,
+ @choice_n$[7], L_MenuItems,
+ @choice_n$[8], L_MenuItems,
+ @choice_n$[9], L_MenuItems;
+ goto L_MenuItems;
+
+L_MenuItems:
+ if (@c < 10)
+ goto L_choice_join;
+
+ if (@c < 20)
+ menu
+ @choice_n$[0], L_MenuItems1,
+ @choice_n$[1], L_MenuItems1,
+ @choice_n$[2], L_MenuItems1,
+ @choice_n$[3], L_MenuItems1,
+ @choice_n$[4], L_MenuItems1,
+ @choice_n$[5], L_MenuItems1,
+ @choice_n$[6], L_MenuItems1,
+ @choice_n$[7], L_MenuItems1,
+ @choice_n$[8], L_MenuItems1,
+ @choice_n$[9], L_MenuItems1,
+ @choice_n$[10], L_MenuItems1,
+ @choice_n$[11], L_MenuItems1,
+ @choice_n$[12], L_MenuItems1,
+ @choice_n$[13], L_MenuItems1,
+ @choice_n$[14], L_MenuItems1,
+ @choice_n$[15], L_MenuItems1,
+ @choice_n$[16], L_MenuItems1,
+ @choice_n$[17], L_MenuItems1,
+ @choice_n$[18], L_MenuItems1,
+ @choice_n$[19], L_MenuItems1;
+ goto L_MenuItems1;
+
+L_MenuItems1:
+ if (@c < 20)
+ goto L_choice_join;
+
+ menu
+ @choice_n$[0], L_choice_join,
+ @choice_n$[1], L_choice_join,
+ @choice_n$[2], L_choice_join,
+ @choice_n$[3], L_choice_join,
+ @choice_n$[4], L_choice_join,
+ @choice_n$[5], L_choice_join,
+ @choice_n$[6], L_choice_join,
+ @choice_n$[7], L_choice_join,
+ @choice_n$[8], L_choice_join,
+ @choice_n$[9], L_choice_join,
+ @choice_n$[10], L_choice_join,
+ @choice_n$[11], L_choice_join,
+ @choice_n$[12], L_choice_join,
+ @choice_n$[13], L_choice_join,
+ @choice_n$[14], L_choice_join,
+ @choice_n$[15], L_choice_join,
+ @choice_n$[16], L_choice_join,
+ @choice_n$[17], L_choice_join,
+ @choice_n$[18], L_choice_join,
+ @choice_n$[19], L_choice_join,
+ @choice_n$[20], L_choice_join,
+ @choice_n$[21], L_choice_join,
+ @choice_n$[22], L_choice_join,
+ @choice_n$[23], L_choice_join,
+ @choice_n$[24], L_choice_join,
+ @choice_n$[25], L_choice_join,
+ @choice_n$[26], L_choice_join,
+ @choice_n$[27], L_choice_join,
+ @choice_n$[28], L_choice_join,
+ @choice_n$[29], L_choice_join,
+ @choice_n$[30], L_choice_join,
+ @choice_n$[31], L_choice_join;
+
+L_choice_join:
+ set @menu, @menu - 1;
+ set @item$, @choice_v$[@menu];
+ set @index, @choice_i[@menu];
+ if (@menu >= @c)
+ set @item$, "";
+ goto L_Clean;
+
+L_Clean:
+ set @menu, 0;
+ set @items_nr, 0;
+ set @c, 0;
+ set @current_index, 0;
+ set @i, 0;
+ set @current$, 0;
+ set @current_name$, "";
+ cleararray @choice_v$, "", getarraysize(@choice_v$);
+ cleararray @choice_n$, "", getarraysize(@choice_n$);
+ cleararray @choice_i, 0, getarraysize(@choice_i);
+ return;
+
+L_ArrayLengthMismatch:
+ debugmes "@items$ and @item_names$ array length mismatch";
+ mapexit;
+}
diff --git a/world/map/npc/functions/quiz.txt b/world/map/npc/functions/quiz.txt
new file mode 100644
index 00000000..ea10a3c4
--- /dev/null
+++ b/world/map/npc/functions/quiz.txt
@@ -0,0 +1,93 @@
+function|script|MultiQuiz
+{
+ if((getarraysize(@quiz_answers$) != getarraysize(@quiz_questions$)) ||
+ (@quiz_answers$[0] == "") || (@quiz_questions$[0] == "")) goto L_ArrayError;
+ set @setindex, 1;
+ set @index, rand(0,(getarraysize(@quiz_answers$) - 1));
+ set @question$, @quiz_questions$[@index];
+ mes "\""+ @question$ + "\"";
+ next;
+ mes "Pick the correct answer.";
+ callfunc "Quiz";
+ return;
+
+L_ArrayError:
+ if(@quiz_answers$[0] == "") debugmes "@quiz_answers$ is empty";
+ if(@quiz_questions$[0] == "") debugmes "@quiz_questions$ is empty";
+ if(getarraysize(@quiz_answers$) != getarraysize(@quiz_questions$)) debugmes "Size of @quiz_answers$ is not equal to size of @quiz_questions$";
+ mapexit;
+}
+
+function|script|Quiz
+{
+ if((@choices_nr < 1) || (@choices_nr > 8)) set @choices_nr, 3;
+ if(@choices_nr > getarraysize(@quiz_answers$)) set @choices_nr, getarraysize(@quiz_answers$);
+ if(@quiz_answers$[0] == "") goto L_ArrayError;
+ set @success, 0;
+ if(@setindex < 1) set @index, @answer;
+ set @good, rand(0,(@choices_nr - 1));
+ setarray @choices$, "";
+ cleararray @choices$, "", getarraysize(@choices$);
+ set @loop, 0;
+ goto L_Shuffle;
+
+L_Shuffle:
+ set @nindex, rand(0,(getarraysize(@quiz_answers$) - 1));
+ if(@nindex == @index) goto L_Shuffle; // do not get the good definition
+ set @loop2, 0;
+ goto L_Search;
+
+L_Search:
+ if(@choices$[@loop2] == @quiz_answers$[@nindex]) goto L_Shuffle; // array is already populated with this choice
+ if(@loop2 >= (@choices_nr - 1)) goto L_Shuffle2;
+ set @loop2, @loop2 + 1;
+ goto L_Search;
+
+L_Shuffle2:
+ set @choices$[@loop], @quiz_answers$[@nindex];
+ if(@loop >= (@choices_nr - 1)) goto L_Answer;
+ set @loop, @loop + 1;
+ goto L_Shuffle;
+
+L_Answer:
+ set @choices$[@good], @quiz_answers$[@index]; // set the good definition
+ menu
+ @choices$[0], L_Enter,
+ @choices$[1], L_Enter,
+ @choices$[2], L_Enter,
+ @choices$[3], L_Enter,
+ @choices$[4], L_Enter,
+ @choices$[5], L_Enter,
+ @choices$[6], L_Enter,
+ @choices$[7], L_Enter;
+
+L_Enter:
+ if(@menu != (@good + 1)) goto L_Shift;
+ set @success, 1;
+ goto L_Shift;
+
+L_Shift:
+ if(@shift < @index) set @shift, @index;
+
+ if(@shift == @index) set @quiz_answers$[@index], ""; // do not allow twice the same question
+
+ if((@quiz_questions$[0] != "") && (@shift == @index)) set @quiz_questions$[@index], "";
+ if((@quiz_questions$[0] != "") && (@quiz_questions$[(@shift + 1)] != "")) set @quiz_questions$[@shift], @quiz_questions$[(@shift + 1)];
+ if((@quiz_questions$[0] != "") && (@quiz_questions$[(@shift + 1)] != "")) set @quiz_questions$[(@shift + 1)], "";
+
+ if(@quiz_answers$[(@shift + 1)] != "") set @quiz_answers$[@shift], @quiz_answers$[(@shift + 1)];
+ if(@quiz_answers$[(@shift + 1)] != "") set @quiz_answers$[(@shift + 1)], "";
+
+ set @shift, @shift + 1;
+ if(@quiz_answers$[(@shift + 1)] != "") goto L_Shift;
+ set @shift, 0;
+ goto L_Close;
+
+L_Close:
+ set @answer, 0;
+ return;
+
+L_ArrayError:
+ if(@quiz_answers$[0] == "") debugmes "@quiz_answers$ is empty";
+ mapexit;
+}
diff --git a/world/map/npc/scripts.conf b/world/map/npc/scripts.conf
index 77e9c8a8..d9fbd64d 100644
--- a/world/map/npc/scripts.conf
+++ b/world/map/npc/scripts.conf
@@ -25,6 +25,8 @@ npc: npc/functions/undead_debug.txt
npc: npc/functions/headstyles.txt
npc: npc/functions/global_event_handler.txt
npc: npc/functions/stat_reset.txt
+npc: npc/functions/quiz.txt
+npc: npc/functions/dynamic_menu.txt
// Item Functions
npc: npc/items/magic_gm_top_hat.txt