// TMW2 Scripts // Author: // Jesusalva // Description: // Chagashroom → Red Plush Wine // Variables: // REDWINE_DATE = When the wine started being done // REDWINE_DONE = When the wine will be ready // REDWINE_AMMO = How much Wine you're trying to make // Success Rate is based on how much you're trying to do and how long ago that was 017-3,25,78,0 script Wine Making Barrel NPC_NO_SPRITE,{ goto L_Main; // redwine_chance() // Returns chance (0~10,000) to successfully obtain wine // REDWINE_DONE/REDWINE_DATE is taken in account function redwine_chance { .@max=10000; .@base=REDWINE_DATE;//-(REDWINE_DONE-REDWINE_DATE); // .@c = how much time is left until completion // .@d = original amount of time required // .@e = Current time .@c=REDWINE_DONE-.@base; //-gettimetick(2); .@d=REDWINE_DATE-.@base; //-REDWINE_DONE; .@e=gettimetick(2)-.@base; // We must divide everything by 10 to cause imprecision // aka. don't cause overflow bug .@c=.@c/10; .@d=.@d/10; .@e=.@e/10; //debugmes "%d - %d - %d", .@d, .@e, .@c; //debugmes "Start - Now - Finish"; if (.@c == 0) return .@max; if ($@GM_OVERRIDE) debugmes "Ratio: %d/%d = %d", .@e, .@c, (.@e*.@max)/.@c; return min(10000, (.@e*.@max)/.@c); } L_Main: if (!REDWINE_DATE) { mesn; mesc l("Do you want to make wine?"); next; select l("Information"), l("Yes"), l("No"); mes ""; switch (@menu) { case 1: mesc l("Produced item:"); mesc l("@@", getitemlink(RedPlushWine)); mes ""; mesc l("Cost per two glass:"); mesc l("* @@/@@ @@", countitem(SeaDrops), 1, getitemlink(SeaDrops)); mesc l("* @@/@@ @@", countitem(Plushroom), 1, getitemlink(Plushroom)); mesc l("* @@/@@ @@", countitem(Chagashroom), 30, getitemlink(Chagashroom)); mesc l("* @@ Water Bottle", 1); next; break; case 2: mesc l("How many batches do you want to produce? (max. 5)"); input .@glass_count; if (.@glass_count < 1 || .@glass_count > 5 || countitem(SeaDrops) < .@glass_count || countitem(Plushroom) < .@glass_count || countitem(Chagashroom) < .@glass_count*30 ) { mesc l("Not enough ingredients or invalid amount."), 1; break; } mesc l("Which water will you use?"); mesc l("The bottom-most the water, the better the bonus."); menuint l("Cancel"), -1, rif(countitem(BottleOfSewerWater) >= .@glass_count, l("Sewer Water")), 0, rif(countitem(BottleOfSeaWater) >= .@glass_count, l("Sea Water")), 3600, rif(countitem(BottleOfTonoriWater) >= .@glass_count, l("Tonori Water")), 11760, rif(countitem(BottleOfWoodlandWater) >= .@glass_count, l("Woodland Water")), 12000, rif(countitem(BottleOfDivineWater) >= .@glass_count, l("Divine Water")), 21600; mes ""; if (@menuret < 0) break; switch (@menuret) { case 0: .@bonus=@menuret; .@water=BottleOfSewerWater; break; case 3600: .@bonus=@menuret; .@water=BottleOfSeaWater; break; case 11760: .@bonus=@menuret; .@water=BottleOfTonoriWater; break; case 12000: .@bonus=@menuret; .@water=BottleOfWoodlandWater; break; case 21600: .@bonus=@menuret; .@water=BottleOfDivineWater; break; default: mesc l("Error, invalid return code, blame Saulc"), 1; mes "==== SCRIPT ABORTED"; close; } // Save data delitem SeaDrops, .@glass_count; delitem Plushroom, .@glass_count; delitem Chagashroom, .@glass_count*30; delitem .@water, .@glass_count; REDWINE_AMMO=.@glass_count; REDWINE_DATE=gettimetick(2); REDWINE_DONE=gettimetick(2)-.@bonus+.mintime; REDWINE_DONE+=(.cuptime-(.@bonus/3))*REDWINE_AMMO; break; case 3: close; break; } goto L_Main; } else { mesn; mesc l("Your request for @@ @@ are being fermented for @@.", REDWINE_AMMO, getitemlink(RedPlushWine), FuzzyTime(REDWINE_DATE)); next; inventoryplace RedPlushWine, REDWINE_AMMO; mesn; mes l("Trying to retrieve it now will have @@ % chance to be successful.", redwine_chance()/100); if (redwine_chance()/100 < 1) close; mes l("Attempt to retrieve it now?"); next; if (askyesno() == ASK_YES) { if (rand(1000,10000) < redwine_chance()) { mesc l("Success!"), 3; getitem RedPlushWine, REDWINE_AMMO*2; } else { mesc l("The wine wasn't ready yet and you lost it..."), 1; } REDWINE_DATE=0; REDWINE_AMMO=0; } } close; OnInit: .sex = G_OTHER; .distance = 4; // Time to make each batch .cuptime=(60*60*6); // Base time to make any amount of cups .mintime=(60*60*24); end; }