$item_mp_use = intval($HTTP_POST_VARS['item_mp_use']); $item_element = intval($HTTP_POST_VARS['element_weap_list']); $item_element_str = intval($HTTP_POST_VARS['item_element_str']); $item_element_same = intval($HTTP_POST_VARS['item_element_same']); $item_element_weak = intval($HTTP_POST_VARS['item_element_weak']); $item_weight = intval($HTTP_POST_VARS['item_weight']); $item_max_skill = intval($HTTP_POST_VARS['item_max_skill']); if ($item_name == '' || !$item_power || !$item_duration) { message_die(MESSAGE, $lang['Fields_empty']); } if ($item_price == '') { // If no price is defined , let's calculate the real item price $adr_general = adr_get_general_config(); // Get the base and modifier price $adr_quality_price = adr_get_item_quality($item_quality, price); $adr_type_price = adr_get_item_type($item_type, price); // First define the base price $item_price = $adr_type_price; // Then apply the quality modifier $item_price = $item_price * ($adr_quality_price / 100); // And now the power - it's a little more complicated $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price; // Apply the duration penalty $item_price = abs($item_price / ($item_duration_max / $item_duration)); // Finally let's use a non decimal value & add 10 % $item_price = ceil($item_price * 1.1); } $sql = "INSERT INTO " . ADR_BEGGAR_DONATIONS . "\r\n\t\t\t\t( item_id , item_owner_id , item_chance , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , item_duration , item_duration_max , item_power , item_add_power , item_mp_use , item_weight , item_max_skill , item_element , item_element_str_dmg , item_element_same_dmg , item_element_weak_dmg )\r\n\t\t\t\tVALUES ( {$item_id} , 1 , {$item_chance} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , '" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration} , {$item_duration_max} , {$item_power} , {$item_add_power} , {$item_mp_use} , {$item_weight} , {$item_max_skill} , {$item_element} , {$item_element_str} , {$item_element_same} , {$item_element_weak} )"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql);
$item_price = $adr_type_price; // Then apply the quality modifier $item_price = $item_price * ($adr_quality_price / 100); // And now the power - it's a little more complicated $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price; // Apply the duration penalty $item_price = abs($item_price / ($item_duration_max / $item_duration)); // Finally let's use a non decimal value & add 10 % $item_price = ceil($item_price * 1.1); } if ($recipe_price == '') { // If no price is defined , let's calculate the real item price $adr_general = adr_get_general_config(); // Get the base and modifier price $adr_quality_price = adr_get_item_quality($recipe_quality, price); $adr_type_price = adr_get_item_type($recipe_type, price); // First define the base price $recipe_price = $adr_type_price; // Then apply the quality modifier $recipe_price = $recipe_price * ($adr_quality_price / 100); // And now the power - it's a little more complicated $recipe_price = $recipe_power > 1 ? $recipe_price + $recipe_price * (($recipe_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $recipe_price; // Apply the duration penalty $recipe_price = abs($recipe_price / ($recipe_duration_max / $recipe_duration)); // Finally let's use a non decimal value & add 10 % $recipe_price = ceil($recipe_price * 1.1); } //recipe_items_req $recipe_items_req_list = array(); $recipe_items_req_list = $HTTP_POST_VARS['recipe_items_req']; $recipe_items_amount_list = array();
$tools = $db->sql_fetchrowset($result); $tool_list = '<select name="item_tool">'; $tool_list .= '<option value = "0" >' . $lang['Adr_forge_mining_no_tool'] . '</option>'; for ($i = 0; $i < count($tools); $i++) { $tool_list .= '<option value = "' . $tools[$i]['item_id'] . '" >' . adr_get_lang($tools[$i]['item_name']) . ' ( ' . $lang['Adr_items_power'] . ' : ' . $tools[$i]['item_power'] . ' - ' . $lang['Adr_items_duration'] . ' : ' . $tools[$i]['item_duration'] . ' )' . '</option>'; } $tool_list .= '</select>'; $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\tWHERE item_owner_id = {$user_id}\r\n\t\t\t\tAND item_quality < 5 \r\n\t\t\t\tAND item_in_shop = 0\r\n\t\t\t\tAND item_in_warehouse = 0\r\n\t\t\t\tAND item_duration > 0\r\n\t\t\t\tAND item_type_use IN ( 1 , 2 ) "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not check user items', "", __LINE__, __FILE__, $sql); } $items = $db->sql_fetchrowset($result); $items_list = '<select name="item_to_repair">'; $items_list .= '<option value = "0" >' . $lang['Adr_forge_repair_no_item'] . '</option>'; for ($i = 0; $i < count($items); $i++) { $items_list .= '<option value = "' . $items[$i]['item_id'] . '" >' . adr_get_lang($items[$i]['item_name']) . ' ( ' . $lang['Adr_items_power'] . ' : ' . $items[$i]['item_power'] . ' - ' . $lang['Adr_items_quality'] . ' : ' . adr_get_item_quality($items[$i]['item_quality'], simple) . ' - ' . $lang['Adr_items_type_use'] . ' : ' . adr_get_item_type($items[$i]['item_type_use'], simple) . ')' . '</option>'; } $items_list .= '</select>'; $template->assign_vars(array('ITEMS_LIST' => $items_list, 'TOOL_LIST' => $tool_list, 'L_SELECT_TOOL' => $lang['Adr_forge_mining_select_tool'], 'L_SELECT_ITEMS' => $lang['Adr_forge_stone_select_item'], 'L_GO_REPAIR' => $lang['Adr_forge_stone_go'], 'L_STONE_EXPLAIN' => $lang['Adr_forge_stone_explain'])); break; case 'stone_action': $tool = intval($HTTP_POST_VARS['item_tool']); $item_to_repair = intval($HTTP_POST_VARS['item_to_repair']); // No tool , no repair if (!$tool) { adr_previous(Adr_forge_stone_tool_needed, adr_TownMap_forge, "mode=stone"); } // No item to repair ? if (!$item_to_repair) { adr_previous(Adr_forge_stone_item_to_repair_needed, adr_TownMap_forge, "mode=stone"); }
function adr_get_item_real_price($item_id, $user_id) { global $db; // Fix the values $item_id = intval($item_id); $user_id = intval($user_id); $adr_general = adr_get_general_config(); $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_id = {$item_id} \n\t\tAND item_owner_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Couldn't query item infos", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); // Once again , let's protect us about malicious users ... if (!is_numeric($row['item_type_use'])) { message_die(GENERAL_ERROR, "This item doesn't exist"); } $item_type = $row['item_type_use']; $item_quality = $row['item_quality']; $item_duration = $row['item_duration']; $item_duration_max = $row['item_duration_max']; $item_power = $row['item_power']; // Get the base and modifier price $adr_quality_price = adr_get_item_quality($item_quality, price); $adr_type_price = adr_get_item_type($item_type, price); // First define the base price $item_price = $adr_type_price; // Apply the sell back penalty $item_price = $row['item_sell_back_percentage'] * $item_price / 100; // Then apply the quality modifier $item_price = $item_price * ($adr_quality_price / 100); // And now the power - it's a little more complicated $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price; // Apply the duration penalty $item_price = abs($item_price / ($item_duration_max / $item_duration)); // Finally let's use a non decimal value $item_price = ceil($item_price); return $item_price; }
$shop_name = isset($_POST['shop_name']) ? trim($_POST['shop_name']) : trim($_GET['shop_name']); $shop_desc = isset($_POST['shop_desc']) ? trim($_POST['shop_desc']) : trim($_GET['shop_desc']); $shop_id = !empty($_POST['shop_id']) ? $_POST['shop_id'] : $_GET['shop_id']; if (!$shop_name) { message_die(MESSAGE, $lang['Fields_empty']); } $sql = "UPDATE " . ADR_SHOPS_TABLE . " \n\t\t\t\tSET shop_name = '" . str_replace("\\'", "''", $shop_name) . "',\n\t\t\t\t shop_desc = '" . str_replace("\\'", "''", $shop_desc) . "'\n\t\t\t\tWHERE shop_id = {$shop_id}\n\t\t\t\tAND shop_owner_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new shop", "", __LINE__, __FILE__, $sql); } adr_previous(Adr_users_shops_edited_success, adr_shops, "?mode=see_shop&shop_id=" . $shop_id . ""); break; case 'search_item': $template->assign_block_vars('search_item', array()); $template->assign_vars(array('ITEM_TYPE' => adr_get_item_type(0, search), 'ITEM_QUALITY' => adr_get_item_quality(0, search), 'L_POINTS' => get_reward_name(), 'L_ITEM_QUALITY' => $lang['Adr_items_quality'], 'L_ITEM_TYPE' => $lang['Adr_items_type_use'], 'L_ITEM_QUALITY_LEAST' => $lang['Adr_items_type_least'], 'L_ITEM_POWER_LEAST' => $lang['Adr_items_power_least'], 'L_ITEM_DURATION_LEAST' => $lang['Adr_items_duration_least'], 'L_ITEM_PRICE_MAX' => $lang['Adr_items_price_max'], 'L_SEARCH_ITEM_CRITERA' => $lang['Adr_items_search_criteria'], 'L_SUBMIT' => $lang['Submit'])); break; case 'search_item_results': $template->assign_block_vars('search_item_results', array()); $item_quality = intval($_POST['item_quality']) - 1; $item_power_least = intval($_POST['item_power_least']) - 1; $item_duration_least = intval($_POST['item_duration_least']) - 1; $item_type = intval($_POST['item_type_use']); $item_price_max = intval($_POST['item_price_max']); // Check user input for errors $item_quality = $item_quality < '0' ? intval(0) : $item_quality; $item_power_least = $item_power_least < '0' ? intval(0) : $item_power_least; $item_duration_least = $item_duration_least < '0' ? intval(0) : $item_duration_least; $search_type_sql = $item_type > '0' ? 'AND item_type_use = ' . $item_type : ''; $search_price_sql = $item_price_max > '0' ? 'AND item_price < ' . $item_price_max : ''; // $sql = "SELECT i.*, s.*, q.item_quality_lang, t.item_type_lang FROM " . ADR_SHOPS_ITEMS_TABLE . " i, " . ADR_SHOPS_TABLE . " s
} else { $mode = ""; } if ($mode != "") { switch ($mode) { case 'add_store': adr_template_file('admin/config_adr_store_cats_edit_body.tpl'); $template->assign_block_vars('add', array()); $s_hidden_fields = '<input type="hidden" name="mode" value="savenew_store" /><input type="hidden" name="store_type" value="' . $item_type . '" />'; $sql = "SELECT * FROM " . ADR_STORES_TABLE; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain elements information', "", __LINE__, __FILE__, $sql); } $items = $db->sql_fetchrowset($result); $template->assign_vars(array("ITEM_QUALITY" => adr_get_item_quality($items['item_quality'], 'list'), "ITEM_TYPE" => adr_get_item_type($items['item_type_use'], 'list'), "L_POINTS" => $board_config['points_name'], "L_CLOSED" => $lang['Adr_store_status_closed'], "L_OPEN" => $lang['Adr_store_status_open'], "L_NORMAL" => $lang['Adr_store_sales_off'], "L_SALE" => $lang['Adr_store_sales_on'], "L_ALL" => $lang['Adr_store_auth_all'], "L_ADMIN" => $lang['Adr_store_auth_admin'], "L_NAME_EXPLAIN" => $lang['Adr_races_name_explain'], "L_ITEMS_TITLE" => $lang['Adr_shops_item_add_title'], "L_ITEMS_EXPLAIN" => $lang['Adr_shops_item_add_title_explain'], "L_ITEM_NAME" => $lang['Adr_shops_categories_item_name'], "L_ITEM_DESC" => $lang['Adr_shops_categories_item_desc'], "L_ITEM_STATUS" => $lang['Adr_store_status'], "L_ITEM_SALES" => $lang['Adr_store_sales'], "L_ITEM_AUTH" => $lang['Adr_store_auth'], "L_ITEM_VIEW" => $lang['Adr_store_view'], "L_NAME" => $lang['Adr_races_name'], "L_DESC" => $lang['Adr_races_desc'], "L_ACTION" => $lang['Action'], "L_ITEMS" => $lang['Adr_shops_categories_items'], "L_EDIT" => $lang['Edit'], "L_DELETE" => $lang['Delete'], "L_ITEM_IMG" => $lang['Adr_races_image'], "L_ITEM_PRICE" => $lang['Adr_items_price'], "L_ITEM_PRICE_EXPLAIN" => $lang['Adr_items_price_explain'], "L_IMG" => $lang['Adr_races_image'], "L_IMG_EXPLAIN" => $lang['Adr_items_image_explain'], "L_SUBMIT" => $lang['Submit'], "S_ITEMS_ACTION" => append_sid("admin_adr_store_cats.{$phpEx}"), "S_HIDDEN_FIELDS" => $s_hidden_fields)); $template->pparse("body"); break; case 'delete_store': $store_id = !empty($_POST['store_id']) ? intval($_POST['store_id']) : intval($_GET['store_id']); $sql = "DELETE FROM " . ADR_STORES_TABLE . "\n\t\t\t\tWHERE store_id = " . $store_id . "\n\t\t\t\tAND store_owner_id = 1 "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't delete item", "", __LINE__, __FILE__, $sql); } adr_previous(Adr_store_cats_successful_deleted, admin_adr_store_cats, ''); break; case 'edit_store': $store_id = !empty($_POST['store_id']) ? intval($_POST['store_id']) : intval($_GET['store_id']); adr_template_file('admin/config_adr_store_cats_edit_body.tpl'); $template->assign_block_vars('edit', array());
function adr_use_skill_mining($user_id, $tool) { global $db; $user_id = intval($user_id); $tool = intval($tool); $new_item_id = 0; $adr_general = adr_get_general_config(); // START skill limit check $sql = " SELECT character_skill_limit FROM " . ADR_CHARACTERS_TABLE . "\n\t\t\tWHERE character_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query skill limit value', '', __LINE__, __FILE__, $sql); } $limit_check = $db->sql_fetchrow($result); if ($adr_general['Adr_character_limit_enable'] != 0 && $limit_check['character_skill_limit'] < 1) { adr_previous(Adr_skill_limit, adr_town, ''); } // END skill limit check $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_in_shop = 0 \n\t\tAND item_owner_id = {$user_id} \n\t\tAND item_id = {$tool} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); if ($item['item_duration'] < 0) { adr_previous(Adr_forge_mining_broken, adr_forge, "mode=mining"); } // Alter the tool adr_use_item($tool, $user_id); $adr_general = adr_get_general_config(); $adr_user = adr_get_user_infos($user_id); $skill_data = adr_get_skill_data(1); $user_chance = $adr_user['character_skill_mining'] * $skill_data['skill_chance']; $user_chance = $user_chance > 100 ? 100 : $user_chance; $rand = rand(0, 100); if ($user_chance > $rand) { $modif = $item['item_quality'] > 3 ? $item['item_quality'] - 3 : 0; $modif = $modif + ($item['item_power'] - 1); $happiness = rand($modif, 10); $new_item_type = $happiness > 8 ? 2 : 1; // Make the new id for the item $sql = "SELECT item_id FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tWHERE item_owner_id = {$user_id}\n\t\t\tORDER BY item_id \n\t\t\tDESC LIMIT 1"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql); } $data = $db->sql_fetchrow($result); $new_item_id = $data['item_id'] + 1; $item_type = $new_item_type; $item_name = $new_item_type == 1 ? 'Adr_item_ore' : 'Adr_items_diamond'; $item_desc = $new_item_type == 1 ? 'Adr_item_ore_desc' : 'Adr_items_diamond_desc'; $item_icon = $new_item_type == 1 ? 'ore.gif' : 'diamond.gif'; $item_quality = rand(1, 6); $item_duration = rand(1, 3); $item_power = rand(1, 3); adr_skill_limit($user_id); // Generate the item price $adr_quality_price = adr_get_item_quality($item_quality, price); $adr_type_price = adr_get_item_type($item_type, price); $item_price = $adr_type_price; $item_price = $item_price * ($adr_quality_price / 100); $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price; $item_price = ceil($item_price); $sql = "INSERT INTO " . ADR_SHOPS_ITEMS_TABLE . " \n\t\t\t( item_id , item_owner_id , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , item_duration, item_duration_max , item_power )\n\t\t\tVALUES ( {$new_item_id} , {$user_id} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , '" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration}, {$item_duration} , {$item_power} )"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql); } // Increases the success uses of this skill and increase level if needed if ($adr_user['character_skill_mining_uses'] + 1 >= $skill_data['skill_req']) { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\tSET character_skill_mining_uses = 0 , \n\t\t\t\t\tcharacter_skill_mining = character_skill_mining + 1\n\t\t\t\tWHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain skill information', "", __LINE__, __FILE__, $sql); } } else { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\tSET character_skill_mining_uses = character_skill_mining_uses + 1\n\t\t\t\tWHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql); } } } return $new_item_id; }
} $item_info = $db->sql_fetchrow($result_info); //check the amount in user inventory of each needed item $req_item_name = str_replace("'", "\\'", $item_info['item_name']); $sql = "SELECT count(*) AS total FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\t\t\tWHERE item_owner_id = {$user_id}\r\n\t\t\t\t\t\t\tAND item_name = '" . $req_item_name . "'\r\n\t\t\t\t\t\t\tAND item_in_warehouse = 0\r\n\t\t\t\t\t\t\tAND item_in_shop = 0\r\n\t\t\t\t\t\t\tAND item_duration > 0\r\n\t\t\t\t\t\t\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain total amount of the needed item', "", __LINE__, __FILE__, $sql); } $total = $db->sql_fetchrow($result); $color = $total['total'] >= $items_req[$i] ? $color_enough : $color_not_enough; $items_req_print .= '<td align="center" style="color:#FFFFFF;">(x' . $items_req[$i] . ') (<font color="' . $color . '">' . $total['total'] . '</font>)</td></tr>'; } } $items_req_print .= '</table>'; $template->assign_vars(array('RECIPE_ID' => $recipe_data['item_id'], "RECIPE_IMG" => $recipe_data['item_icon'], "RECIPE_NAME" => $recipe_data['item_name'], "RECIPE_LEVEL" => $recipe_data['item_power'], "RECIPE_DESC" => $recipe_data['item_desc'], "RECIPE_PRICE" => $recipe_data['item_price'], "RECIPE_WEIGHT" => $recipe_data['item_weight'], "RECIPE_EFFECT" => $effects_print_list, "RECIPE_ITEMS_REQ" => $items_req_print, "FOOD_NAME" => $food_data['item_name'], "FOOD_IMG" => $food_data['item_icon'], "FOOD_DESC" => $food_data['item_desc'], "FOOD_LEVEL" => $food_data['item_power'], "FOOD_MP_USE" => $food_data['item_mp_use'], "FOOD_DESC" => $food_data['item_desc'], "FOOD_EFFECTS" => $effects_print_list, "FOOD_PRICE" => $food_data['item_price'], "FOOD_WEIGHT" => $food_data['item_weight'], "FOOD_DURATION" => $food_data['item_duration'], "FOOD_DURATION_MAX" => $food_data['item_duration_max'], "FOOD_TYPE" => adr_get_item_type($food_data['item_type_use'], 'simple'))); } break; } } $template->assign_block_vars('main', array()); $sql = "SELECT * FROM " . ADR_RECIPEBOOK_TABLE . "\r\n\tWHERE recipe_owner_id = {$user_id}\r\n\tAND recipe_skill_id = 12\r\n\tORDER BY recipe_level\r\n\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain owners recipes information', "", __LINE__, __FILE__, $sql); } $recipes = $db->sql_fetchrowset($result); if (count($recipes) > 0) { for ($i = 0; $i < count($recipes); $i++) { $owner_recipes .= $owner_recipes == '' ? $recipes[$i]['recipe_original_id'] : ':' . $recipes[$i]['recipe_original_id']; }
function adr_use_skill($user_id, $tool, $recipe_item_id, $skill_id, $type) { global $db; $user_id = intval($user_id); $item_id = intval($item_id); $tool = intval($tool); $recipe_item_id = intval($recipe_item_id); $new_item_id = 0; $adr_general = adr_get_general_config(); $adr_user = adr_get_user_infos($user_id); $skill_data = adr_get_skill_data($skill_id); $current_file = 'adr_' . $type; $character_skill = 'character_skill_' . $type; $character_skill_uses = 'character_skill_' . $type . '_uses'; // START skill limit check if ($adr_general['Adr_character_limit_enable'] != 0 && $adr_user['character_skill_limit'] < 1) { adr_previous(Adr_skill_limit, $current_file, "mode=view&known_recipes={$recipe_item_id}"); } // END skill limit check $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_in_shop = 0 \r\n\t\tAND item_owner_id = {$user_id} \r\n\t\tAND item_id = {$tool} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); // get the information of the item that will be crafted //get original recipe information $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_owner_id = 1\r\n\t\tAND item_original_recipe_id = {$recipe_item_id}\r\n\t\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain owners recipes information', "", __LINE__, __FILE__, $sql); } $original_recipe = $db->sql_fetchrow($result); //get original (up-to-date) recipe info now $sql_recipe = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_id = " . $original_recipe['item_recipe_linked_item'] . "\r\n\t\tAND item_owner_id = 1\r\n\t\t"; $result_recipe = $db->sql_query($sql_recipe); if (!$result_recipe) { message_die(GENERAL_ERROR, "Couldn't select recipe info", "", __LINE__, __FILE__, $sql_recipe); } $crafted_item = $db->sql_fetchrow($result_recipe); if ($item['item_duration'] < 0) { adr_previous(Adr_forge_broken, $current_file, "mode=view&known_recipes={$recipe_item_id}"); } // Alter the tool adr_use_item($tool, $user_id); //roll $difference = intval($adr_user['character_skill_' . $type . ''] - $original_recipe['item_power']); $impossible_loose_bonus = 0; switch (TRUE) { case $difference < -9: $modifier = '-100%'; $lose_roll = 100; $impossible_loose_bonus = 1; break; //Impossible //Impossible case $difference >= -9 && $difference < -6: $modifier = '-80%'; $lose_roll = 80; $item_quality = rand(1, 2); break; //Very Hard //Very Hard case $difference >= -6 && $difference < -4: $modifier = '-60%'; $lose_roll = 60; $item_quality = rand(1, 3); break; //Hard //Hard case $difference >= -4 && $difference < -2: $modifier = '-40%'; $lose_roll = 40; $item_quality = rand(1, 4); break; //Normal //Normal case $difference >= -2 && $difference < 0: $modifier = '-20%'; $lose_roll = 20; $item_quality = rand(1, 5); break; //Easy //Easy case $difference >= 0: $modifier = '-1%'; $lose_roll = 5; $item_quality = rand(1, 6); break; //Very Easy } $user_chance = rand(0, $adr_user['character_skill_' . $type . ''] * 100); $user_chance = $user_chance + floor($user_chance * $modifier / 100); $loose_chance = rand($impossible_loose_bonus, $adr_user['character_skill_' . $type . ''] * $lose_roll); /* echo $modifier." : modifier<br>"; echo $difference." : difference<br>"; echo $user_chance." : user chance<br>"; echo $loose_chance." : loose_chance<br>"; */ // loose a needed item if the rolled dice is bad $items_req = explode(':', $crafted_item['item_brewing_items_req']); if ($user_chance < $loose_chance) { for ($i = 0; $i < count($items_req); $i++) { $switch = !($i % 2) ? $get_info = 1 : ($get_info = 0); if ($get_info == 1) { $req_list .= $req_list == '' ? $items_req[$i] : ':' . $items_req[$i]; } } $req_list = explode(':', $req_list); $random = rand(0, count($req_list) - 1); $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\tWHERE item_id = '" . $req_list[$random] . "'\r\n\t\t\t\tAND item_owner_id = 1\r\n\t\t\t\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql); } $req_item = $db->sql_fetchrow($result); $req_item_name = str_replace("'", "\\'", $req_item['item_name']); //delete item from inventory $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = 0\r\n\t\t\tAND item_in_warehouse = 0\r\n\t\t\tAND item_owner_id = {$user_id}\r\n\t\t\tAND item_name = '" . $req_item_name . "'\r\n\t\t\tLIMIT 1\r\n\t\t\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not delete item', "", __LINE__, __FILE__, $sql); } $new_item_id = 'You lost a <br><br><center>' . adr_get_lang($req_item['item_name']) . '<br><img src="./adr/images/items/' . $req_item['item_icon'] . '"></center><br>during your attempt to cook this food!'; } elseif ($user_chance > $loose_chance) { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\tSET character_xp = character_xp + 3 \r\n\t\t\tWHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not update characters xp', "", __LINE__, __FILE__, $sql); } for ($i = 0; $i < count($items_req); $i++) { $switch = !($i % 2) ? $check_item = 0 : ($check_item = 1); if ($check_item == 1) { //get item info $sql_info = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\twhere item_id = " . $items_req[$i - 1]; $result_info = $db->sql_query($sql_info); if (!$result_info) { message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql_info); } $item_info = $db->sql_fetchrow($result_info); $req_item_name = str_replace("'", "\\'", $item_info['item_name']); echo $rew_item_name . "<br>"; //delete item from inventory $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\tWHERE item_in_shop = 0\r\n\t\t\t\t\tAND item_in_warehouse = 0\r\n\t\t\t\t\tAND item_owner_id = {$user_id}\r\n\t\t\t\t\tAND item_name = '" . $req_item_name . "'\r\n\t\t\t\t\tLIMIT " . $items_req[$i] . "\r\n\t\t\t\t\t"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not delete item', "", __LINE__, __FILE__, $sql); } } } // Make the new id for the item $sql = "SELECT item_id FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_owner_id = {$user_id}\r\n\t\t\tORDER BY item_id \r\n\t\t\tDESC LIMIT 1"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql); } $data = $db->sql_fetchrow($result); $new_item_id = $data['item_id'] + 1; $item_name = $crafted_item['item_name']; $item_type = $crafted_item['item_type_use']; $item_desc = 'Crafted by ' . $adr_user['character_name'] . ''; $item_icon = $crafted_item['item_icon']; $item_duration = $crafted_item['item_duration']; $item_duration_max = $crafted_item['item_duration_max']; $item_power = $crafted_item['item_power']; $item_add_power = $crafted_item['item_add_power']; $item_mp_use = $crafted_item['item_mp_use']; $item_element = $crafted_item['item_element']; $item_element_str_dmg = $crafted_item['item_element_str_dmg']; $item_element_same_dmg = $crafted_item['item_element_same_dmg']; $item_element_weak_dmg = $crafted_item['item_element_weak_dmg']; $item_max_skill = $crafted_item['item_max_skill']; $item_weight = $crafted_item['item_weight']; $item_brewing_items_req = $crafted_item['item_brewing_items_req']; $item_effect = $crafted_item['item_effect']; adr_skill_limit($user_id); // Generate the item price $adr_quality_price = adr_get_item_quality($item_quality, price); $adr_type_price = adr_get_item_type($item_type, price); $item_price = $adr_type_price; $item_price = $item_price * ($adr_quality_price / 100); $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price; $item_price = ceil($item_price); $sql = "INSERT INTO " . ADR_SHOPS_ITEMS_TABLE . " ( item_id , item_owner_id , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , \r\n\t\t\t\titem_duration , item_duration_max , item_power , item_add_power , item_mp_use , item_element , item_element_str_dmg , \r\n\t\t\t\titem_element_same_dmg , item_element_weak_dmg , item_max_skill , item_weight, item_brewing_items_req, item_effect ) \r\n\t\t\t\tVALUES ( {$new_item_id} , {$user_id} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , \r\n\t\t\t\t'" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration} , {$item_duration_max} , {$item_power} , \r\n\t\t\t\t{$item_add_power} , {$item_mp_use} , {$item_element} , {$item_element_str_dmg} , {$item_element_same_dmg} , {$item_element_weak_dmg} , {$item_max_skill} , {$item_weight}, '" . $item_brewing_items_req . "', '" . $item_effect . "')"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql); } // Increases the success uses of this skill and increase level if needed if ($adr_user['character_skill_' . $type . '_uses'] + 1 >= $skill_data['skill_req']) { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . " \r\n\t\t SET {$character_skill_uses} = 0 , \r\n\t\t {$character_skill} = {$character_skill} + 1 \r\n\t\t WHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not update skill information', "", __LINE__, __FILE__, $sql); } } else { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . " \r\n\t\t SET {$character_skill_uses} = {$character_skill_uses} + 1 \r\n\t\t WHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not update item information', "", __LINE__, __FILE__, $sql); } } } return $new_item_id; }
if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql); } adr_previous(Adr_shops_items_successful_added, admin_adr_forums_shop, ''); break; } } else { adr_template_file('admin/config_adr_shops_items_list_body.tpl'); $start = isset($HTTP_GET_VARS['start']) ? intval($HTTP_GET_VARS['start']) : 0; if (isset($HTTP_GET_VARS['mode2']) || isset($HTTP_POST_VARS['mode2'])) { $mode2 = isset($HTTP_POST_VARS['mode2']) ? htmlspecialchars($HTTP_POST_VARS['mode2']) : htmlspecialchars($HTTP_GET_VARS['mode2']); } else { $mode2 = 'itemname'; } if (isset($HTTP_POST_VARS['order'])) { $sort_order = $HTTP_POST_VARS['order'] == 'ASC' ? 'ASC' : 'DESC'; } else { if (isset($HTTP_GET_VARS['order'])) { $sort_order = $HTTP_GET_VARS['order'] == 'ASC' ? 'ASC' : 'DESC'; } else { $sort_order = 'ASC'; } } if (isset($HTTP_GET_VARS['cat']) || isset($HTTP_POST_VARS['cat'])) { $cat = isset($HTTP_POST_VARS['cat']) ? htmlspecialchars($HTTP_POST_VARS['cat']) : htmlspecialchars($HTTP_GET_VARS['cat']); } else { $cat = 0; } $cat_sql = $cat ? 'AND i.item_type_use = ' . $cat : ''; $select_category = adr_get_item_type($items['item_type_use'], 'list'); $select_category = str_replace('<select name="item_type_use">', '<select name="cat"><option value="0" selected="selected">All</option>', $select_category);
function adr_get_item_type_categories($category = 'none') { global $categories_text, $categories, $categories_cat, $db, $phpbb_root_path, $phpEx, $lang, $adr_item_type; adr_get_item_type(0, ''); require_once $phpbb_root_path . './adr/cache/cache_item_type.' . $phpEx; if (!isset($adr_item_type)) { if ($category != 'none') { $category = explode(",", $category); for ($a = 0; $a <= count($category); $a++) { $category_list .= "'" . $category[$a] . "',"; } $where = " AND item_type_category IN (" . $category_list . " 0)"; } else { $where = ''; } // Get and display all the items type $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TYPE_TABLE . "\r\n\t\t\tWHERE item_type_id <> 0 {$where}\r\n\t\t\tORDER BY item_type_category, item_type_order ASC"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to query config infos (updating cache)', '', __LINE__, __FILE__, $sql); } $items_type = $db->sql_fetchrowset($result); for ($t = 0; $t < count($items_type); $t++) { array_push($categories_text, $items_type[$t]['item_type_lang']); array_push($categories, $items_type[$t]['item_type_id']); array_push($categories_cat, $items_type[$t]['item_type_category']); } } else { if ($category != 'none') { $category = explode(',', $category); } for ($t = 0; $t < count($adr_item_type); $t++) { if ($category == 'none') { array_push($categories_text, $adr_item_type[$t]['item_type_lang']); array_push($categories, $adr_item_type[$t]['item_type_id']); array_push($categories_cat, $adr_item_type[$t]['item_type_category']); } elseif (in_array($adr_item_type[$t]['item_type_category'], $category)) { array_push($categories_text, $adr_item_type[$t]['item_type_lang']); array_push($categories, $adr_item_type[$t]['item_type_id']); array_push($categories_cat, $adr_item_type[$t]['item_type_category']); } } } }
} $items_list .= '<option value = "' . $itemslist[$i]['item_id'] . '" ' . $selected_items . '>' . adr_get_lang($itemslist[$i]['item_name']) . ' - ' . $lang['Adr_items_level'] . ' ' . $itemslist[$i]['item_power'] . '</option>'; $selected_items = ''; } $items_list .= '</select>'; // Battle options $battle[0] = $lang['Adr_spells_battle']; $battle[1] = $lang['Adr_spells_no_battle']; $battle[2] = $lang['Adr_spells_battle_no_battle']; $battle_list = '<select name="battle_list">'; for ($i = 0; $i < 3; $i++) { $selected = $i == $items['spell_battle'] ? ' selected="selected"' : ''; $battle_list .= '<option value = "' . $i . '" ' . $selected . '>' . $battle[$i] . '</option>'; } $battle_list .= '</select>'; $template->assign_vars(array("ITEM_NAME" => $items['spell_name'], "ITEM_DESC" => $items['spell_desc'], "ITEM_CLASS_LIMIT" => $class_type, "ITEM_NAME_EXPLAIN" => adr_get_lang($items['spell_name']), "ITEM_DESC_EXPLAIN" => adr_get_lang($items['spell_desc']), "ITEM_IMG" => $items['spell_icon'], "ITEM_TYPE" => adr_get_item_type($items['item_type_use'], 'list'), "ITEM_LEVEL" => $items['spell_level'], "ITEM_POWER" => $items['spell_power'], "ITEM_ADD_POWER" => $items['spell_add_power'], "ITEM_MP_USE" => $items['spell_mp_use'], "ITEM_ELEMENT_LIST" => $element_weap_list, "ITEM_ELEMENT_STR" => $items['spell_element_str_dmg'], "ITEM_ELEMENT_SAME" => $items['spell_element_same_dmg'], "ITEM_ELEMENT_WEAK" => $items['spell_element_weak_dmg'], "ITEM_RECIPE" => $spell_recipe, "ITEM_MAX_SKILL" => $items['spell_max_skill'], "ITEM_AUTH" => $items['spell_auth'] ? 'checked' : '', "ITEMS_REQ" => $items_list, "ITEMS_AMOUNT" => $items['spell_items_amount'], "ITEM_BATTLE_LIST" => $battle_list, "ITEM_XTREME" => $items['spell_xtreme'], "ITEM_XTREME_BATTLE" => $items['spell_xtreme_battle'], "ITEM_XTREME_PVP" => $items['spell_xtreme_pvp'], "ITEM_ALIGNMENT_LIMIT" => $alignment_type, "ITEM_ELEMENT_LIMIT" => $element_restrict_list, "L_ITEMS_REQ" => $lang['Adr_spells_items_req'], "L_ITEMS_REQ_DESC" => $lang['Adr_spells_items_req_desc'], "L_ITEMS_AMOUNT" => $lang['Adr_spells_items_amount'], "L_ITEMS_AMOUNT_DESC" => $lang['Adr_spells_items_amount_desc'], "L_CLASS_LIMIT" => $lang['Adr_items_class_limit'], "L_CLASS_LIMIT_EXPLAIN" => $lang['Adr_spells_class_explain'], "L_ITEM_ELEMENT" => $lang['Adr_shops_item_element'], "L_ITEM_ELEMENT_STR" => $lang['Adr_shops_item_element_str'], "L_ITEM_ELEMENT_SAME" => $lang['Adr_shops_item_element_same'], "L_ITEM_ELEMENT_WEAK" => $lang['Adr_shops_item_element_weak'], "L_ITEM_MAX_SKILL" => $lang['Adr_item_max_skill'], "L_ITEM_ADD_POWER" => $lang['Adr_items_dex'], "L_ITEM_ADD_POWER_EXPLAIN" => $lang['Adr_items_dex_explain'], "L_ITEM_MP_USE" => $lang['Adr_items_mp_use'], "L_ITEM_MP_USE_EXPLAIN" => $lang['Adr_items_mp_use_explain'], "L_NAME_EXPLAIN" => $lang['Adr_races_name_explain'], "L_ITEMS_TITLE" => $lang['Adr_spells_add_title'], "L_ITEMS_EXPLAIN" => $lang['Adr_spells_add_title_explain'], "L_ITEM_NAME" => $lang['Adr_shops_categories_item_name'], "L_ITEM_DESC" => $lang['Adr_shops_categories_item_desc'], "L_ITEM_LEVEL" => $lang['Adr_items_level'], "L_ITEM_LEVEL_EXPLAIN" => $lang['Adr_spells_level_explain'], "L_ITEM_POWER" => $lang['Adr_items_power'], "L_NAME" => $lang['Adr_races_name'], "L_DESC" => $lang['Adr_races_desc'], "L_ACTION" => $lang['Action'], "L_ITEMS" => $lang['Adr_shops_categories_items'], "L_EDIT" => $lang['Edit'], "L_DELETE" => $lang['Delete'], "L_ITEM_IMG" => $lang['Adr_races_image'], "L_IMG" => $lang['Adr_races_image'], "L_IMG_EXPLAIN" => $lang['Adr_items_image_explain'], "L_ITEM_TYPE" => $lang['Adr_spells_type'], "L_ITEM_TYPE_EXPLAIN" => $lang['Adr_spells_type_use_explain'], "L_ITEM_AUTH" => $lang['Adr_spells_auth'], "L_ITEM_AUTH_EXPLAIN" => $lang['Adr_spells_auth_explain'], "L_ITEM_RECIPE" => $lang['Adr_spells_item_recipe'], "L_ITEM_RECIPE_EXPLAIN" => $lang['Adr_spells_item_recipe_explain'], "L_ITEM_BATTLE" => $lang['Adr_spells_battle'], "L_ITEM_BATTLE_EXPLAIN" => $lang['Adr_spells_battle_explain'], "L_ITEM_XTREME" => $lang['Adr_spells_xtreme'], "L_ITEM_XTREME_EXPLAIN" => $lang['Adr_spells_xtreme_explain'], "L_ITEM_XTREME_BATTLE" => $lang['Adr_spells_xtreme_battle'], "L_ITEM_XTREME_BATTLE_EXPLAIN" => $lang['Adr_spells_xtreme_battle_explain'], "L_ITEM_XTREME_PVP" => $lang['Adr_spells_xtreme_pvp'], "L_ITEM_XTREME_PVP_EXPLAIN" => $lang['Adr_spells_xtreme_pvp_explain'], "L_ALIGNMENT_LIMIT" => $lang['Adr_spells_alignment_limit'], "L_ALIGNMENT_LIMIT_EXPLAIN" => $lang['Adr_spells_alignment_limit_explain'], "L_ELEMENT_LIMIT" => $lang['Adr_spells_element_limit'], "L_ELEMENT_LIMIT_EXPLAIN" => $lang['Adr_spells_element_limit_explain'], "L_SUBMIT" => $lang['Submit'], "S_ITEMS_ACTION" => append_sid("admin_adr_forums_shop_spells.{$phpEx}"), "S_HIDDEN_FIELDS" => $s_hidden_fields)); $template->pparse("body"); break; case "save_item": $item_id = intval($_POST['item_id']); $item_name = isset($_POST['item_name']) ? trim($_POST['item_name']) : trim($_GET['item_name']); $item_desc = isset($_POST['item_desc']) ? trim($_POST['item_desc']) : trim($_GET['item_desc']); $item_icon = isset($_POST['item_img']) ? trim($_POST['item_img']) : trim($_GET['item_img']); $item_type_use = intval($_POST['item_type_use']); $item_power = intval($_POST['item_power']); $item_level = intval($_POST['item_level']); $item_add_power = intval($_POST['item_add_power']); $item_mp_use = intval($_POST['item_mp_use']); $item_element = intval($_POST['element_weap_list']); $item_element_str = intval($_POST['item_element_str']); $item_element_same = intval($_POST['item_element_same']);