Example #1
0
 public function drop_loot($user_id)
 {
     if ($this->error == 1) {
         return;
     }
     if ($this->npc['dropable'] == 1) {
         $seldrop = myquery("SELECT * FROM game_npc_drop WHERE npc_id=" . $this->templ['npc_id'] . ";");
         if ($seldrop != false and mysql_num_rows($seldrop)) {
             $sum_chance = 0;
             $massiv = array(0);
             $m_last = 1;
             $mes = "";
             $lcm = array();
             $str = "";
             $r = 0;
             $no_loot = 0;
             //Обработаем профессию "Охотник"
             if ($this->templ['npc_id'] == npc_id_olen) {
                 if (checkCraftTrain($user_id, 8)) {
                     $r = $r + 2 * getCraftLevel($user_id, 8);
                 } else {
                     $no_loot = 1;
                 }
             }
             while ($chance = mysql_fetch_array($seldrop)) {
                 $lcm[] = $chance['random_max'];
             }
             mysql_data_seek($seldrop, 0);
             $lcm = lcm_arr($lcm);
             while ($chance = mysql_fetch_array($seldrop)) {
                 $this_chance = ($chance['random'] + $r) * $lcm / gcd($lcm, $chance['random_max']);
                 $massiv = array_merge($massiv, array_fill($m_last, $this_chance, $chance));
                 $m_last += $this_chance;
             }
             if ($m_last < $lcm + 1) {
                 $massiv = array_merge($massiv, array_fill($m_last, $lcm + 1 - $m_last, array('items_id' => 0)));
             }
             $drop = $massiv[mt_rand(1, $lcm)];
             if ($drop['items_id'] != 0 and $no_loot == 0) {
                 $it_user_id = 0;
                 $priznak = 2;
                 $kol_predmetov = mt_rand($drop['mincount'], $drop['maxcount']);
                 $map_name = 0;
                 $map_xpos = 0;
                 $map_ypos = 0;
                 for ($cikl = 1; $cikl <= $kol_predmetov; $cikl++) {
                     $add_result = array(0);
                     if ($drop['kuda'] == 1) {
                         $it_user_id = $user_id;
                         $priznak = 0;
                         //проверим вес
                         if ($drop['drop_type'] == 1) {
                             $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . ""));
                         } elseif ($drop['drop_type'] == 2) {
                             $item = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id=" . $drop['items_id'] . ""));
                         }
                         list($CW, $CC) = mysql_fetch_array(myquery("SELECT CW,CC FROM view_active_users WHERE user_id={$it_user_id}"));
                         $prov = mysqlresult(myquery("SELECT COUNT(*) FROM game_wm WHERE user_id={$it_user_id} AND type=1"), 0, 0);
                         if ($CC - $CW < $item['weight'] and $prov == 0) {
                             //инвентарь заполнен. На землю его!
                             $it_user_id = 0;
                             $priznak = 2;
                             list($map_name, $map_xpos, $map_ypos) = mysql_fetch_array(myquery("SELECT map_name,map_xpos,map_ypos FROM game_users_map WHERE user_id={$it_user_id}"));
                             $drop['kuda'] = 0;
                         }
                     }
                     //если предмет
                     if ($drop['drop_type'] == 1) {
                         if ($priznak == 0) {
                             $Item = new Item();
                             $add_result = $Item->add_user($drop['items_id'], $it_user_id, 0, 0, 1);
                             // не получилось добавить один - не выйдет и остальные.
                             if ($add_result[0] == 0) {
                                 break;
                             }
                         } else {
                             if (!isset($item)) {
                                 $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . ""));
                             }
                             myquery("INSERT INTO game_items (user_id,item_id,priznak,ref_id,item_uselife,item_uselife_max,item_cost,map_name,map_xpos,map_ypos) VALUES ('{$it_user_id}','" . $drop['items_id'] . "','{$priznak}',0,'" . $item['item_uselife'] . "','" . $item['item_uselife_max'] . "','" . $item['item_cost'] . "','{$map_name}','{$map_xpos}','{$map_ypos}')");
                         }
                     } elseif ($drop['drop_type'] == 2) {
                         if ($drop['kuda'] == 1) {
                             $Res = new Res($item, 0);
                             $Res->add_user(0, $it_user_id, 1);
                             if ($this->templ['npc_id'] == npc_id_olen) {
                                 myquery("INSERT INTO craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, " . $drop['items_id'] . ", 0, 1, " . time() . ", {$it_user_id}, 'z')");
                                 setCraftTimes($it_user_id, 8, 1, 1);
                                 add_exp_for_craft($it_user_id, 8);
                             }
                         } elseif ($drop['kuda'] == 0) {
                             $Res = new Res(0, $drop['items_id']);
                             $Res->add_map(0, 0, 1, 0, $map_name, $map_xpos, $map_ypos);
                             myquery("INSERT INTO craft_resource_market (user_id,town,col,price,res_id,opis,map_name,map_xpos,map_ypos) VALUES (0,0,1,0," . $drop['items_id'] . ",'','" . $map_name . "','" . $map_xpos . "','" . $map_ypos . "')");
                         }
                     }
                     if ($it_user_id > 0) {
                         if ($drop['drop_type'] == 1) {
                             $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('увидел', 'увидела') . ' оставшийся от него предмет: <b>' . $item['name'] . '</b>.Ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший предмет и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>';
                         } elseif ($drop['drop_type'] == 2) {
                             $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('заметил', 'заметила') . ', как он выронил из рук: <b>' . $item['name'] . '<b/>. Не мешкая ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший ресурс и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>';
                         }
                         $result = myquery("INSERT game_battles SET attacker_id=" . $user_id . ", target_id=0, map_name=" . $map_name . ", map_xpos=" . $map_xpos . ", map_ypos=" . $map_ypos . ", contents='" . $mes . "', post_time=" . time() . "");
                     }
                 }
             }
         }
     }
 }
