示例#1
0
 $total_challenger = $db->sql_fetchrow($result);
 // Make sure challenger hasn't already exceeded max active PvP battles
 if ($adr_general['battle_pvp_defies_max'] <= $total_challenger['total'] && $adr_general['battle_pvp_defies_max']) {
     adr_previous(Adr_pvp_defy_too_much, adr_character_pvp, '');
 }
 // Make sure character isn't already dead
 if ($char['character_hp'] < '1') {
     $message = $lang['Adr_battle_character_dead'];
     $message .= '<br /><br />' . sprintf($lang['Adr_battle_temple'], "<a href=\"" . 'adr_temple.' . $phpEx . "\">", "</a>");
     $message .= '<br /><br />' . sprintf($lang['Adr_character_return'], "<a href=\"" . 'adr_character.' . $phpEx . "\">", "</a>");
     message_die(GENERAL_MESSAGE, $message);
 }
 ##=== END challenger checks ===##
 ##=== START opponent checks ===##
 // Grab opponent infos
 $other_user = adr_get_user_infos($defied);
 // Be sure he has a character
 if (!is_numeric($other_user['character_id'])) {
     adr_previous(Adr_your_character_lack, adr_character, '');
 }
 // Check opponent has enough quota left for today
 //			if(($adr_general['Adr_character_limit_enable'] == '1') && ($other_user['character_pvp_limit'] < '1'))
 //				adr_previous(Adr_pvp_no_quota_other, adr_character_pvp, '');
 // Check if the user hasn't already his maximum number of defies allowed
 $sql = "SELECT count(*) AS total FROM " . ADR_BATTLE_PVP_TABLE . "\n\t\t\t\tWHERE (battle_result = 0 OR battle_result = 3)\n\t\t\t\tAND (battle_opponent_id = {$defied}\tOR battle_challenger_id = {$defied})";
 if (!($result = $db->sql_query($sql))) {
     message_die(GENERAL_ERROR, 'Could not obtain user list', '', __LINE__, __FILE__, $sql);
 }
 $total_opponent = $db->sql_fetchrow($result);
 // Make sure challenger hasn't already exceeded max active PvP battles
 if ($adr_general['battle_pvp_defies_max'] <= $total_opponent['total'] && $adr_general['battle_pvp_defies_max']) {
function adr_steal_item($user_id, $item_id, $shop_owner_id, $shop_id)
{
    global $db, $lang, $phpEx, $adr_general, $board_config, $store_id;
    // Fix the values
    $user_id = intval($user_id);
    $item_id = intval($item_id);
    $shop_owner_id = intval($shop_owner_id);
    $shop_id = intval($shop_id);
    if ($shop_owner_id != 1) {
        $direction = append_sid("adr_shops.{$phpEx}?mode=see_shop&amp;shop_id=" . $shop_id);
    } else {
        $direction = append_sid("adr_shops.{$phpEx}?mode=view_store&amp;shop_id=" . $shop_id);
    }
    // Check if stealing is enabled by admin
    if (!$adr_general['allow_shop_steal']) {
        $message = sprintf($lang['Adr_steal_item_forbidden'], $sum, $points_name);
        $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
        message_die(GENERAL_MESSAGE, $message);
    }
    // Check if user is high enough lvl to be allowed steal attempt
    if ($adr_general['Adr_shop_steal_min_lvl'] > '0') {
        $adr_user = adr_get_user_infos($user_id);
        if ($adr_user['character_level'] < $adr_general['Adr_shop_steal_min_lvl']) {
            $message = $lang['Adr_shop_steal_min_lvl'] . '<br /><br />';
            $message .= sprintf($lang['Adr_shop_steal_min_lvl2'], '<b>', $adr_general['Adr_shop_steal_min_lvl'], '</b>');
            $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
            message_die(GENERAL_MESSAGE, $message);
        }
    }
    $sql = "SELECT character_thief_limit FROM " . ADR_CHARACTERS_TABLE . "\n\t\tWHERE character_id = {$user_id} ";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain thief limit info', "", __LINE__, __FILE__, $sql);
    }
    $thief_limit = $db->sql_fetchrow($result);
    if ($adr_general['Adr_character_limit_enable'] != 0 && $thief_limit['character_thief_limit'] < 1) {
        adr_previous(Adr_thief_limit, adr_shops, '');
    }
    // Select the item infos
    $shop_more_sql = $shop_owner_id != '1' ? 'AND item_in_shop = 1' : '';
    $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_owner_id = '{$shop_owner_id}'\n\t\tAND item_id = '{$item_id}'\n\t\t{$shop_more_sql}";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql);
    }
    $item_data = $db->sql_fetchrow($result);
    // Check item is stealable
    if ($item_data['item_steal_dc'] == '0' && $shop_owner_id == '1') {
        //		adr_previous(Adr_store_not_stealable, shops, "view_store&amp;shop_id=".$shop_id."", '', 'adr/images/store_owners/'.$store_info['shop_logo'].'');
        adr_previous(Adr_store_not_stealable, adr_shops);
    }
    // Check for successful steal or not
    $success = adr_use_skill_thief($user_id, $item_data['item_steal_dc']);
    if ($success == TRUE) {
        // 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;
        if ($shop_owner_id != '1') {
            // This will never be TRUE as of v0.4.3 because there is no player store stealing allowed
            $sql = "UPDATE " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\t\tSET item_owner_id = {$user_id},\n\t\t\t\t\titem_id = {$new_item_id},\n\t\t\t\t\titem_bought_timestamp = " . time() . ",\n\t\t\t\t\titem_in_shop = '0', \n\t\t\t\t\titem_auth = '0'\n\t\t\t\t\titem_stolen_by = '',\n\t\t\t\t\titem_stolen_timestamp = " . time . "\n\t\t\t\tWHERE item_owner_id = '{$shop_owner_id}'\n\t\t\t\tAND item_id = '{$item_id}'";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql);
            }
        } else {
            // Insert item details
            $type = 1;
            //This is so the insert function knows that this is a stolen item for update purposes only (optional function variable)
            adr_shop_insert_item($item_id, $new_item_id, $user_id, $shop_owner_id, $type, $shop_id);
        }
        adr_thief_limit($user_id);
        adr_store_stats_update_steal($success, $user_id, $shop_owner_id, $store_id);
        $message = sprintf($lang['Adr_steal_item_success'], $sum, $points_name);
        $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
        message_die(GENERAL_MESSAGE, $message);
    } else {
        $message = sprintf($lang['Adr_steal_item_failure'], $sum, $points_name);
        if ($adr_general['skill_thief_failure_damage']) {
            // Select the item price
            $shop_more_sql = $shop_owner_id != 1 ? 'AND i.item_in_shop = 1' : '';
            // Prevents users to buy items not in shops
            $sql = "SELECT i.item_price, i.item_name, u.user_points FROM " . ADR_SHOPS_ITEMS_TABLE . " i , " . USERS_TABLE . " u\n\t\t\t\tWHERE i.item_owner_id = {$shop_owner_id}\n\t\t\t\t\tAND u.user_id = {$user_id}\n\t\t\t\t\tAND i.item_id = {$item_id} \n\t\t\t\t{$shop_more_sql} ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql);
            }
            $data = $db->sql_fetchrow($result);
            $user_points = $data['user_points'];
            $price = $data['item_price'];
            $fine = $price < intval($adr_general['skill_thief_failure_damage']) ? intval($adr_general['skill_thief_failure_damage']) : $price;
            if ($fine > $user_points && $adr_general['skill_thief_failure_punishment']) {
                $sql = " SELECT owner_id , account_sum FROM " . ADR_VAULT_USERS_TABLE . "\n\t\t\t\t\t\tWHERE owner_id = {$user_id} ";
                if (!($result = $db->sql_query($sql))) {
                    message_die(GENERAL_ERROR, 'Could not query user stats page', '', __LINE__, __FILE__, $sql);
                }
                $vault_sum = $db->sql_fetchrow($result);
                if ($adr_general['skill_thief_failure_punishment'] == 1) {
                    if (is_numeric($vault_sum['owner_id']) && $vault_sum['account_sum'] >= $fine) {
                        $vault_fine = $fine;
                        $fine = 0;
                        // Remove cash from Vault instead
                        $sql = "UPDATE " . ADR_VAULT_USERS_TABLE . "\n\t\t\t\t\t\t\tSET account_sum = account_sum - {$vault_fine}\n\t\t\t\t\t\t\tWHERE owner_id = {$user_id} ";
                        if (!$db->sql_query($sql)) {
                            message_die(GENERAL_ERROR, 'Could not update user points from Vault', "", __LINE__, __FILE__, $sql);
                        }
                    } elseif (is_numeric($vault_sum['owner_id']) && $vault_sum['account_sum'] > 0 && $vault_sum['account_sum'] < $fine) {
                        $vault_fine = $vault_sum['account_sum'];
                        $fine = 0;
                        // Remove cash from Vault instead
                        $sql = "UPDATE " . ADR_VAULT_USERS_TABLE . "\n\t\t\t\t\t\t\tSET account_sum = account_sum - {$vault_fine}\n\t\t\t\t\t\t\tWHERE owner_id = {$user_id} ";
                        if (!$db->sql_query($sql)) {
                            message_die(GENERAL_ERROR, 'Could not update user points from Vault', "", __LINE__, __FILE__, $sql);
                        }
                    } else {
                        $fine = $user_points;
                        $vault_fine = 0;
                    }
                } else {
                    if ($adr_general['skill_thief_failure_punishment'] == 2) {
                        adr_cell_imprison_user($user_id, 0, $adr_general['skill_thief_failure_time'], 0, $price, 1, 1, $lang['Adr_steal_item_failure_critical_all_sentence'], $adr_general['skill_thief_failure_type']);
                        $failure[0] = $lang['Adr_steal_item_failure_critical_all'];
                        $failure[1] = $lang['Adr_steal_item_failure_critical_post'];
                        $failure[2] = $lang['Adr_steal_item_failure_critical_read'];
                        $fail = $failure[$adr_general['skill_thief_failure_type']];
                        $fail_message = sprintf($lang['Adr_steal_item_failure_critical'], '<b>', adr_get_lang($data['item_name']), '</b>') . '<br /><br />' . $fail;
                        $fail_message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
                        message_die(GENERAL_MESSAGE, $fail_message);
                    }
                }
            }
            adr_thief_limit($user_id);
            adr_store_stats_update_steal($success, $user_id, $shop_owner_id, $store_id);
            subtract_reward($user_id, $fine);
        }
        if ($fine != 0) {
            $fine = $fine;
        } else {
            $fine = $vault_fine;
        }
        $message .= '<br /><br />' . sprintf($lang['Adr_steal_item_failure_suite'], $fine, $points_name);
        $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
        message_die(GENERAL_MESSAGE, $message);
    }
}
示例#3
0
define('IN_ADR_SHOPS', true);
define('IN_ADR_CHARACTER', true);
$phpbb_root_path = './';
include $phpbb_root_path . 'extension.inc';
include $phpbb_root_path . 'common.' . $phpEx;
$loc = 'town';
$sub_loc = 'adr_enchant';
//
// Start session management
$userdata = session_pagestart($user_ip, PAGE_ADR);
init_userprefs($userdata);
// End session management
//
$user_id = $userdata['user_id'];
$points = $userdata['user_points'];
include $phpbb_root_path . 'adr/includes/adr_global.' . $phpEx;
// Sorry , only logged users ...
if (!$userdata['session_logged_in']) {
    $redirect = "adr_familiar.{$phpEx}";
    $redirect .= isset($user_id) ? '&user_id=' . $user_id : '';
    header('Location: ' . append_sid("login.{$phpEx}?redirect={$redirect}", true));
}
// Includes the tpl and the header
adr_template_file('adr_enchant_body.tpl');
include $phpbb_root_path . 'includes/page_header.' . $phpEx;
// Get the general config
$adr_general = adr_get_general_config();
//
//BEGIN zone Enchant Restriction
//
$zone_user = adr_get_user_infos($user_id);
示例#4
0
 }
 $total_opponent = $db->sql_fetchrow($result);
 // Make sure challenger hasn't already exceeded max active PvP battles
 if ($adr_general['battle_pvp_defies_max'] <= $total_opponent['total'] && $adr_general['battle_pvp_defies_max']) {
     adr_previous(Adr_pvp_defy_too_much_opponent, adr_character_pvp, '');
 }
 // Make sure character isn't already dead
 if ($other_user['character_hp'] < '1') {
     $message = $lang['Adr_battle_character_dead'];
     $message .= '<br /><br />' . sprintf($lang['Adr_battle_temple'], "<a href=\"" . 'adr_temple.' . $phpEx . "\">", "</a>");
     $message .= '<br /><br />' . sprintf($lang['Adr_character_return'], "<a href=\"" . 'adr_character.' . $phpEx . "\">", "</a>");
     message_die(GENERAL_MESSAGE, $message);
 }
 ##=== END opponent checks ===##
 $sql = " SELECT battle_id FROM " . ADR_BATTLE_PVP_TABLE . "\r\t\t\t\tORDER BY battle_id DESC LIMIT 1 ";
 if (!($result = $db->sql_query($sql))) {
     message_die(GENERAL_ERROR, 'Could not obtain user list', '', __LINE__, __FILE__, $sql);
 }
 $last_row = $db->sql_fetchrow($result);
 $last_id = $last_row['battle_id'] + 1;
 // Fix the items ids
 $armor = intval($HTTP_POST_VARS['item_armor']);
 $buckler = intval($HTTP_POST_VARS['item_buckler']);
 $helm = intval($HTTP_POST_VARS['item_helm']);
 $greave = intval($HTTP_POST_VARS['item_greave']);
 $boot = intval($HTTP_POST_VARS['item_boot']);
 $gloves = intval($HTTP_POST_VARS['item_gloves']);
 $amulet = intval($HTTP_POST_VARS['item_amulet']);
 $ring = intval($HTTP_POST_VARS['item_ring']);
 // Get the user infos
 $char = adr_get_user_infos($user_id);
示例#5
0
//}
// Show user list
$sql = "SELECT u.user_id , u.username , c.* FROM " . USERS_TABLE . " u , " . ADR_CHARACTERS_TABLE . " c\r\n\tWHERE u.user_id = c.character_id \r\n\tAND c.character_hp < c.character_hp_max\r\n\tAND c.character_hp > 0\r\n\tORDER by u.username ";
if (!($result = $db->sql_query($sql))) {
    message_die(GENERAL_ERROR, 'Could not obtain user list', '', __LINE__, __FILE__, $sql);
}
$users = $db->sql_fetchrowset($result);
$chars_list = '<select name="cast">';
$chars_list .= '<option value = "0" >Select member:</option>';
for ($i = 0; $i < count($users); $i++) {
    $chars_list .= '<option value = "' . $users[$i]['user_id'] . '" >' . $users[$i]['character_name'] . '&nbsp;(&nbsp;HP:&nbsp;' . $users[$i]['character_hp'] . '/' . $users[$i]['character_hp_max'] . '&nbsp;-&nbsp;MP:&nbsp;' . $users[$i]['character_mp'] . '/' . $users[$i]['character_mp_max'] . '&nbsp;-&nbsp;' . $lang['Adr_character_level'] . ':&nbsp;' . $users[$i]['character_level'] . '&nbsp;)&nbsp;</option>';
}
$chars_list .= '</select>';
if ($cast_spell) {
    // Get other char info
    $other_member = adr_get_user_infos($to_member_id);
    // Get spell info
    $sql = "SELECT * FROM " . ADR_SHOPS_SPELLS_TABLE . " \r\n\t\tWHERE spell_owner_id = {$user_id}\r\n\t\tAND spell_original_id = {$spell_id}\r\n\t\tLIMIT 1";
    if (!($result = $db->sql_query($sql))) {
        adr_previous(Adr_shop_items_failure_deleted, adr_spellbook, '');
    }
    $item = $db->sql_fetchrow($result);
    $spell_skill = $item['item_type_use'];
    $power = 0;
    // Spell components check
    if ($item['spell_items_req'] != '' && $item['spell_items_req'] != '0') {
        adr_spell_check_components($spell_id, $user_id, 'adr_spellbook');
    }
    // MP check
    if ($adr_user['character_mp'] < $item['spell_mp_use'] + $item['spell_power'] || $adr_user['character_mp'] < 0) {
        adr_previous(Adr_battle_check_two, 'adr_spellbook', '');
示例#6
0
//if ( $access == '0' )
//	adr_previous( Adr_zone_building_noaccess , adr_zones , '' );
// Clan list
if (!isset($_GET['action']) || $_GET['action'] == "list") {
    $this_title = $lang['clans_title_clanslist'];
    // Get clans user belongs to!
    $sql = "SELECT * FROM " . ADR_CLANS_TABLE . "\r\n\t\t\tWHERE leader = '" . $user_id . "' OR members LIKE '%ß" . $user_id . "Þ%' OR approvelist LIKE '%ß" . $user_id . "Þ%'\r\n\t\t\tORDER BY name,id";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Error retrieving data', '', __LINE__, __FILE__, $sql);
    }
    if ($db->sql_numrows($result) < 1) {
        $template->assign_block_vars('no_userclans', array('L_NONE' => $lang['clans_none']));
    }
    if ($row = $db->sql_fetchrow($result)) {
        // Get leader name!
        $Lrow = adr_get_user_infos($row['leader']);
        $leader = '<a href="' . $phpbb_root_path . 'adr_character.php?' . POST_USERS_URL . '=' . $row['leader'] . '" target="_blank">' . $Lrow['character_name'] . '</a>';
        // Get member names!
        $members = '';
        if ($row['members'] == '') {
            $members = $lang['clans_none'];
        } else {
            $allmembers = str_replace("ß", "", $row['members']);
            $newmembers = explode("Þ", $allmembers);
            $count = count($newmembers);
            for ($x = 0; $x < $count; $x++) {
                $Usql = "SELECT character_name FROM " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\tWHERE character_id = '" . $newmembers[$x] . "' ";
                if (!($Uresult = $db->sql_query($Usql))) {
                    message_die(GENERAL_ERROR, 'Error retrieving data', '', __LINE__, __FILE__, $Usql);
                }
                while ($Urow = $db->sql_fetchrow($Uresult)) {
示例#7
0
        message_die(GENERAL_ERROR, 'Could not delete PvP battle at exploit', '', __LINE__, __FILE__, $sql);
    }
    adr_previous(Adr_pvp_exploit_error, adr_character, '');
}
// have the mail sender infos , it will be of use later
$script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path']));
$script_name = $script_name != '' ? $script_name . '/adr_battle_pvp.' . $phpEx : 'adr_battle_pvp.' . $phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://';
$server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/';
// Includes the tpl and the header
adr_template_file('adr_battle_pvp_body.tpl');
include $phpbb_root_path . 'includes/page_header.' . $phpEx;
// Grab both user infos
$current_infos = $user_id === $battle_pvp['battle_challenger_id'] ? adr_get_user_infos($battle_pvp['battle_challenger_id']) : adr_get_user_infos($battle_pvp['battle_opponent_id']);
$opponent_infos = $user_id === $battle_pvp['battle_challenger_id'] ? adr_get_user_infos($battle_pvp['battle_opponent_id']) : adr_get_user_infos($battle_pvp['battle_challenger_id']);
### START restriction checks ###
$item_sql = adr_make_restrict_sql($current_infos);
### END restriction checks ###
// Get the current user and the opponent infos
if ($user_id == $battle_pvp['battle_challenger_id']) {
    $current_hp = $battle_pvp['battle_challenger_hp'];
    $current_mp = $battle_pvp['battle_challenger_mp'];
    $current_hp_max = $battle_pvp['battle_challenger_hp_max'];
    $current_mp_max = $battle_pvp['battle_challenger_mp_max'];
    $current_hp_regen = $battle_pvp['battle_challenger_hp_regen'];
    $current_mp_regen = $battle_pvp['battle_challenger_mp_regen'];
    $current_att = $battle_pvp['battle_challenger_att'];
    $current_def = $battle_pvp['battle_challenger_def'];
    $current_element = $battle_pvp['battle_challenger_element'];
    $current_alignment = $current_infos['character_alignment'];
示例#8
0
//
include $phpbb_root_path . 'adr/includes/adr_global.' . $phpEx;
// Sorry , only logged users ...
if (!$userdata['session_logged_in']) {
    $redirect = "adr_character.{$phpEx}";
    $redirect .= isset($user_id) ? '&user_id=' . $user_id : '';
    header('Location: ' . append_sid("login.{$phpEx}?redirect={$redirect}", true));
}
// Includes the tpl and the header
adr_template_file('adr_character_prefs_body.tpl');
include $phpbb_root_path . 'includes/page_header.' . $phpEx;
$user_id = $userdata['user_id'];
// Get the general settings
$adr_general = adr_get_general_config();
adr_enable_check();
adr_ban_check($user_id);
adr_character_created_check($user_id);
if (!(isset($HTTP_POST_VARS[POST_USERS_URL]) || isset($HTTP_GET_VARS[POST_USERS_URL])) || empty($HTTP_POST_VARS[POST_USERS_URL]) && empty($HTTP_GET_VARS[POST_USERS_URL])) {
    $view_userdata = $userdata;
} else {
    $view_userdata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
}
$searchid = $view_userdata['user_id'];
if ($user_id != $searchid) {
    $message = $lang['Adr_no_access'] . '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . append_sid("adr_character.{$phpEx}?" . POST_USERS_URL . "={$searchid}") . "\">", "</a>");
    message_die(GENERAL_MESSAGE, $message);
}
// Get the general settings
$adr_general = adr_get_general_config();
// See if the user has ever created a character or no
$row = adr_get_user_infos($user_id);
示例#9
0
function adr_shield_skill_check($user_id)
{
    global $db, $lang, $adr_general, $item;
    $char = adr_get_user_infos($user_id);
    $sql = "SELECT * FROM " . ADR_CHARACTERS_TABLE . "\r\n\t\tWHERE character_id = {$user_id} ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain user list', '', __LINE__, __FILE__, $sql);
    }
    if ($char['character_skill_shield_uses'] + 1 >= $adr_general['weapon_prof'] * $char['character_skill_shield_level']) {
        $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\tSET character_skill_shield_uses = 0 , \r\n\t\t\t\tcharacter_skill_shield_level = character_skill_shield_level + 1\r\n\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 . "\r\n\t\t\tSET character_skill_shield_uses = character_skill_shield_uses + 1\r\n\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);
        }
    }
}
示例#10
0
                 if ($defend && $bat['battle_turn'] == 1) {
                     $def = TRUE;
                     $power = floor($monster['monster_level'] * rand(1, 3) / 2);
                     $battle_message .= sprintf($lang['Adr_battle_defend'], $challenger['character_name'], $monster['monster_name']) . '<br>';
                     // Update the database
                     $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\n\t\t\tSET\tbattle_turn = 2,\n\t\t\t\tbattle_round = (battle_round + 1)\n\t\t\tWHERE battle_challenger_id = {$user_id}\n\t\t\tAND battle_result = 0\n\t\t\tAND battle_type = 1 ";
                     if (!($result = $db->sql_query($sql))) {
                         message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
                     }
                 }
             }
         }
     }
 }
 // Get the user infos
 $challenger = adr_get_user_infos($user_id);
 ##=== START: additional status checks on user ===##
 if ($bat['battle_turn'] == '1' && ($attack || $item_spell || $item_potion || $defend || $flee || $equip)) {
     $hp_regen = adr_hp_regen_check($user_id, $bat['battle_challenger_hp']);
     $challenger['character_hp'] += $hp_regen;
     $mp_regen = adr_mp_regen_check($user_id, $bat['battle_challenger_mp']);
     $battle_message .= '<span class="gensmall"><font color="#FF0000">';
     // prefix new span class
     if ($hp_regen > '0' && $mp_regen == '0' || $mp_regen > '0' && $hp_regen == '0') {
         if ($hp_regen > '0') {
             $battle_message .= '&nbsp;&nbsp;>&nbsp;' . sprintf($lang['Adr_battle_regen_xp'], $challenger['character_name'], intval($hp_regen)) . '<br />';
         } elseif ($mp_regen > '0') {
             $battle_message .= '&nbsp;&nbsp;>&nbsp;' . sprintf($lang['Adr_battle_regen_mp'], $challenger['character_name'], intval($mp_regen)) . '<br />';
         }
     } elseif ($hp_regen > '0' && $mp_regen > '0') {
         $battle_message .= '&nbsp;&nbsp;>&nbsp;' . sprintf($lang['Adr_battle_regen_both'], $challenger['character_name'], intval($hp_regen), intval($mp_regen)) . '<br />';
示例#11
0
function adr_admin_cmd_endpvp($battle_id)
{
    global $db, $lang;
    $user_id = $user_infos['user_id'];
    $battle_id = intval($battle_id);
    $sql = "SELECT battle_id, battle_challenger_id, battle_opponent_id FROM  " . ADR_BATTLE_PVP_TABLE . "\r\n\t\tWHERE battle_id = '{$battle_id}'";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
    }
    $bat = $db->sql_fetchrow($result);
    if (is_numeric($bat['battle_id'])) {
        if ($user_id == $battle_pvp['battle_challenger_id']) {
            $battle_result = 9;
        } else {
            $battle_result = 8;
        }
        $challenger_name = adr_get_user_infos($bat['battle_challenger_id']);
        $opponent_name = adr_get_user_infos($bat['battle_opponent_id']);
        $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\tSET battle_result = {$battle_result}\r\n\t\t\tWHERE battle_id = '{$battle_id}'";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
        }
        $error_messages = sprintf($lang['Adr_global_shout_endpvp_yes'], $challenger_name['character_name'], $opponent_name['character_name']);
    } else {
        $error_messages = sprintf($lang['Adr_global_shout_endpvp_none'], $battle_id);
    }
    return $error_messages;
}
示例#12
0
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;
}
示例#13
0
function adr_character_replenish_timer($user_id)
{
    global $db, $phpEx, $adr_general;
    $user_id = intval($user_id);
    $adr_user = adr_get_user_infos($user_id);
    // Show time until next replenish
    $replenish_timer = 24 - floor(((time() - $adr_user['character_birth']) / 86400 - ($adr_user['character_limit_update'] + ($adr_general['Adr_limit_regen_duration'] - 1))) * 24);
    $replenish_timer = $replenish_timer < '1' ? '1' : $replenish_timer;
    return $replenish_timer;
}
示例#14
0
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);
    }
}
    header('Location: ' . append_sid("login.{$phpEx}?redirect={$redirect}", true));
}
include $phpbb_root_path . 'includes/page_header.' . $phpEx;
if (!(isset($_POST[POST_USERS_URL]) || isset($_GET[POST_USERS_URL])) || empty($_POST[POST_USERS_URL]) && empty($_GET[POST_USERS_URL])) {
    $view_userdata = $userdata;
} else {
    $view_userdata = get_userdata(intval($_GET[POST_USERS_URL]));
}
$searchid = $view_userdata['user_id'];
// Get the general config
$adr_general = adr_get_general_config();
adr_enable_check();
adr_ban_check($user_id);
adr_character_created_check($user_id);
// See if the user has ever created a character or no
$char = adr_get_user_infos($searchid);
// Deny access if user is imprisioned
if ($userdata['user_cell_time']) {
    adr_previous(Adr_shops_no_thief, adr_cell, '');
}
$equip_armor = $char['equip_armor'];
$equip_buckler = $char['equip_buckler'];
$equip_helm = $char['equip_helm'];
$equip_gloves = $char['equip_gloves'];
$equip_amulet = $char['equip_amulet'];
$equip_ring = $char['equip_ring'];
adr_template_file('adr_equipment_body.tpl');
$submit = isset($_POST['equip']);
if ($submit && $user_id == $searchid) {
    $armor = intval($_POST['item_armor']);
    $buckler = intval($_POST['item_buckler']);
示例#16
0
function adr_character_replenish_timer($user_id)
{
    global $db, $adr_general, $lang;
    $user_id = intval($user_id);
    $adr_user = adr_get_user_infos($user_id);
    // Show time until next replenish
    $replenish_timer = 24 - floor(((time() - $adr_user['character_birth']) / 86400 - ($adr_user['character_limit_update'] + ($adr_general['Adr_limit_regen_duration'] - 1))) * 24);
    $replenish_timer = adr_make_time($replenish_timer);
    $replenish_timer = $replenish_timer < '5' ? $lang['Adr_update_quota_timer'] : intval($replenish_timer);
    return $replenish_timer;
}
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;
}
示例#18
0
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;
}
示例#19
0
function adr_spell_add_new($spell_id, $user_id, $location)
{
    global $db;
    $spell_id = intval($spell_id);
    $user_id = intval($user_id);
    $location = $location;
    $user = adr_get_user_infos($user_id);
    $level = $user['character_level'];
    $char_class = $user['character_class'];
    $sql = "SELECT spell_id FROM " . ADR_SHOPS_SPELLS_TABLE . "\r\n\t\tWHERE spell_owner_id = {$user_id}\r\n\t\tORDER BY spell_id \r\n\t\tDESC LIMIT 1";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
    }
    $new_spell = $db->sql_fetchrow($result);
    $new_item_id = $new_spell['spell_id'] + 1;
    $sql = "SELECT * FROM " . ADR_SHOPS_SPELLS_TABLE . "\r\n\t\tWHERE spell_owner_id = '1'\r\n\t\tAND spell_id = {$spell_id}";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
    }
    $data = $db->sql_fetchrow($result);
    $sql = "SELECT * FROM " . ADR_SHOPS_SPELLS_TABLE . "\r\n\t\tWHERE spell_owner_id = {$user_id}\r\n\t\tAND spell_original_id = {$spell_id}";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
    }
    $learned = $db->sql_fetchrow($result);
    if (!$learned) {
        $classes = explode(",", $data['spell_class']);
        $success = in_array($char_class, $classes) || in_array('0', $classes);
        if ($success) {
            if ($data['spell_level'] > $level) {
                adr_previous(Adr_spells_too_powerful, $location, '');
            } else {
                $item_type_use = $data['item_type_use'];
                $item_name = addslashes($data['spell_name']);
                $item_desc = addslashes($data['spell_desc']);
                $item_icon = trim($data['spell_icon']);
                $item_power = $data['spell_power'];
                $item_add_power = $data['spell_add_power'];
                $item_mp_use = $data['spell_mp_use'];
                $item_element = $data['spell_element'];
                $item_element_str_dmg = $data['spell_element_str_dmg'];
                $item_element_same_dmg = $data['spell_element_same_dmg'];
                $item_element_weak_dmg = $data['spell_element_weak_dmg'];
                $item_max_skill = $data['spell_max_skill'];
                $item_original_id = $data['spell_id'];
                $item_components = $data['spell_items_req'];
                $item_battle = $data['spell_battle'];
                $item_xtreme = addslashes($data['spell_xtreme']);
                $item_xtreme_battle = addslashes($data['spell_xtreme_battle']);
                $item_xtreme_pvp = addslashes($data['spell_xtreme_pvp']);
                $sql = "INSERT INTO " . ADR_SHOPS_SPELLS_TABLE . " \r\n\t\t\t\t\t( spell_id , spell_owner_id , item_type_use , spell_name , spell_desc , spell_icon , spell_power , spell_add_power , spell_mp_use , spell_element , spell_element_str_dmg , spell_element_same_dmg , spell_element_weak_dmg , spell_max_skill , spell_original_id, spell_items_req, spell_battle, spell_xtreme, spell_xtreme_battle, spell_xtreme_pvp)\r\n\t\t\t\t\tVALUES ( {$new_item_id} , {$user_id} , {$item_type_use} , '{$item_name}' , '{$item_desc}' , '" . str_replace("\\'", "''", $item_icon) . "' , {$item_power} , {$item_add_power} , {$item_mp_use} , {$item_element} , {$item_element_str_dmg} , {$item_element_same_dmg} , {$item_element_weak_dmg} , {$item_max_skill} , {$item_original_id} , '" . $item_components . "' , {$item_battle} , '" . str_replace("\\'", "''", $item_xtreme) . "' , '" . str_replace("\\'", "''", $item_xtreme_battle) . "' , '" . str_replace("\\'", "''", $item_xtreme_pvp) . "' )";
                $result = $db->sql_query($sql);
                if (!$result) {
                    message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql);
                }
            }
        } else {
            adr_previous(Adr_spells_wrong_class, $location, '');
        }
    } else {
        adr_previous(Adr_spells_already_learned, $location, '');
    }
}
示例#20
0
$board_config['points_name'] = $board_config['points_name'] ? $board_config['points_name'] : $lang['Adr_default_points_name'];
// Who is looking at this page ?
$user_id = $userdata['user_id'];
if (!(isset($_POST[POST_USERS_URL]) || isset($_GET[POST_USERS_URL])) || empty($_POST[POST_USERS_URL]) && empty($_GET[POST_USERS_URL])) {
    $view_userdata = $userdata;
} else {
    $view_userdata = get_userdata(intval($_GET[POST_USERS_URL]));
}
$searchid = $view_userdata['user_id'];
// Get the general settings
$adr_general = adr_get_general_config();
adr_enable_check();
adr_ban_check($user_id);
adr_character_created_check($user_id);
// See if the user has ever created a character or no
$row = adr_get_user_infos($searchid);
// If someone is looking at a character's user that doesn't exist , let's display an error message
if (!$row['character_class'] && $searchid != $user_id) {
    message_die(GENERAL_MESSAGE, $lang['Adr_character_lack']);
} else {
    $skills = adr_get_skill_data('');
    list($mining_percent_width, $mining_percent_empty) = adr_make_bars($row['character_skill_mining_uses'], $skills[1]['skill_req'], '250');
    list($stone_percent_width, $stone_percent_empty) = adr_make_bars($row['character_skill_stone_uses'], $skills[2]['skill_req'], '250');
    list($forge_percent_width, $forge_percent_empty) = adr_make_bars($row['character_skill_forge_uses'], $skills[3]['skill_req'], '250');
    list($enchantment_percent_width, $enchantment_percent_empty) = adr_make_bars($row['character_skill_enchantment_uses'], $skills[4]['skill_req'], '250');
    list($thief_percent_width, $thief_percent_empty) = adr_make_bars($row['character_skill_thief_uses'], $skills[6]['skill_req'], '250');
    $template->assign_vars(array('MINING' => $row['character_skill_mining'], 'MINING_IMG' => $skills[1]['skill_img'], 'MINING_MIN' => $row['character_skill_mining_uses'], 'MINING_MAX' => $skills[1]['skill_req'], 'MINING_BAR' => $mining_percent_width, 'MINING_BAR_EMPTY' => $mining_percent_empty, 'STONE' => $row['character_skill_stone'], 'STONE_IMG' => $skills[2]['skill_img'], 'STONE_MIN' => $row['character_skill_stone_uses'], 'STONE_MAX' => $skills[2]['skill_req'], 'STONE_BAR' => $stone_percent_width, 'STONE_BAR_EMPTY' => $stone_percent_empty, 'FORGE' => $row['character_skill_forge'], 'FORGE_IMG' => $skills[3]['skill_img'], 'FORGE_MIN' => $row['character_skill_forge_uses'], 'FORGE_MAX' => $skills[3]['skill_req'], 'FORGE_BAR' => $forge_percent_width, 'FORGE_BAR_EMPTY' => $forge_percent_empty, 'ENCHANTMENT' => $row['character_skill_enchantment'], 'ENCHANTMENT_IMG' => $skills[4]['skill_img'], 'ENCHANTMENT_MIN' => $row['character_skill_enchantment_uses'], 'ENCHANTMENT_MAX' => $skills[4]['skill_req'], 'ENCHANTMENT_BAR' => $enchantment_percent_width, 'ENCHANTMENT_BAR_EMPTY' => $enchantment_percent_empty, 'THIEF' => $row['character_skill_thief'], 'THIEF_IMG' => $skills[6]['skill_img'], 'THIEF_MIN' => $row['character_skill_thief_uses'], 'THIEF_MAX' => $skills[6]['skill_req'], 'THIEF_BAR' => $thief_percent_width, 'THIEF_BAR_EMPTY' => $thief_percent_empty, 'L_MINING' => $lang['Adr_mining'], 'L_MINING_DESC' => adr_get_lang($skills[1]['skill_desc']), 'L_STONE' => $lang['Adr_stone'], 'L_STONE_DESC' => adr_get_lang($skills[2]['skill_desc']), 'L_FORGE' => $lang['Adr_forge'], 'L_FORGE_DESC' => adr_get_lang($skills[3]['skill_desc']), 'L_ENCHANTMENT' => $lang['Adr_enchantment'], 'L_ENCHANTMENT_DESC' => adr_get_lang($skills[4]['skill_desc']), 'L_TRADING' => $lang['Adr_trading'], 'L_TRADING_DESC' => adr_get_lang($skills[5]['skill_desc']), 'L_THIEF' => $lang['Adr_thief'], 'L_THIEF_DESC' => adr_get_lang($skills[6]['skill_desc'])));
}
$template->assign_vars(array('L_NAME' => $lang['Adr_races_name'], 'L_DESC' => $lang['Adr_races_desc'], 'L_IMG' => $lang['Adr_races_image'], 'L_LEVEL' => $lang['Adr_character_level'], 'L_PROGRESS' => $lang['Adr_character_progress'], 'L_CHARACTER_OF' => sprintf($lang['Adr_character_of'], $view_userdata['username']), 'L_NEW_CHARACTER_CLASS' => $lang['Adr_character_new_class'], 'L_SKILLS' => $lang['Adr_character_skills'], 'S_CHARACTER_ACTION' => append_sid("adr_character_skills.{$phpEx}")));
include $phpbb_root_path . 'adr/includes/adr_header.' . $phpEx;
$template->pparse('body');
示例#21
0
     }
     $classes = $db->sql_fetchrowset($result);
     $classes_list = '<select name="character_class">';
     for ($i = 0; $i < count($classes); $i++) {
         $classes[$i]['class_name'] = adr_get_lang($classes[$i]['class_name']);
         $class_selected = $row['character_class'] == $classes[$i]['class_id'] ? 'selected' : '';
         $classes_list .= '<option value = "' . $classes[$i]['class_id'] . '" ' . $class_selected . ' >' . $classes[$i]['class_name'] . '</option>';
     }
     $classes_list .= '</select>';
     $template->assign_vars(array('RACES_LIST' => $races_list, 'ELEMENTS_LIST' => $elements_list, 'ALIGNMENTS_LIST' => $alignments_list, 'CLASSES_LIST' => $classes_list, 'LEVEL' => $row['character_level'], 'POWER' => $row['character_might'], 'AGILITY' => $row['character_dexterity'], 'CONSTIT' => $row['character_constitution'], 'INT' => $row['character_intelligence'], 'WIS' => $row['character_wisdom'], 'CHA' => $row['character_charisma'], 'HP' => $row['character_hp'], 'HP_MAX' => $row['character_hp_max'], 'MP' => $row['character_mp'], 'MP_MAX' => $row['character_mp_max'], 'EXP' => $row['character_xp'], 'HP_MAX' => $row['character_hp_max'], 'MP_MAX' => $row['character_mp_max'], 'SP' => $row['character_sp'], 'EXP_MAX' => $max_hp, 'BATTLE_VICTORIES' => $row['character_victories'], 'BATTLE_DEFEATS' => $row['character_defeats'], 'BATTLE_FLEES' => $row['character_flees'], 'AC' => $row['character_ac'], 'NAME' => $row['character_name'], 'CLASS' => $class, 'RACE' => $race, 'ELEMENT' => $element, 'ALIGNMENT' => $alignment, 'NEW_BIO' => $message, 'MINING' => $row['character_skill_mining'], 'MINING_MIN' => $row['character_skill_mining_uses'], 'MINING_MAX' => $skills[1]['skill_req'], 'STONE' => $row['character_skill_stone'], 'STONE_MIN' => $row['character_skill_stone_uses'], 'STONE_MAX' => $skills[2]['skill_req'], 'FORGE' => $row['character_skill_forge'], 'FORGE_MIN' => $row['character_skill_forge_uses'], 'FORGE_MAX' => $skills[3]['skill_req'], 'ENCHANTMENT' => $row['character_skill_enchantment'], 'ENCHANTMENT_MIN' => $row['character_skill_enchantment_uses'], 'ENCHANTMENT_MAX' => $skills[4]['skill_req'], 'TRADING' => $row['character_skill_trading'], 'TRADING_MIN' => $row['character_skill_trading_uses'], 'TRADING_MAX' => $skills[5]['skill_req'], 'THIEF' => $row['character_skill_thief'], 'THIEF_MIN' => $row['character_skill_thief_uses'], 'THIEF_MAX' => $skills[6]['skill_req'], 'BATTLE_LIMIT' => $row['character_battle_limit'], 'SKILL_LIMIT' => $row['character_skill_limit'], 'TRADING_LIMIT' => $row['character_trading_limit'], 'THIEF_LIMIT' => $row['character_thief_limit'], 'U_INVENTORY' => append_sid("admin_adr_users.{$phpEx}?mode=inventory&amp;user_id=" . $searchid . ""), 'L_INVENTORY' => $lang['Adr_character_admin_inventory'], 'L_BIO' => $lang['Adr_character_new_bio'], 'L_CLASS' => $lang['Adr_character_class'], 'L_RACE' => $lang['Adr_character_race'], 'L_ELEMENT' => $lang['Adr_character_element'], 'L_ALIGNMENT' => $lang['Adr_character_alignment'], 'L_HEALTH' => $lang['Adr_character_health'], 'L_MAGIC' => $lang['Adr_character_magic'], 'L_EXPERIENCE' => $lang['Adr_character_experience'], 'L_AC' => $lang['Adr_character_ac'], 'L_POWER' => $lang['Adr_character_power'], 'L_AGILITY' => $lang['Adr_character_agility'], 'L_CONSTIT' => $lang['Adr_character_endurance'], 'L_INT' => $lang['Adr_character_intelligence'], 'L_WIS' => $lang['Adr_character_willpower'], 'L_CHA' => $lang['Adr_character_charm'], 'L_MA' => $lang['Adr_character_ma'], 'L_MD' => $lang['Adr_character_md'], 'L_SP' => $lang['Adr_character_sp'], 'L_POINTS' => $board_config['points_name'], 'L_BATTLE_STATISTICS' => $lang['Adr_character_battle_statistics'], 'L_BATTLE_VICTORIES' => $lang['Adr_character_victories'], 'L_BATTLE_DEFEATS' => $lang['Adr_character_defeats'], 'L_BATTLE_FLEES' => $lang['Adr_character_flees'], 'L_BATTLE_SEE' => $lang['Adr_character_battle_history'], 'L_DELETE_CHARACTER' => $lang['Adr_admin_character_delete'], 'L_EDIT_CHARACTER' => $lang['Adr_admin_character_edit'], 'L_CHARACTERISTICS' => $lang['Adr_admin_character_charac'], 'L_MINING' => $lang['Adr_mining'], 'L_STONE' => $lang['Adr_stone'], 'L_FORGE' => $lang['Adr_forge'], 'L_ENCHANTMENT' => $lang['Adr_enchantment'], 'L_TRADING' => $lang['Adr_trading'], 'L_THIEF' => $lang['Adr_thief'], 'L_BATTLE_SKILLS' => $lang['Adr_user_battle_skills'], 'L_BATTLE_LIMIT' => $lang['Adr_user_battle_limit'], 'L_SKILL_LIMIT' => $lang['Adr_user_skill_limit'], 'L_TRADING_LIMIT' => $lang['Adr_user_trading_limit'], 'L_THIEF_LIMIT' => $lang['Adr_user_thief_limit'], 'L_SKILLS' => $lang['Adr_character_skills']));
     break;
 case 'inventory':
     adr_template_file('admin/config_adr_character_body.tpl');
     $template->assign_block_vars('inventory', array());
     $user_id = intval($_GET['user_id']);
     $other_user_infos = adr_get_user_infos($user_id);
     $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
     if (isset($_GET['mode2']) || isset($_POST['mode2'])) {
         $mode2 = isset($_POST['mode2']) ? htmlspecialchars($_POST['mode2']) : htmlspecialchars($_GET['mode2']);
     } else {
         $mode2 = 'itemname';
     }
     if (isset($_POST['order'])) {
         $sort_order = $_POST['order'] == 'ASC' ? 'ASC' : 'DESC';
     } else {
         if (isset($_GET['order'])) {
             $sort_order = $_GET['order'] == 'ASC' ? 'ASC' : 'DESC';
         } else {
             $sort_order = 'ASC';
         }
     }
