daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. turn {
  2.   if (!$1) { echo LOL NO TRY AGAIN | return }
  3.   var %curr = $replace($1,_,$chr(32))
  4.   writeini encounter.ini Encounter turn $1
  5.   var %hp = $readini(encounter.ini,$1,hp)
  6.   var %mhp = $readini(encounter.ini,$1,mhp)
  7.   var %hpp = $calc( %hp / %mhp )
  8.   var %hpc = 04
  9.   if ( %hpp >= .2 ) var %hpc = 07
  10.   if ( %hpp >= .5 ) var %hpc = 03
  11.   var %hpbarnum = $ceil($calc( %hpp * 40 ))
  12.   var %hpbar = [ $+ %hpc $+ $str(¤,%hpbarnum) $+ 15 $+ $str(¤,$calc(40 - %hpbarnum)) $+ ]
  13.   var %sp = $readini(encounter.ini,$1,sp)
  14.   var %msp = $readini(encounter.ini,$1,msp)
  15.   var %spp = $calc( %sp / %msp )
  16.   var %spbarnum = $ceil($calc( %spp * 40 ))
  17.   var %spbar = [6 $+ $str(¤,%spbarnum) $+ 15 $+ $str(¤,$calc(40 - %spbarnum)) $+ ]
  18.   var %class = $readini(encounter.ini,$1,class)
  19.   var %hide = $readini(encounter.ini,$1,hide)
  20.   msg # TURN:  $+ $mcol(%curr) ( $+ %class $+ )
  21.   if (!%hide) {
  22.     msg # HP:  $+ %hpc $+ %hp $+ / $+ %mhp $+  %hpbar
  23.     msg # SP: 06 $+ %sp $+ / $+ %msp $+  %spbar
  24.   }
  25.   else if (%hide == BAR) {
  26.     msg # HP:  $+ %hpc $+ ??? %hpbar
  27.     msg # SP: 06 $+ ??? %spbar
  28.   }
  29.   else if (%hide == HIDE) {
  30.     msg # HP:  $+ %hpc $+ ???
  31.     msg # SP: 06 $+ ???
  32.   }
  33.   TOcopy
  34.   msg # NEXT: $mcol($nextTO)
  35. }
  36. next {
  37.   turn $nextturn
  38. }
  39. nextturn {
  40.   if ($lines(queue.txt) > 0) {
  41.     return $nextqueue
  42.   }
  43.   while ($lines(queue.txt) == 0) {
  44.     clocktick
  45.     var %combatants = $ini(encounter.ini,0)
  46.     var %comb = 1
  47.     while (%comb <= %combatants) {
  48.       if ($readini(encounter.ini,$ini(encounter.ini,%comb),CT) >= 100) { write queue.txt $ini(encounter.ini,%comb) | echo $ini(encounter.ini,%comb) CT is 100+ }
  49.       inc %comb
  50.     }
  51.   }
  52.   return $nextqueue
  53. }
  54. clocktick {
  55.   var %comb = 1
  56.   while (%comb <= $ini(encounter.ini,0)) {
  57.     writeini encounter.ini $ini(encounter.ini,%comb) CT $calc($readini(encounter.ini,$ini(encounter.ini,%comb),CT) + $readini(encounter.ini,$ini(encounter.ini,%comb),speed))
  58.     inc %comb
  59.   }
  60. }
  61. nextqueue {
  62.   var %queuenum = $lines(queue.txt)
  63.   var %check = 1
  64.   var %bestCT = 0
  65.   while (%check <= %queuenum) {
  66.     var %curCT = $readini(encounter.ini,$read(queue.txt,%check),CT)
  67.     echo Checking combatant %check in queue. Best CT: %bestCT Combatant's CT: $readini(encounter.ini,$read(queue.txt,%check),CT)
  68.     if (%curCT >= 100 && (%curCT > %bestCT || (%curCT == %bestCT && $readini(encounter.ini,$read(queue.txt,%check),speed) > $readini(encounter.ini,%best,speed)))) {
  69.       var %best = $read(queue.txt,%check)
  70.       var %bestCT = $readini(encounter.ini,%best,CT)
  71.       echo NEW BEST: %best ( $+ %bestCT $+ )
  72.       var %delnum = %check
  73.     }
  74.     if (%curCT < 100) write -dl $+ %check queue.txt
  75.     else inc %check
  76.   }
  77.   write -dl $+ %delnum queue.txt
  78.   if (%best) writeini encounter.ini %best CT $calc($readini(encounter.ini,%best,CT) - 100)
  79.   if (%best) return %best
  80. }
  81.  
  82.  
  83.  
  84.  
  85. ; WHEN PEOPLE JOIN THE BATTLE MAKE SURE YOU WRITE THEIR SPEED TO TO.ini AS WELL
  86.  
  87. TOcopy {
  88.   var %comb = 1
  89.   while (%comb <= $ini(encounter.ini,0)) {
  90.     writeini TO.ini $ini(encounter.ini,%comb) CT $readini(encounter.ini,$ini(encounter.ini,%comb),CT)
  91.     inc %comb
  92.   }
  93.   var %count = $lines(TOqueue.txt)
  94.   while (%count) {
  95.     write -dl TOqueue.txt 1
  96.     dec %count
  97.   }
  98. }
  99. nextTO {
  100.   var %comb = 1
  101.   while (%comb <= %combatants) {
  102.     if ($readini(TO.ini,$ini(TO.ini,%comb),CT) >= 100) { write TOqueue.txt $ini(TO.ini,%comb) }
  103.     inc %comb
  104.   }
  105.   if ($lines(TOqueue.txt) > 0) {
  106.     return $nextTOqueue
  107.   }
  108.   while ($lines(TOqueue.txt) == 0) {
  109.     TOclocktick
  110.     var %combatants = $ini(TO.ini,0)
  111.     var %comb = 1
  112.     while (%comb <= %combatants) {
  113.       if ($readini(TO.ini,$ini(TO.ini,%comb),CT) >= 100) { write TOqueue.txt $ini(TO.ini,%comb) }
  114.       inc %comb
  115.     }
  116.   }
  117.   return $nextTOqueue
  118. }
  119. TOclocktick {
  120.   var %comb = 1
  121.   while (%comb <= $ini(TO.ini,0)) {
  122.     writeini TO.ini $ini(TO.ini,%comb) CT $calc($readini(TO.ini,$ini(TO.ini,%comb),CT) + $readini(encounter.ini,$ini(TO.ini,%comb),speed))
  123.     inc %comb
  124.   }
  125. }
  126. nextTOqueue {
  127.   var %queuenum = $lines(TOqueue.txt)
  128.   var %check = 1
  129.   var %bestCT = 0
  130.   while (%check <= %queuenum) {
  131.     var %curCT = $readini(TO.ini,$read(TOqueue.txt,%check),CT)
  132.     if (%curCT >= 100 && (%curCT > %bestCT || (%curCT == %bestCT && $readini(encounter.ini,$read(queue.txt,%check),speed) > $readini(encounter.ini,%best,speed)))) {
  133.       var %best = $read(TOqueue.txt,%check)
  134.       var %bestCT = $readini(TO.ini,%best,CT)
  135.       echo NEW BEST: %best ( $+ %bestCT $+ )
  136.       var %delnum = %check
  137.     }
  138.     if (%curCT < 100) write -dl $+ %check TOqueue.txt
  139.     else inc %check
  140.   }
  141.   write -dl $+ %delnum TOqueue.txt
  142.   if (%best) writeini TO.ini %best CT $calc($readini(TO.ini,%best,CT) - 100)
  143.   if (%best) return %best
  144. }
  145. TO {
  146.   TOcopy
  147.   var %num = $iif($1,$1,10)
  148.   var %TO = TURN ORDER:
  149.   var %count = 1
  150.   while (%count <= %num) {
  151.     var %TO = %TO $mcol($nextTO)
  152.     inc %count
  153.   }
  154.   msg # %TO
  155. }
RAW Paste Data
Top