From c52867f3e29d35044fad5c74e42cf5f28809b3e3 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 10 Aug 2019 22:26:02 -0300 Subject: Introduce a transcheck helper to optimize transmigration code --- npc/magic/transmigration.txt | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'npc/magic') diff --git a/npc/magic/transmigration.txt b/npc/magic/transmigration.txt index ddc2dcdc8..cd04b9fcd 100644 --- a/npc/magic/transmigration.txt +++ b/npc/magic/transmigration.txt @@ -26,6 +26,7 @@ OnCall: mes ""; menuint l("Crazy Rum"), CrazyRum, + rif(false, l("Downgrade Snake Skin")), SnakeSkin, l("Mouboo Figurine"), MoubooFigurine; mes ""; @@ -33,15 +34,23 @@ OnCall: // Requeriments listing switch (@menuret) { - case CrazyRum: - mesc l("* @@/@@ @@", countitem(Plushroom), 10, getitemlink(Plushroom)); - mesc l("* @@/@@ @@", countitem(Milk), 1, getitemlink(Milk)); - break; - case MoubooFigurine: - mesc l("* @@/@@ @@", countitem(WoodenLog), 1, getitemlink(WoodenLog)); - break; - default: - Exception("ERROR, INVALID TRANSMIGRATION OPTION", RB_DEFAULT|RB_SPEECH); @menuret=0; break; + case CrazyRum: + mesc l("* @@/@@ @@", countitem(Plushroom), 10, getitemlink(Plushroom)); + mesc l("* @@/@@ @@", countitem(Milk), 1, getitemlink(Milk)); + break; + case MoubooFigurine: + mesc l("* @@/@@ @@", countitem(WoodenLog), 1, getitemlink(WoodenLog)); + break; + case SnakeSkin: + //mesc l("* @@/@@ @@", countitem(WoodenLog), 1, getitemlink(WoodenLog)); + menuint + rif(countitem(BlackMambaSkin), l("Black Mamba Skin -> Mountain Snake Skin")), MountainSnakeSkin, + rif(countitem(MountainSnakeSkin), l("Mountain Snake Skin -> Snake Skin")), SnakeSkin, + rif(countitem(SnakeSkin), l("Snake Skin -> Cave Snake Skin")), CaveSnakeSkin, + l("Cancel"); + break; + default: + Exception("ERROR, INVALID TRANSMIGRATION OPTION", RB_DEFAULT|RB_SPEECH); @menuret=0; break; } // Confirmation if (@menuret) { @@ -58,22 +67,16 @@ OnCall: // Check and Consume the reagents switch (@menuret) { case CrazyRum: - if (countitem(Plushroom) < 10 || - countitem(Milk) < 1) { + if (!transcheck(Plushroom, 10, Milk, 1)) { dispbottom l("Not enough items!"); end; } - // Consume items - delitem Plushroom, 10; - delitem Milk, 1; break; case MoubooFigurine: - if (countitem(WoodenLog) < 1) { + if (!transcheck(WoodenLog, 1)) { dispbottom l("Not enough items!"); end; } - // Consume items - delitem WoodenLog, 1; break; default: Exception("ERROR, INVALID TRANSMIGRATION REAGENTS", RB_DEFAULT|RB_SPEECH|RB_ISFATAL); break; -- cgit v1.2.3-70-g09d2