Advertisement
blackretina

csgo_weapon_getdata_spreadsheet

Oct 18th, 2012
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.05 KB | None | 0 0
  1. #!/bin/bash
  2. #:      Title: csgo_weapon_getdata_spreadsheet
  3. #:      Date: 2013-07-11
  4. #       License: Public Domain
  5.      
  6. scriptname="csgo_weapon_getdata_spreadsheet"
  7. version="0.6"
  8. author="Cameron Bullivant <BlackRetina@gmail.com>"
  9. description="Description: csgo_weapon_getdata_spreadsheet finds information relevant to weapons in /csgo/scripts/weapon_*.txt and formats it for spreadsheets"
  10. usage="csgo_weapon_getdata_spreadsheet [-h | -v ] weapon_*.txt"
  11.      
  12. function usage () #@ DESCRIPTION: print usage information
  13. {
  14. #@ USAGE: usage
  15. #@ REQUIRES: variable defined: $scriptname
  16.         printf "%s - %s\n" "$scriptname" "$description"
  17.         printf "USAGE: %s\n" "$usage"
  18. }
  19. readonly -f usage
  20. function version() #@ DESCRIPTION: print version information
  21. {
  22. #@ USAGE: version
  23. #@ REQUIRES: variables defined: $scriptname, $author and $version
  24.         printf "%s version %s\n" "$scriptname" "$version"
  25.         printf "by %s, \n" "$author"
  26. }
  27. readonly -f version
  28.  
  29. optstring=hv
  30. while getopts $optstring opt
  31. do
  32.         case $opt in
  33.           h) usage; exit 0 ;;
  34.           v) version; exit 0;;
  35.           *) usage; exit 1 ;;
  36.         esac
  37. done
  38.      
  39. for var in $@
  40. do
  41.         weapontype=`awk '/"?WeaponType"?/ { print $2 }' $var `
  42.         case $weapontype in
  43.           *SniperRifle*) sniperrifle="$sniperrifle $var";;
  44.           *Rifle*) rifle="$rifle $var" ;;
  45.           *SubMachinegun*) submachinegun="$submachinegun $var";;
  46.           *Machinegun*) machinegun="$machinegun $var";;
  47.           *Shotgun*) shotgun="$shotgun $var";;
  48.           *Pistol*) pistol="$pistol $var";;
  49.           *Grenade*) grenade="$grenade $var";;
  50.           *) miscellaneous="$miscellaneous $var";;
  51.         esac
  52. done
  53.      
  54. function getData() {
  55.         COUNT=0;
  56.         for filename in $@
  57.         do
  58.                 n=0;
  59.                 arr1=()
  60.                 arr2=()
  61.  
  62.                 printf -v bullets "%d" $(awk '/"?Bullets"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//')
  63.                 printf -v killaward "%d" $(awk '/"?KillAward"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//')
  64.                    
  65.                 printf -v arr2[$n] "%s" "Armor Ratio"
  66.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?WeaponArmorRatio"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//')
  67.                 printf -v arr2[$n] "%s" "Damage"
  68.                 printf -v arr1[$[n++]] "%d" $(awk '/"?Damage"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  69.                 printf -v arr2[$n] "%s" "RangeModifier"
  70.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?RangeModifier"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  71.                 printf -v arr2[$n] "%s" "CycleTime"
  72.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?CycleTime"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  73.                 printf -v arr2[$n] "%s" "Penetration"
  74.                 printf -v arr1[$[n++]] "%d" $(awk '/"?Penetration"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  75.                 printf -v arr2[$n] "%s" "Kill Award"
  76.                 if [ $killaward -eq 0 ]; then printf -v arr1[$[n++]] "%d" '300'; else printf -v arr1[$[n++]] "%d" $killaward; fi
  77.                 printf -v arr2[$n] "%s" "Speed"
  78.                 printf -v arr1[$[n++]] "%d" $(awk '/(MaxPlayerSpeed )|("MaxPlayerSpeed")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  79.                 printf -v arr2[$n] "%s" "Clip Size"
  80.                 printf -v arr1[$[n++]] "%d" $(awk '/"?clip_size"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//')
  81.                 printf -v arr2[$n] "%s" "Price"
  82.                 printf -v arr1[$[n++]] "%d" $(awk '/"?WeaponPrice"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  83.                 printf -v arr2[$n] "%s" "Range"
  84.                 printf -v arr1[$[n++]] "%d" $(awk '/(Range )|("Range")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  85.                 printf -v arr2[$n] "%s" "FullAuto"
  86.                 printf -v arr1[$[n++]] "%d" $(awk '/(FullAuto )|("FullAuto")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  87.                 printf -v arr2[$n] "%s" "FlinchVelocityModifierLarge"
  88.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(FlinchVelocityModifierLarge )|("?FlinchVelocityModifierLarge"?)/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  89.                 printf -v arr2[$n] "%s" "FlinchVelocityModifierSmall"
  90.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(FlinchVelocityModifierSmall )|("?FlinchVelocityModifierSmall"?)/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  91.  
  92.                 printf -v arr2[$n] "%s" "Spread"
  93.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(Spread )|("Spread")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  94.                 printf -v arr2[$n] "%s" "InaccuracyCrouch"
  95.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyCrouch )|("InaccuracyCrouch")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  96.                 printf -v arr2[$n] "%s" "InaccuracyStand"
  97.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyStand )|("InaccuracyStand")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  98.                 printf -v arr2[$n] "%s" "InaccuracyFire"
  99.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyFire )|("InaccuracyFire")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  100.                 printf -v arr2[$n] "%s" "InaccuracyMove"
  101.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyMove )|("InaccuracyMove")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  102.                 printf -v arr2[$n] "%s" "InaccuracyJump"
  103.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyJump )|("InaccuracyJump")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  104.                 printf -v arr2[$n] "%s" "InaccuracyLand"
  105.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyLand )|("InaccuracyLand")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  106.                 printf -v arr2[$n] "%s" "InaccuracyLadder"
  107.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyLadder )|("InaccuracyLadder")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  108.  
  109.                 printf -v arr2[$n] "%s" "RecoveryTimeCrouch"
  110.                 printf -v arr1[$[n++]] "%.6f" $(awk '/"?RecoveryTimeCrouch"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  111.                 printf -v arr2[$n] "%s" "RecoveryTimeStand"
  112.                 printf -v arr1[$[n++]] "%.6f" $(awk '/"?RecoveryTimeStand"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  113.                 printf -v arr2[$n] "%s" "RecoilAngleVariance"
  114.                 printf -v arr1[$[n++]] "%d" $(awk '/(RecoilAngleVariance )|("RecoilAngleVariance")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  115.                 printf -v arr2[$n] "%s" "RecoilMagnitude"
  116.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(RecoilMagnitude )|("RecoilMagnitude")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  117.                 printf -v arr2[$n] "%s" "RecoilMagnitudeVariance"
  118.                 printf -v arr1[$[n++]] "%d" $(awk '/(RecoilMagnitudeVariance )|("RecoilMagnitudeVariance")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  119.  
  120.                 printf -v arr2[$n] "%s" "SpreadAlt"
  121.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?SpreadAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  122.                 printf -v arr2[$n] "%s" "InaccuracyCrouchAlt"
  123.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?InaccuracyCrouchAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  124.                 printf -v arr2[$n] "%s" "InaccuracyStandAlt"
  125.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?InaccuracyStandAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  126.                 printf -v arr2[$n] "%s" "InaccuracyFireAlt"
  127.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?InaccuracyFireAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/\r//' )
  128.                 printf -v arr2[$n] "%s" "InaccuracyMoveAlt"
  129.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?InaccuracyMoveAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  130.                 printf -v arr2[$n] "%s" "InaccuracyJumpAlt"
  131.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyJumpAlt )|("InaccuracyJumpAlt")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  132.                 printf -v arr2[$n] "%s" "InaccuracyLandAlt"
  133.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyLandAlt )|("InaccuracyLandAlt")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  134.                 printf -v arr2[$n] "%s" "InaccuracyLadderAlt"
  135.                 printf -v arr1[$[n++]] "%.3f" $(awk '/(InaccuracyLadderAlt )|("InaccuracyLadderAlt")/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  136.                 printf -v arr2[$n] "%s" "RecoilAngleVarianceAlt"
  137.                 printf -v arr1[$[n++]] "%d" $(awk '/"?RecoilAngleVarianceAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  138.                 printf -v arr2[$n] "%s" "RecoilMagnitudeAlt"
  139.                 printf -v arr1[$[n++]] "%.3f" $(awk '/"?RecoilMagnitudeAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  140.                 printf -v arr2[$n] "%s" "RecoilMagnitudeVarianceAlt"
  141.                 printf -v arr1[$[n++]] "%d" $(awk '/"?RecoilMagnitudeVarianceAlt"?/ { print $2 }' $filename | sed -e 's/\"//g' -e 's/.$//' )
  142.      
  143.                 if [ $bullets -ne 1 ]; then printf -v arr2[$n] "%s" "Bullets"; printf -v arr1[$[n++]] "%d" $bullets; fi
  144.                
  145.                 if [ $COUNT -eq 0 ]; then printf "%s:" "${arr2[@]}"; echo ""; fi
  146.                 printf "%s:" "$(echo $filename | sed -e 's/weapon_//' -e 's/.txt//' )" "${arr1[@]}"; echo "";
  147.                 (( COUNT++ ))
  148.         done
  149. }
  150. printf "%s" "Pistols:"
  151. getData $pistol
  152. printf "\n%s" "Shotguns:"
  153. getData $shotgun
  154. printf "\n%s" "SMGs:"
  155. getData $submachinegun
  156. printf "\n%s" "Automatic Rifles:"
  157. getData $rifle
  158. printf "\n%s" "LMGs:"
  159. getData $machinegun
  160. printf "\n%s" "Sniper Rifles:"
  161. getData $sniperrifle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement