Nice find! I will fix that right now. I think I will leave the "behaviorinrange" the same, and just do a check to see if the player Y position is greater than the height to the treehouse floor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
}elseif (count_behaviourinrange("object","cover",80)==1){
	$y=gety("unit",1);
	if ($y>=100){
		if($sleeping_duration==9) {
			$damage=10;
			consume 10,0,0,0;
		}elseif($sleeping_duration==6) {
			$damage=7;
			consume 7,0,0,0;
		}elseif($sleeping_duration==3) {
			$damage=4;
			consume 4,0,0,0;
		}
		msg "Cover detected!",3,20000;
		msg "+$damage Bonus blood rejuvenation!",2,20000;
	}else{
		if($sleeping_duration==9) {
			$damage=10;
			consume 10,0,0,0;
		}elseif($sleeping_duration==6) {
			$damage=7;
			consume 7,0,0,0;
		}elseif($sleeping_duration==3) {
			$damage=4;
			consume 4,0,0,0;
		}
		msg "Cover detected!",3,20000;
		msg "+$damage Bonus blood rejuvenation!",2,20000;
	}
}
Your fix will fix the treehouse only yes...but break the other ground covers detection range...meaning now when you sleep way outside the other ground shelters, you will be "detected" well outside the shelter perimeter at 160 meters. That is not intended.