Advertisement
h3x3r0

npc rate compare php test

Jun 8th, 2022
1,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.18 KB | None | 0 0
  1. RPG-CLUB npc rate compare -> test
  2.  
  3. <?php
  4. $st=file('stock.txt');
  5. foreach($st as $k=>$v)$st[$k]=trim($v);
  6. $res=file('res.txt');
  7. foreach($res as $k=>$v)$res[$k]=trim($v);
  8. $c1='corpse_make_list=';
  9. $c2='additional_make_list=';
  10. $c3='additional_make_multi_list=';
  11. $c4='ex_item_drop_list=';
  12. $c5='};{{{';
  13. $c6='};{';
  14. $npc='';
  15. $npc_id=0;
  16. $grate='';
  17. function np($v){
  18.     global $npc,$npc_id;
  19.     $a=explode("\t",$v);
  20.     if(count($a)>3)
  21.     $npc_id=trim($a[2]);
  22.     $npc=trim($a[3]);
  23. }
  24. function p3($l){
  25.     return str_replace('=','',$l);
  26. }
  27. function p2($l){
  28.     return str_replace('{','',str_replace('}','',$l));
  29. }
  30. $pzz=array();$pza=array();$oth=array();
  31. function p1($v,$c,$o1,$o2,$lo=false){
  32.             global $npc,$npc_id,$op,$c1,$c2,$c3,$c4,$st,$res,$grate,$ii,$il,$pzz,$pza,$oth;
  33.             $il2=0;$ii2=0;
  34.             $cc=trim($c);
  35.             $z=explode($c,$v);
  36.             $bb=explode('acquire_rp=',$v);
  37.             if(count($bb)>1){
  38.                 $bb=explode("\t",$bb[1]);
  39.                 $bb=intval(trim($bb[0]));
  40.             }else $bb=0;
  41.             if(count($z)>1){
  42.             $op=0;
  43.                 $z=explode("\t",$z[1]);
  44.                 $z=trim($z[0]);
  45.                 $old=$z;
  46.                 $ol2='';
  47.                 $z=explode($o1,$z);
  48.                 if($z[0]!='{}')
  49.                 foreach($z as $v2){
  50.                     $z2=explode($o2,$v2);
  51.                     $pz2='';
  52.                     $oz=explode('}};',$v2);
  53.                     if(count($oz)>1){
  54.                         $pz2=p2(end($oz));
  55.                         $op+=$pz2;
  56.                     }
  57.                     $op2=0;
  58.                     $op3=0;
  59.                     $ao=array();
  60.                     $x=0;
  61.                     foreach($z2 as $v2){
  62.                         $p='';
  63.                         $o=explode('}};',$v2);
  64.                         if(count($o)>1){
  65.                             $p=p2(end($o));
  66.                             $op2+=$p;
  67.                         }
  68.                         $o=explode(';',$v2);
  69.                         foreach($o as $ov=>$ok)$o[$ov]=trim(p2($ok));
  70.                         $op3+=$o[3];
  71.                         $ozz=$o[0];
  72.                         $ao[$x][0]=$o[0];
  73.                         $ao[$x][1]=$o[1];
  74.                         $ao[$x][2]=$o[2];
  75.                         $ao[$x][3]=$o[3];
  76.                         $x++;
  77.                     }
  78.                     if($op3>0){
  79.                         $op4=$op3;
  80.                         if($c1==$c){
  81.                         $opz=0;
  82.                             $ol='';
  83.                             foreach($ao as $opp) { if($opp[0]!=''){
  84.                                 if($lo){
  85.                                 if(!isset($pza[$npc]))$pza[$npc]=array();if(!isset($pza[$npc][$opp[0]]))$pza[$npc][$opp[0]]=0;
  86.                                 $pza[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3];
  87.                                 }else{
  88.                                 if(!isset($pzz[$npc]))$pzz[$npc]=array();if(!isset($pzz[$npc][$opp[0]]))$pzz[$npc][$opp[0]]=0;
  89.                                 $pzz[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3];
  90.                                 }
  91.                             if($ol!='')$ol.=';'; $ol.='{'.$opp[0].';'.$opp[1].';'.$opp[2].';'.$opp[3].'}';
  92.                             }
  93.                             }
  94.                             $ol='{'.$ol.'}';
  95.                             $ol2=$ol;
  96.                         }else
  97.                         if($c2==$c){
  98.                             $ol='';
  99.                              foreach($ao as $opk=>$opp) { if($opp[0]!=''){
  100.                                 if($lo){
  101.                                 if(!isset($pza[$npc]))$pza[$npc]=array();if(!isset($pza[$npc][$opp[0]]))$pza[$npc][$opp[0]]=0;
  102.                                 $pza[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3];
  103.                                 }else{
  104.                                 if(!isset($pzz[$npc]))$pzz[$npc]=array();if(!isset($pzz[$npc][$opp[0]]))$pzz[$npc][$opp[0]]=0;
  105.                                 $pzz[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3];
  106.                                 }
  107.                                 if($ol!='')$ol.=';'; $ol.='{'.$opp[0].';'.$opp[1].';'.$opp[2].';'.$opp[3].'}';
  108.                              }
  109.                              }
  110.                             $ol='{'.$ol.'}';
  111.                             $ol2=$ol;
  112.                         }else
  113.                         if($c3==$c){
  114.                         if($ao[$opk][2]<1)$ao[$opk][2]=1;
  115.                             $ol='';
  116.                             foreach($ao as $opp) { if($opp[0]!=''){
  117.                             if($lo){
  118.                             if(!isset($pza[$npc]))$pza[$npc]=array();if(!isset($pza[$npc][$opp[0]]))$pza[$npc][$opp[0]]=0;
  119.                             $pza[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3]*$pz2/100;
  120.                             }else{
  121.                             if(!isset($pzz[$npc]))$pzz[$npc]=array();if(!isset($pzz[$npc][$opp[0]]))$pzz[$npc][$opp[0]]=0;
  122.                             $pzz[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3]*$pz2/100;
  123.                             }
  124.                             if($ol!='')$ol.=';'; $ol.='{'.$opp[0].';'.$opp[1].';'.$opp[2].';'.$opp[3].'}';
  125.                            
  126.                             }
  127.                             }
  128.                             $ol='{'.$ol.'};'.$pz2;
  129.                             if($ol2!='')$ol2.=';';
  130.                             $ol2.='{'.$ol.'}';
  131.                         }else
  132.                         if($c4==$c){
  133.                         if($ao[$opk][2]<1)$ao[$opk][2]=1;
  134.                             $ol='';
  135.                             foreach($ao as $opp) { if($opp[0]!=''){
  136.                             if($lo){
  137.                             if(!isset($pza[$npc]))$pza[$npc]=array();if(!isset($pza[$npc][$opp[0]]))$pza[$npc][$opp[0]]=0;
  138.                             $pza[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3]*$pz2/100;
  139.                             }else{
  140.                             if(!isset($pzz[$npc]))$pzz[$npc]=array();if(!isset($pzz[$npc][$opp[0]]))$pzz[$npc][$opp[0]]=0;
  141.                             $pzz[$npc][$opp[0]]+=(($opp[1]+$opp[2])/2)*$opp[3]*$pz2/100;
  142.                             }
  143.                             if($ol!='')$ol.=';'; $ol.='{'.$opp[0].';'.$opp[1].';'.$opp[2].';'.$opp[3].'}';
  144.                            
  145.                             }
  146.                             }
  147.                             $ol='{'.$ol.'};'.$pz2;
  148.                             if($ol2!='')$ol2.=';';
  149.                             $ol2.='{'.$ol.'}';
  150.                         }
  151.                     }
  152.  
  153.                 }  
  154.                 if(!$lo){
  155.                     if(is_array($pzz[$npc]))foreach($pzz[$npc] as $kzz=>$gzz){
  156.                         if($gzz<$pza[$npc][$kzz]){
  157.                             if(!isset($oth[$npc]))$oth[$npc]=array();
  158.                             $oth[$npc][$kzz]=array($gzz,$pza[$npc][$kzz]);
  159.                         }
  160.                     }
  161.                 }
  162.             }
  163. return $v;
  164. }
  165. if(file_exists('debug.txt'))
  166. unlink('debug.txt');
  167. set_time_limit(0);
  168. ini_set('memory_limit','3200000000');
  169. function fopen_utf8($filename){
  170.     $encoding='';
  171.     $handle = fopen($filename, 'r');
  172.     $bom = fread($handle, 2);
  173.     rewind($handle);
  174.     if($bom === chr(0xff).chr(0xfe)  || $bom === chr(0xfe).chr(0xff)){
  175.             $encoding = 'UTF-16';
  176.     } else {
  177.         $file_sample = fread($handle, 1000) + 'e';
  178.         rewind($handle);
  179.         $encoding = mb_detect_encoding($file_sample , 'UTF-8, UTF-7, ASCII, EUC-JP,SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP');
  180.     }
  181.     if ($encoding){
  182.         stream_filter_append($handle, 'convert.iconv.'.$encoding.'/UTF-8');
  183.     }
  184.     return  ($handle);
  185. }
  186. $k=0;
  187. function npc($d,$lo=true){
  188. global $grate,$ii,$k,$c1,$c2,$c3,$c4,$c5,$c6,$npc,$op,$il,$oth;
  189.     $ii=0;$il=0;
  190.     $grate=$d;
  191. $handle = fopen_utf8("../npcdata{$d}.txt");
  192. $bb = array();
  193. $gg=1;
  194. if ($handle) {
  195.     while (($b = fgets($handle, 20000)) !== false) {
  196.             np($b);
  197.             $b=p1($b,$c1,$c5,$c6,$lo);          
  198.             $b=p1($b,$c2,$c5,$c6,$lo);          
  199.             $b=p1($b,$c3,$c5,$c6,$lo);          
  200.             $b=p1($b,$c4,$c5,$c6,$lo);          
  201.             $k++;
  202.     }
  203.     fclose($handle);
  204.     print_r($oth);
  205. }
  206. }
  207.  
  208. npc("_x7",true);
  209. npc("_x30",false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement