Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple things.
#6
Code:
int get_closest_enemy(){
int lowest = 99999;
int final;
    for(i = 0; i <= 399; i++)
{
    if (loadTarget(i)!=-1 && xdistance < lowest)
    {
        lowest = xdistance;
        final = i;
        
    }


}
return final;
}

loadTarget() itself returns the object type of the loaded object; -1 if it doesn't exist.
(change !=-1 into ==0 and also add a team check to only get enemies - this one will actually get the closest object right now)
Reply
Thanks given by: Gad


Messages In This Thread
Simple things. - by Gad - 08-13-2013, 11:17 PM
RE: Simple things. - by YinYin - 08-14-2013, 06:36 AM
RE: Simple things. - by Gad - 08-14-2013, 08:02 PM
RE: Simple things. - by YinYin - 08-14-2013, 08:19 PM
RE: Simple things. - by Gad - 08-14-2013, 08:37 PM
RE: Simple things. - by YinYin - 08-15-2013, 04:38 AM
RE: Simple things. - by Gad - 08-15-2013, 09:49 AM
RE: Simple things. - by YinYin - 08-15-2013, 04:10 PM
RE: Simple things. - by Silverthorn - 08-15-2013, 01:31 PM
RE: Simple things. - by Gad - 08-16-2013, 12:58 PM
RE: Simple things. - by Azriel - 08-16-2013, 01:11 PM
RE: Simple things. - by Silverthorn - 08-16-2013, 01:22 PM
RE: Simple things. - by Gad - 08-16-2013, 02:37 PM



Users browsing this thread: 1 Guest(s)