Posts: 233
Threads: 13
Joined: Oct 2008
Both links are down.
To live a life of power, you must have faith that what you believe is right, even if others tell you you're wrong.
The first thing you must do to live a life of power is to find courage. You must reach beyond the boundaries of time itself.
And to do that, all you need is the will to take that first step...
Ask not what others can do for you, but what you can do for others.
Posts: 2,340
Threads: 78
Joined: Mar 2008
Posts: 1,419
Threads: 89
Joined: Jul 2008
05-02-2013, 11:03 AM
(This post was last modified: 05-02-2013, 11:06 AM by Memento.)
I made quite the noob script probably, lol. I'm also expected a real noob mistake.. I don't really understand it all just yet.
I'm getting the following error(s):
ai\692.as: INFORMATION : Building.
ai\692.as: <12, 2>: ERROR : Unexpected token 'else'
ai\692.as: ERROR : Unable to build module
int ego(){
//close range:
if (target.y == 0 && abs(target.z-self.z) < 9 && (self.x-target.x)*((self.facing?1:0)*2-1) < 0 && (self.x-target.x)*((self.facing?1:0)*2-1) < 80 && target.state == 16 && self.mp >= 50){
if (abs(self.x-target.x) > 0 && (self.state == 2 || self.state == 0))
if (self.x-target.x > 0){left();} //turn back
else {right();}
}
else if (self.x-target.x < 0){left();} //
else {right();}
return 1;}
//basic move conditions:
else if (target.y == 0 && abs(target.z-self.z) < 9 && (self.x-target.x)*((self.facing?1:0)*2-1) > 0 && (self.x-target.x)*((self.facing?1:0)*2-1) < 80){
if (target.state == 16 && self.mp >= 50 && abs(self.x-target.x) > 50){DuA();} //D^A against DoP
else if (target.state == 16 && self.mp >= 50){ //adjust x for D^A
if (self.x-target.x < 0){left();}
else {right();}
return 1;
}
else if (target.state == 8 || target.state == 16){a();} //A against DoP and broken defense
else if target.state == 16) {dda();} //DvA against DoP
else if (target.state == 3 && self.mp >= 50){D();} //D against attacks with enough mp
if (self.state == 7 && self.bdefend >= 20){DuA();} //D^A from critical defense
//long/mid range:
if (target.y == 0 && abs(target.z-self.z) < 7 && (self.x-target.x)*((self.facing?1:0)*2-1) && if (((self.x-target.x) => 120) && ((self.x-target.x) =< 220)) && self.mp >= 110){
if (abs(self.x-target.x) > 0 && (self.state == 1 || self.state == 0))
if (self.x-target.x > 0){dda();} //DvA
else {left();} //turn back
else {right();} //turn back
}
if (target.y == 0 && abs(target.z-self.z) < 7 && (self.x-target.x)*((self.facing?1:0)*2-1) && if (((self.x-target.x) => 300) && ((self.x-target.x) =< 500)) && self.mp >= 175){
if (abs(self.x-target.x) > 0 && (self.state == 1 || self.state == 0)){
if (self.x-target.x > 0){DrJ();} //D>J
else if (self.x-target.x < 0){DlJ();} //D<J
else {right();} //turn back
else {left();} //turn back
}
else if (abs(100*(self.z-target.z)/((self.x-target.x)*((self.facing?1:0)*2-1))) <= 15 && abs(self.x-target.x) < 300 && abs(self.x-target.x) > 150){
if (self.x-target.x > 0){DlA();} //D<A
else if (self.x-target.x < 0){DrA();} //D>A
}
//instant attacks
if (self.state == 5){A();} //dash attack
if ((self.frame == 286 && target.state == 11 || target.state == 16) {A();} //long combination
if ((self.frame == 353 && target.state == 11 || target.state == 16) {J();} //meteor combination
else if ((self.frame == 353 && target.state == 11 || target.state == 16) {DrJ();} //kamehameha combination
if (self.frame == 244) && (abs(self.z-target.z) => 15){DuJ();} //IT kamehameha
return 0;
I also don't really understand when I should use certain characters such as {. And yes, I used Clide as a base for his AI...
Thanks given by:
Posts: 2,340
Threads: 78
Joined: Mar 2008
Well just like normal mathematics you need to open and close your braces properly.
Your second if statement is missing the {do stuff}.
if (abs(self.x-target.x) > 0 && (self.state == 2 || self.state == 0)) { }
And I think you are missing/closing other {/} braces too.
First return 1;} closes the main ego() function (this should happen at the end).
Second if after long/mid again is missing braces. if (abs(self.x-target.x) > 0 && (self.state == 1 || self.state == 0)) { }
Maybe use Someoneelse's data changer and choose new AI file, it will make braces that belong together bold when your cursor is near them.
Posts: 746
Threads: 55
Joined: Apr 2008
(05-02-2013, 11:03 AM)Neocrypt Wrote: ai\692.as: INFORMATION : Building.
ai\692.as: <12, 2>: ERROR : Unexpected token 'else'
ai\692.as: ERROR : Unable to build module <x,y> means that there is a mistake on line x, in this case 12.
The mistake is that everything beyond "//basic move conditions:" isn't within a function, and once it encounters something that should be inside a function (such as an "else"-statement), it throws an error.
Also the "else"-statement has to follow an "if"-statement, but in this case it is following the function declaration ("int ego(){").
(05-02-2013, 11:03 AM)Neocrypt Wrote: I also don't really understand when I should use certain characters such as {. And yes, I used Clide as a base for his AI... {'s and }'s are used to indicate a block of code.
An example of this is in an "if"-statement. If you want to execute multiple lines of code you'll have to group it within the two brackets like this:
CPP-Code:
if(this_is_true){
do_one_thing();
do_another_thing();
}
|
If we were to leave out the brackets like this:
CPP-Code:
if(this_is_true)
do_one_thing();
do_another_thing();
|
it would only be the next statement ("do_one_thing();"), and the statements after that would be executed no matter the the result of the "if"-statement.
Also note that the indentation of the lines doesn't matter, so all the following pieces of code mean exactly the same thing
CPP-Code:
//code 1
if(this_is_true)
do_one_thing();
do_another_thing();
//code 2
if(this_is_true){
do_one_thing();
}
do_another_thing();
//code 3
if(this_is_true){do_one_thing();}
do_another_thing();
|
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Posts: 1,556
Threads: 77
Joined: May 2011
05-07-2013, 02:54 PM
(This post was last modified: 05-07-2013, 02:55 PM by A-Man.)
(05-07-2013, 12:08 PM)Neocrypt Wrote: I am starting to understand the scripting a little. I now want to set a dodging move for attacks that cause >= 70 injury (AI will only do it when it has >= 400 MP so it won't be a cheap move). Is there a way to do this? An alternative would be using target.state == 3, perhaps with a target.mp condition.. but it would not have the same effect I don't think a class parent that checks the target's itr injury value is implemented. I don't want to be nosy, but I wouldn't advice being that specific with your AI's. Imagine a scenario where your opponent is about to hit you with a super deadly combo with 10 hits. Each hit causes 30 damage (which means your character won't do the dodging move D: ), and thus 300 of your hp. Checking all that would just be a waste of time.
(05-07-2013, 12:08 PM)Neocrypt Wrote: Another problem. I want to make my character use DJA+A+A+A.... when the opponent is at a distance. It's a move to charge MP. However, he DOES go to the charging stance (caused by DJA), but he only starts tapping A when I walk.
Code: else if (self.mp <= 400 && (abs(self.z-target.z) > 40) || (abs(self.x-target.x) < 1000 && abs(self.x-target.x) > 320)) {
if (self.x-target.x > 0){DJA();} //DJA
else if (self.x-target.x < 0){DJA();} //DJA
return 1;
}
//instant attacks
if (self.state == 5){A();} //dash attack
if ((self.frame == 286 && target.state == 11) || (target.state == 16)) {A();} //long combination
if ((self.frame == 353 && (target.state == 11) || (target.state == 16))) {DuJ();} //meteor combination
if ((self.frame == 353 && (target.state == 16) && self.mp >= 220)) {DrJ();} //kamehameha combination
if (self.frame == 365 && target.state == 12){A();} //kick up
if (self.frame == 244 && (self.mp >= 85) && (self.x-target.x)*((self.facing?1:0)*2-1) > 50) {DuJ();} //IT Kamehameha
if (self.frame == 166 || self.frame == 20 || self.frame == 172 || self.frame == 22 && (self.mp < 500) && (abs(self.x-target.x) < 1000 && abs(self.x-target.x) > 250)|| self.frame == 166 || self.frame == 20 || self.frame == 172 || self.frame == 22 && (abs(self.z-target.z) > 30)) {A();} //DJA+A+A..
return 0;
}
Can you please show use the code above the "else if" statement? Namely the original first "if" statement.
(05-07-2013, 12:08 PM)Neocrypt Wrote: And is there a way to make him avoid picking objects? Well, if the script you are working isn't an extension for a main AI - a brand new AI where you even control walking and stuff-, it won't pick items by default.
Thanks given by:
Posts: 2,340
Threads: 78
Joined: Mar 2008
(05-07-2013, 02:54 PM)A-MAN Wrote: I don't think a class parent that checks the target's itr injury value is implemented. I don't want to be nosy, but I wouldn't advice being that specific with your AI's. Imagine a scenario where your opponent is about to hit you with a super deadly combo with 10 hits. Each hit causes 30 damage (which means your character won't do the dodging move D: ), and thus 300 of your hp. Checking all that would just be a waste of time. Actually you can - but I agree that this isn't the best approach.
Thanks given by:
Posts: 1,419
Threads: 89
Joined: Jul 2008
(05-07-2013, 03:03 PM)YinYin Wrote: (05-07-2013, 02:54 PM)A-MAN Wrote: I don't think a class parent that checks the target's itr injury value is implemented. I don't want to be nosy, but I wouldn't advice being that specific with your AI's. Imagine a scenario where your opponent is about to hit you with a super deadly combo with 10 hits. Each hit causes 30 damage (which means your character won't do the dodging move D: ), and thus 300 of your hp. Checking all that would just be a waste of time. Actually you can - but I agree that this isn't the best approach.
I'm making this pretty confusing: moved the post to a new topic just before you guys replied.
I will add the first part of the code in that new topic..
Also, the character should only dodge sometimes, not always.. that is the main reason for choosing a higher injury. If there are other ways, I'm fine with that too.
Thanks given by:
Posts: 1,556
Threads: 77
Joined: May 2011
Also one more thing, that is here:
Code: (self.mp <= 400 && (abs(self.z-target.z) > 40) || (abs(self.x-target.x) < 1000 && abs(self.x-target.x) > 320))
I would recommend you use parentheses when using "||" and "&&" at the same time. Cuz without them, you can make sure the computer will interpret condition the way you want.
P.S: a mod should please merge these to the new thread.
Thanks given by:
Posts: 49
Threads: 11
Joined: Oct 2010
wonder why my exe file crashes when com character begins to move!
dctbullshit changed his name into Kuriza!
Thanks given by:
|