diff options
-rwxr-xr-x | tmw-info.sh | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tmw-info.sh b/tmw-info.sh index cf46fc3..e4e7a04 100755 --- a/tmw-info.sh +++ b/tmw-info.sh @@ -348,10 +348,8 @@ elif [ "$1" == "mob-search" ]; then DROP_PERCS=$(echo "$LINE" | awk -F ',' '{print $31 $33 $35 $37 $39 $41 $43 $45}' | sed -E 's/ 0,//g' | sed 's/,//g' | sed -E 's/^\s*//g') if [[ $(ls "$ITEM_DIR"/* 2> '/dev/null') != '' ]]; then for DROP_ID in "${DROP_IDS[@]}"; do - grep -hE "^$DROP_ID, " "$ITEM_DIR"/* | awk '{print $2}' >> "$TMW_INFO/mob-drop-names-$MOB_ID.tmp" + grep -hE "^$DROP_ID, " "$ITEM_DIR"/* | awk '{print $2}' | tr ',\n' ' ' >> "$TMW_INFO/mob-drop-names-$MOB_ID.tmp" done - cat < "$TMW_INFO/mob-drop-names-$MOB_ID.tmp" | tr ',\n' ' ' > "$TMW_INFO/mob-drop-names-$MOB_ID.tmp.tmp" - mv "$TMW_INFO/mob-drop-names-$MOB_ID.tmp.tmp" "$TMW_INFO/mob-drop-names-$MOB_ID.tmp" DROP_NAMES=$(sed 's/^$//g' "$TMW_INFO/mob-drop-names-$MOB_ID.tmp") else echo 'Warning: To get the names of item drops, rather than just their IDs, you must run item-update first' @@ -362,11 +360,12 @@ elif [ "$1" == "mob-search" ]; then while [ "$DROP_COUNT" -le "$DROP_COUNT_MAX" ]; do DROP_NAME=$(echo "$DROP_NAMES" | awk "{print $"$DROP_COUNT"}") DROP_PERC=$(echo "$DROP_PERCS" | awk "{print $"$DROP_COUNT"}") - DROP_PERCENT=$(echo "scale=2; $DROP_PERC / 100" | bc) - DROP_RATIO=$(echo "scale=2; 100 / $DROP_PERCENT" | bc | sed 's/.00$//g' ) - echo "$DROP_NAME($DROP_PERCENT% | $DROP_RATIO:1)," >> "$TMW_INFO/mob-drops-$MOB_ID.tmp" - cat < "$TMW_INFO/mob-drops-$MOB_ID.tmp" | tr '\n' ' ' > "$TMW_INFO/mob-drops-$MOB_ID.tmp.tmp" - mv "$TMW_INFO/mob-drops-$MOB_ID.tmp.tmp" "$TMW_INFO/mob-drops-$MOB_ID.tmp" + # Improved drop percentage formatting, kept old line for reference + #DROP_PERCENT=$(echo "scale=2; $DROP_PERC / 100" | bc) + #DROP_RATIO=$(echo "scale=2; 100 / $DROP_PERCENT" | bc | sed 's/.00$//g') + DROP_PERCENT=$(awk "BEGIN {printf \"%3.2f\n\", $DROP_PERC / 100}") + DROP_RATIO=$(awk "BEGIN {printf \"%.2f\n\", 100 / $DROP_PERC}") + echo " - $DROP_NAME ($DROP_PERCENT% | $DROP_RATIO:1)" >> "$TMW_INFO/mob-drops-$MOB_ID.tmp" DROP_COUNT=$(( DROP_COUNT + 1 )) done DROPS=$(sed 's/^$//g' "$TMW_INFO/mob-drops-$MOB_ID.tmp" 2> '/dev/null' | sed -E 's/,\s*$//g' | sed -E 's/,\s*$//g') @@ -381,7 +380,7 @@ SPD: $(echo "$LINE" | awk '{print $26}')\n\ STATS: STR=$(echo "$LINE" | awk '{print $14}') AGI=$(echo "$LINE" | awk '{print $15}') VIT=$(echo "$LINE" | awk '{print $16}') \ INT=$(echo "$LINE" | awk '{print $17}') DEX=$(echo "$LINE" | awk '{print $18}') LUK=$(echo "$LINE" | awk '{print $19}')\n\ MUTATIONS: $(echo "$LINE" | awk '{print $56}') MUTATION STR: $(echo "$LINE" | awk '{print $57}')\n\ -DROPS: $DROPS\n\ +DROPS:\n$DROPS\n\ " done < "$TMW_INFO/mob-search$LAST_COUNT.tmp" elif [ "$1" == 'cmds-update' ];then |