@name Thermometer
@outputs Temp
@persist FindNum NumEnts Dist Ent:entity TempChange FindNum2 Ent2:entity

interval(50)
   findInSphere(entity():pos(),1000)
   findClipToClass("prop_physics")
   NumEnts = findSortByDistance(entity():pos())
   if (FindNum > NumEnts) {FindNum = 1}
   
   Ent = findResult(FindNum)
   Dist = entity():pos():distance(Ent:pos())
   if (Ent:isOnFire() & Dist <= 500) {
       if (FindNum2 > NumEnts) {FindNum2 = 1}
       Ent2 = findResult(FindNum2)
       if (Ent2:isOnFire() & Ent2:pos():distance(entity():pos()) < Dist) {Ent = Ent2}
       FindNum2 += 1
           if (Dist > 150) {TempChange = (500 - Dist)/10}
       elseif (Dist > 100) {TempChange = (500 - Dist)/5}
       elseif (Dist >  40) {TempChange = (500 - Dist)/3}
       elseif (Dist <  40) {TempChange =  300 - Dist}
   } else {
       FindNum +=1
       TempChange = 0
   }
   
   Temp = 72 + round(TempChange) - (entity():isUnderWater()*20+TempChange)
