float visible(entity targ); void NewGoalCheck(); void FindNewGoal() { local entity NewGoal; NewGoal = findradius(self.origin, 4000); while(NewGoal) { if(NewGoal == self) NewGoal = NewGoal.chain; if(NewGoal == world) NewGoal = NewGoal.chain; if(NewGoal.classname != "player" && NewGoal.classname != "bot") NewGoal = NewGoal.chain; if(NewGoal.health < 1) NewGoal = NewGoal.chain; if(NewGoal.deadflag > 0) NewGoal = NewGoal.chain; if(random() > 0.5) { self.goalentity = NewGoal; return; } else NewGoal = NewGoal.chain; } self.goalentity = world; NewGoalCheck(); // return; } void NewGoalCheck() { if(self.goalentity == world) FindNewGoal(); } // checks and sets player's direction void BotSetDirection(entity CheckedEntity) { local float DirectionCheck; DirectionCheck = 1; local float PDir; PDir = CheckedEntity.angles_y; local float DirInc; DirInc = 90; PDir = PDir + 270; while(DirectionCheck) { /* if(DirInc == 0) { if(PDir >= 348.75 || PDir <= 11.25) { DirInc = DirInc - 180; CheckedEntity.angles_y = DirInc; CheckedEntity.fixangle = true; DirectionCheck = 0; return; } } */ if(PDir >= (DirInc - 11.25) && PDir <= (DirInc + 11.25)) { DirInc = DirInc - 270; CheckedEntity.angles_y = DirInc; CheckedEntity.fixangle = true; DirectionCheck = 0; return; } // The below code is a redundancy and a fail-safe // If it is executed, it means that the function has failed, which may result in a player's compass and orientation becoming corrupt // To prevent this, this code will arbitrarily set the player's angle to 0 or north if(DirInc == 427.5) { CheckedEntity.angles_y = 0; CheckedEntity.fixangle = true; DirectionCheck = 0; return; } DirInc = DirInc + 22.5; } // end of function } void healthcheck() { if(self.goalentity.classname == "item_health") { movetogoal(40); return; } entity PossHealth; PossHealth = findradius(self.origin, 4000); while(PossHealth) { if(PossHealth.classname == "item_health" && visible(PossHealth)) { self.goalentity = PossHealth; movetogoal(40); return; } if(PossHealth.classname == "item_health") { if(random() > 0.5) { self.goalentity = PossHealth; movetogoal(40); return; } } PossHealth = PossHealth.chain; } }