function adr_battle_effects_initialise($user_id, $potion_id, $monster_name, $pvp)
{
    global $db;
    $user_id = intval($user_id);
    $potion_id = intval($potion_id);
    $pvp = intval($pvp);
    $user = adr_get_user_infos($user_id);
    if ($potion_id != 0) {
        //get potion info
        $sql_potion = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_id = {$potion_id}\r\n\t\t\tAND item_owner_id = {$user_id} ";
        if (!($result_potion = $db->sql_query($sql_potion))) {
            message_die(GENERAL_ERROR, 'Could not get potion info', '', __LINE__, __FILE__, $sql_potion);
        }
        $potion = $db->sql_fetchrow($result_potion);
    }
    if ($pvp == 0) {
        //get all battle stats
        $sql = "SELECT * FROM " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\tAND battle_result = 0 \r\n\t\t\tAND battle_type = 1 \r\n\t\t";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, "Couldn't get current opponent stats", "", __LINE__, __FILE__, $sql);
        }
        $battle_stats = $db->sql_fetchrow($result);
    } else {
        if ($pvp == 1) {
            //get all pvp battle stats
            $sql = "SELECT * FROM " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\tAND (battle_result = 0 OR battle_result = 3)\r\n\t\t";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, "Couldn't get current opponent stats", "", __LINE__, __FILE__, $sql);
            }
            $battle_stats = $db->sql_fetchrow($result);
        }
    }
    //check if user used a potion with temp effects before entering a battle
    if (substr_count($potion['item_effect'], 'HP') || substr_count($potion['item_effect'], 'MP') || $user['character_pre_effects'] != '' && $user['character_pre_effects'] != NULL || $battle_stats['battle_effects'] == '' && $battle_stats['battle_effects'] == NULL) {
        if ($potion_id != 0) {
            $update_battle_effects = $potion['item_effect'];
        } else {
            $update_battle_effects = $user['character_pre_effects'];
        }
        if ($pvp == 0) {
            //update battle_list with effects and clear character_pre_effects
            $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t\t\tSET battle_effects = '" . $update_battle_effects . "'\r\n\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\tAND battle_result = 0\r\n\t\t\t\tAND battle_type = 1 \r\n\t\t\t";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
            }
        } else {
            if ($pvp == 1) {
                //update battle_list with effects and clear character_pre_effects
                $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\t\tSET battle_effects = '" . $update_battle_effects . "'\r\n\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\tAND (battle_result = 0 OR battle_result = 3)\r\n\t\t\t";
                $result = $db->sql_query($sql);
                if (!$result) {
                    message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                }
            }
        }
        $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\tSET character_pre_effects = ''\r\n\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);
        }
        $effects = explode(':', $update_battle_effects);
        for ($i = 0; $i < count($effects); $i++) {
            switch (TRUE) {
                case ($effects[$i] == 'ATT' || $effects[$i] == 'DEF' || $effects[$i] == 'MA' || $effects[$i] == 'MD') && $battle_stats['battle_effects'] == '':
                    $effects[$i] = $effects[$i] == 'MA' ? 'magic_attack' : $effects[$i];
                    $effects[$i] = $effects[$i] == 'MD' ? 'magic_resistance' : $effects[$i];
                    if (substr_count($effects[$i + 1], '%')) {
                        $value = floor($battle_stats['battle_opponent_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100);
                    } else {
                        $value = $effects[$i + 1];
                    }
                    //execute effects now
                    if ($effects[$i + 3] == 1) {
                        $value_sql = 'battle_opponent_' . strtolower($effects[$i]) . ' = battle_opponent_' . strtolower($effects[$i]) . ' + ' . $value;
                        if ($pvp == 0) {
                            // Update battle with effect on monster
                            $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND battle_result = 0\r\n\t\t\t\t\t\t\t\tAND battle_type = 1 ";
                            $result = $db->sql_query($sql);
                            if (!$result) {
                                message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                            }
                        } else {
                            if ($pvp == 1) {
                                // Update battle with effect on opponent player
                                $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND (battle_result = 0 OR battle_result = 3) ";
                                $result = $db->sql_query($sql);
                                if (!$result) {
                                    message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                                }
                            }
                        }
                        if ($potion_id != 0) {
                            if (substr_count($effects[$i + 1], '-')) {
                                $battle_message .= $user['character_name'] . ' throws a ' . $potion['item_name'] . ' at ' . $monster_name . ' losing ' . $value . ' ' . $effects[$i] . '<br>';
                            } else {
                                $battle_message .= $user['character_name'] . ' throws a ' . $potion['item_name'] . ' at ' . $monster_name . ' gaining ' . $value . ' ' . $effects[$i] . '<br>';
                            }
                        }
                    } else {
                        if ($effects[$i + 3] == 0) {
                            $value_sql = 'battle_challenger_' . strtolower($effects[$i]) . ' = battle_challenger_' . strtolower($effects[$i]) . ' + ' . $value;
                            if ($pvp == 0) {
                                // Update battle with effect on monster
                                $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND battle_result = 0\r\n\t\t\t\t\t\t\t\tAND battle_type = 1 ";
                                $result = $db->sql_query($sql);
                                if (!$result) {
                                    message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                                }
                            } else {
                                if ($pvp == 1) {
                                    // Update battle with effect on opponent player
                                    $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND (battle_result = 0 OR battle_result = 3) ";
                                    $result = $db->sql_query($sql);
                                    if (!$result) {
                                        message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                                    }
                                }
                            }
                            if ($potion_id != 0) {
                                if (substr_count($effects[$i + 1], '-')) {
                                    $battle_message .= $user['character_name'] . ' consumes a ' . $potion['item_name'] . ' losing ' . $value . ' ' . $effects[$i] . '<br>';
                                } else {
                                    $battle_message .= $user['character_name'] . ' consumes a ' . $potion['item_name'] . ' gaining ' . $value . ' ' . $effects[$i] . '<br>';
                                }
                            }
                        }
                    }
                    break;
                case $effects[$i] == 'HP' || $effects[$i] == 'MP':
                    //execute effects now
                    if ($effects[$i + 3] == 1) {
                        if (substr_count($effects[$i + 1], '%')) {
                            $value = floor($battle_stats['battle_opponent_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100);
                        } else {
                            $value = $effects[$i + 1];
                        }
                        $value_sql = 'battle_opponent_' . strtolower($effects[$i]) . ' = battle_opponent_' . strtolower($effects[$i]) . ' + ' . $value;
                        if ($pvp == 0) {
                            // Update battle with effect on monster
                            $sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND battle_result = 0\r\n\t\t\t\t\t\t\t\tAND battle_type = 1 ";
                            $result = $db->sql_query($sql);
                            if (!$result) {
                                message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                            }
                        } else {
                            if ($pvp == 1) {
                                // Update battle with effect on opponent player
                                $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n\t\t\t\t\t\t\t\tSET {$value_sql}\r\n\t\t\t\t\t\t\t\tWHERE battle_challenger_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND (battle_result = 0 OR battle_result = 3) ";
                                $result = $db->sql_query($sql);
                                if (!$result) {
                                    message_die(GENERAL_ERROR, "Couldn't update battle list with effects", "", __LINE__, __FILE__, $sql);
                                }
                            }
                        }
                        if ($potion_id != 0) {
                            if (substr_count($effects[$i + 1], '-')) {
                                $battle_message .= $user['character_name'] . ' throws a ' . $potion['item_name'] . ' at ' . $monster_name . ' losing ' . $value . ' ' . $effects[$i] . '<br>';
                            } else {
                                $battle_message .= $user['character_name'] . ' throws a ' . $potion['item_name'] . ' at ' . $monster_name . ' restoring ' . $value . ' ' . $effects[$i] . '<br>';
                            }
                        }
                    } else {
                        if ($effects[$i + 3] == 0) {
                            if (substr_count($effects[$i + 1], '%')) {
                                $value = floor($user['character_' . strtolower($effects[$i]) . ''] * $effects[$i + 1] / 100);
                            } else {
                                $value = $effects[$i + 1];
                            }
                            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\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);
                            }
                            if ($potion_id != 0) {
                                if (substr_count($effects[$i + 1], '-')) {
                                    $battle_message .= $user['character_name'] . ' consumes a ' . $potion['item_name'] . ' losing ' . $value . ' ' . $effects[$i] . '<br>';
                                } else {
                                    $battle_message .= $user['character_name'] . ' consumes a ' . $potion['item_name'] . ' restoring ' . $value . ' ' . $effects[$i] . '<br>';
                                }
                            }
                        }
                    }
                    break;
            }
        }
        if ($potion_id != 0) {
            return $battle_message;
        }
    }
}
示例#23
0
define('IN_ADR_CHARACTER', true);
$phpbb_root_path = './';
include_once $phpbb_root_path . 'extension.inc';
include_once $phpbb_root_path . 'common.' . $phpEx;
//
// Start session management
$userdata = session_pagestart($user_ip, PAGE_ADR);
init_userprefs($userdata);
// End session management
//
$user_id = $userdata['user_id'];
include_once $phpbb_root_path . 'adr/includes/adr_global.' . $phpEx;
// Sorry , only logged users ...
if (!$userdata['session_logged_in']) {
    $redirect = "adr_character.{$phpEx}";
    $redirect .= isset($user_id) ? '&user_id=' . $user_id : '';
    header('Location: ' . append_sid("login.{$phpEx}?redirect={$redirect}", true));
}
// Includes the tpl and the header
adr_template_file('adr_tower_body.tpl');
include_once $phpbb_root_path . 'includes/page_header.' . $phpEx;
// Get the general config and character infos
$adr_general = adr_get_general_config();
adr_enable_check();
adr_ban_check($user_id);
adr_character_created_check($user_id);
$adr_user = adr_get_user_infos($user_id);
$template->assign_vars(array('L_ZONE_TOWER' => $lang['Adr_zone_tower_title'], 'L_ZONE_CHARACTER_SKILLS' => $lang['Adr_zone_character_skills'], 'L_ZONE_CHARACTER_EQUIP' => $lang['Adr_zone_character_equip'], 'U_ZONE_CHARACTER_SKILLS' => append_sid("adr_character_skills.{$phpEx}"), 'U_ZONE_CHARACTER_EQUIP' => append_sid("adr_character_equipment.{$phpEx}"), 'S_ZONES_ACTION' => append_sid("adr_tower.{$phpEx}")));
include $phpbb_root_path . 'adr/includes/adr_header.' . $phpEx;
$template->pparse('body');
include_once $phpbb_root_path . 'includes/page_tail.' . $phpEx;
示例#24
0
adr_advanced_template_file('adr_header_body.tpl', 'header');
// Job check
adr_job_salary_check($userdata['user_id']);
// Just because this may be if use for furthers versions
// $template->assign_block_vars('header',array());
// Display message to admin if RPG is currently disabled while viewing
if (!$adr_general['Adr_disable_rpg']) {
    echo '<br><center><b>' . $lang['Adr_disabled_admin_msg1'] . ':</b> <i>' . $lang['Adr_disabled_admin_msg2'] . '</i></center>';
}
// V: character replen (every 15 minutes)
if (empty($adr_general['last_character_replen']) || time() < $adr_general['last_character_replen'] + 15 * 60) {
    adr_character_replen_quota();
    adr_update_general_config();
}
// Includes the tpl
$adr_user = adr_get_user_infos($userdata['user_id']);
// Get Zone infos
$area_id = $adr_user['character_area'];
$actual_season = $board_config['adr_seasons'];
$actual_time = $board_config['adr_time'];
$sql = " SELECT * FROM  " . ADR_ZONES_TABLE . "\n       WHERE zone_id = '{$area_id}' ";
if (!($result = $db->sql_query($sql))) {
    message_die(GENERAL_ERROR, 'Could not query area list', '', __LINE__, __FILE__, $sql);
}
$zone = $db->sql_fetchrow($result);
$zone_shops = $zone['zone_shops'];
$zone_forge = $zone['zone_forge'];
$zone_mine = $zone['zone_mine'];
$zone_enchant = $zone['zone_enchant'];
$zone_temple = $zone['zone_temple'];
$zone_prison = $zone['zone_prison'];