From a12c79f7828031b0e521ebf69afac47c347345e3 Mon Sep 17 00:00:00 2001 From: Aleos Date: Sun, 27 May 2018 16:07:39 -0400 Subject: [PATCH] Moved remaining refine NPC to the database (#3145) * Fixes #2510. * Added Holink and Wagjak values to their own entries in the refine database. * Added several anti-hack checks to refine NPC. Thanks to the suggestion from @mazvi and @Atemo! --- db/re/refine_db.yml | 30 ++++++++++++++++ doc/script_commands.txt | 2 ++ npc/merchants/advanced_refiner.txt | 23 ++++++++++--- npc/re/jobs/novice/academy.txt | 49 ++++++++++++--------------- npc/re/merchants/advanced_refiner.txt | 36 +++++++++++++------- npc/re/merchants/hd_refiner.txt | 28 +++++++++++++++ npc/re/merchants/refine.txt | 14 ++++++++ npc/re/merchants/ticket_refiner.txt | 17 ++++++++-- src/map/script_constants.hpp | 2 ++ src/map/status.hpp | 2 ++ 10 files changed, 157 insertions(+), 46 deletions(-) diff --git a/db/re/refine_db.yml b/db/re/refine_db.yml index f96e0d2d9a..0d8e473369 100644 --- a/db/re/refine_db.yml +++ b/db/re/refine_db.yml @@ -38,6 +38,12 @@ Armor: - Type: REFINE_COST_OVER10_HD Price: 100000 Material: 6225 + - Type: REFINE_COST_HOLINK + Price: 15000 + Material: 7619 + - Type: REFINE_COST_WAGJAK + Price: 20000 + Material: 985 Rates: - Level: 1 Bonus: 100 @@ -163,6 +169,12 @@ WeaponLv1: - Type: REFINE_COST_OVER10_HD Price: 100000 Material: 6226 + - Type: REFINE_COST_HOLINK + Price: 500 + Material: 7620 + - Type: REFINE_COST_WAGJAK + Price: 1000 + Material: 1010 Rates: - Level: 8 NormalChance: 60 @@ -254,6 +266,12 @@ WeaponLv2: - Type: REFINE_COST_OVER10_HD Price: 100000 Material: 6226 + - Type: REFINE_COST_HOLINK + Price: 2000 + Material: 7620 + - Type: REFINE_COST_WAGJAK + Price: 2000 + Material: 1011 Rates: - Level: 7 NormalChance: 60 @@ -350,6 +368,12 @@ WeaponLv3: - Type: REFINE_COST_OVER10_HD Price: 100000 Material: 6226 + - Type: REFINE_COST_HOLINK + Price: 20000 + Material: 7620 + - Type: REFINE_COST_WAGJAK + Price: 10000 + Material: 984 Rates: - Level: 6 NormalChance: 60 @@ -451,6 +475,12 @@ WeaponLv4: - Type: REFINE_COST_OVER10_HD Price: 100000 Material: 6226 + - Type: REFINE_COST_HOLINK + Price: 50000 + Material: 7620 + - Type: REFINE_COST_WAGJAK + Price: 20000 + Material: 984 Rates: - Level: 5 NormalChance: 60 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5d4eb1d491..a72b3f9e8b 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2768,6 +2768,8 @@ REFINE_COST_OVER10 - For refining over +10 REFINE_COST_HD - For refining with HD ores REFINE_COST_ENRICHED - For refining with enriched ores REFINE_COST_OVER10_HD - For refining over +10 with HD ores +REFINE_COST_HOLINK - For refining at Holink in Malangdo +REFINE_COST_WAGJAK - For refining at Refining Machine Wagjak in the Novice Academy This function will return required cost for refining based on argument. diff --git a/npc/merchants/advanced_refiner.txt b/npc/merchants/advanced_refiner.txt index de09883df1..ebe40b7d18 100644 --- a/npc/merchants/advanced_refiner.txt +++ b/npc/merchants/advanced_refiner.txt @@ -55,12 +55,14 @@ payon,157,146,6 script Suhnbi#cash 85,{ close; } + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count .@price = getequiprefinecost(.@part, REFINE_COST_ENRICHED, REFINE_ZENY_COST); .@material = getequiprefinecost(.@part, REFINE_COST_ENRICHED, REFINE_MATERIAL_ID); - // Make sure you have the neccessary items and Zeny to refine your items + // Make sure you have the necessary items and Zeny to refine your items // Determines chance of failure and verifies that you want to continue. - callsub S_RefineValidate,getequipweaponlv(.@part),.@material,.@price,.@part; + callsub S_RefineValidate,getequipweaponlv(.@part),.@material,.@price,.@part,.@refineitemid,.@refinerycnt; mes "[Suhnbi]"; mes "Clang! Clang! Clang!"; @@ -89,7 +91,8 @@ payon,157,146,6 script Suhnbi#cash 85,{ S_RefineValidate: .@weapon_lvl = getarg(0); .@item_req = getarg(1); - set .@price, getarg(2); + .@price = getarg(2); + .@part = getarg(3); // If the VIP system is enabled, the prices for non-VIP players are considerably higher. if (VIP_SCRIPT && !vip_status(VIP_STATUS_ACTIVE)) { @@ -109,7 +112,7 @@ S_RefineValidate: mes "Would you like to continue?"; next; if(select("Yes:No") == 1) { - if (getequippercentrefinery(getarg(3)) < 100) { + if (getequippercentrefinery(.@part) < 100) { if (.@weapon_lvl) { mes "[Suhnbi]"; mes "Wow!!"; @@ -152,6 +155,18 @@ S_RefineValidate: if (countitem(.@item_req) > 0 && Zeny > .@price) { delitem .@item_req,1; set Zeny, Zeny - .@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, getarg(4)) || + callfunc("F_IsEquipRefineHack", .@part, getarg(5))) { + mes "[Holink]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + return; } mes "[Suhnbi]"; diff --git a/npc/re/jobs/novice/academy.txt b/npc/re/jobs/novice/academy.txt index 11935f2559..e409e37e1b 100644 --- a/npc/re/jobs/novice/academy.txt +++ b/npc/re/jobs/novice/academy.txt @@ -12921,7 +12921,7 @@ izlude_d,153,126,1 duplicate(Refinery Owner Han#iz) Refinery Owner Han#iz_d 4_M_ if (isbegin_quest(5153) == 1) { if (getequipweaponlv(.@part) == 1) { mes "[Refining Machine Wagjak]"; - mes "Type : 1 level weapon"; + mes "Type : Level 1 weapon"; mes "Charge : Phracon, 1000 zeny"; mes "Service usage coupon sensed. No charge to be requested. Will you refine?"; next; @@ -12969,33 +12969,17 @@ izlude_d,153,126,1 duplicate(Refinery Owner Han#iz) Refinery Owner Han#iz_d 4_M_ } } } - switch(getequipweaponlv(.@part)) { - case 0: + + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count + .@price = getequiprefinecost(.@part, REFINE_COST_WAGJAK, REFINE_ZENY_COST); + .@material = getequiprefinecost(.@part, REFINE_COST_WAGJAK, REFINE_MATERIAL_ID); + + if ((getequipweaponlv(.@part) >= 1) && (getequipweaponlv(.@part) <= 4)) + .@type$ = "Level " + getequipweaponlv(.@part) + " weapon"; + else .@type$ = "Armor"; - .@material = 985;// Elunium - .@price = 20000; - break; - case 1: - .@type$ = "Level 1 weapon"; - .@material = 1010;// Phracon - .@price = 1000; - break; - case 2: - .@type$ = "Level 2 weapon"; - .@material = 1011;// Emveretarcon - .@price = 2000; - break; - case 3: - .@type$ = "Level 3 weapon"; - .@material = 984;// Oridecon - .@price = 10000; - break; - case 4: - .@type$ = "Level 4 weapon"; - .@material = 984;// Oridecon - .@price = 20000; - break; - } + mes "[Refining Machine Wagjak]"; mes "Type : "+ .@type$ +""; mes "Charge : "+ getitemname(.@material) +", "+ .@price +" zeny"; @@ -13025,6 +13009,17 @@ izlude_d,153,126,1 duplicate(Refinery Owner Han#iz) Refinery Owner Han#iz_d 4_M_ if (countitem(.@material) > 0 && Zeny >= .@price) { delitem .@material, 1; Zeny -= .@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Refining Machine Wagjak]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } } else { mes "[Refining Machine Wagjak]"; mes "^FF0000- error number 8282 -^000000"; diff --git a/npc/re/merchants/advanced_refiner.txt b/npc/re/merchants/advanced_refiner.txt index 574ca76030..d1f70dc946 100644 --- a/npc/re/merchants/advanced_refiner.txt +++ b/npc/re/merchants/advanced_refiner.txt @@ -70,33 +70,31 @@ malangdo,221,174,6 script Holink#mal_cash 559,{ close; } mes "[Holink]"; - // TODO: Price is different to Suhnbi of Payon. Intended? [Secret] - .@material = getequiprefinecost(.@part, REFINE_COST_ENRICHED, REFINE_MATERIAL_ID); + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count + .@price = getequiprefinecost(.@part, REFINE_COST_HOLINK, REFINE_ZENY_COST); + .@material = getequiprefinecost(.@part, REFINE_COST_HOLINK, REFINE_MATERIAL_ID); + switch(getequipweaponlv(.@part)) { default: case 0: // Armor - set .@price,15000; - set .@type$,"armor"; + .@type$ = "armor"; mes "You have chosen an armor, meow~"; break; case 1: // Level 1 Weapon - set .@price,500; - set .@type$,"weapon"; + .@type$ = "weapon"; mes "A level 1 weapon...?"; break; case 2: // Level 2 Weapon - set .@price,2000; - set .@type$,"weapon"; + .@type$ = "weapon"; mes "Meow, a level 2 weapon...?"; break; case 3: // Level 3 Weapon - set .@price,20000; - set .@type$,"weapon"; + .@type$ = "weapon"; mes "Meow Meow~~ A level 3 weapon~~"; break; case 4: // Level 4 Weapon - set .@price,50000; - set .@type$,"weapon"; + .@type$ = "weapon"; mes "Me-Meow!... A level 4 weapon...!"; mes "I've only seen it twice while"; mes "learning from Aragam... Me-Meow!!"; @@ -108,7 +106,7 @@ malangdo,221,174,6 script Holink#mal_cash 559,{ if(select("Yes!!:No!!") == 2) { mes "[Holink]"; mes "Kyack!!"; - mes "You don't belive in refine master Holink, meow?~"; + mes "You don't believe in refine master Holink, meow?~"; close; } if (getequippercentrefinery(.@part, true) < 100) { @@ -148,6 +146,18 @@ malangdo,221,174,6 script Holink#mal_cash 559,{ } delitem .@material,1; set Zeny, Zeny-.@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Holink]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + if (getequippercentrefinery(.@part, true) > rand(100)) { successrefitem .@part; mes "[Holink]"; diff --git a/npc/re/merchants/hd_refiner.txt b/npc/re/merchants/hd_refiner.txt index 533bba6d36..1f6c86661f 100644 --- a/npc/re/merchants/hd_refiner.txt +++ b/npc/re/merchants/hd_refiner.txt @@ -74,6 +74,8 @@ close; } + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count .@price = getequiprefinecost(.@part, REFINE_COST_HD, REFINE_ZENY_COST); .@material = getequiprefinecost(.@part, REFINE_COST_HD, REFINE_MATERIAL_ID); @@ -105,6 +107,18 @@ } delitem .@material,1; set Zeny, Zeny-.@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Blacksmith Mighty Hammer]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + mes "[Blacksmith Mighty Hammer]"; mes "Tac! Tac! Tac!"; if (getequippercentrefinery(.@part, true) > rand(100)) { @@ -200,6 +214,8 @@ lhz_in02,280,19,3 duplicate(MightyHammer) Mighty Hammer#lhz 826 mes "This weapon is perfect, no need to refine it anymore~"; close; } + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count .@price = getequiprefinecost(.@part, REFINE_COST_OVER10_HD, REFINE_ZENY_COST); .@material = getequiprefinecost(.@part, REFINE_COST_OVER10_HD, REFINE_MATERIAL_ID); switch(getequipweaponlv(.@part)) { @@ -253,6 +269,18 @@ lhz_in02,280,19,3 duplicate(MightyHammer) Mighty Hammer#lhz 826 } delitem .@material,1; set Zeny, Zeny-.@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Basta]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + mes "Pow! Pow! Pow! Pow!"; if (getequippercentrefinery(.@part, true) > rand(100)) { successrefitem .@part; diff --git a/npc/re/merchants/refine.txt b/npc/re/merchants/refine.txt index 81d8a34e09..e91b509110 100644 --- a/npc/re/merchants/refine.txt +++ b/npc/re/merchants/refine.txt @@ -439,6 +439,8 @@ malangdo,224,172,6 script Clink#mal_normal 544,{ close; } + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count .@price = getequiprefinecost(.@part, REFINE_COST_NORMAL, REFINE_ZENY_COST); .@material = getequiprefinecost(.@part, REFINE_COST_NORMAL, REFINE_MATERIAL_ID); @@ -502,6 +504,18 @@ malangdo,224,172,6 script Clink#mal_normal 544,{ } delitem .@material,1; Zeny = Zeny-.@price; + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Clink]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + if (getequippercentrefinery(.@part) <= rand(100)) { failedrefitem .@part; mes "[Clink]"; diff --git a/npc/re/merchants/ticket_refiner.txt b/npc/re/merchants/ticket_refiner.txt index 1e173135d4..eb2827562a 100644 --- a/npc/re/merchants/ticket_refiner.txt +++ b/npc/re/merchants/ticket_refiner.txt @@ -76,6 +76,8 @@ prontera,184,177,6 script Refine Master 851,{ mes "This item is impossible to refine."; close; } + .@refineitemid = getequipid(.@part); // save id of the item + .@refinerycnt = getequiprefinerycnt(.@part); //save refinery count switch(getequipweaponlv(.@part)) { default: case 0: @@ -143,9 +145,20 @@ prontera,184,177,6 script Refine Master 851,{ mes "I have my own special way to refine..."; mes ".......ka boom!"; specialeffect EF_SUI_EXPLOSION; - if (countitem(.@ticket_id)) + if (countitem(.@ticket_id)) { delitem .@ticket_id,1; - else { + + // anti-hack + if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) || + callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) { + mes "[Refine Master]"; + emotion ET_FRET; + mes "Wait a second..."; + mes "Do you think I'm stupid?!"; + mes "You switched the item while I wasn't looking! Get out of here!"; + close; + } + } else { next; mes "Error!"; mes "Please report this."; diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index f2be5ff4a4..0d31cc280e 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -4960,6 +4960,8 @@ export_constant(REFINE_COST_HD); export_constant(REFINE_COST_ENRICHED); export_constant(REFINE_COST_OVER10_HD); + export_constant(REFINE_COST_HOLINK); + export_constant(REFINE_COST_WAGJAK); export_constant(REFINE_COST_MAX); /* refine information types */ diff --git a/src/map/status.hpp b/src/map/status.hpp index 89c771035a..95b967e28a 100644 --- a/src/map/status.hpp +++ b/src/map/status.hpp @@ -44,6 +44,8 @@ enum refine_cost_type { REFINE_COST_HD, REFINE_COST_ENRICHED, REFINE_COST_OVER10_HD, + REFINE_COST_HOLINK, + REFINE_COST_WAGJAK, REFINE_COST_MAX };