From e4fb06529d6f26eef45930094607324504d8c836 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 13 Sep 2018 14:14:53 -0300 Subject: This should simplify pet_detective logic --- npc/017-1/pet_detective.txt | 17 ++--------------- npc/functions/petsales.txt | 30 ++++++++++++++++++++++++++++++ npc/scripts.conf | 1 + 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 npc/functions/petsales.txt diff --git a/npc/017-1/pet_detective.txt b/npc/017-1/pet_detective.txt index 2eb1d47e9..1a7c69e5b 100644 --- a/npc/017-1/pet_detective.txt +++ b/npc/017-1/pet_detective.txt @@ -49,21 +49,8 @@ L_Menu: mes ""; switch (@menu) { case 1: - .@price=30**(PETMEMO[GHQ_GetQuestIDByMonsterID(ForestMushroom)]+1); - mesn; - mesq l("That'll cost you @@ @@.", .@price, getitemlink(MushroomSpores)); - next; - if (askyesno() == ASK_YES) { - if (countitem(MushroomSpores) >= .@price && .stock) { - delitem MushroomSpores, .@price; - makepet ForestMushroom; - getexp .@price*100, 0; - PETMEMO[GHQ_GetQuestIDByMonsterID(ForestMushroom)]+=1; - .stock-=1; - mesn; - mesq l("There you go!"); - } - } + if (PDQ_InnerSwitch(ForestMushroom, MushroomSpores, 30)) + .stock-=1; break; default: closedialog; diff --git a/npc/functions/petsales.txt b/npc/functions/petsales.txt new file mode 100644 index 000000000..68dc46d24 --- /dev/null +++ b/npc/functions/petsales.txt @@ -0,0 +1,30 @@ +// TMW-2 Script +// Author: Jesusalva +// Desc: Grand Hunter Pet Quest Utils. +// Note: Remember to update GHQ and pet_detective on LoF Village (017-1) + +// Core logic for Pet Detective. Doesn't checks for stock, allowing exploits. +// MobID, ItemID, Base Value +function script PDQ_InnerSwitch { + + .@mid=getarg(0); + .@iid=getarg(1); + .@val=getarg(2, 30); + + .@price=.@val**(PETMEMO[GHQ_GetQuestIDByMonsterID(.@mid)]+1); + mesn; + mesq l("That'll cost you @@ @@.", .@price, getitemlink(.@iid)); + next; + if (askyesno() == ASK_YES) { + if (countitem(.@iid) >= .@price) { + delitem .@iid, .@price; + makepet .@mid; + getexp .@price*BaseLevel, 0; + PETMEMO[GHQ_GetQuestIDByMonsterID(.@mid)]+=1; + mesn; + mesq l("There you go!"); + return 1; + } + } + return 0; +} diff --git a/npc/scripts.conf b/npc/scripts.conf index 4fbe83ec1..5f3ce9e70 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -44,6 +44,7 @@ "npc/functions/npcmove.txt", "npc/functions/npcmovegraph.txt", "npc/functions/nurse.txt", +"npc/functions/petsales.txt", "npc/functions/questgen.txt", "npc/functions/refine.txt", "npc/functions/riddle.txt", -- cgit v1.2.3-60-g2f50