Simple things. - 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: Simple things. (/showthread.php?tid=8877) Pages:
1
2
|
|
Simple things. - Gad - 08-13-2013 Ok. I may be retarded. Still I have some questions. I hope somebody could help me. I'm trying to write an AI (very simple for a beginning). I've red a book about C++ programming, so this isn't something hard to understand, but I think I'm in lack of some informations. I've been studying other AIs, and I don't get why my isn't working. THIS WORKS: (Click to View) After adding absolute z distance it doesn't - expected expression value (Click to View) RE: Simple things. - YinYin - 08-14-2013 You are missing brackets on DrA() and DlA() (08-13-2013, 11:17 PM)Gad Wrote: expected expression valueSuch an error comes with a line and symbol number so you know where exactly you have to look. RE: Simple things. - Gad - 08-14-2013 Well. I think I've already pointed out which parameter is a problem. Nevermind this. Anyway I'm really confused, with the usage of functions. Let's say I want to script something like this: Code: int xdistance = (self.x-target.x)*(2*(self.facing?1:0)-1); I'm not trying to ask you to write whole AI for me. RE: Simple things. - YinYin - 08-14-2013
RE: Simple things. - Gad - 08-14-2013 but wait. get_closest_enemy will work? is this function built in? thought i need to write it over with some other keywords ah wait, just red the comment Sooo, I need to use "for" loop? Code: int lowest = 99999; I'd add another condition. How do I check if object is existing? Would this work? RE: Simple things. - YinYin - 08-15-2013 Code: int get_closest_enemy(){ 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) RE: Simple things. - Gad - 08-15-2013 OK. So how do I get the team and state. etc now Code: (self.team != target.team && target.type == 0 && target.state !=(12 || 18)) And ofcourse the script is red by the program every frame? and btw, can't i use abs(self.x - target.x) to get distance? seems ok for me, I'm checking the facing anyway EDIT: Hmmm, the get_closest function seems to be jamming. It doesn't get the target properly, it usually takes one and doesn't change it. The code looks ok for me, any ideas? Edit2: Just wondering. Is it possible to connect to someone who didn't install AI dll, while I do have it? If possible how AI will react? RE: Simple things. - Silverthorn - 08-15-2013 (08-15-2013, 09:49 AM)Gad Wrote:Try: Code: (self.team != target.team && target.type == 0 && (target.state != 12 || target.state != 18)) - target must be in different team than you - target must be a character The third condition will always yield true. If the char is in state 12, the second part will make it valid (state != 18), if he is in state 18, the first validates it. Any other state is passed as well. Not quite sure what you're trying to achieve there (08-15-2013, 09:49 AM)Gad Wrote: And ofcourse the script is red by the program every frame?Yup. (08-15-2013, 09:49 AM)Gad Wrote: and btw, can't i use abs(self.x - target.x) to get distance?You might want to add the z-component, too. If you're really picky, y as well. The proper way would be sqrt((self.x - target.x)² + (self.y - target.y)² + (self.z - target.z)²). Distance in 3D-space. But then again, if you just go for the x-component, it shortens down to the abs(self.x - target.x) part. So I guess that's fine, too. (08-15-2013, 09:49 AM)Gad Wrote: Hmmm, the get_closest function seems to be jamming.Just to rule out anything, do you call "get_closest_enemy()" in your AI? Also, have you tried to print out the target-index + its xdistance? (08-15-2013, 09:49 AM)Gad Wrote: Just wondering.The game will most likely throw a synchronization-error at you once the AI behaves differently from normal. RE: Simple things. - YinYin - 08-15-2013 (08-15-2013, 09:49 AM)Gad Wrote: Hmmm, the get_closest function seems to be jamming.How do you know it sticks to one selected target? Are you loading your target before your other stuff? The games basic AI selects it's own target and starts the ego function with it, so that might be the reason your target selection doesn't really do anything at all (or at least look like it). Basically if you don't intend to do something special you don't have to select targets inside the ego function - it's easier to just work with the pre selected one. (08-15-2013, 09:49 AM)Gad Wrote: Just wondering.It is, but whenever two computer characters with different AI are fighting both games will run differently and get a sync error once the checksum (I think it works by checking the object hp only) on both games differs. RE: Simple things. - Gad - 08-16-2013 (08-15-2013, 01:31 PM)Blue Phoenix Wrote: The third condition will always yield true.doesn't Code: target.state !=(12 || 18) Code: target.state !=12 && target.state != 18 I maybe thinking wrong though. (08-15-2013, 01:31 PM)Blue Phoenix Wrote: add the z-component, too.Can't check right now. But the topic started with the Z-distance problem, which didn't work, still dunno why. Code looks ok. (08-15-2013, 01:31 PM)Blue Phoenix Wrote: Just to rule out anything, do you call "get_closest_enemy()" in your AI? Also, have you tried to print out the target-index + its xdistance? Cmon, BP. I'm not THAT stupid. I've been programming for months at least. I know how to test the program ;P. I printed the result of getting closest enemies. (08-15-2013, 04:10 PM)YinYin Wrote: How do you know it sticks to one selected target? Are you loading your target before your other stuff?Print(i); (lags as hell xDD) (08-15-2013, 04:10 PM)YinYin Wrote: The games basic AI selects it's own target and starts the ego function with it, so that might be the reason your target selection doesn't really do anything at all (or at least look like it).i tried return 1, the character keeps running forever and doesnt change the target (08-15-2013, 04:10 PM)YinYin Wrote: Basically if you don't intend to do something special you don't have to select targets inside the ego function - it's easier to just work with the pre selected one.It's a script for a shooting unit. I want it to stay as far as possible from the enemy. Ofcourse I'm not going to use simple run-left-right script, but I need to start with something. |