UltronoArena TV https://ultronoarena.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

107 lines
2.5 KiB

#!/usr/bin/mawk
# awk_extract summarizes a demo from the game Ultrono Arena
# usage: $ strings /path/to/demo | awk -f /path/to/awk_extract
# set map
{ if (NR==1)
if (!m) map=$1
else if ($1==m) map=$1
else exit
}
# remove back ticks
{ gsub(/\047/,"") }
# between start and finish flags, increment point values
# add to player array, update point streak
/Match has begun/ {sf++}
/take it/ && (sf) && (!ff) { pv["1",$1]++; pa[$1]; streak($1,1) }
/rocket/ && (sf) && (!ff) { pv["2",$1]++; pa[$1]; streak($1) }
/railed/ && (sf) && (!ff) { pv["3",$1]++; pa[$1]; streak($1) }
/light/ && (sf) && (!ff) { pv["4",$1]++; pa[$1]; streak($1) }
/telefragged/ && (sf) && (!ff) { pv["5",$1]++; pa[$1]; streak($1) }
# accept early gg, add to pa
(sf) && (!ff) && $2=="gg" { sub(":",""); pa[$1]; ff++; gg++ }
# for full matches set finish flag, player array, scorelines
(sf) && /Timelimit hit|Match has ended/ {ff++}
(ff) && (!gg) && ( $3=="10:00" || $3=="02:00" ) {
pa[$2]
sl["0",$2]=$1
sl["1",$2]=$2
sl["2",$2]=$3 }
END {
#for every player
for (i in pa) {
# for every point value
for (j=0;j<6;j++) {
# zero empties
if (!pv[j,i]) pv[j,i]=0
# total points
if (j>0) t[i]+=pv[j,i]
}
for (j=0;j<6;j++)
# set point percentages
if (pv[j,i]==0) pp[j,i]=0
else pp[j,i]=100*(pv[j,i]/t[i])
# create scoreline if early gg
if (gg) {
sl["0",i]=t[i]-(pv[1,i]*2)
sl["1",i]=i
sl["2",i]="xx:xx" }
}
# print
printf "%s\t","map:"
printf "%s\n",map
# column headers
printf "%-*s",8,"score"
printf "%-*s",16,"name"
printf "%-*s",10,"time"
printf "%-*s",9,"streak"
printf "%-*s",11,"own goals"
printf "%-*s",10,"rocket"
printf "%-*s",7,"rail"
printf "%-*s",10,"lightning"
printf "%-*s\n",7,"telefrag"
# for every player
for (i in pa) {
# give scoreline
for (j=0;j<3;j++) {
# normalize name lengths
if (j==1 && length(i)<8)
printf "%s\t\t",sl[j,i]
else
printf "%s\t",sl[j,i]
}
printf "%2s",""
# give point values, point percentages
for (j=0;j<6;j++) {
printf "%-3s",pv[j,i]
printf "%-s","%"
printf "%-3.0f",pp[j,i]
printf "%-3s",""
}
printf "\n"
}
printf "\n"
}
# consecutive scoring
function streak(p,o) {
# if own goal and most recent scorer
# save max in pv array and reset
if (o) {
if (p==mrs) {
(s[p]>pv["0",p]) && pv["0",p]=s[p]
s[p]=0; mrs=""
}
# else if most recent scorer increment and save
} else if (p==mrs) {
s[p]++
(s[p]>pv["0",p]) && pv["0",p]=s[p]
# else new streak and most recent scorer
} else { s[p]=0; mrs=p }
}