Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to: script Artificial Intelligence
#41
I am getting the following error:

ai\690.as(4, 36): ERROR : / 'target' is not a member of 'const int&'

I probably has something to do with brackets that are placed wrong or something.. however, I can't get it fixed. When I add brackets, I get other errors (expected expression value). Who knows what this error means and how to fix it?

int ego(){
//close range:
if (target.y == 0 && abs(target.z-self.z) < 9) {
if (self.x-target.x > 0 && (self.x.target.x) < 50 && self.mp >= 180){DuA();} //D^A

EDIT: I may have figured it out, not sure... could the error mean that I have to make a true/false choice, and therefor I am using the wrong code?
Original character edits
Goku2021
LF2 Timelapse (open source mod)

Reply
Thanks given by:
#42
I'm not quite up-to-date with the latest AI-stuff but this one caught my attention:

self.x.target.x

self.x should be a scalar value. That's at least what the error-message implies: it should be a "const"(ant) "int"(eger). Looking for a child-object "target" seems a little off in such case :p
Guess you mean something like self.x-target.x?
Silverthorn / Blue Phoenix
~ Breaking LFE since 2008 ~

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

» Gallery | » Sprites | » DeviantArt
Reply
Thanks given by:
#43
(06-26-2013, 08:59 PM)Blue Phoenix Wrote:  I'm not quite up-to-date with the latest AI-stuff but this one caught my attention:

self.x.target.x

self.x should be a scalar value. That's at least what the error-message implies: it should be a "const"(ant) "int"(eger). Looking for a child-object "target" seems a little off in such case :p
Guess you mean something like self.x-target.x?

You may be right. It seems like the error originated because I used 'self.x.target.x' instead of 'self.x-target.x'.
Original character edits
Goku2021
LF2 Timelapse (open source mod)

Reply
Thanks given by:
#44
Code:
int ego(){

int xdistance = (self.x-target.x)*(2*(self.facing?1:0)-1);

int hitable = (target.y == 0 && target.state != 6 || target.state != 14);

How can i create more variables? When there is only one (int xdistance) everythings working, after add another one (int hitable), I'm getting this error:
Can't implicitly convert from 'bool' to 'int'.

Reply
Thanks given by:
#45
your hitable is a boolean and not an integer

bool hitable = (condition);
Reply
Thanks given by: The Hari
#46
Thanks for the tutorial i kinda need it for a reason
Quit Playing LF2 But Still Love LF-EMPIRE....          
Reply
Thanks given by:
#47
How do you use arest and vrest? No matter what I do my arest is always = 0. I I want my character to wait until make the same action again.
Reply
Thanks given by:
#48
arest is a value on the attacking character, so you'll have to look into self.arest.
It runs back down to 0 pretty quickly and usually doesn't interfere with being able to hit again (Template has a rather high arest on the super punch).

vrest is a value on the attacked character(s), so that'll be found on target.vrest.
This affects game play more often due to the attacker being stuck in hit lag while new opponents can keep walking into his itr (see Davis' D^A against a big crowd of Knights for example).

Maybe provide us with the respective itr and AI that only returns 0?
Reply
Thanks given by:
#49
YinYin, I tried to make a small Davis AI, to shoot energy balls when he is under 250 HP(Newbie AI I know), but, If I use DlA he randomly shoots left and gets himself kicked in the back, but if I try to make another one with DrA it worked the first I tested it, it is not working right now, here's what I coded.

Code:
int ego(){
if (self.hp < 250){
  DrA();
}
return 0;
}

int ego(){
if (self.hp < 250){
  DlA();
}
return 0;
}

Is something actually wrong with the AI, or did I do something wrong in it?
Oh Also, if I delete one of the code lines, It works again, but after I redo it, it again sends the same error, that 2 functions have the same name
I think I kinda figured it out, so, I will test if that works.
Nope, didn't work.
Spoilered Spoilers (Click to View)

You're just dying if you're living and thinking about a betrayal, revive yourself.
Think about that one person that has trusted you forever, not the thousand people that have betrayed you.
Reply
Thanks given by:
#50
You can only have unique functions, not multiple ones with the same name.

So every condition the character is supposed to act upon needs to be inside the ego function.
Reply
Thanks given by: AmadisLFE




Users browsing this thread: 1 Guest(s)