Exeryte2008-08-30 01:54:41
Anyone have a kill counter for CMUD?
Rika2008-08-30 02:01:11
Unknown2008-08-30 12:36:10
The one I built for (the now defunct) Treant, should work without the rest of the system just fine.
CODE
#MODULE "Treant Kills"
#DELCLASS "//Treant Kills/Interface"
#CLASS "//Treant KIlls/Interface"
#ALIAS kills($full) {
i_info "Things killed by you:"
#IF (%numkeys(@kills) == 0) {
  i_info "Nothing yet. Get to work!"
}
$kills_list = %subregex(%expanddb(@kills, "|"), "(+)=(\\d+)", "(\\1|\\2)")
#IF ($full) {
  #FORALL $kills_list {
    $name = %left(%item(%i, 1), 55)
    $count = %item(%i, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-55s", $name)
  }
} {
  $midpoint = (%numitems($kills_list) / 2)
  #LOOP $midpoint {
    $item = %item($kills_list, %i)
    $name1 = %left(%item($item, 1), 25)
    $count1 = %item($item, 2)
   Â
    $item = %item($kills_list, %i + $midpoint)
    $name2 = %left(%item($item, 1), 25)
    $count2 = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name1)" "%ansi(blue)" "%ansi(white)%format("&-25s", $name2)
  }
  #IF (%mod(%numitems($kills_list), 2) == 1) {
    $item = %item($kills_list, %numitems($kills_list))
    $name = %left(%item($item, 1), 25)
    $count = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name)
  }
}
}
#ALIAS deaths($full) {
i_info "You have been killed by:"
#IF (%numkeys(@deaths) == 0) {
  i_info "Nothing yet! Way to go!"
}
$deaths_list = %subregex(%expanddb(@deaths, "|"), "(+)=(\\d+)", "(\\1|\\2)")
#IF ($full) {
  #FORALL $deaths_list {
    $name = %left(%item(%i, 1), 55)
    $count = %item(%i, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-55s", $name)
  }
} {
  $midpoint = (%numitems($deaths_list) / 2)
  #LOOP $midpoint {
    $item = %item($deaths_list, %i)
    $name1 = %left(%item($item, 1), 25)
    $count1 = %item($item, 2)
   Â
    $item = %item($deaths_list, %i + $midpoint)
    $name2 = %left(%item($item, 1), 25)
    $count2 = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name1)" "%ansi(blue)" "%ansi(white)%format("&-25s", $name2)
  }
  #IF (%mod(%numitems($deaths_list), 2) == 1) {
    $item = %item($deaths_list, %numitems($deaths_list))
    $name = %left(%item($item, 1), 25)
    $count = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name)
  }
}
#CLASS 0
#DELCLASS "//Treant Kills/Internals"
#CLASS "//Treant Kills/Internals"
#EVENT onLoad {
#IF (%numkeys(@kills) == 0 and %numkeys(@deaths) == 0) {
  #VAR "//Treant Persistent/Vars/kills" {}
  #VAR "//Treant Persistent/Vars/deaths" {}
}
}
#CLASS 0
#DELCLASS "//Treant Kills/Tracking"
#CLASS "//Treant Kills/Tracking"
#REGEX {^You have slain (.+?)\\.$} {
#IF (!@flags.arena) {
  #ADDKEY kills {%1} (%db(@kills, %1) + 1)
}
} "" {case}
#REGEX {^You have been slain by (.+?)\\.$} {
#IF (!@flags.arena) {
  #ADDKEY deaths {%1} (%db(@deaths, %1) + 1)
}
} "" {case}
#CLASS 0
#MODULE 0
#SAY "** Treant Kills"
#DELCLASS "//Treant Kills/Interface"
#CLASS "//Treant KIlls/Interface"
#ALIAS kills($full) {
i_info "Things killed by you:"
#IF (%numkeys(@kills) == 0) {
  i_info "Nothing yet. Get to work!"
}
$kills_list = %subregex(%expanddb(@kills, "|"), "(+)=(\\d+)", "(\\1|\\2)")
#IF ($full) {
  #FORALL $kills_list {
    $name = %left(%item(%i, 1), 55)
    $count = %item(%i, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-55s", $name)
  }
} {
  $midpoint = (%numitems($kills_list) / 2)
  #LOOP $midpoint {
    $item = %item($kills_list, %i)
    $name1 = %left(%item($item, 1), 25)
    $count1 = %item($item, 2)
   Â
    $item = %item($kills_list, %i + $midpoint)
    $name2 = %left(%item($item, 1), 25)
    $count2 = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name1)" "%ansi(blue)" "%ansi(white)%format("&-25s", $name2)
  }
  #IF (%mod(%numitems($kills_list), 2) == 1) {
    $item = %item($kills_list, %numitems($kills_list))
    $name = %left(%item($item, 1), 25)
    $count = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name)
  }
}
}
#ALIAS deaths($full) {
i_info "You have been killed by:"
#IF (%numkeys(@deaths) == 0) {
  i_info "Nothing yet! Way to go!"
}
$deaths_list = %subregex(%expanddb(@deaths, "|"), "(+)=(\\d+)", "(\\1|\\2)")
#IF ($full) {
  #FORALL $deaths_list {
    $name = %left(%item(%i, 1), 55)
    $count = %item(%i, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-55s", $name)
  }
} {
  $midpoint = (%numitems($deaths_list) / 2)
  #LOOP $midpoint {
    $item = %item($deaths_list, %i)
    $name1 = %left(%item($item, 1), 25)
    $count1 = %item($item, 2)
   Â
    $item = %item($deaths_list, %i + $midpoint)
    $name2 = %left(%item($item, 1), 25)
    $count2 = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name1)" "%ansi(blue)" "%ansi(white)%format("&-25s", $name2)
  }
  #IF (%mod(%numitems($deaths_list), 2) == 1) {
    $item = %item($deaths_list, %numitems($deaths_list))
    $name = %left(%item($item, 1), 25)
    $count = %item($item, 2)
    i_info %ansi(blue)" "%ansi(white)%format("&-25s", $name)
  }
}
#CLASS 0
#DELCLASS "//Treant Kills/Internals"
#CLASS "//Treant Kills/Internals"
#EVENT onLoad {
#IF (%numkeys(@kills) == 0 and %numkeys(@deaths) == 0) {
  #VAR "//Treant Persistent/Vars/kills" {}
  #VAR "//Treant Persistent/Vars/deaths" {}
}
}
#CLASS 0
#DELCLASS "//Treant Kills/Tracking"
#CLASS "//Treant Kills/Tracking"
#REGEX {^You have slain (.+?)\\.$} {
#IF (!@flags.arena) {
  #ADDKEY kills {%1} (%db(@kills, %1) + 1)
}
} "" {case}
#REGEX {^You have been slain by (.+?)\\.$} {
#IF (!@flags.arena) {
  #ADDKEY deaths {%1} (%db(@deaths, %1) + 1)
}
} "" {case}
#CLASS 0
#MODULE 0
#SAY "** Treant Kills"