From 5ef231cd66b8385bec4234a1b2f372448feec3a1 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 27 Jun 2021 15:39:40 -0300 Subject: Reintroduce Alchemy (untested). Close #27 --- npc/functions/alchemy.txt | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 npc/functions/alchemy.txt (limited to 'npc/functions/alchemy.txt') diff --git a/npc/functions/alchemy.txt b/npc/functions/alchemy.txt new file mode 100644 index 00000000..ea77011e --- /dev/null +++ b/npc/functions/alchemy.txt @@ -0,0 +1,91 @@ +// TMW2 Script +// Author: +// Jesusalva +// Description: +// Alchemy System (oversimplified) + +// Usage: AlchemySystem () +// Returns true on success, false on failure +function script AlchemySystem { + .success=false; + + setskin "craft2"; + .@var$ = requestcraft(2); + .@craft = initcraft(.@var$); + .@entry = findcraftentry(.@craft, CRAFT_ALCHEMY); + if (debug || $@GM_OVERRIDE) mes "found craft entry: " + .@entry; + if (.@entry < 0) { + .success=false; + } else { + // Determine how many units to make + // This code comes from Moubootaur Legends + // Where sponsors could make up to 25 units + // And you could configure a fixed number to + // avoid prompts... + // ... + // PS. This is not using freeloop() + // Max amount is limited for performance. + if (GSET_FIXED_ALCHEMY) { + .@m=limit(1, GSET_FIXED_ALCHEMY, 25); + } else { + .@max=(is_trusted() ? 25 : 10); + mesc l("How many to brew? (%d-%d)", 1, .@max); + input(.@m, 1, .@max); + } + // Alchemy loop + .@i=0; + while (.@i < .@m) { + .@s=validatecraft(.@craft); + // Could not validate (not enough resources) + if (!.@s) { + mesc l("Insufficient materials to continue."), 1; + if (.@i) + mesc l("Only %d/%d units were produced.", .@i, .@m), 1; + break; + } + .@s=usecraft(.@craft); + .@i++; + // Exploiting?! + if (!.@s) + break; + } + .success=true; + } + deletecraft .@craft; + setskin ""; + return .success; +} + +//////////////////////////////////////////////////////////////////////////////// +// Build the various crafting tables on the world +001-2,92,76,0 script #AlchemyTable000 NPC_NO_SPRITE,{ + title l("Alchemy Lab"); + mes l("This is an alchemy lab."); + mes l("With it, you can combine reagents together to create powerful potions."); + next; + mes b(l("Drag & drop 2 items from your inventory. All items used will be lost.")); + if (AlchemySystem()) + mesc l("Success!"), 3; + else + mesc l("That didn't work!"), 1; + close; + +OnInit: + .distance=2; + end; +} + +// Tonori Region (0~99) +001-2,92,89,0 duplicate(#AlchemyTable000) #AlchemyTable001 NPC_NO_SPRITE +001-2,98,76,0 duplicate(#AlchemyTable000) #AlchemyTable002 NPC_NO_SPRITE +001-2,98,89,0 duplicate(#AlchemyTable000) #AlchemyTable003 NPC_NO_SPRITE + +// Argaes Region (100~199) +026-2,35,117,0 duplicate(#AlchemyTable000) #AlchemyTable100 NPC_NO_SPRITE + +// Candor Region (200~299) +029-2,113,57,0 duplicate(#AlchemyTable000) #AlchemyTable200 NPC_NO_SPRITE + + + + -- cgit v1.2.3-70-g09d2