Advertisement
Minzee

001

Jun 11th, 2020
1,457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.20 KB | None | 0 0
  1. <?
  2. function showItemList($list, $type)
  3. {
  4.     global $tpl;
  5.  
  6.     for ($x = 0; $x < count($list); $x++)
  7.     {
  8.         if ($list[$x]["add_name"] != "")
  9.             $list[$x]["name"] .= " <span class='uk-text-desc'>{$list[$x]['add_name']}</span>";
  10.  
  11.         $hint = !empty($list[$x]["description"]) ? " data-uk-tooltip=\"{pos:'top-left'}\" title=\"{$list[$x]['description']}\"" : "";
  12.  
  13.         $tpl->insert_loop("main.body.info.{$type}.item", array(
  14.             "ID" => $list[$x]["id"],
  15.             "ICON" => getIcon($list[$x]["icon"], $list[$x]["icon_ex"], "ID: {$list[$x]['id']}"),
  16.             "NAME" => "<a href='?show=item_info&amp;id={$list[$x]['item_id']}&amp;tab=1'{$hint}>{$list[$x]['name']}</a>",
  17.             "COUNT" => $list[$x]["min"] != $list[$x]["max"] ? "{$list[$x]['min']} - {$list[$x]['max']}" : $list[$x]["min"],
  18.             "CHANCE" => $list[$x]["chance"] >= 1 ? "{$list[$x]['chance']}%" : "1/".round(100 / $list[$x]['chance'])));
  19.     }
  20. }
  21.  
  22. if ($id > 0 && $db->is_exists("SELECT id FROM npc_data WHERE id = {$id} LIMIT 1"))
  23. {
  24.     $tpl->assign("N_ID", $id);
  25.  
  26.     $tabs = array("Параметры", "Дроп / Спойл", "Места спавнов", "Торговля");
  27.     $tab = $util->getNumber(@$_GET["tab"], 0, range(0, count($tabs) - 1));
  28.     $disabled = array();
  29.  
  30.     $result = $db->query("SELECT * FROM npc_data WHERE id = {$id} LIMIT 1");
  31.     $npc = $db->fetch_assoc($result);
  32.  
  33.     if ($npc["is_drop"] != 1 && $npc["is_spoil"] != 1)
  34.         $disabled[] = 1;
  35.  
  36.     if ($npc["is_spawn"] != 1)
  37.         $disabled[] = 2;
  38.  
  39.     if ($npc["is_merchant"] != 1)
  40.         $disabled[] = 3;
  41.  
  42.     if (in_array($tab, $disabled))
  43.         $tab = 0;
  44.  
  45.     showTabsControl($tab, $tabs, "main.body.info.tabs", $disabled);
  46.  
  47.     // --------------- params ---------------
  48.     $raceName = getSkillName(289406976 + $npc["race"]);
  49.     $attrAtk = explode(";", $npc["attr_atk"]);
  50.     $attrDef = explode(";", $npc["attr_def"]);
  51.  
  52.     showParam("Уровень", $npc["level"]);
  53.     showParam("Раса", "<a href='?show=npcs&amp;type=race&amp;race={$npc['race']}'>".getSkillName(289406976 + $npc["race"])."</a>", "uk-text-danger");
  54.     showParam("Опыт (рейты х{$serverRates})", number_format($npc["exp"]), true);
  55.     showParam("SP (рейты х{$serverRates})", number_format($npc["sp"]), true);
  56.     showParam("Сила (<b>STR</b>)", $npc["_str"]);
  57.     showParam("Интеллект (<b>INT</b>)", $npc["_int"]);
  58.     showParam("Ловкость (<b>DEX</b>)", $npc["_dex"]);
  59.     showParam("Разум (<b>WIT</b>)", $npc["_wit"]);
  60.     showParam("Телосложение (<b>CON</b>)", $npc["_con"]);
  61.     showParam("Ментальная защита (<b>MEN</b>)", $npc["_men"]);
  62.     showParam("HP", number_format(round($npc["hp"] * $npc["hp_mod"])), "uk-text-hp");
  63.     showParam("MP", number_format(round($npc["mp"] * $npc["mp_mod"])), "uk-text-mp");
  64.     showParam("Физическая атака", number_format(round($npc["patk"] * $npc["patk_mod"])));
  65.     showParam("Магическая атака", number_format(round($npc["matk"] * $npc["matk_mod"])));
  66.     showParam("Физическая защита", number_format(round($npc["pdef"] * $npc["pdef_mod"])));
  67.     showParam("Магическая защита", number_format(round($npc["mdef"] * $npc["mdef_mod"])));
  68.  
  69.     if ($npc["sdef"] > 0)
  70.     {
  71.         showParam("Физическая защита щита", number_format($npc["sdef"]));
  72.         showParam("Шанс блокировки щитом", $npc["sdef_rate"]."%");
  73.     }
  74.  
  75.     showParam("Шанс критической атаки", round($npc["critical"] / 10, 1)."%");
  76.     showParam("Дальность физической атаки", number_format($npc["attack_range"]));
  77.     showParam("Скорость физической атаки", number_format($npc["patk_speed"]));
  78.     showParam("Скорость магической атаки", number_format($npc["matk_speed"]));
  79.     showParam("Скорость ходьбы", $npc["walk_speed"]);
  80.     showParam("Скорость бега", $npc["run_speed"]);
  81.     showParam("Атрибут атаки", $attrAtk[0] > -1 ? $attrList[$attrAtk[0]]." (".number_format($attrAtk[1]).")" : "Нейтральный");
  82.     showParam("Атрибут защиты от огня", $attrDef[0]);
  83.     showParam("Атрибут защиты от воды", $attrDef[1]);
  84.     showParam("Атрибут защиты от ветра", $attrDef[2]);
  85.     showParam("Атрибут защиты от земли", $attrDef[3]);
  86.     showParam("Атрибут защиты от света", $attrDef[4]);
  87.     showParam("Атрибут защиты от тьмы", $attrDef[5]);
  88.  
  89.     if ($npc["rhand"] > 0)
  90.     {
  91.         $item = getItemName($npc["rhand"]);
  92.  
  93.         if ($item != null)
  94.             showParam("В правой руке держит", "<a href='?show=item_info&amp;id={$item['id']}'>{$item['name']}</a>");
  95.     }
  96.  
  97.     if ($npc["lhand"] > 0)
  98.     {
  99.         $item = getItemName($npc["lhand"]);
  100.  
  101.         if ($item != null)
  102.             showParam("В левой руке держит", "<a href='?show=item_info&amp;id={$item['id']}'>{$item['name']}</a>");
  103.     }
  104.  
  105.     showParam("Социальный (дальность)", strYN($npc["faction"] != "").($npc["faction_range"] > 0 ? " ({$npc['faction_range']})" : ""));
  106.     showParam("Агрессивный (дальность)", strYN($npc["aggro_range"] > 0, true).($npc["aggro_range"] > 0 ? " ({$npc['aggro_range']})" : ""));
  107.     showParam("Есть дроп хербов", strYN($npc["is_drop_herb"]));
  108.  
  109.     // --------------- skills
  110.  
  111.     $result=$db->query("SELECT B.uid, B.id, B.level, B.name, B.description, B.icon, B.is_done
  112.         FROM npc_skills AS A
  113.         LEFT JOIN skill_info AS B ON (A.uid = B.uid)
  114.         WHERE A.npc_id = {$id} AND B.lang = '{$lang}'
  115.         ORDER BY B.name");
  116.  
  117.     if ($db->num_rows($result) > 0)
  118.     {
  119.         $list = $db->fetch_array($result);
  120.  
  121.         for ($x = 0; $x < count($list); $x++)
  122.         {
  123.             $hint = !empty($list[$x]["description"]) ? " data-uk-tooltip=\"{pos:'top-left'}\" title=\"{$list[$x]['description']}\"" : "";
  124.  
  125.             $tpl->insert_loop("main.body.info.skills.skill", array(
  126.                 "ICON" => $list[$x]["icon"],
  127.                 "ID" => $list[$x]["id"],
  128.                 "LEVEL" => $list[$x]["level"],
  129.                 "NAME" => "<a href='?show=skill_info&amp;uid={$list[$x]['uid']}'{$hint}>{$list[$x]['name']}</a>",
  130.                 "IS_DONE" => !$list[$x]["is_done"] ? "<span class='uk-badge uk-badge-warning uk-icon-bug uk-box-shadow' data-uk-tooltip title='Умение не реализовано'></span>" : ""));
  131.         }
  132.  
  133.         $tpl->parse("main.body.info.skills");
  134.     }
  135.  
  136.     // --------------- minions
  137.  
  138.     $result=$db->query("SELECT A.id, A.count, B.name, B.title, C.race
  139.         FROM npc_minions AS A
  140.         LEFT JOIN npc_info AS B ON (A.id = B.id)
  141.         LEFT JOIN npc_data AS C ON (A.id = C.id)
  142.         WHERE A.npc_id = {$id} AND B.lang = '{$lang}'
  143.         ORDER BY B.name");
  144.  
  145.     if ($db->num_rows($result) > 0)
  146.     {
  147.         $list = $db->fetch_array($result);
  148.  
  149.         for ($x = 0; $x < count($list); $x++)
  150.         {
  151.             if (!empty($npc["title"]))
  152.                 $list[$x]["name"] = "<span class='uk-text-desc'>{$npc['title']}</span> {$list[$x]['name']}";
  153.  
  154.             $tpl->insert_loop("main.body.info.minions.minion", array(
  155.                 "ICON" => $list[$x]["race"],
  156.                 "ID" => $list[$x]["id"],
  157.                 "COUNT" => $list[$x]["count"],
  158.                 "NAME" => "<a href='?show=npc_info&amp;id={$list[$x]['id']}'>{$list[$x]['name']}</a>"));
  159.         }
  160.  
  161.         $tpl->parse("main.body.info.minions");
  162.     }
  163.  
  164.     // --------------- spawns
  165.  
  166.     $result = $db->query("SELECT * FROM spawn_data WHERE npc_id = {$npc['id']}");
  167.     $list = array();
  168.     $sMul = 1;
  169.  
  170.     if ($db->num_rows($result) == 0)
  171.     {
  172.         $result = $db->query("SELECT * FROM npc_minions WHERE id = {$npc['id']} LIMIT 1");
  173.  
  174.         if ($db->num_rows($result) > 0)
  175.         {
  176.             $mData = $db->fetch_assoc($result);
  177.             $result = $db->query("SELECT * FROM spawn_data WHERE npc_id = {$mData['npc_id']}");
  178.  
  179.             if ($db->num_rows($result) > 0)
  180.             {
  181.                 $list = $db->fetch_array($result);
  182.                 $sMul = $mData['count'];
  183.             }
  184.         }
  185.     }
  186.     else
  187.         $list = $db->fetch_array($result);
  188.  
  189.     if (count($list) > 0)
  190.     {
  191.         $instances = array();
  192.  
  193.         foreach ($list as $spawn)
  194.             if ($spawn["ref_id"] > 0)
  195.                 $instances[] = $spawn["ref_id"];
  196.  
  197.         if (count($instances) > 0)
  198.         {
  199.             $result = $db->query("SELECT * FROM instance_info WHERE id IN (".implode(",", array_unique($instances)).") AND lang = '{$lang}'");
  200.             $instances = $db->fetch_array($result, "id");
  201.         }
  202.  
  203.         $spawnCount = 0;
  204.  
  205.         $w = 1095;
  206.         $h = 1026;
  207.         $c = 32768;
  208.         $cX = 15;
  209.         $cY = 16;
  210.         $k = $h / $cY / $c;
  211.  
  212.         for ($x = 0; $x < count($list); $x++)
  213.         {
  214.             $hint = "Количество: ".($list[$x]['count'] * $sMul)."<br>Координаты: {$list[$x]['x']}, {$list[$x]['y']}, {$list[$x]['z']}";
  215.  
  216.             if ($list[$x]['respawn'] > 0)
  217.                 $hint .= "<br>Период респавна: ".strTime($list[$x]['respawn'], true).($list[$x]['respawn_rand'] > 0 ? " &plusmn; ".strTime($list[$x]['respawn_rand'], true) : "");
  218.             else if ($list[$x]['respawn'] == 0)
  219.                 $hint .= "<br>Период респавна: одноразовый спавн";
  220.             else
  221.                 $hint .= "<br>Период респавна: спавн в определенное время";
  222.  
  223.             if ($list[$x]['ref_id'] != 0)
  224.                 $hint .= "<br>Измерение: #{$list[$x]['ref_id']}".(!empty($instances[$list[$x]['ref_id']]) ? " ({$instances[$list[$x]['ref_id']]['name']})" : "");
  225.  
  226.             if ($list[$x]['period_of_day'] == "DAY")
  227.                 $hint .= "<br>Время суток: день";
  228.             else if ($list[$x]['period_of_day'] == "NIGHT")
  229.                 $hint .= "<br>Время суток: ночь";
  230.  
  231.             $posX = round($w / 2 + ($w / $cX) * 1.21 + $list[$x]["x"] * $k);
  232.             $posY = round($h / 2 + $list[$x]["y"] * $k);
  233.             $tpl->insert_loop("main.body.info.point", array(
  234.                 "POS_X" => $posX,
  235.                 "POS_Y" => $posY,
  236.                 "POS_HINT" => "data-uk-tooltip title='{$hint}'"));
  237.  
  238.             $spawnCount += $list[$x]["count"];
  239.         }
  240.  
  241.         $tpl->assign("SPAWN_COUNT", $spawnCount * $sMul);
  242.     }
  243.     // --------------- drop & spoil
  244.  
  245.     $tpl->assign("SERVER_RATES", $serverRates);
  246.  
  247.     if ($npc["is_drop"] == 1)
  248.     {
  249.         $result = $db->query("SELECT *
  250.             FROM drop_data AS A
  251.             LEFT JOIN item_info AS B ON (A.item_id = B.id)
  252.             WHERE A.npc_id = {$id} AND A.group_id > -1 AND B.lang = '{$lang}'
  253.             ORDER BY A.chance DESC, B.name ASC");
  254.         $list = $db->fetch_array($result);
  255.  
  256.         if (count($list) > 0)
  257.         {
  258.             showItemList($list, "drop");
  259.             $tpl->parse("main.body.info.drop");
  260.         }
  261.         else
  262.             $tpl->parse("main.body.info.no_drop");
  263.     }
  264.     else
  265.         $tpl->parse("main.body.info.no_drop");
  266.  
  267.  
  268.     if ($npc["is_spoil"] == 1)
  269.     {
  270.         $result = $db->query("SELECT *
  271.             FROM drop_data AS A
  272.             LEFT JOIN item_info AS B ON (A.item_id = B.id)
  273.             WHERE A.npc_id = {$id} AND A.group_id = -1 AND B.lang = '{$lang}'
  274.             ORDER BY A.chance DESC, B.name ASC");
  275.         $list = $db->fetch_array($result);
  276.  
  277.         if (count($list) > 0)
  278.         {
  279.             showItemList($list, "spoil");
  280.             $tpl->parse("main.body.info.spoil");
  281.         }
  282.         else
  283.             $tpl->parse("main.body.info.no_spoil");
  284.     }
  285.     else
  286.         $tpl->parse("main.body.info.no_spoil");
  287.  
  288.     // --------------- merchant
  289.  
  290.     if ($npc["is_merchant"] == 1)
  291.     {
  292.         $result = $db->query("SELECT A.*, B.*, C.price
  293.             FROM merchant_data AS A
  294.             LEFT JOIN item_info AS B ON (A.item_id = B.id)
  295.             LEFT JOIN item_data AS C ON (A.item_id = C.id)
  296.             WHERE A.npc_id = {$id} AND B.lang = '{$lang}'
  297.             ORDER BY B.name");
  298.         $list = $db->fetch_array($result);
  299.  
  300.         if (count($list) > 0)
  301.         {
  302.             for ($x = 0; $x < count($list); $x++)
  303.             {
  304.                 if (empty($list[$x]["name"]))
  305.                     $list[$x]["name"] = $lang == "ru" ? "[нет имени]" : "[no name]";
  306.  
  307.                 $hint = !empty($list[$x]["description"]) ? " data-uk-tooltip=\"{pos:'top-left'}\" title=\"{$list[$x]['description']}\"" : "";
  308.  
  309.                 $tpl->insert_loop("main.body.info.trade.item", array(
  310.                     "ID" => $list[$x]["id"],
  311.                     "ICON" => getIcon($list[$x]["icon"], $list[$x]["icon_ex"], "ID: {$list[$x]['id']}"),
  312.                     "NAME" => "<a href='?show=item_info&amp;id={$list[$x]['item_id']}&amp;tab=3'{$hint}>".$list[$x]["name"].($list[$x]["add_name"] != "" ? " <span class='uk-text-desc'>{$list[$x]['add_name']}</span> " : "")."</a>",
  313.                     "PRICE" => number_format(floor($list[$x]["price"] * (1. + $list[$x]["markup"] / 100.))),
  314.                     "PERIOD" => $list[$x]["count"] > 0 ? "период обновления: ".strTime($list[$x]["time"] * 60, false, false).", количество: {$list[$x]['count']}" : "продается всегда, в неограниченном количестве"));
  315.             }
  316.  
  317.             $tpl->parse("main.body.info.trade");
  318.         }
  319.         else
  320.             $tpl->parse("main.body.info.no_trade");
  321.     }
  322.     else
  323.         $tpl->parse("main.body.info.no_trade");
  324.  
  325.     $tpl->parse("main.body.info");
  326. }
  327. else
  328.     showMessage404();
  329. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement