Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple things.
#1
-- content removed --
Reply
Thanks given by:
#2
You are missing brackets on DrA() and DlA()
(08-13-2013, 11:17 PM)Gad Wrote:  expected expression value
Such an error comes with a line and symbol number so you know where exactly you have to look.
Reply
Thanks given by:
#3
    C-Code:
//assuming this will be an ego function to have 'normal' acting - otherwise you have to control all actions
int ego(){
int xdistance = (self.x-target.x)*(2*(self.facing?1:0)-1);
if(self.mp < 100)
{
 
//target = get_closest_enemy();
//this one won't work as target isn't defined on it's own in any way
//you need to use the loadTarget(object.num as integer) function:
loadTarget(get_closest_enemy());
 
//your get_closest_enemy() function will need to cycle through all 400 objects, check their distance to self
//and return the object number of the closest one
 
	if(xdistance > 100)
	{
		if(self.x-target.x > 0)
		{
			run_left();
		}
		else
			run_right();
	}
//left(1,0) and right(1,0) will do to make the character run - the script will need to run past this twice of course
 
return 1;
//this will make the games id() function return control to your ego() function unless it's got an item to pick or a downed opponent to run away from etc
 
}
//else act_normally();
return 0;
//this will return control to the games id() function to do as it pleases
}
Reply
Thanks given by: Gad
#4
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
#5
(08-15-2013, 09:49 AM)Gad Wrote:  
Code:
(self.team != target.team && target.type == 0 && target.state !=(12 || 18))
doesn't seem to work for me (at least the team)
Try:
Code:
(self.team != target.team && target.type == 0 && (target.state != 12 || target.state != 18))
I didn't quite follow what you're trying to do but that'd be the proper syntax, which backtranslates to the following:
- 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 :p

(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?
seems ok for me, I'm checking the facing anyway
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.
It doesn't get the target properly, it usually takes one and doesn't change it.
The code looks ok for me, any ideas?
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.
Is it possible to connect to someone who didn't install AI dll, while I do have it?
If possible how AI will react?
The game will most likely throw a synchronization-error at you once the AI behaves differently from normal.
Silverthorn / Blue Phoenix
~ Breaking LFE since 2008 ~

"Freeze, you're under vrest!" - Mark, probably.

» Gallery | » Sprites | » DeviantArt
Reply
Thanks given by:
#6
(08-15-2013, 09:49 AM)Gad Wrote:  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?
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.
Is it possible to connect to someone who didn't install AI dll, while I do have it?
If possible how AI will react?
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.
Reply
Thanks given by:
#7
(target.state != 12 || target.state != 18)
what it checks: my target's state is not 12, OR, my target's state is not 18.

if my target's state is 12, then it is true that my target's state is not 18. therefore my condition is true.
if my target's state is 18, then it is true that my target's state is not 12. therefore my condition is true.
if my target's state is 9001, then it is true that my target's state is not 12. therefore my condition is true.

(target.state != 12 || target.state != 18) is not equivalent to (target.state !=12 && target.state != 18)



Azriel~
Reply
Thanks given by:
#8
(08-16-2013, 12:58 PM)Gad Wrote:  
(08-15-2013, 01:31 PM)Blue Phoenix Wrote:  The third condition will always yield true.
doesn't
Code:
target.state !=(12 || 18)
equals
Code:
target.state !=12 && target.state != 18
?
I maybe thinking wrong though.
Well, can you phrase in words how you want it to be?
In case you're thinking of something along the lines of "target.state may be neither 12 nor 18", the above snippet is correct. Guess you managed to confuse me completely in my last post :p

(08-16-2013, 12:58 PM)Gad Wrote:  
(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.
Heh, I just wanted to be on the safe side :p

Have you tried to print out object-id AND xdistance to see if it changes at all?
Maybe even print out all t0-objects currently in-game and check manually if it picked the right one?


az u so ninja-y
Silverthorn / Blue Phoenix
~ Breaking LFE since 2008 ~

"Freeze, you're under vrest!" - Mark, probably.

» Gallery | » Sprites | » DeviantArt
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)