if (!is_numeric($row['character_class'])) { adr_previous(Adr_admin_character_lack, admin_adr_users, ''); } $max_hp = $row['class_update_xp_req']; for ($p = 1; $p < $row['character_level']; $p++) { $max_hp = floor($max_hp * (($adr_general['next_level_penalty'] + 100) / 100)); } $class = adr_get_lang($row['class_name']); $race = adr_get_lang($row['race_name']); $element = adr_get_lang($row['element_name']); $alignment = adr_get_lang($row['alignment_name']); $message = $row['character_desc']; $message = str_replace('<', '<', $message); $message = str_replace('>', '>', $message); $message = str_replace('<br />', "\n", $message); $skills = adr_get_skill_data(''); // Generate the lists $sql = "SELECT * FROM " . ADR_RACES_TABLE; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain races information', "", __LINE__, __FILE__, $sql); } $races = $db->sql_fetchrowset($result); $races_list = '<select name="character_race" >'; for ($i = 0; $i < count($races); $i++) { $races[$i]['race_name'] = adr_get_lang($races[$i]['race_name']); $race_selected = $row['character_race'] == $races[$i]['race_id'] ? 'selected' : ''; $races_list .= '<option value = "' . $races[$i]['race_id'] . '" ' . $race_selected . ' >' . $races[$i]['race_name'] . '</option>'; } $races_list .= '</select>'; $sql = "SELECT * FROM " . ADR_ELEMENTS_TABLE;
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; }
function adr_use_skill_stone($user_id, $tool, $item_to_repair) { global $db; $user_id = intval($user_id); $tool = intval($tool); $item_to_repair = intval($item_to_repair); $success = 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 // 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(2); $user_chance = $adr_user['character_skill_stone'] * $skill_data['skill_chance']; $user_chance = $user_chance > 100 ? 100 : $user_chance; $rand = rand(0, 100); // At first let's introduce a little fun if ($rand < 5) { // Destroy the item $success = -1; $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tWHERE item_in_shop = 0 \n\t\t\tAND item_owner_id = {$user_id} \n\t\t\tAND item_id = {$item_to_repair} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not update item information', "", __LINE__, __FILE__, $sql); } } else { if ($user_chance > $rand && $rand > 4) { $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tWHERE item_in_shop = 0 \n\t\t\tAND item_owner_id = {$user_id} \n\t\t\tAND item_id = {$tool} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql); } $tool_data = $db->sql_fetchrow($result); $modif = $tool_data['item_quality'] > 3 ? $tool_data['item_quality'] - 3 : 0; $modif = $modif + ($tool_data['item_power'] - 1); $repair_power = floor(($modif + $adr_user['character_skill_stone']) / 2); $success = $repair_power; adr_skill_limit($user_id); // Check max dura $sql = "SELECT item_duration, item_duration_max FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tWHERE item_owner_id = '{$user_id}'\n\t\t\tAND item_id = '{$item_to_repair}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql); } $max_dura_check = $db->sql_fetchrow($result); $new_max_dura = $max_dura_check['item_duration'] + $repair_power > $max_dura_check['item_duration_max'] ? $max_dura_check['item_duration'] + $repair_power : $max_dura_check['item_duration_max']; $sql = " UPDATE " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tSET item_duration = item_duration + {$repair_power} ,\n\t\t\t\titem_duration_max = {$new_max_dura},\n\t\t\t item_quality = item_quality + 1\n\t\t\tWHERE item_in_shop = 0\n\t\t\tAND item_quality < 5\n\t\t\tAND item_owner_id = {$user_id}\n\t\t\tAND item_id = {$item_to_repair} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update item informations', '', __LINE__, __FILE__, $sql); } // Increases the success uses of this skill and increase level if needed if ($adr_user['character_skill_stone_uses'] + 1 >= $skill_data['skill_req']) { $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\tSET character_skill_stone_uses = 0 , \n\t\t\t\t\tcharacter_skill_stone = character_skill_stone + 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_stone_uses = character_skill_stone_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 $success; }
$items_req_print = '<table border="0" width="95%">'; for ($i = 0; $i < count($items_req); $i++) { $switch = !($i % 2) ? $get_info = 1 : ($get_info = 0); if ($get_info == 1) { $sql_info = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\twhere item_id = " . $items_req[$i]; $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); $items_req_print .= '<tr><td>' . $lang[$item_info['item_name']] . '</td><td><img src="../adr/images/items/' . $item_info['item_icon'] . '"></td>'; } else { $items_req_print .= '<td>(x' . $items_req[$i] . ')</td></tr>'; } } $items_req_print .= '</table>'; $skill_data = adr_get_skill_data($recipes[$k]['item_recipe_skill_id']); $template->assign_block_vars("recipes", array("ROW_CLASS" => $row_class, "RECIPE_IMG" => $recipes[$k]['item_icon'], "RECIPE_NAME" => $recipes[$k]['item_name'], "RECIPE_SKILL" => adr_get_lang($skill_data['skill_name']), "RECIPE_LEVEL" => $recipes[$k]['item_power'], "RECIPE_DESC" => $recipes[$k]['item_desc'], "RECIPE_EFFECT" => $effects_print_list, "RECIPE_ITEMS_REQ" => $items_req_print, "RECIPE_ADMIN_ONLY" => $recipes[$k]['item_auth'], "U_RECIPE_EDIT" => append_sid("admin_adr_crafting_recipes.{$phpEx}?mode=edit_recipe&recipe_id=" . $recipes[$k]['item_id']), "U_RECIPE_DELETE" => append_sid("admin_adr_crafting_recipes.{$phpEx}?mode=delete_recipe&recipe_id=" . $recipes[$k]['item_id']))); } $sql = "SELECT count(*) AS total FROM " . ADR_SHOPS_ITEMS_TABLE . " \r\n\t\twhere item_brewing_recipe = 1\r\n\t\t"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Error getting total crafting recipes', '', __LINE__, __FILE__, $sql); } if ($total = $db->sql_fetchrow($result)) { $total_recipes = $total['total']; $pagination = generate_pagination("admin_adr_crafting_recipes.{$phpEx}?mode2={$mode2}&order={$sort_order}", $total_recipes, $board_config['topics_per_page'], $start) . ' '; } $template->assign_vars(array("L_RECIPES_TITLE" => $lang['Adr_recipes_title'], "L_RECIPES_ATTENTION" => $lang['Adr_recipe_attention'], "L_RECIPES_EXPLAIN" => $lang['Adr_recipes_title_explain'], "L_RECIPES_IMG" => $lang['Adr_recipes_img'], "L_RECIPES_NAME" => $lang['Adr_recipes_name'], "L_RECIPE_SKILL" => $lang['Adr_recipe_skill'], "L_RECIPES_LEVEL" => $lang['Adr_recipes_level'], "L_RECIPES_DESC" => $lang['Adr_recipes_desc'], "L_RECIPES_EFFECT" => $lang['Adr_recipes_effect'], "L_RECIPES_ITEMS_REQ" => $lang['Adr_recipes_items_req'], "L_RECIPES_ADMIN_ONLY" => $lang['Adr_recipes_admin_only'], "L_RECIPES_ADD" => $lang['Adr_recipes_add'], "L_RECIPES_ACTION" => $lang['Action'], "L_RECIPES_EDIT" => $lang['Edit'], "L_RECIPES_DELETE" => $lang['Delete'], 'L_RECIPES_ORDER' => $lang['Order'], 'L_RECIPES_SORT' => $lang['Sort'], 'L_RECIPES_SELECT_SORT_METHOD' => $lang['Select_sort_method'], 'S_RECIPES_MODE_SELECT' => $select_sort_mode, 'S_RECIPES_ORDER_SELECT' => $select_sort_order, 'RECIPES_PAGINATION' => $pagination, 'RECIPES_PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $board_config['topics_per_page']) + 1, max(1, ceil($total_recipes / $board_config['topics_per_page']))), "S_RECIPES_ACTION" => append_sid("admin_adr_crafting_recipes.{$phpEx}?mode2={$mode2}&order={$sort_order}"), "S_HIDDEN_FIELDS" => $s_hidden_fields)); $template->pparse("body"); } include './page_footer_admin.' . $phpEx;