OFFR500

Edited version of Greatkhan's level announcer for levelers

Apr 12th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //exp poster via dropbox
  2. //stole some code from hostile handler
  3. //Originally posted by Greatkhan
  4. //Edited by OFFR500 so that this would also post current level progress as %, and so that it would post to both the "Character only" file and the "All chars running" file.
  5. //I take no credit for the scripts used, I stole them from NTExp.ntj which says "Original Concept and Code by petrus2, Modified by Provalone" ^.^
  6.  
  7. var MilTime;
  8. var EXPLogA = "logs/EXPLog/Dropbox/Public/" + me.name + "_XPLog.txt";
  9. var EXPLogB = "logs/EXPLog/Dropbox/Public/XPLog.txt";
  10. var TheTime = MyTime();
  11. var Today = new Date().toLocaleFormat("%d %b");
  12.  
  13. var _TotalExp = [0, 0, 500, 1500, 3750, 7875, 14175, 22680, 32886, 44396, 57715, 72144, 90180, 112725, 140906, 176132, 220165, 275207, 344008, 430010, 537513, 671891, 839864, 1049830, 1312287, 1640359, 2050449, 2563061, 3203826, 3902260, 4663553, 5493363, 6397855, 7383752, 8458379, 9629723, 10906488, 12298162, 13815086, 15468534, 17270791, 19235252, 21376515, 23710491, 26254525, 29027522, 32050088, 35344686, 38935798, 42850109, 47116709, 51767302, 56836449, 62361819, 68384473, 74949165, 82104680, 89904191, 98405658, 107672256, 117772849, 128782495, 140783010, 153863570, 168121381, 183662396, 200602101, 219066380, 239192444, 261129853, 285041630, 311105466, 339515048, 370481492, 404234916, 441026148, 481128591, 524840254, 572485967, 624419793, 681027665, 742730244, 809986056, 883294891, 963201521, 1050299747, 1145236814, 1248718217, 1361512946, 1484459201, 1618470619, 1764543065, 1923762030, 2097310703, 2286478756, 2492671933, 2717422497, 2962400612, 3229426756, 3520485254, 0, 0];
  14. var _ExpToNextLvl = [0, 500, 1000, 2250, 4125, 6300, 8505, 10206, 11510, 13319, 14429, 18036, 22545, 28181, 35226, 44033, 55042, 68801, 86002, 107503, 134378, 167973, 209966, 262457, 328072, 410090, 512612, 640765, 698434, 761293, 829810, 904492, 985897, 1074627, 1171344, 1276765, 1391674, 1516924, 1653448, 1802257, 1964461, 2141263, 2333976, 2544034, 2772997, 3022566, 3294598, 3591112, 3914311, 4266600, 4650593, 5069147, 5525370, 6022654, 6564692, 7155515, 7799511, 8501467, 9266598, 10100593, 11009646, 12000515, 13080560, 14257811, 15541015, 16939705, 18464279, 20126064, 21937409, 23911777, 26063836, 28409582, 30966444, 33753424, 36791232, 40102443, 43711663, 47645713, 51933826, 56607872, 61702579, 67255812, 73308835, 79906630, 87098226, 94937067, 103481403, 112794729, 122946255, 134011418, 146072446, 159218965, 173548673, 189168053, 206193177, 224750564, 244978115, 267026144, 291058498, 0, 0];
  15. var _startLvl;
  16. var _startExp;
  17. var _startTime;
  18. var _prop = GetXPToLevel();
  19.  
  20. function NTMain(){
  21. Include("libs/common/NTExp.ntl");
  22. Include("libs/common/NTCommon.ntl");
  23. NTC_IncludeLibs();
  24. NTC_IncludeConfig("NTBot/char_configs");
  25. NT_LoadConfig();
  26. NTSI_LoadNIPFiles("NTBot/item_configs");
  27. NTA_Initialize();
  28.  
  29. XPLog = FileOpen(EXPLogA, 2);
  30. //XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") Level " + me.GetStat(12) + " (Current Level Progress " + _prop + "): Stopping at: " + NTConfig_stopLevel);
  31. //XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") level " + me.GetStat(12) + " (" + me.GetStat(13) + " exp)");
  32. XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") level " + me.GetStat(12) + " (Current Level Progress " + _prop + ")");
  33. XPLog.Close(); Delay(Random(100,200));
  34.  
  35. XPLog = FileOpen(EXPLogB, 2);
  36. //XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") level " + me.GetStat(12) + " (Current Level Progress " + _prop + "): Stopping at: " + NTConfig_stopLevel);
  37. //XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") level " + me.GetStat(12) + " (" + me.GetStat(13) + " exp)");
  38. XPLog.WriteLine(Today + " - " + TheTime + " - " + me.name + " (*" + me.account + ") Level " + me.GetStat(12) + " (Current Level Progress " + _prop + ")");
  39. XPLog.Close(); Delay(Random(100,200));
  40.  
  41. Say("Posted Exp");
  42. NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END");
  43. }
  44.  
  45. function NTE_InitializeStats() {
  46.     _startLvl = me.GetStat(12);
  47.     _startExp = me.GetStat(13);
  48.     if (_startExp < 0 || _startLvl >= 86) { _startExp = (2147483648 + _startExp); }
  49.     if (_startExp < 2147483648 && _startLvl >= 97) { _startExp = (2147483648 + _startExp); }
  50.  
  51.     _startTime = GetTickCount();
  52.     //Print("Exp = " + _startExp);
  53.     //Print("Level = " + _startLvl);
  54.  
  55. }
  56.  
  57. function GetXPToLevel()
  58. {
  59. var _endLvl = me.GetStat(12);
  60.     var _lvlsGained = _endLvl - _startLvl;
  61.     var _endExp = me.GetStat(13);
  62.     if (_endExp < 0 || _endLvl >= 86) { _endExp = (2147483648 + _endExp); }
  63.     if (_endExp < 2147483648 && _endLvl >= 97) { _endExp = (2147483648 + _endExp); }
  64.  
  65.     var _endLvlExp = _TotalExp[_endLvl];
  66.     var _expGained = _endExp - _startExp;
  67.     var _endTime = GetTickCount();
  68.     if (_expGained <= 0) { _expGained = '0'; }
  69.  
  70.     // Calculate percent of Exp obtained toward next level
  71.     // Remaining Exp / Exp needed to level
  72.     var _progressPercent = parseInt(1000 * (_endExp - _endLvlExp) / _ExpToNextLvl[_endLvl],10) / 10;
  73.     if(_progressPercent >= 0) { var _prop = _progressPercent + "%"; } else { var _prop = "0%"; };
  74.  
  75.     // Estimate number of runs remaining until next level based on Exp gained
  76.     // Remaining Exp needed to level / Exp Gained
  77.     if(_expGained > 0)
  78.     {   var _runsToLevel = (100 - _progressPercent) * _ExpToNextLvl[_endLvl] / (100 * _expGained);
  79.         if(_runsToLevel > 10) {_runsToLevel = parseInt(_runsToLevel,10); } else { _runsToLevel = parseInt(100 * _runsToLevel,10) / 100; };
  80.         _runsToLvl = addSeparatorsNF(_runsToLevel, ",", ".", ",")
  81.     }
  82.     else {if(_endLvl == 99) {var _runsToLvl = 'You have reached Level 99';} else {var _runsToLvl = 'NA'}}
  83.        
  84.     var GameIP = me.gameserverip.split(".")[3];
  85.     if(!GameIP) { GameIP = "Single Player"; }
  86.     var RunTime = parseInt(((_endTime - _startTime) / 60000),10) + "m " + (parseInt(((_endTime - _startTime) / 1000),10) - parseInt(((_endTime - _startTime) / 60000),10) * 60) + "s";
  87.    
  88.     if(_lvlsGained > 0) var DidGainLvl = COLOR_1 + "\n Levels Gained : " + COLOR_1 + _lvlsGained;
  89.     else if(_lvlsGained < 1) var DidGainLvl = "";
  90.    
  91.     //----------------------------------
  92.     //petrus2 edit starts here
  93.     //----------------------------------
  94.    
  95.     var _timeToLvl = (_runsToLevel * (_endTime - _startTime)) ;
  96.    
  97.     if(_expGained > 0)
  98.     {   if (_timeToLvl >= 86400000)
  99.             var TimeToLvl = parseInt((_timeToLvl / 86400000),10) + "d " + (parseInt((_timeToLvl / 3600000),10) - parseInt((_timeToLvl / 86400000),10) * 24)  + "h " + (parseInt((_timeToLvl / 60000),10) - parseInt((_timeToLvl / 3600000),10) * 60) + "m " + (parseInt((_timeToLvl / 1000),10) - parseInt((_timeToLvl / 60000),10) * 60) + "s";
  100.         else
  101.             {   if (_timeToLvl >= 3600000)
  102.                     var TimeToLvl = parseInt((_timeToLvl / 3600000),10) + "h " + (parseInt((_timeToLvl / 60000),10) - parseInt((_timeToLvl / 3600000),10) * 60) + "m " + (parseInt((_timeToLvl / 1000),10) - parseInt((_timeToLvl / 60000),10) * 60) + "s";
  103.                 else
  104.                     var TimeToLvl = parseInt((_timeToLvl / 60000),10) + "m " + (parseInt((_timeToLvl / 1000),10) - parseInt((_timeToLvl / 60000),10) * 60) + "s";
  105.             }
  106.     }
  107.     else var TimeToLvl = "NA";
  108.    
  109.    
  110.     //if(_runsToLvl == 'You have reached Level 99') var LvLProgXP = "";
  111.     //else if(_runsToLvl != 'You have reached Level 99') var LvLProgXP = COLOR_4 + "\n Est. Time Until Next Level: " + COLOR_2 + TimeToLvl + COLOR_4 + "\n Est. Runs Until Next Level: " + COLOR_2 + _runsToLvl + COLOR_4 + "\n Current Level Progress: " + COLOR_2 + _prop + COLOR_4 + "\n Experience Gained: " + COLOR_2 + addSeparatorsNF(_expGained, ",", ".", ",");
  112. return _prop;
  113.  
  114. }
  115.  
  116. function MyTime()
  117. {
  118. var now  = new Date();
  119. var HR  = now.getHours();
  120. var MM   = now.getMinutes();
  121. var SS   = now.getSeconds();
  122. var MS  = now.getMilliseconds();
  123. var DT;
  124.  
  125. if(!MilTime) {
  126.   if (HR < 12) { DT = "AM"; }
  127.   if (HR > 11) { DT = "PM"; }
  128.   if (HR > 12) { HR = HR - 12; }
  129.   if (HR == 0) { HR = 12; }
  130. }
  131. if (HR < 10) { HR = "0" + HR; }
  132. if (MM < 10) { MM = "0" + MM; }
  133. if (SS < 10) { SS = "0" + SS; }
  134. if (MS < 10) { MS = "0" + MS; }
  135.  
  136. return HR + ":" + MM + " " + DT;
  137. if(MilTime) TheTime = HR + ":" + MM + ":" + SS + "." + MS;
  138. else TheTime = HR + ":" + MM + ":" + SS + "." + MS + " " + DT;
  139. return TheTime;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment