$build = mysql_fetch_array($select); //вычитание у владельца $selo = myquery("select * from craft_resource_user where res_id={$b['0']} and user_id={$build_vladel}"); $resko = mysql_fetch_array($selo); if (mysql_num_rows($selo) and $resko['col'] >= $b[1]) { if ($admin_build != 1) { myquery("update craft_resource_user set col=GREATEST(0,col-{$b['1']}) where user_id={$build_vladel} and res_id={$b['0']}"); myquery("UPDATE game_users SET CW=CW-" . $build['weight'] * $b[1] . " WHERE user_id={$build_vladel}"); } $chance = 100; mt_srand(make_seed()); $r = mt_rand(0, 100); $inc = 0; if ($build['spets'] != '') { $craft_index = get_craft_index($build['spets']); $spetstime = getCraftTimes($user_id, $craft_index); $spetslevel = CraftSpetsTimeToLevel($craft_index, $spetstime + 1); if ($craft_index == 1) { if (getCraftLevel($user_id, $craft_index) < 19) { $chance = 50; } else { $chance = min(100, 50 + (getCraftLevel($user_id, $craft_index) - 18) * 2); } if ($r > $chance) { // промашка при сборе. Навык не увеличиваем } else { $inc = 1; } } else { $inc = 1; }
function getCraftLevel($user_id, $craft_index) { $craft_times = getCraftTimes($user_id, $craft_index); return floor(CraftSpetsTimeToLevel($craft_index, $craft_times)); }