![]() |
||
|
Object not on the map - Printable Version +- Little Fighter Empire - Forums (https://lf-empire.de/forum) +-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7) +--- Forum: AI Scripting (https://lf-empire.de/forum/forumdisplay.php?fid=56) +--- Thread: Object not on the map (/showthread.php?tid=9206) |
||
Object not on the map - pikol - 05-12-2014 I want my character to make an attack (e.g. ball) only if it's not on the map already or if it's far enough for him. Code: for (int i = 0; i < 100; ++i)
{
//darkness
if (loadTarget(i)==-1 && target.id==448 && target.team==self.team && abs(self.x-target.x)<500)
{
DdA();
}
}RE: Object not on the map - A-Man - 05-13-2014 Dude, that's not how you're supposed to do it XD. Whenever you write such a code try to run it in your head. For instance: You're looping on the first 100 objects (although you're supposed to loop on 399 since THAT is the maximum number of the objects you can have on the screen) and assigning the index to the variable i. Every loop, you check if that target doesn't exist AND if its ID equals 448. That's like checking if you don't have a cake, and if you don't, you check what color it is; it doesn't exist in the first place!!? So how can you check a property or something that doesn't exist? The right thing you should do is:
RE: Object not on the map - pikol - 05-13-2014 Ok, I'll keep that in mind. But it doesn't work either. He just keep spamming with this attack, bacause "theballexists" is always false, just like he would ignore the "if" in the loop. Ok, it should be loadTarget(i)==3 and it's alright then. Thanks a lot
RE: Object not on the map - A-Man - 05-13-2014 (05-13-2014, 03:33 PM)pikol Wrote: Ok, I'll keep that in mind.OOps. Yes my bad. The range conditioning check must've been in the if the ball exist condition as well:
|