Просмотр файла game/2/f_addnpc.dat

Размер файла: 1.47Kb
  1. <?php
  2. // перемещение npc
  3. global $l_i,$loc,$login,$page_d,$l_tt;
  4.  
  5. if ($to && !file_exists('l_i/'.$to)) return;
  6.  
  7. $tnpc='';
  8. if ($from && $from!=$to) {
  9. loadloc($from);
  10. if (isset($l_i[$from][$id])) {
  11. $floc=explode('|',$l_tt[$from]['d']);
  12. $tnpc=$l_i[$from][$id];
  13. $tchar=explode('|',$tnpc['char']);
  14. if ($to && array_search($to,$floc)) addjournal($from,'all',$tchar[0].' ушел '.$floc[array_search($to,$floc)-1],$id); else addjournal($from,'all',$tchar[0].' исчез',$id);
  15. unset($l_i[$from][$id]);
  16. }
  17. }
  18.  
  19. if ($to && $from!=$to) {
  20. loadloc($to);
  21. if (isset($l_i[$to][$id])) {$tnpc=$l_i[$to][$id]; $tchar=explode('|',$tnpc['char']);}
  22. if ($tnpc) {
  23. $tloc=explode('|',$l_tt[$to]['d']);
  24. if ($from && array_search($from,$tloc)) {
  25.  
  26. addjournal($to,'all','Пришел '.$tchar[0],$id);
  27. if (substr($id,0,2)=='n.') { // история следов npc
  28. $steps=explode(':',$tchar[12]);
  29. if (count($steps)==0) $steps[]=$from;
  30. else {if ($steps[count($steps)-1]==$to) unset($steps[count($steps)-1]); else $steps[]=$from;}
  31. $tchar[12]=implode(':',$steps);
  32. $tnpc['char']=implode('|',$tchar);
  33. }
  34. } else addjournal($to,'all','Появился '.$tchar[0],$id);
  35. $l_i[$to][$id]=$tnpc;
  36. if ($from && substr($id,0,2)=='u.') {
  37. if ($floc[1] && !$tloc[1]) addjournal($to,$id,'Вы покинули охраняемую территорию');
  38. if (!$floc[1] && $tloc[1]) addjournal($to,$id,'Вы на охраняемой территории');
  39. }
  40. }
  41. }
  42.  
  43. if ($id==$login && $to && isset($l_i[$to][$id])) {
  44. if ($loc==$to) $page_d=0; else {$page_d=1; $loc=$to;}
  45. }