$greave_name = adr_get_lang($item['item_name']); } if ($boot) { $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\t\t\t\t\tWHERE item_in_shop = 0 \r\t\t\t\t\tAND item_owner_id = {$user_id} \r\t\t\t\t\t{$item_sql}\r\t\t\t\t\tAND item_id = {$boot} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $def = $def + $item['item_power'] + $item['item_add_power']; adr_use_item($boot, $user_id); $boot_name = adr_get_lang($item['item_name']); } // Now we modify mp and hp regeneration with amulets and rings if ($amulet) { $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\t\t\t\t\tWHERE item_in_shop = 0 \r\t\t\t\t\tAND item_owner_id = {$user_id} \r\t\t\t\t\t{$item_sql}\r\t\t\t\t\tAND item_id = {$amulet} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $hp_regen = $hp_regen + $item['item_power']; adr_use_item($amulet, $user_id); $amulet_name = adr_get_lang($item['item_name']); } if ($ring) { $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\t\t\t\t\tWHERE item_in_shop = 0 \r\t\t\t\t\tAND item_owner_id = {$user_id} \r\t\t\t\t\t{$item_sql}\r\t\t\t\t\tAND item_id = {$ring} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $mp_regen = $mp_regen + $item['item_power']; adr_use_item($ring, $user_id);
$item = $db->sql_fetchrow($result); if ($current_mp < $item['item_mp_use'] || $current_mp < '0') { adr_previous(Adr_battle_check, 'adr_battle', ''); } // Remove any MP costs if ($item['item_mp_use'] > '0') { $check_mp = $user_id === $battle_challenger_id ? 'battle_challenger_mp' : 'battle_opponent_mp'; $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\n\t\t\t\t\t\tSET {$check_mp} = ({$check_mp} - " . $item['item_mp_use'] . ")\n\t\t\t\t\t\tWHERE battle_id = '{$battle_id}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql); } } // Define theses values according to the item type ( enchanted weapon are better than normal weapons ) $quality = $item['item_type_use'] == '6' ? $item['item_quality'] * 2 : $item['item_quality']; $power = $item['item_power'] + $item['item_add_power']; adr_use_item($weap, $user_id); } // Let's check if the attack succeeds $dice = rand(1, 20); $diff = $current_att + $quality + $dice + $current_infos['character_level'] > $opponent_def + $opponent_infos['character_level'] ? TRUE : FALSE; $power = $power + adr_modifier_calc($current_infos['character_might']); $damage = 1; // Elemental infos $elemental = adr_get_element_infos($opponent_element); $element_name = $item['item_name'] != '' ? adr_get_element_infos($item['item_element']) : ''; // Here we apply text colour if set if ($element_name['element_colour'] != '') { $item['item_name'] = '<font color="' . $element_name['element_colour'] . '">' . adr_get_lang($item['item_name']) . '</font>'; } else { $item['item_name'] = adr_get_lang($item['item_name']); }
function adr_potion_generic() { global $monster, $bat, $adr_user, $opponent_element, $item, $db, $lang, $user_id, $power; global $challenger, $battle_message, $user_action, $monster_action, $attack_img, $attackwith_overlay; rabbit_pet_regen(); include_once $phpbb_root_path . '/adr/includes/adr_functions_battle_setup.' . $phpEx; $e_message = adr_battle_effects_initialise($user_id, $item_potion, $monster['monster_name'], 0); // Use item adr_use_item($item_potion, $user_id); $battle_message .= $e_message; // low dura message if ($item['item_duration'] < '2' && $power > '0') { $battle_message .= '</span><span class="gensmall">'; // set new span class $battle_message .= ' > ' . sprintf($lang['Adr_battle_potion_mp_dura_none'], $challenger['character_name'], adr_get_lang($item['item_name']), adr_get_lang($item['item_name'])) . '<br>'; $battle_message .= '</span><span class="genmed">'; // reset span class to default } //($item['item_duration'] < '2') && ($power > '0') // Update the database $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\n\t\tSET battle_turn = 2,\n\t\t\tbattle_round = (battle_round + 1)\n\t\tWHERE battle_challenger_id = '{$user_id}'\n\t\tAND battle_result = '0'\n\t\tAND battle_type = '1'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql); } //!($result = $db->sql_query($sql)) // Let's sort out the potion (mp) animations... // Make table for start battle sequence... // 0 = Standing image , 1 = Attack image $user_action = 0; $monster_action = 1; $attack_img = $item['item_name']; $attackwith_overlay = file_exists("adr/images/battle/spells/" . $attack_img . ".gif") ? '<img src="adr/images/battle/spells/' . $attack_img . '.gif" width="256" height="96" border="0">' : ''; }
$tool_list = '<select name="item_tool">'; $tool_list .= '<option value = "0" >' . $lang['Adr_forge_lumberjack_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>'; $template->assign_vars(array('TOOL_LIST' => $tool_list, 'L_SELECT_TOOL' => $lang['Adr_forge_lumberjack_select_tool'], 'L_GO_LUMBERJACK' => $lang['Adr_forge_lumberjack_go'], 'L_LUMBERJACK_EXPLAIN' => $lang['Adr_forge_lumberjack_explain'])); break; case 'lumberjack_action': $tool = intval($HTTP_POST_VARS['item_tool']); // No tool , no lumberjacking if (!$tool) { adr_previous(Adr_forge_lumberjack_tool_needed, adr_lumberjack, "mode=lumberjacking"); } else { //Tool gets used even if character doesn't find anything adr_use_item($tool, $user_id); $item = drop_gather_loot($actual_zone, $user_id, 'herbalism', 8); if (!$item) { include $phpbb_root_path . 'adr/includes/adr_header.' . $phpEx; $direction = append_sid("adr_lumberjack.{$phpEx}?mode=lumberjacking"); $message .= "Vous n'avez rien trouvé."; $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } else { include $phpbb_root_path . 'adr/includes/adr_header.' . $phpEx; $message = $item . '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } } break; }
function adr_battle_equip_initialise($user_id, $armor, $buckler, $helm, $gloves, $amulet, $ring) { global $db, $lang, $adr_general, $template, $board_config; $user_id = intval($user_id); $armor = intval($armor); $buckler = intval($buckler); $helm = intval($helm); $gloves = intval($gloves); $amulet = intval($amulet); $ring = intval($ring); // Get the user infos $char = adr_get_user_infos($user_id); ### START restriction checks ### $item_sql = adr_make_restrict_sql($char); ### END restriction checks ### // Be sure he has a character if (!is_numeric($char['character_id'])) { adr_previous(Adr_your_character_lack, adr_character, ''); } // Calculate the base stats $hp = 0; $mp = 0; $level = $char['character_level']; $char_element = $char['character_element']; $char_mp = $char['character_mp']; // Create base attack & defence stats $att = adr_battle_make_att($char['character_might'], $char['character_constitution']); $ma = adr_battle_make_magic_att($char['character_intelligence']); $def = adr_battle_make_def($char['character_ac'], $char['character_dexterity']); $md = adr_battle_make_magic_def($char['character_wisdom']); if ($armor) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$armor}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $armor_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($armor, $user_id); } if ($buckler) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$buckler}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $buckler_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($buckler, $user_id); } if ($gloves) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$gloves}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $gloves_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($gloves, $user_id); } if ($helm) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$helm}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $helm_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($helm, $user_id); } // Now we modify mp and hp regeneration with amulets and rings if ($amulet) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$amulet}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $amulet_id = $item['item_id']; $hp = $hp + $item['item_power']; adr_use_item($amulet, $user_id); } if ($ring) { $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_in_warehouse = '0'\n\t\t\t{$item_sql}\n\t\t\tAND item_id = '{$ring}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $ring_id = $item['item_id']; $mp = $mp + $item['item_power']; adr_use_item($ring, $user_id); } ##=== START: new monster rand selection code as posted by Sederien ===## // Let's care about the opponent now $sql = " SELECT * FROM " . ADR_BATTLE_MONSTERS_TABLE . "\n\t\tWHERE monster_level <= '{$level}'\n\t\tORDER BY RAND() LIMIT 1"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query monsters list', '', __LINE__, __FILE__, $sql); } $monsters = $db->sql_fetchrow($result); // Be sure monsters of the user level exists if (!$monsters) { adr_previous(Adr_no_monsters, adr_character, ''); } // Get this monster base stats $monster_id = $monsters['monster_id']; $monster_level = $monsters['monster_level']; $monster_base_hp = $monsters['monster_base_hp']; $monster_base_att = $monsters['monster_base_att']; $monster_base_def = $monsters['monster_base_def']; $monster_base_element = $monsters['monster_base_element']; $monster_base_mp = $monsters['monster_base_mp']; $monster_base_mp_power = $monsters['monster_base_mp_power']; $monster_base_ma = $monsters['monster_base_magic_attack']; $monster_base_md = $monsters['monster_base_magic_resistance']; $monster_base_sp = $monsters['monster_base_sp']; ##=== END: new monster selection code by Sederien ===## // If the user is higher level than the monster , update the monster stats if ($monster_level < $level) { if ($adr_general['battle_calc_type']) { // Xanathis's alternative battle modifier calculation for monster battles $modifier = ($adr_general['battle_monster_stats_modifier'] - 100) / 100 * ($level - $monster_level) + 1; } else { $modifier = $adr_general['battle_monster_stats_modifier'] / 100 * ($level - $monster_level); } $monster_base_hp = ceil($monster_base_hp * $modifier); $monster_base_att = ceil($monster_base_att * $modifier); $monster_base_def = ceil($monster_base_def * $modifier); $monster_base_mp = ceil($monster_base_mp * $modifier); $monster_base_ma = ceil($monster_base_ma * $modifier); $monster_base_md = ceil($monster_base_md * $modifier); $monster_base_sp = ceil($monster_base_sp * $modifier); } ##=== START array for equipment id's ## $equip_array = intval($helm_id) . '-' . intval($armor_id) . '-' . intval($gloves_id) . '-' . intval($buckler_id) . '-' . intval($amulet_id) . '-' . intval($ring_id) . '-' . intval($hp) . '-' . intval($mp); ##=== END array for equipment id's ## ##=== START: Initiative Checks // 1d20 roll. Highest starts. $monster_dex = 10 + rand(1, $monster_level) * 2; //temp $challenger_init_check = rand(1, 20) + adr_modifier_calc($char['character_dexterity']); $monster_init_check = rand(1, 20) + adr_modifier_calc($monster_dex); // Check who will start ELSE do a rand to determine. if ($challenger_init_check >= $monster_init_check) { $turn = 1; } else { $turn = 2; } ##=== END: Initiative Checks // Finally insert all theses values into the database $sql = "INSERT INTO " . ADR_BATTLE_LIST_TABLE . "\n\t\t(battle_type, battle_start, battle_turn, battle_result, battle_text, battle_challenger_id, battle_challenger_hp, battle_challenger_mp, battle_challenger_att, battle_challenger_def, battle_challenger_element, battle_challenger_magic_attack, battle_challenger_magic_resistance, battle_challenger_equipment_info, battle_opponent_id, battle_opponent_hp, battle_opponent_hp_max, battle_opponent_mp, battle_opponent_mp_max, battle_opponent_mp_power, battle_opponent_att, battle_opponent_def, battle_opponent_element, battle_opponent_magic_attack, battle_opponent_magic_resistance, battle_opponent_sp)\n\t\tVALUES(1, " . time() . ", {$turn}, 0, '', {$user_id}, {$hp}, {$mp}, {$att}, {$def}, {$char_element}, {$ma}, {$md}, '{$equip_array}', {$monster_id}, {$monster_base_hp}, {$monster_base_hp}, {$monster_base_mp}, {$monster_base_mp}, {$monster_base_mp_power}, {$monster_base_att}, {$monster_base_def}, {$monster_base_element}, {$monster_base_ma}, {$monster_base_md}, {$monster_base_sp})"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new battle", "", __LINE__, __FILE__, $sql); } return; }
function adr_battle_equip_initialise($user_id, $armor, $buckler, $helm, $gloves, $amulet, $ring, $greave, $boot) { global $db, $lang, $adr_general, $template, $board_config, $phpEx; $user_id = intval($user_id); $armor = intval($armor); $buckler = intval($buckler); $helm = intval($helm); $gloves = intval($gloves); $amulet = intval($amulet); $ring = intval($ring); // Get the user infos $char = adr_get_user_infos($user_id); ### START restriction checks ### $item_sql = adr_make_restrict_sql($char); ### END restriction checks ### // Be sure he has a character if (!is_numeric($char['character_id'])) { adr_previous(Adr_your_character_lack, adr_character, ''); } // Calculate the base stats $hp = 0; $mp = 0; $level = $char['character_level']; $char_element = $char['character_element']; $char_mp = $char['character_mp']; // Create base attack & defence stats $att = adr_battle_make_att($char['character_might'], $char['character_constitution']); $ma = adr_battle_make_magic_att($char['character_intelligence']); $def = adr_battle_make_def($char['character_ac'], $char['character_dexterity']); $md = adr_battle_make_magic_def($char['character_wisdom']); // Modify stats depending to zone element $zone_user = adr_get_user_infos($user_id); $actual_zone = $zone_user['character_area']; $sql = "SELECT * FROM " . ADR_ZONES_TABLE . "\r\n\t\tWHERE zone_id = {$actual_zone}"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain zones information', "", __LINE__, __FILE__, $sql); } $zone_check = $db->sql_fetchrow($result); if ($board_config['zone_bonus_enable'] == '1' && $zone_check['zone_element'] == '$char_element') { $bonus_att = $board_config['zone_bonus_att']; $bonus_def = $board_config['zone_bonus_def']; $att = ($char['character_might'] + $char['character_constitution']) * 2 + $bonus_att; $def = $char['character_dexterity'] + $char['character_wisdom'] + $char['character_ac'] + $bonus_def; } // Start party $party = $char['character_party']; if ($party > 0) { $sql = " SELECT character_party FROM " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t WHERE character_party = {$party} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query count for info page', '', __LINE__, __FILE__, $sql); } $count_members = $db->sql_numrows($result); } elseif ($party = 0) { $sql = " SELECT character_party FROM " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t WHERE character_party = 0 "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query count for info page', '', __LINE__, __FILE__, $sql); } $count_members = $db->sql_numrows($result); } // Boost ATT $att = $att + $count_members + $count_members + $count_members; $att = round($att); // Boost DEF $def = $def + $count_members + $count_members + $count_members + $count_members + $count_members; $def = round($def); // Boost MA $ma = $ma + $count_members + $count_members + $count_members; $ma = round($ma); // Boost MD $md = $md + $count_members + $count_members + $count_members + $count_members + $count_members; $md = round($md); // End Party if ($armor) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$armor}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $armor_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($armor, $user_id); $armour_name = adr_get_lang($item['item_name']); } $def = $def + $adr_general['shield_bonus'] * $char['character_skill_shield_level']; if ($buckler) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$buckler}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $buckler_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($buckler, $user_id); $buckler_name = adr_get_lang($item['item_name']); } if ($gloves) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$gloves}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $gloves_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($gloves, $user_id); $gloves_name = adr_get_lang($item['item_name']); } if ($helm) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$helm}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $helm_id = $item['item_id']; $def = $def + ($item['item_power'] + $item['item_add_power']); adr_use_item($helm, $user_id); $helm_name = adr_get_lang($item['item_name']); } // Now we modify mp and hp regeneration with amulets and rings if ($amulet) { $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$amulet}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $amulet_id = $item['item_id']; $hp = $hp + $item['item_power']; adr_use_item($amulet, $user_id); $amulet_name = adr_get_lang($item['item_name']); } if ($ring) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = '0'\r\n\t\t\tAND item_owner_id = '{$user_id}'\r\n\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t{$item_sql}\r\n\t\t\tAND item_id = '{$ring}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $ring_id = $item['item_id']; $mp = $mp + $item['item_power']; adr_use_item($ring, $user_id); $ring_name = adr_get_lang($item['item_name']); } if ($greave) { $sql = " SELECT item_name , item_power , item_add_power FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = 0 \r\n\t\t\tAND item_owner_id = {$user_id} \r\n\t\t\tAND item_in_warehouse = 0\r\n\t\t\tAND item_id = {$greave} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $def = $def + $item['item_power'] + $item['item_add_power']; $greave_name = $item['item_name']; adr_use_item($greave, $user_id); $greave_name = adr_get_lang($item['item_name']); } if ($boot) { $sql = " SELECT item_name , item_power , item_add_power FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = 0 \r\n\t\t\tAND item_owner_id = {$user_id} \r\n\t\t\tAND item_in_warehouse = 0\r\n\t\t\tAND item_id = {$boot} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql); } $item = $db->sql_fetchrow($result); $def = $def + $item['item_power'] + $item['item_add_power']; $boot_name = $item['item_name']; adr_use_item($boot, $user_id); $boot_name = adr_get_lang($item['item_name']); } if ($zone_check['zone_monsters_list'] == '') { adr_previous(Adr_zone_no_monsters, adr_zones, ''); } $monster_area = $zone_check['zone_monsters_list'] == '0' ? "" : "AND monster_id IN (" . $zone_check['zone_monsters_list'] . ")"; ##=== START: new monster rand selection code as posted by Sederien ===## # V: JK. That's zone mod's code :). // Let's care about the opponent now $actual_weather = $zone_user['character_weather']; $actual_season = $board_config['adr_seasons']; $actual_time = $board_config['adr_time']; $sql = " SELECT * FROM " . ADR_BATTLE_MONSTERS_TABLE . "\r\n\t\t\tWHERE monster_level <= {$level} \r\n\t\t\t{$monster_area}\r\n\t\t\tAND ( monster_weather = {$actual_weather} || monster_weather = 0 )\r\n\t\t\tAND (monster_time = {$actual_time} OR monster_time = 0)\r\n\t\t\tAND ( monster_season = {$actual_season} || monster_season = 0 )"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query monsters list', '', __LINE__, __FILE__, $sql); } $monsters = $db->sql_fetchrow($result); // Be sure monsters of the user level exists if (!$monsters) { adr_previous(Adr_no_monsters, adr_character, ''); } // Get this monster base stats $monster_id = $monsters['monster_id']; $monster_level = $monsters['monster_level']; $monster_base_hp = $monsters['monster_base_hp']; $monster_base_att = $monsters['monster_base_att']; $monster_base_def = $monsters['monster_base_def']; $monster_base_element = $monsters['monster_base_element']; $monster_base_mp = $monsters['monster_base_mp']; $monster_base_mp_power = $monsters['monster_base_mp_power']; $monster_base_ma = $monsters['monster_base_magic_attack']; $monster_base_md = $monsters['monster_base_magic_resistance']; $monster_base_sp = $monsters['monster_base_sp']; ##=== END: new monster selection code by Sederien ===## // If the user is higher level than the monster , update the monster stats if ($monster_level < $level) { if ($adr_general['battle_calc_type']) { // Xanathis's alternative battle modifier calculation for monster battles $modifier = ($adr_general['battle_monster_stats_modifier'] - 100) / 100 * ($level - $monster_level) + 1; } else { $modifier = $adr_general['battle_monster_stats_modifier'] / 100 * ($level - $monster_level); } $monster_base_hp = ceil($monster_base_hp * $modifier); $monster_base_att = ceil($monster_base_att * $modifier); $monster_base_def = ceil($monster_base_def * $modifier); $monster_base_mp = ceil($monster_base_mp * $modifier); $monster_base_ma = ceil($monster_base_ma * $modifier); $monster_base_md = ceil($monster_base_md * $modifier); $monster_base_sp = ceil($monster_base_sp * $modifier); } ##=== START array for equipment id's ## $equip_array = intval($helm_id) . '-' . intval($armor_id) . '-' . intval($gloves_id) . '-' . intval($buckler_id) . '-' . intval($amulet_id) . '-' . intval($ring_id) . '-' . intval($hp) . '-' . intval($mp) . '-' . intval($greave) . '-' . intval($boot); ##=== END array for equipment id's ## ##=== START: Initiative Checks // 1d20 roll. Highest starts. $monster_dex = 10 + rand(1, $monster_level) * 2; //temp $challenger_init_check = rand(1, 20) + adr_modifier_calc($char['character_dexterity']); $monster_init_check = rand(1, 20) + adr_modifier_calc($monster_dex); // Check who will start ELSE do a rand to determine. if ($challenger_init_check >= $monster_init_check) { $turn = 1; } else { $turn = 2; } ##=== END: Initiative Checks $spell_effects = explode(':', $char['character_spell_pre_effects']); for ($i = 0; $i < count($spell_effects); $i++) { if ($spell_effects[$i] == 'ATT') { $value = $spell_effects[$i + 1]; $att = $att + $value; } if ($spell_effects[$i] == 'DEF') { $value = $spell_effects[$i + 1]; $def = $def + $value; } } //remove spell pre-effects $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\tSET character_spell_pre_effects = ''\r\n\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t remove characters spell pre effects for battle', '', __LINE__, __FILE__, $sql); } // Finally insert all theses values into the database $sql = "INSERT INTO " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t(battle_type, battle_start, battle_turn, battle_result, battle_text, battle_challenger_id, battle_challenger_hp, battle_challenger_mp, battle_challenger_att, battle_challenger_def, battle_challenger_element, battle_challenger_magic_attack, battle_challenger_magic_resistance, battle_challenger_equipment_info, battle_opponent_id, battle_opponent_hp, battle_opponent_hp_max, battle_opponent_mp, battle_opponent_mp_max, battle_opponent_mp_power, battle_opponent_att, battle_opponent_def, battle_opponent_element, battle_opponent_magic_attack, battle_opponent_magic_resistance, battle_opponent_sp)\r\n\t\tVALUES(1, " . time() . ", {$turn}, 0, '', {$user_id}, {$hp}, {$mp}, {$att}, {$def}, {$char_element}, {$ma}, {$md}, '{$equip_array}', {$monster_id}, {$monster_base_hp}, {$monster_base_hp}, {$monster_base_mp}, {$monster_base_mp}, {$monster_base_mp_power}, {$monster_base_att}, {$monster_base_def}, {$monster_base_element}, {$monster_base_ma}, {$monster_base_md}, {$monster_base_sp})"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new battle", "", __LINE__, __FILE__, $sql); } // Do armour set check // Do armour set check include_once $phpbb_root_path . 'adr/includes/adr_functions_armour_sets.' . $phpEx; adr_armour_set_check($user_id, $armour_name, $buckler_name, $gloves_name, $helm_name, $amulet_name, $ring_name, $greave_name, $boot_name); }
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; }
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_consume($consumable_id, $user_id) { global $db; // Fix the values $consumable_id = intval($consumable_id); $user_id = intval($user_id); $user = adr_get_user_infos($user_id); //get effects of the consumable $sql_consumable = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_owner_id = {$user_id}\r\n\t\tAND item_id = {$consumable_id} "; $result_consumable = $db->sql_query($sql_consumable); if (!$result_consumable) { message_die(GENERAL_ERROR, "Couldn't get owners consumable effects", "", __LINE__, __FILE__, $sql_consumable); } $consumable = $db->sql_fetchrow($result_consumable); //check if user has a battle in progress with already a temp effect consumable used $sql = " SELECT * FROM " . ADR_BATTLE_LIST_TABLE . " \r\n\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\tAND battle_result = 0\r\n\t\tAND battle_type = 1 \r\n\t\tAND battle_effects != ''\r\n\t\t"; $result = $db->sql_query($sql); if (!($check_battle = $db->sql_fetchrow($result))) { //check if user has already used a temp effect consumable before entering a battle if ($user['character_pre_effects'] != '' && $user['character_pre_effects'] != NULL && (substr_count($consumable['item_effect'], 'M:1:PERM:0') || substr_count($consumable['item_effect'], 'M:0:PERM:0'))) { //already ate consumable with temp effects $message = "You already have temporary effects added to your character !"; return array(0, $message); } else { $effects = array(); $effects = explode(':', $consumable['item_effect']); for ($i = 0; $i < count($effects); $i++) { switch (TRUE) { case $effects[$i] == 'HP' || $effects[$i] == 'MP': if (substr_count($effects[$i + 1], '%')) { $value = floor($user['character_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100); } else { $value = $effects[$i + 1]; } if (substr_count($effects[$i + 1], '-')) { $pre_message = 'Your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'Your character refreshed ' . $value . ' ' . $effects[$i] . ' !<br />'; } if ($effects[$i + 3] == 1) { //effect hits the monster //nothing happens, only possible in battle $pre_message = 'You can\'t use the ' . $effects[$i] . ' effect of this consumable cause it\'s meant to hit an opponent<br />'; } else { //effect hits the user if ($user['character_' . strtolower($effects[$i]) . ''] + $value > $user['character_' . strtolower($effects[$i]) . '_max']) { $value_sql = 'character_' . strtolower($effects[$i]) . ' = ' . $user['character_' . strtolower($effects[$i]) . '_max']; } else { if ($user['character_' . strtolower($effects[$i]) . ''] + $value < 0) { $value_sql = 'character_' . strtolower($effects[$i]) . ' = 0'; } else { $value_sql = 'character_' . strtolower($effects[$i]) . ' = character_' . strtolower($effects[$i]) . ' + ' . $value; } } $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update characters ' . $effects[$i] . '', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; } $message .= $pre_message; break; case $effects[$i] == 'AC' || $effects[$i] == 'STR' || $effects[$i] == 'DEX' || $effects[$i] == 'CON' || $effects[$i] == 'INT' || $effects[$i] == 'WIS' || $effects[$i] == 'CHA' || $effects[$i] == 'MA' || $effects[$i] == 'MD' || $effects[$i] == 'EXP' || $effects[$i] == 'SP': $effects[$i] = $effects[$i] == 'STR' ? 'might' : $effects[$i]; $effects[$i] = $effects[$i] == 'DEX' ? 'dexterity' : $effects[$i]; $effects[$i] = $effects[$i] == 'CON' ? 'constitution' : $effects[$i]; $effects[$i] = $effects[$i] == 'INT' ? 'intelligence' : $effects[$i]; $effects[$i] = $effects[$i] == 'WIS' ? 'wisdom' : $effects[$i]; $effects[$i] = $effects[$i] == 'CHA' ? 'charisma' : $effects[$i]; $effects[$i] = $effects[$i] == 'MA' ? 'magic_attack' : $effects[$i]; $effects[$i] = $effects[$i] == 'MD' ? 'magic_resistance' : $effects[$i]; $effects[$i] = $effects[$i] == 'EXP' ? 'xp' : $effects[$i]; if (substr_count($effects[$i + 1], '%')) { $value = floor($user['character_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100); } else { $value = $effects[$i + 1]; } if (substr_count($effects[$i + 1], '-')) { if ($effects[$i + 5] == 1) { // if perm effect $pre_message = 'Your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { if ($effects[$i + 3] == 1) { // hits monster $pre_message = 'For the next battle, your opponent is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'For the next battle your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } } } else { if ($effects[$i + 5] == 1) { // if perm effect $pre_message = 'Your character gains ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { if ($effects[$i + 3] == 1) { // hits monster $pre_message = 'For the next battle, your opponent gets +' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'For the next battle your character gets +' . $value . ' ' . $effects[$i] . ' !<br />'; } } } if ($effects[$i + 3] == 1 || $effects[$i + 3] == 0 && $effects[$i + 5] == 0) { //effect hits the monster //update character_pre_effects field for the next battle $effects[$i] = $effects[$i] == 'magic_attack' ? 'MA' : $effects[$i]; $effects[$i] = $effects[$i] == 'magic_resistance' ? 'MD' : $effects[$i]; $pre_effects .= $pre_effects == '' ? $effects[$i] . ':' . $effects[$i + 1] . ':M:' . $effects[$i + 3] : ':' . $effects[$i] . ':' . $effects[$i + 1] . ':M:' . $effects[$i + 3]; $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\t\tSET character_pre_effects = '" . $pre_effects . "'\r\n\t\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update characters pre effects for battle', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; } else { //effect hits the user if ($user['character_' . strtolower($effects[$i]) . ''] + $value < 0) { $value_sql = 'character_' . strtolower($effects[$i]) . ' = 0'; } else { $value_sql = 'character_' . strtolower($effects[$i]) . ' = character_' . strtolower($effects[$i]) . ' + ' . $value; } $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update characters ' . $effects[$i] . '', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; } $message .= $pre_message; break; case $effects[$i] == 'BATTLES_REM' || $effects[$i] == 'SKILLUSE_REM' || $effects[$i] == 'TRADINGSKILL_REM' || $effects[$i] == 'THEFTSKILL_REM': $effects[$i] = $effects[$i] == 'BATTLES_REM' ? 'battle_limit' : $effects[$i]; $effects[$i] = $effects[$i] == 'SKILLUSE_REM' ? 'skill_limit' : $effects[$i]; $effects[$i] = $effects[$i] == 'TRADINGSKILL_REM' ? 'trading_limit' : $effects[$i]; $effects[$i] = $effects[$i] == 'THEFTSKILL_REM' ? 'thief_limit' : $effects[$i]; if (substr_count($effects[$i + 1], '%')) { $value = floor($user['character_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100); } else { $value = $effects[$i + 1]; } if (substr_count($effects[$i + 1], '-')) { $pre_message = 'Your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'Your character gains ' . $value . ' ' . $effects[$i] . ' !<br />'; } $sql = "SELECT config_value FROM " . ADR_GENERAL_TABLE . " \r\n\t\t\t\t\t\t\tWHERE config_name = 'Adr_character_{$effects[$i]}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query general config', '', __LINE__, __FILE__, $sql); } $general = $db->sql_fetchrow($result); //effect hits the user if ($user['character_' . strtolower($effects[$i]) . ''] + $value > $general['config_value']) { $value_sql = 'character_' . strtolower($effects[$i]) . ' = ' . $general['config_value']; } else { if ($user['character_' . strtolower($effects[$i]) . ''] + $value < 0) { $value_sql = 'character_' . strtolower($effects[$i]) . ' = 0'; } else { $value_sql = 'character_' . strtolower($effects[$i]) . ' = character_' . strtolower($effects[$i]) . ' + ' . $value; } } $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update characters ' . $effects[$i] . '', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; $message .= $pre_message; break; case $effects[$i] == 'ATT' || $effects[$i] == 'DEF': $value = $effects[$i + 1]; if (substr_count($effects[$i + 1], '-')) { if ($effects[$i + 3] == 1) { // hits monster $pre_message = 'For the next battle, your opponent is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'For the next battle your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } } else { if ($effects[$i + 3] == 1) { // hits monster $pre_message = 'For the next battle, your opponent gets +' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'For the next battle your character gets +' . $value . ' ' . $effects[$i] . ' !<br />'; } } //update character_pre_effects field for the next battle $pre_effects .= $pre_effects == '' ? $effects[$i] . ':' . $effects[$i + 1] . ':M:' . $effects[$i + 3] : ':' . $effects[$i] . ':' . $effects[$i + 1] . ':M:' . $effects[$i + 3]; $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\tSET character_pre_effects = '" . $pre_effects . "'\r\n\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update characters pre effects for battle', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; $message .= $pre_message; break; case $effects[$i] == 'GOLD': $effects[$i] = $effects[$i] == 'GOLD' ? 'points' : $effects[$i]; $sql = "SELECT * FROM " . USERS_TABLE . " \r\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query general config', '', __LINE__, __FILE__, $sql); } $phpbb_user = $db->sql_fetchrow($result); if (substr_count($effects[$i + 1], '%')) { $value = floor($phpbb_user['user_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100); } else { $value = $effects[$i + 1]; } if (substr_count($effects[$i + 1], '-')) { $pre_message = 'Your character is losing ' . $value . ' ' . $effects[$i] . ' !<br />'; } else { $pre_message = 'Your character gains ' . $value . ' ' . $effects[$i] . ' !<br />'; } //effect hits the user if ($phpbb_user['user_' . strtolower($effects[$i]) . ''] + $value < 0) { $value_sql = 'user_' . strtolower($effects[$i]) . ' = 0'; } else { $value_sql = 'user_' . strtolower($effects[$i]) . ' = user_' . strtolower($effects[$i]) . ' + ' . $value; } $sql = "UPDATE " . USERS_TABLE . "\r\n\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\tWHERE user_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Couldn\'t update users ' . $effects[$i] . '', '', __LINE__, __FILE__, $sql); } $use_the_consumable = 1; $message .= $pre_message; break; } } if ($use_the_consumable == 1) { adr_use_item($consumable_id, $user_id); } return array(1, $message); } } else { //already ate consumable with temp effects $message = "Vous êtes déjà sous l'emprises d'effets temoraires !"; return array(0, $message); } }
if (is_numeric($bat['battle_id'])) { adr_previous(Adr_spells_target_battle, adr_spellbook, ''); } // Check if other person is alive if ($other_member['character_hp'] < 1) { adr_previous(Adr_spells_target_dead, adr_spellbook, ''); } // Check if target is in the same zone // if($adr_user['character_area'] != $other_member['character_area']) // { // adr_previous( Adr_spells_wrong_place, adr_spellbook , ''); // } // Subtract the magic points spell_remove_mp($user_id, $mp_usage, 0); // Use the item adr_use_item($spell_id, $user_id); // Healing spell if ($spell_skill == '108') { $attbonus = 0; $attbonus = adr_weapon_skill_check($user_id); $power = ceil($power * $attbonus); if ($code = $item['spell_xtreme']) { eval($code); message_die(GENERAL_MESSAGE, $message); } else { // Check if other person is already at full health if ($other_member['character_hp'] >= $other_member['character_hp_max']) { adr_previous(Adr_spells_target_health_full, adr_spellbook, ''); } // Check if other user goes over max_hp with spell $hp_heal = $power + $other_member['character_hp'] > $other_member['character_hp_max'] ? $other_member['character_hp_max'] - $other_member['character_hp'] : $power;