/*
commonskilled.nut
author: Lee Pumphret
https://www.leeland.info
Skeleton script to track number of common zombies killed fairly accurately. De-spawns may get counted
@ https://www.leeland.info/trcoofcozoki.html
*/
ZombiesSpawned <- {}
ZombiesSpawnedCurrent <- 0
ZombiesSpawnedCount <- 0
ZombiesKilledCount <- 0
ThinkCount <- 0
function Think(){
local OurLastSeen = null
local z
local health = 0
ZombiesCurrent <- 0
ToDelete <- []
try{
while (z = Entities.FindByClassname(OurLastSeen,"infected")){
health = z.GetHealth();
if (health > 0 ){
if (ZombiesSpawned.rawin(z) == false){
//printl("new common "+z);
ZombiesSpawnedCount++; // only record if new
}
ZombiesCurrent++
ZombiesSpawned[z] <- health // save it
}
OurLastSeen = z
}
}catch(e){ // this exception handling probably not needed, but why not
printl("Error:"+e);
OurLastSeen = null
}
foreach (k,v in ZombiesSpawned){
try { // this trapping is...
v = k.GetHealth()
}catch(e){
v = -666
}
if (v <= 0){
//printl("dead or invalid: "+v)
ToDelete.push(k)
}else{
// it's alive, do what you want here
}
}
// cleanup
while (ToDelete.len() > 0){
delete ZombiesSpawned[ToDelete.pop()]
ZombiesKilledCount++
ZombiesCurrent--
}
ZombiesSpawnedCurrent = ZombiesCurrent
if (ThinkCount++ % 10 == 0){
// print stats once a second
print_stats()
}
}
function print_stats(){
printl("stats > Z_LIFETIME:"+ZombiesSpawnedCount+" CURRENT:"+ZombiesSpawnedCurrent+" KILLED:"+ZombiesKilledCount+" ERROR:"+(ZombiesSpawnedCount - (ZombiesCurrent+ZombiesKilledCount)));
}