// TMW2 scripts. // Authors: // Pyndragon // Jesusalva // Description: // Warp Crystal - script Warp Crystal NPC_HIDDEN,{ close; function ReturnItem { getitem @itemid, 1; @itemid=0; if (getarg(0, false)) end; return; } function Cooldown { mesn; mesc l("Successive warps cause time-space distortions and are thus not allowed."); mesc l("You can use it again in %s.", FuzzyTime(TELEPORTER_TIME)); ReturnItem(false); close; } OnUse: // Receives @dest$ if (@dest$ == "") ReturnItem(true); if (TELEPORTER_TIME > gettimetick(2)) Cooldown(); if (BaseLevel < 20) { dispbottom l("The might contained in this curious object is too powerful. You have to be at least level 20 to harness it."); ReturnItem(true); } // TODO: Are you already at target point? // In some cases, you're not allowed to use it if (@itemid == EvilWarpCrystal && !MK_WINNER) { dispbottom l("The Crystal doesn't react. You most likely cannot use this item yet."); ReturnItem(true); } // The chance to break is always at least 20% // Begins at 100% and each second will subtract 0.01% // It will never go below 5%, which happens after x seconds .@timet=limit(0, gettimetick(2)-TELEPORTER_TIME, 3600); .@prop=.@timet*2777/1000; // Make it range from 0~10000 .@adj_breakrate=limit( 500, .@prop, 9500 ); if ($EVENT$ == "Rebirth") .@adj_breakrate /= 2; else if ($EVENT$ == "Siege") .@adj_breakrate /= 3; //debugmes "Adjusted break ratio: %d", .@adj_breakrate; if (rand(10000) > .@adj_breakrate) ReturnItem(false); else getitem BrokenWarpCrystal, 1; // Apply Cooldown, same variable as LoF Teleporter, cancel ship travels TELEPORTER_TIME=gettimetick(2)+300; @timer_navio_running=0; // Save new location and warp you there EnterTown(@dest$); ReturnTown(); @itemid=0; end; }