Example #2
0
                    if (isset($_GET['dob']) and $broken_instrument == 0) {
                        $char_mining = getCraftLevel($user_id, 6);
                        if ($char_mining >= ($level - 1) * 3) {
                            if (!isset($_POST['digit'])) {
                                echo 'Для начала работы введи указанный ниже код <br>и нажми кнопку "Начать работу"<br>';
                                echo '<br><img src="captcha_new/index.php?' . time() . '">';
                                echo '<form autocomplete="off" action="craft.php?dob" method="POST" name="captcha"><br>
								<input id="input_digit" type="text" size=6 maxsize=6 name="digit"><br /><br />
								<input type="submit" name="subm" value="Начать работу">
								</form><br />
								<script>
								el = document.getElementById(\'input_digit\');
								el.focus();
								</script>';
                            } else {
                                if (isset($_SESSION['captcha']) and $_POST['digit'] == $_SESSION['captcha'] and checkCraftTrain($user_id, 6)) {
                                    $char_mining = getCraftLevel($user_id, 6);
                                    if (domain_name == 'testing.rpg.su' or domain_name == 'localhost') {
                                        $end_time = 5;
                                    } else {
                                        $end_time = time() + max(120, 5 * 60 - 10 * $char_mining);
                                    }
                                    myquery("UPDATE craft_build_mining SET end_time={$end_time},user_id={$user_id} WHERE id={$id_geks}");
                                    echo 'Ты ' . echo_sex('начал', 'начала') . ' работу в шахте.';
                                    $obval = max(0, ($level - 1) * 5 + $cur_geksa['geksa_obval'] - min(5, $char['lucky']));
                                    mt_srand(make_seed());
                                    $rand = mt_rand(1, 100);
                                    if ($rand <= $obval) {
                                        echo 'Ты ' . echo_sex('попал', 'попала') . ' под обвал шахты. Твоя работа в руднике на этот раз завершена<meta http-equiv="refresh" content="4;url=act.php?func=main">';
                                        myquery("UPDATE craft_build_mining SET geksa_state=1 WHERE id={$id_geks}");
                                        $kol_obvalov = mysqlresult(myquery("SELECT COUNT(*) FROM craft_build_mining WHERE build_id={$build_id} AND level={$level} AND geksa_state=1"), 0, 0);
Example #3
0
<?php

$craft_kuznec = getCraftLevel($user_id, 12);
if (checkCraftTrain($user_id, 12) > 0) {
    $est_molot = myquery("SELECT id,item_uselife FROM game_items WHERE item_uselife>0 AND user_id={$user_id} AND used=21 AND priznak=0 AND item_id=" . molot_kuzn . " LIMIT 1");
    if (mysql_num_rows($est_molot) > 0) {
        $border_by_level = 90 - 8 * $craft_kuznec;
        $min_itemuselife = $border_by_level;
        if (isset($_GET['nak']) and is_numeric($_GET['nak'])) {
            $nak = (int) $_GET['nak'];
            $result_items = myquery("SELECT game_items.item_uselife as uselife_now,game_items.id,game_items_factsheet.name,game_items_factsheet.item_uselife AS uselife_template,game_items_factsheet.breakdown,game_items.item_uselife_max AS uselife_max_now,game_items_factsheet.type FROM game_items, game_items_factsheet WHERE game_items.user_id={$user_id} AND (game_items.used=0 or (game_items.item_uselife>=10 AND game_items_factsheet.type<>24)) and game_items.ref_id=0 and game_items.priznak=0  and game_items_factsheet.type<90 AND game_items_factsheet.type NOT IN (12,13,19,20,21) AND game_items.item_uselife<100 AND game_items.item_id=game_items_factsheet.id AND game_items.id={$nak} AND game_items.item_uselife>={$min_itemuselife}");
            if ($result_items != false and mysql_num_rows($result_items) > 0) {
                //предмет проверили. дальше идем
                $item = mysql_fetch_array($result_items);
                $breakdown = 0;
                $chance = mt_rand(1, 100);
                if ($item['breakdown'] == 1 and $chance > 1) {
                    $breakdown = 1;
                }
                if ($item['type'] == 3) {
                    $item['uselife_template'] = 100;
                }
                list($molot_id, $molot_uselife) = mysql_fetch_array($est_molot);
                $break = ($item['uselife_template'] - $item['uselife_now']) / 100;
                if ($molot_uselife <= $break) {
                    $molot = new Item($molot_id);
                    $molot->down();
                    myquery("UPDATE game_items SET item_uselife=0 WHERE id={$molot_id}");
                } else {
                    myquery("UPDATE game_items SET item_uselife=item_uselife-{$break} WHERE id={$molot_id}");
                }
Example #4
0
         if ($check_null != false and mysql_num_rows($check_null) > 0) {
             myquery("UPDATE craft_build_stonemason SET state=0,user_id=0,end_time=0,klin=0,chance=0 WHERE id={$tr}");
         }
     }
 }
 if (isset($_GET['klin'])) {
     $check = myquery("SELECT id FROM game_items WHERE priznak=0 AND used=0 AND user_id={$user_id} AND item_uselife>0 AND item_id={$id_item_klin} LIMIT 1");
     if ($check != false and mysql_num_rows($check) > 0) {
         $tree_id = (int) $_GET['klin'];
         list($item_id) = mysql_fetch_array($check);
         $KLIN = new Item($item_id);
         $KLIN->admindelete();
         myquery("UPDATE craft_build_stonemason SET klin=klin+1 WHERE id={$tree_id}");
     }
 }
 if (!checkCraftTrain($user_id, 5)) {
     echo '<br /><br />Ты не знаешь базовую профессию каменотеса! Ты можешь выучить ее в городе у Учителя профессий.<br />Тебе запрещено заниматься этой профессией чаще, чем раз в 30 минут.<br /><br />';
 } else {
     $sel_tree = myquery("SELECT * FROM craft_build_stonemason WHERE build_id={$build_id}");
     $ind = 0;
     while ($tree = mysql_fetch_array($sel_tree)) {
         $ind++;
         echo '<div style="padding-left:20%;text-align:left;">' . $ind;
         $type_tree = '';
         switch ($tree['nomer']) {
             case 1:
                 $type_tree = 'Малый валун – опасность обвала ' . obval_chance($tree) . '%';
                 break;
             case 2:
                 $type_tree = 'Средний валун – опасность обвала ' . obval_chance($tree) . '%';
                 break;
Example #5
0
    exit;
}
if ($town != 0) {
    $craft_kuznec = getCraftLevel($user_id, 12);
    $border_by_level = 90 - 8 * $craft_kuznec;
    $min_itemuselife = max(0, $border_by_level);
    $img = 'http://' . img_domain . '/race_table/orc/table';
    echo '<table width=100% border="0" cellspacing="0" cellpadding="0" align=center><tr><td width="1" height="1"><img src="' . $img . '_lt.gif"></td><td background="' . $img . '_mt.gif"></td><td width="1" height="1"><img src="' . $img . '_rt.gif"></td></tr>
	<tr><td background="' . $img . '_lm.gif"></td><td style="text-align:center" background="' . $img . '_mm.gif" valign="top">';
    $est_molot = myquery("SELECT id,item_uselife FROM game_items WHERE user_id={$user_id} AND used=21 AND priznak=0 AND item_id=" . molot_kuzn . "");
    $new_year_lab = array(845, 850, 857, 866, 877);
    if (in_array($char['map_name'], $new_year_lab)) {
        $min_itemuselife = -100;
        $no_kuzn = 1;
    }
    if ((checkCraftTrain($user_id, 12) > 0 and mysql_num_rows($est_molot) > 0 or isset($no_kuzn) and $no_kuzn == 1) and $char['GP'] >= $gp) {
        echo '<br /><br /><b>Для работы в общественной кузне необходимо заплатить ' . $gp . ' монет!</b><br /><br />';
        if (isset($_GET['nak'])) {
            $nak = (int) $_GET['nak'];
            $result_items = myquery("SELECT game_items.item_uselife as uselife_now,game_items.id,game_items_factsheet.name,game_items_factsheet.item_uselife AS uselife_template,game_items_factsheet.breakdown,game_items.item_uselife_max AS uselife_max_now,game_items_factsheet.type FROM game_items, game_items_factsheet WHERE game_items.user_id={$user_id} AND (game_items.used=0 or (game_items.item_uselife>=10 AND game_items_factsheet.type<>24)) and game_items.ref_id=0 and game_items.priznak=0  and game_items_factsheet.type<90 AND game_items_factsheet.type NOT IN (12,13,19,20,21) AND game_items.item_uselife<100 AND game_items.item_id=game_items_factsheet.id AND game_items.id={$nak} AND game_items.item_uselife>={$min_itemuselife}");
            if ($result_items != false and mysql_num_rows($result_items) > 0) {
                echo '<br><br><br><center>';
                //предмет проверили. дальше идем
                myquery("UPDATE game_users SET GP=GP-" . $gp . ",CW=CW-" . $gp * money_weight . " WHERE user_id={$user_id}");
                setGP($user_id, -$gp, 65);
                $item = mysql_fetch_array($result_items);
                $item['uselife_max'] = 100;
                $breakdown = 0;
                $chance = mt_rand(1, 100);
                if ($item['breakdown'] == 1 and $chance > 1) {
                    $breakdown = 1;