function ENT:CalculateOdds(Enemy) if(!Enemy) then return false end local group = ents.FindInSphere(Enemy:GetPos(),4096) -- suitable distance local myHP = self:Health() local hiveHP = 0 local odds = 0.0 for k,v in pairs(group) do if(v && v:Alive() && v:IsNPC() || v:IsPlayer()) then local raytrace={} raytrace.start=self.Entity:GetPos() + self.Entity:GetForward()*90 raytrace.endpos=v:GetPos() + v:GetForward()*-64 raytrace.filter=self.Entity local rt = util.TraceLine(raytrace) if(rt.Hit && rt.Entity) then -- got visual if(rt.Entity:Alive()) then hiveHP += v:Health() end end end end if(myHP > 0 && hiveHP > 0) then odds = (myHP*2) / hiveHP -- omnipotence factor multiplies the current health by 2 end if(odds > 0.0) then local newOdds = string.Explode(".",odds) newOdds[0] = math.ceil(newOdds[0]) newOdds[1] = math.ceil(newOdds[1]) if(newOdds[0] > newOdds[1]) then return true -- do nothing, we can win this elseif(newOdds[0] < newOdds[1]) then local birds = ents.FindByClass("npc_leakheli") local success = 0 for k,v in pairs(birds) do if(v:IsValid() && (v:Distance(self:GetPos()) < 8000)) then v.ForcedTarget = self.Target success += 1 else success -= 1 end end if(success > 0) then return true -- nothing, backup is on it's way elseif(success == 0 or success < 0) then ENT.HotSpot = Enemy:GetPos() self.Target = self.CycleTarget return false end end elseif(newOdds[0] == newOdds[1]) then return true endend