Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env bash
- #>-------------------------------------------------------------------------------
- #>
- #> [ bl3-dps ]
- #>
- #> Calculate damage-per-second on guns found in Borderlands 3
- #>
- #> This is an interactive script (no direct inputs are required). Outputs
- #> are saved into a local CSV file. Over time, this output file can serve
- #> as a personal DPS database.
- #>
- #> SOURCE:
- #>
- #> Pastebin: http://bit.ly/39qhOiG
- #> Github: http://bit.ly/39slArV
- #>
- #> USAGE:
- #>
- #> ./bl3-dps.sh (<OPTION>)
- #>
- #> where "OPTION" is an optional input; and where "OPTION" is one of the
- #> following:
- #>
- #> |
- #> --change-log | Print the script change log to the terminal
- #> |
- #> -h, --help | Print this help text to the terminal
- #> |
- #> -r, --read | Print the entire local DPS data file to the standard
- #> | output (renders data in JSON syntax)
- #> |
- #> -R, --read-csv | Same as '--read' but prints the output in CSV format
- #> |
- #>
- #>-------------------------------------------------------------------------------
- #C>-------------------------------------------------------------------------------
- #C> CHANGE LOG:
- #C>
- #C> Created on 20210125 by h8rt3rmin8r
- #C>
- #C> - Began script creation
- #C>
- #C> Updated on 20210127 by h8rt3rmin8r
- #C>
- #C> - Completed first version of the script
- #C>
- #C> Updated on 20210128 by h8rt3rmin8r
- #C>
- #C> - Added help text function
- #C> - Added change log function
- #C> - Added standalone function for conversion of JSON syntax into CSV
- #C> - Truncated sub-decimal zeros on damage_final and fire_rate_final
- #C> - Added support for anoint text
- #C> - Added automatic de-duplication on record inserts
- #C> - Updated self-referencing process used by script verbosity function
- #C>
- #C> TO-DO:
- #C>
- #C> - Add support for weapon elements
- #C> - Add support for Accuracy, Handling, Reload Time, and Magazine Size
- #C>
- #C>-------------------------------------------------------------------------------
- #________________________________________________________________________________
- # Declare functions
- ## interactive functions
- function bl3dps_ask_string() {
- #> Ask the user for a string in response to a specified question
- #>
- #> Outputs are exported as the global variable "$OUST"
- #>
- #______________________________________________________________________________
- local question=$(echo -n "$@")
- read -p "${question} " REPLY
- local reply_mod=$(tr -d "'*\\\"," <<<"${REPLY}")
- export OUST="${reply_mod}"
- return $?
- }
- function bl3dps_ask_number_positive() {
- #> Ask the user to enter a non-negative number in response to a question
- #>
- #> Outputs are exported as the global variable "$OUST"
- #>
- #______________________________________________________________________________
- local reply_mod=""
- local INST="$@"
- read -p "${INST} (#?): " REPLY
- local reply_src="${REPLY}"
- local reply_mod=$(echo "${REPLY,,}" | tr -d "'*\\\"+%,")
- local reply_mod_test=$(egrep --quiet '^([1-9]|[1-9][0-9]+|[0-9][.][0-9]+|[1-9][0-9]+[.][0-9]+)$' <<<"${reply_mod}"; echo $?)
- while [[ ! "${reply_mod_test}" -eq 0 ]]; do
- echo "" &>/dev/stderr ##==> line break
- echo "ERROR: Unknown response detected" &>/dev/stderr
- echo "Please enter a valid non-negative number ..." &>/dev/stderr
- ${FUNCNAME} "${INST}"
- local reply_mod_test=$(egrep --quiet '^([1-9]|[1-9][0-9]+|[0-9][.][0-9]+|[1-9][0-9]+[.][0-9]+)$' <<<"${reply_mod}"; echo $?)
- done
- export OUST="${reply_mod}"
- return $?
- }
- function bl3dps_ask_number_whole() {
- #> Ask the user to enter a whole number in response to a question
- #>
- #> Outputs are exported as the global variable "$OUST"
- #>
- #______________________________________________________________________________
- local reply_mod=""
- local INST="$@"
- read -p "${INST} (#?): " REPLY
- local reply_src="${REPLY}"
- local reply_mod=$(echo "${REPLY,,}" | tr -d "'*\\\"+%,")
- while [[ ! "${reply_mod}" =~ ^-?[0-9]+$ ]]; do
- echo "" &>/dev/stderr ##==> line break
- echo "ERROR: Unknown response detected" &>/dev/stderr
- echo "Please enter a valid positive or negative whole number ..." &>/dev/stderr
- ${FUNCNAME} "${INST}"
- done
- export OUST="${reply_mod}"
- return $?
- }
- function bl3dps_ask_number_whole_positive() {
- #> Ask the user to enter a non-negative whole number in response to a question
- #>
- #> Outputs are exported as the global variable "$OUST"
- #>
- #______________________________________________________________________________
- local reply_mod=""
- local INST="$@"
- read -p "${INST} (#?): " REPLY
- local reply_src="${REPLY}"
- local reply_mod=$(echo "${REPLY,,}" | tr -d "'*\\\"+%,")
- while [[ ! "${reply_mod}" =~ ^[0-9]+$ ]]; do
- echo "" &>/dev/stderr ##==> line break
- echo "ERROR: Unknown response detected" &>/dev/stderr
- echo "Please enter a valid non-negative whole number ..." &>/dev/stderr
- ${FUNCNAME} "${INST}"
- done
- export OUST="${reply_mod}"
- return $?
- }
- function bl3dps_ask_options() {
- #> Ask the user to select an answer from a list of indicated options
- #>
- #> Outputs are exported as the global variable "$OUST"
- #>
- #______________________________________________________________________________
- local runtime="$(date '+%s%N')"
- local nonce="${RANDOM:0:1}${RANDOM: -1}${RANDOM: -1}${RANDOM: -1}${RANDOM: -1}"
- local tmpf="/tmp/${FUNCNAME}_${runtime}-${nonce}"
- local OPTIONS_COUNT="$#"
- local OPTIONS_INPUT="$@"
- local PRINT_OPEN="(Select a number from the following list)"
- echo "${OPTIONS_INPUT}" \
- | sed 's/--//g' \
- | tr ' ' '\n' \
- | tr -d '"' \
- | tr '_' ' ' >> "${tmpf}"
- mapfile -t L_ARR <"${tmpf}"
- echo "${PRINT_OPEN}" &>/dev/stderr
- select opt in "${L_ARR[@]}"; do
- echo "" &>/dev/stderr
- export OUST="$opt"
- break
- done
- rm "${tmpf}" &>/dev/null
- return $?
- }
- function bl3dps_ask_truefalse() {
- #> Ask a true/false question (output is $OUST as "true" or "false")
- #>
- #______________________________________________________________________________
- local reply_mod=""
- local INST="$@"
- read -p "${INST} (True/False): " REPLY
- local reply_src="${REPLY}"
- local reply_mod=$(echo "${REPLY,,}" | tr -d "'*\\\",")
- local reply_mod="${reply_mod:0:1}"
- while [[ ! "${reply_mod}" =~ ^[FfTt]$ ]]; do
- echo "" &>/dev/stderr ##==> line break
- echo "ERROR: Unknown response detected" &>/dev/stderr
- echo "Please indicate either (T)rue or (F)alse ..." &>/dev/stderr
- ${FUNCNAME} "${INST}"
- done
- case "${reply_mod}" in
- f|F)
- export OUST="false"
- return $?
- ;;
- t|T)
- export OUST="true"
- return $?
- ;;
- esac
- }
- ## math functions
- function bl3dps_math_add() {
- # Addition function
- declare -a IN_ARR=( $@ )
- dc -e "0 ${IN_ARR[*]/-/_} ${IN_ARR[*]/*/+} p" 2>/dev/null
- local e_c="$?"
- unset IN_ARR
- return $?
- }
- function bl3dps_math_divide() {
- # Division function
- declare -a IN_ARR=( $@ )
- if [[ "${#IN_ARR[@]}" -gt 2 ]]; then
- local result=""
- while [[ "${#IN_ARR[@]}" -gt 0 ]]; do
- if [[ "x${result}" == "x" ]]; then
- local result=$(echo "${IN_ARR[0]} / ${IN_ARR[1]}" | bc -l 2>/dev/null)
- local e_c="$?"
- local IN_ARR=(${IN_ARR[@]:2})
- else
- local result=$(echo "${result} / ${IN_ARR[0]}" | bc -l 2>/dev/null)
- local e_c="$?"
- local IN_ARR=(${IN_ARR[@]:1})
- fi
- done
- echo "${result}"
- else
- echo "${IN_ARR[0]} / ${IN_ARR[1]}" \
- | bc -l 2>/dev/null
- local e_c="$?"
- fi
- unset IN_ARR
- return ${e_c}
- }
- function bl3dps_math_multiply() {
- # Multiplication function
- declare -a IN_ARR=( $@ )
- if [[ "${#IN_ARR[@]}" -gt 2 ]]; then
- local result=""
- while [[ "${#IN_ARR[@]}" -gt 0 ]]; do
- if [[ "x${result}" == "x" ]]; then
- local result=$(echo "${IN_ARR[0]} * ${IN_ARR[1]}" | bc -l 2>/dev/null)
- local e_c="$?"
- local IN_ARR=(${IN_ARR[@]:2})
- else
- local result=$(echo "${result} * ${IN_ARR[0]}" | bc -l 2>/dev/null)
- local e_c="$?"
- local IN_ARR=(${IN_ARR[@]:1})
- fi
- done
- echo "${result}"
- else
- echo "${IN_ARR[0]} * ${IN_ARR[1]}" \
- | bc -l 2>/dev/null
- local e_c="$?"
- fi
- unset IN_ARR
- return ${e_c}
- }
- function bl3dps_math_subtract() {
- # Subtraction function
- declare -a IN_ARR=( $@ )
- local IN_ARR_MOD=(${IN_ARR[@]:1})
- local X_1="${IN_ARR[0]}"
- local X_2=$(dc -e "0 ${IN_ARR_MOD[*]/-/_} ${IN_ARR_MOD[*]/*/+} p" 2>/dev/null)
- echo "scale=11; ${X_1} - ${X_2} " \
- | bc 2>/dev/null
- local e_c="$?"
- unset IN_ARR
- return ${e_c}
- }
- ## core process functions
- function bl3dps_proc_csv2json() {
- #> Convert JSON syntax into CSV (requires incoming pipe)
- jq -Rnc '( input | split(",") ) as $keys | ( inputs | split(",") ) as $vals | [[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries' \
- | sed 's/$/,/' \
- | tr -d '\n' \
- | sed 's/^/\[/;s/,$/\]/;s/\"\\\"/\"/g;s/\\\"\"/\"/g' \
- | jq '.' 2>/dev/null
- return $?
- }
- function bl3dps_proc_damage_final() {
- # (base_damage * damage_multiplier) + (base_damage * damage_multiplier) * (damage_bump / 100)
- local total_base_damage=$(bl3dps_math_multiply "${x_base_damage}" "${x_damage_multiplier}")
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "${FUNCNAME}: total_base_damage: ${total_base_damage}"
- if [[ "${x_damage_bump}" == "0" ]]; then
- local total_damage_bump=0
- else
- local total_damage_bump_pre=$(bl3dps_math_divide "${x_damage_bump}" "100")
- local total_damage_bump=$(bl3dps_math_multiply "${total_base_damage}" "${total_damage_bump_pre}")
- fi
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "${FUNCNAME}: total_damage_bump: ${total_damage_bump}"
- local output_pre=$(bl3dps_math_add "${total_base_damage}" "${total_damage_bump}")
- if [[ "${output_pre}" =~ [.] ]]; then
- ## truncate sub-decimal results to only TWO decimal places
- local out_mod_prefix="${output_pre//.*}"
- local out_mod_suffix="${output_pre//*.}"
- local out_mod_suffix_trunk="${out_mod_suffix:0:2}"
- local output="${out_mod_prefix}.${out_mod_suffix_trunk}"
- else
- local output="${output_pre}"
- fi
- echo "${output}"
- return $?
- }
- function bl3dps_proc_dps() {
- ## damage_final * fire_rate_final
- local output_pre$(bl3dps_math_multiply "${x_damage_final}" "${x_fire_rate_final}")
- if [[ "${output_pre}" =~ [.] ]]; then
- ## truncate sub-decimal results to only TWO decimal places
- local out_mod_prefix="${output_pre//.*}"
- local out_mod_suffix="${output_pre//*.}"
- local out_mod_suffix_trunk="${out_mod_suffix:0:2}"
- local output="${out_mod_prefix}.${out_mod_suffix_trunk}"
- else
- local output="${output_pre}"
- fi
- echo "${output}"
- return $?
- }
- function bl3dps_proc_firerate_final() {
- ## fire_rate + (fire_rate * (fire_rate_bump / 100))
- local total_base_fire_rate="${x_fire_rate}"
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "${FUNCNAME}: total_base_fire_rate: ${total_base_fire_rate}"
- if [[ "${x_fire_rate_bump}" == "0" ]]; then
- local total_fire_rate_bump=0
- else
- local total_fire_rate_bump_pre=$(bl3dps_math_divide "${x_fire_rate_bump}" "100")
- local total_fire_rate_bump=$(bl3dps_math_multiply "${total_base_fire_rate}" "${total_fire_rate_bump_pre}")
- fi
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "${FUNCNAME}: total_fire_rate_bump: ${total_fire_rate_bump}"
- local output_pre=$(bl3dps_math_add "${total_base_fire_rate}" "${total_fire_rate_bump}")
- if [[ "${output_pre}" =~ [.] ]]; then
- ## truncate sub-decimal results to only TWO decimal places
- local out_mod_prefix="${output_pre//.*}"
- local out_mod_suffix="${output_pre//*.}"
- local out_mod_suffix_trunk="${out_mod_suffix:0:2}"
- local output="${out_mod_prefix}.${out_mod_suffix_trunk}"
- else
- local output="${output_pre}"
- fi
- echo "${output}"
- return $?
- }
- function bl3dps_proc_output_columns() {
- ## meta values
- local col_a="${_q2}id${_q2}" ## [SHA-256 checksum of all record data]
- local col_b="${_q2}title${_q2}" ## [text string]
- local col_c="${_q2}datetime${_q2}" ## [human-friendly date and time]
- local col_d="${_q2}runtime${_q2}" ## [unix timestamp]
- local col_e="${_q2}weapon_type${_q2}" ## Pistol, SMG, Assault Rifle, Shotgun, Sniper Rifle, Launcher
- local col_f="${_q2}mayhem_level${_q2}" ## 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- local col_g="${_q2}level_required${_q2}" ## 1, 2, 3 ... 65
- local col_h="${_q2}item_score${_q2}" ## [whole number between 1 and 999]
- local col_i="${_q2}is_anointed${_q2}" ## true, false
- local col_j="${_q2}anointed_type${_q2}" ## Operative, Gunner, Siren, Beastmaster, Generic, null
- local col_k="${_q2}anoint_text${_q2}" ## [text string]
- ## damage values
- local col_l="${_q2}base_damage${_q2}" ## [non-negative whole number]
- local col_m="${_q2}has_base_multiplier${_q2}" ## true, false
- local col_n="${_q2}damage_multiplier${_q2}" ## [non-negative whole number]
- local col_o="${_q2}damage_bump${_q2}" ## [positive or negative whole number]
- local col_p="${_q2}damage_final${_q2}" ## [positive whole number]
- ## fire-rate values
- local col_q="${_q2}fire_rate${_q2}" ## [positive decimal number]
- local col_r="${_q2}fire_rate_bump${_q2}" ## [positive or negative whole number]
- local col_s="${_q2}fire_rate_final${_q2}" ## [positive whole number]
- ## final DPS value
- local col_t="${_q2}damage_per_second${_q2}" ## [positive decimal number]
- ## column sections
- local cols_meta="${col_a}${_cm}${col_b}${_cm}${col_c}${_cm}${col_d}${_cm}${col_e}${_cm}${col_f}${_cm}${col_g}${_cm}${col_h}${_cm}${col_i}${_cm}${col_j}${_cm}${col_k}"
- local cols_damage="${col_l}${_cm}${col_m}${_cm}${col_n}${_cm}${col_o}${_cm}${col_p}"
- local cols_firerate="${col_q}${_cm}${col_r}${_cm}${col_s}"
- local cols_dps="${col_t}"
- ## final columns header line
- local cols_header="${cols_meta}${_cm}${cols_damage}${_cm}${cols_firerate}${_cm}${cols_dps}"
- echo "${cols_header}"
- return $?
- }
- function bl3dps_proc_output_data() {
- # column sections
- ### meta values
- local cols_meta="${_q2}${x_id}${_q2}${_cm}${_q2}${x_title}${_q2}${_cm}${_q2}${x_datetime}${_q2}${_cm}${_q2}${x_runtime}${_q2}${_cm}${_q2}${x_weapon_type}${_q2}${_cm}${_q2}${x_mayhem_level}${_q2}${_cm}${_q2}${x_level_required}${_q2}${_cm}${_q2}${x_item_score}${_q2}${_cm}${_q2}${x_is_anointed}${_q2}${_cm}${_q2}${x_anointed_type}${_q2}${_cm}${_q2}${x_anoint_text}${_q2}"
- ### damage values
- local cols_damage="${_q2}${x_base_damage}${_q2}${_cm}${_q2}${x_has_base_multiplier}${_q2}${_cm}${_q2}${x_damage_multiplier}${_q2}${_cm}${_q2}${x_damage_bump}${_q2}${_cm}${_q2}${x_damage_final}${_q2}"
- ### fire-rate values
- local cols_firerate="${_q2}${x_fire_rate}${_q2}${_cm}${_q2}${x_fire_rate_bump}${_q2}${_cm}${_q2}${x_fire_rate_final}${_q2}"
- ### final DPS value
- local cols_dps="${_q2}${x_damage_per_second}${_q2}"
- # final data string
- local data_output="${cols_meta}${_cm}${cols_damage}${_cm}${cols_firerate}${_cm}${cols_dps}"
- echo "${data_output}"
- return $?
- }
- function bl3dps_proc_output_file() {
- if [[ ! -f "${out_file}" ]]; then
- bl3dps_proc_output_columns > "${out_file}"
- fi
- return $?
- }
- function bl3dps_proc_output_result() {
- local i_n="$@"
- if [[ "x${i_n}" == "x" ]]; then
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "${FUNCNAME}: ERROR: null input detected; No output string was generated"
- return 1
- fi
- ## make sure the required output file exists and contains required column names
- bl3dps_proc_output_file
- ## perform automatic de-duplication before record insert
- sed -i "/$x_id/d" "${out_file}"
- ## write the new record into the DPS storage file
- echo "${i_n}" >> "${out_file}"
- ## create and print a copy of only the latest record
- bl3dps_proc_output_columns > "${tmpf}"
- echo "${i_n}" >> "${tmpf}"
- csvjson "${tmpf}" 2>/dev/null \
- | jq '.' 2>/dev/null
- local e_c="$?"
- ## remove the temp file and kill the function
- rm "${tmpf}" &>/dev/null
- return ${e_c}
- }
- function bl3dps_proc_sha256() {
- printf '%s' "${x_title}${x_weapon_type}${x_mayhem_level}${x_level_required}${x_item_score}${x_is_anointed}${x_anointed_type}${x_base_damage}${x_has_base_multiplier}${x_damage_multiplier}${x_damage_bump}${x_fire_rate}${x_fire_rate_bump}" \
- | sha256sum \
- | cut -d ' ' -f1
- return $?
- }
- ## verbosity and help functions
- function bl3dps_vbs() {
- local i_n="$@"
- local runtime="$(date '+%s')"
- echo "${runtime}|${sh_name}|${i_n}" &>/dev/stderr
- return $?
- }
- function bl3dps_changelog() {
- cat "${0}" \
- | grep -E '^#C[>]' \
- | sed 's/^...//'
- return $?
- }
- function bl3dps_vbs_help() {
- cat "${0}" \
- | grep -E '^#[>]' \
- | sed 's/^..//'
- return $?
- }
- #________________________________________________________________________________
- # Declare variables
- ## unicode character variables (Reference: https://home.unicode.org/)
- _cm=$'\u002C'
- _co=$'\u003A'
- _pa=$'\u0028'
- _pb=$'\u0029'
- _q1=$'\u0027'
- _q2=$'\u0022'
- _sp=$'\u0020'
- _and=$'\u0026'
- _cba=$'\u007B'
- _cbb=$'\u007D'
- _sba=$'\u005B'
- _sbb=$'\u005D'
- _usd=$'\u0024'
- ## main script variables
- sh_path="${0}"
- sh_file_name="${sh_path//*\/}"
- sh_name="${sh_file_name%.sh}"
- t_s=$(date '+%s')
- d_t=$(printf "%(%Y-%m-%d %H:%M:%S)T\n" "${t_s}" | tr 'T' ' ')
- here_now="${PWD}"
- out_file="${here_now}/bl3-dps.csv"
- tmpf="/tmp/${sh_name}_${t_s}"
- in_main="${1}"
- in_mod="${in_main//-}"
- ## output field variables
- ## id .................... [SHA-256 checksum of all record data]
- ## title ................. [text string]
- ## datetime .............. [human-friendly date and time]
- ## runtime ............... [unix timestamp]
- ## weapon_type ........... Pistol, SMG, Assault Rifle, Shotgun, Sniper Rifle, Launcher
- ## mayhem_level .......... 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- ## level_required ........ 1, 2, 3 ... 65
- ## item_score ............ [whole number between 1 and 999]
- ## is_anointed ........... true, false
- ## anointed_type ......... Operative, Gunner, Siren, Beastmaster, Generic, null
- ## anoint_text ........... [text string]
- ## base_damage ........... [non-negative whole number]
- ## has_base_multiplier ... true, false
- ## damage_multiplier ..... [non-negative whole number]
- ## damage_bump ........... [positive or negative whole number]
- ## damage_final .......... [positive whole number]
- ## fire_rate ............. [positive decimal number]
- ## fire_rate_bump ........ [positive or negative whole number]
- ## fire_rate_final ....... [positive whole number]
- ## damage_per_second ..... [positive decimal number]
- x_id=""
- x_title=""
- x_datetime="${d_t}"
- x_runtime="${t_s}"
- x_weapon_type=""
- x_mayhem_level="0"
- x_level_required=""
- x_item_score=""
- x_is_anointed=""
- x_anointed_type=""
- x_anoint_text=""
- x_base_damage=""
- x_has_base_multiplier=""
- x_damage_multiplier="1"
- x_damage_bump=""
- x_damage_final=""
- x_fire_rate=""
- x_fire_rate_bump=""
- x_fire_rate_final=""
- x_damage_per_second=""
- ## final data string
- data_string=""
- #________________________________________________________________________________
- # Execute operations
- case "${in_mod}" in
- c|C|changelog)
- bl3dps_changelog
- exit $?
- ;;
- h|H|help)
- bl3dps_vbs_help
- exit $?
- ;;
- r|read|readjson)
- if [[ ! -f "${out_file}" ]]; then
- bl3dps_vbs "ERROR: No local data file found"
- exit 1
- fi
- cat "${out_file}" \
- | bl3dps_proc_csv2json
- exit $?
- ;;
- R|readcsv)
- if [[ ! -f "${out_file}" ]]; then
- bl3dps_vbs "ERROR: No local data file found"
- exit 1
- fi
- cat "${out_file}"
- exit $?
- ;;
- esac
- ## title
- bl3dps_ask_string "Weapon title:"
- x_title="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_title: ${x_title}"
- ## weapon_type
- echo "Select the weapon type:" &>/dev/stderr
- bl3dps_ask_options --Pistol --SMG --Assault_Rifle --Shotgun --Sniper_Rifle --Launcher
- x_weapon_type="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_weapon_type: ${x_weapon_type}"
- ## mayhem_level
- bl3dps_ask_number_whole_positive "Mayhem level (0-10)"
- x_mayhem_level_temp="${OUST}"
- x_mayhem_level_test=$(egrep --quiet '^(0|1|2|3|4|5|6|7|8|9|10)$' <<<"${x_mayhem_level_temp}"; echo $?)
- if [[ "${x_mayhem_level_test}" -ne 0 ]]; then
- bl3dps_vbs "ERROR: Mayhem level must be a number between 0 and 10"
- bl3dps_vbs "Please try again ..."
- bl3dps_ask_number_whole_positive "Mayhem level (0-10)"
- fi
- x_mayhem_level="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_mayhem_level: ${x_mayhem_level}"
- ## level_required
- bl3dps_ask_number_whole_positive "Item user level (1-65)"
- x_level_required_temp="${OUST}"
- x_level_required_test=$(egrep --quiet '^(1|2|3|4|5|6|7|8|9|[1-5][0-9]|6[0-5])$' <<<"${x_level_required_temp}"; echo $?)
- if [[ "${x_level_required_test}" -ne 0 ]]; then
- bl3dps_vbs "ERROR: The required user level must be a number between 1 and 65"
- bl3dps_vbs "Please try again ..."
- bl3dps_ask_number_whole_positive "Item user level (1-65)"
- fi
- x_level_required="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_level_required: ${x_level_required}"
- ## item_score
- bl3dps_ask_number_whole_positive "Item point score (1-999)"
- x_item_score_temp="${OUST}"
- x_item_score_test=$(egrep --quiet '^(1|2|3|4|5|6|7|8|9|[1-9][0-9]|[1-9][0-9][0-9])$' <<<"${x_item_score_temp}"; echo $?)
- if [[ "${x_item_score_test}" -ne 0 ]]; then
- bl3dps_vbs "ERROR: The item score must be a number between 1 and 999"
- bl3dps_vbs "Please try again ..."
- bl3dps_ask_number_whole_positive "Item point score (1-999)"
- fi
- x_item_score="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_item_score: ${x_item_score}"
- ## is_anointed
- bl3dps_ask_truefalse "Is the item 'Anointed'"
- x_is_anointed="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_is_anointed: ${x_is_anointed}"
- ## anointed_type && anoint_text
- if [[ "${x_is_anointed}" =~ "true" ]]; then
- echo "Select the Anointed type" &>/dev/stderr
- bl3dps_ask_options --Operative --Gunner --Siren --Beastmaster --Generic
- x_anointed_type="${OUST}"
- unset OUST
- bl3dps_ask_string "Anoint text (on one line):"
- x_anoint_text="${OUST}"
- unset OUST
- else
- x_anointed_type="null"
- x_anoint_text="null"
- fi
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_anointed_type: ${x_anointed_type}"
- #bl3dps_vbs "x_anoint_text: ${x_anoint_text}"
- ## Define: base_damage
- bl3dps_ask_number_whole_positive "Base damage (without a shot multiplier)"
- x_base_damage="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_base_damage: ${x_base_damage}"
- ## Define: has_base_multiplier
- bl3dps_ask_truefalse "Does base damage have a shot multiplier (Example: '394x3')"
- x_has_base_multiplier="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_has_base_multiplier: ${x_has_base_multiplier}"
- ## Define: damage_multiplier
- if [[ "${x_has_base_multiplier}" =~ "true" ]]; then
- bl3dps_ask_number_whole_positive "Base damage shot multiplier"
- x_damage_multiplier="${OUST}"
- unset OUST
- else
- x_damage_multiplier="1"
- fi
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_damage_multiplier: ${x_damage_multiplier}"
- ## Define: damage_bump
- bl3dps_ask_number_whole "Percent damage bump (positive or negative); if none, enter '0'"
- x_damage_bump="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_damage_bump: ${x_damage_bump}"
- ## Define: damage_final
- x_damage_final=$(bl3dps_proc_damage_final)
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_damage_final: ${x_damage_final}"
- ## Define: fire_rate
- bl3dps_ask_number_positive "Fire rate (a positive decimal number)"
- x_fire_rate="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_fire_rate: ${x_fire_rate}"
- ## Define: fire_rate_bump
- bl3dps_ask_number_whole "Percent fire rate bump (positive or negative); if none, enter '0'"
- x_fire_rate_bump="${OUST}"
- unset OUST
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_fire_rate_bump: ${x_fire_rate_bump}"
- ## Define: fire_rate_final
- x_fire_rate_final=$(bl3dps_proc_firerate_final)
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_fire_rate_final: ${x_fire_rate_final}"
- ## Define: damage_per_second
- ## damage_per_second =
- ## [
- ## (
- ## base_damage * damage_multiplier
- ## ) + (
- ## (base_damage * damage_multiplier) * (damage_bump / 100)
- ## )
- ## ] * [
- ## fire_rate + (fire_rate * (fire_rate_bump / 100))
- ## ]
- x_damage_per_second=$(bl3dps_proc_dps)
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_damage_per_second: ${x_damage_per_second}"
- ## Define: id
- x_id=$(bl3dps_proc_sha256)
- ## uncomment the following line for debugging purposes:
- #bl3dps_vbs "x_id: ${x_id}"
- ## Generate output and kill the script
- data_string=$(bl3dps_proc_output_data)
- bl3dps_proc_output_result "${data_string}"
- #________________________________________________________________________________
- exit $?
RAW Paste Data