diff options
-rw-r--r-- | npc/functions/util.txt | 20 | ||||
-rw-r--r-- | npc/magic/transmigration.txt | 37 |
2 files changed, 40 insertions, 17 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 0e50e2d30..df4cc8463 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -699,6 +699,26 @@ function script mlearn { return true; } */ +// transcheck( {item 1, amount 1}, {item 2, amount 2}... ) +// returns true upon success +function script transcheck { + if (getargcount() < 2 || getargcount() % 2 != 0) + return Exception("Faulty learning skill command invoked - error"); + + // Count items + for (.@i=0;.@i < getargcount(); .@i++) { + if (countitem(getarg(.@i)) < getarg(.@i+1)) + return false; + .@i++; + } + + // Delete Items + for (.@i=0;.@i < getargcount(); .@i++) { + delitem getarg(.@i), getarg(.@i+1); + .@i++; + } + return true; +} // Returns a value defining your current magic control (affects success ratio, higher is better) // A value of '5' means perfect control, and a value of '0' means overwhelm. 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; |