function adr_attack_weap()
{
    global $monster, $bat, $adr_user, $opponent_element, $item, $db, $lang, $user_id, $power, $crit_result;
    global $challenger, $battle_message, $user_action, $monster_action, $attack_img, $attackwith_overlay;
    global $damage, $dice;
    // weaprof
    $attbonus = adr_weapon_skill_check($user_id);
    if ($diff === TRUE && $dice != '1' || $dice >= $threat_range) {
        // Prefix msg if crit hit
        $battle_message .= $crit_result === TRUE ? '<br>' . $lang['Adr_battle_critical_hit'] . '</b><br />' : '';
        $damage = adr_calc_item_damage($item, $power, $attbonus);
        $damage = $damage > $bat['battle_opponent_hp'] ? $bat['battle_opponent_hp'] : $damage;
        // V: fix element
        $element_name = adr_get_element_infos($item['item_element']);
        // Here we apply text colour if set
        if ($element_name['element_colour'] != '') {
            $item['item_name'] = '<span style="color: ' . $element_name['element_colour'] . '">' . $item['item_name'] . '</span>';
        } else {
            $item['item_name'] = $item['item_name'];
        }
        // Fix attack msg type
        if ($item['item_element'] > '0' && $element_name['element_name'] != '') {
            $battle_message .= sprintf($lang['Adr_battle_attack_success'], $challenger['character_name'], $monster['monster_name'], $item['item_name'], adr_get_lang($element_name['element_name']), floor($attbonus), $damage) . '<br>';
        } else {
            $battle_message .= sprintf($lang['Adr_battle_attack_success_norm'], $challenger['character_name'], $monster['monster_name'], $item['item_name'], floor($attbonus), $damage) . '<br>';
        }
    } else {
        $damage = 0;
        $battle_message .= sprintf($lang['Adr_battle_attack_failure'], $challenger['character_name'], $monster['monster_name'], $item['item_name']) . '<br>';
    }
}
Пример #2
0
                 message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
             }
         } else {
             if ($user_id == $battle_opponent_id) {
                 // Update the database
                 $sql = "UPDATE " . ADR_BATTLE_PVP_TABLE . "\r\n                        SET battle_opponent_hp = battle_opponent_hp + {$power} , \r\n                            battle_turn = 1 \r\n                        WHERE battle_opponent_id = {$user_id}\r\n                        AND battle_id = {$battle_id} ";
                 if (!($result = $db->sql_query($sql))) {
                     message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
                 }
             }
         }
     }
 } else {
     if ($item['item_type_use'] == 109) {
         $attbonus = 0;
         $attbonus = adr_weapon_skill_check($user_id);
         $power = ceil($power * $attbonus);
         // V: todo remove?
         if ($code = $item['spell_xtreme_pvp']) {
             eval($code);
         } else {
             // Create message
             $battle_message .= sprintf($lang['Adr_pvp_spell_defensive_success'], $current_name, adr_get_lang($item['spell_name']), $current_name, $power) . '<br />';
             // Update the database
             if ($user_id === $battle_challenger_id) {
                 $check_att = 'battle_challenger_att';
                 $check_def = 'battle_challenger_def';
             } elseif ($user_id === $battle_opponent_id) {
                 $check_att = 'battle_opponent_att';
                 $check_def = 'battle_opponent_def';
             }