AI Update from Nave after receiving feedback from SomeoneElse. Minor update, but important if you like to have more than 1 STM running around in the game.
Copy the following code below and replace the text in 930.as using a text editor such as Notepad++.
Quote:<Nave_> the one thing was a memory issiue
<Nave_> where I accidently copied the instances of self and target every frame instead of using a pointer
<Nave_> and the other one was, that the Phase was globaly, so every stm in the same game would always be in the same phase
<Nave_> so now it works properly
Copy the following code below and replace the text in 930.as using a text editor such as Notepad++.
Code:
array<int> PHASE(400,0);
int ego(){
int k = target.num;
int dist = 400;
for (int i = 0; i < 400; ++i){
if (loadTarget(i) >= 0 && target.team != self.team && xyz_Distance() < dist && movesTorwards(target, self) && target.x_velocity != 0 && sameZ()){
k = i;
}
}
loadTarget(k);
if(PHASE[self.num] == 0 && self.mp < 100 && !(self.frame >= 240 && self.frame <= 278)){
PHASE[self.num] = 1;
}
if(PHASE[self.num] == 1 && (self.mp > 500-self.hp || self.mp > 200)){
PHASE[self.num] = 0;
}
if(PHASE[self.num] == 0){
if(target.y > self.y+10 && distance() < 60 && facesTorwards(self, target) && target.type == 0){
A();
}
if(self.mp > 150 && distance() < 40 && target.type == 0){
if(abs(target.z-self.z) > 50){
DuJ();
if(target.z < self.z){
up();
}
else{
down();
}
return 1;
}
else if(abs(target.z-self.z) < 20){
DdA();
}
}
if(movesTorwards(target, self) && abs(target.x_velocity) > 6 && distance() < 140 && sameZ()) {
if(self.mp > self.hp/3){
dashTo();
}
else if(self.y == 0){
if(target.x < self.x){
right();
}
if(target.x > self.x){
left();
}
J();
}
}
if(self.mp > 300 && distance() < 200 && sameZ() && self.frame == 312 && target.type == 0){
if(distance() > 100){
hadouken();
}
else{
J();
}
}
if(self.mp > 50 && distance() >= 150 && distance() < 1000 && sameZ() && (!facesTorwards(target, self) || (distance() > 500 && self.mp > 350)) && target.type == 0){
if(self.frame >= 240 && self.frame <= 278){
if(!self.facing){
left();
return 1;
}
else{
right();
return 1;
}
}
else if(self.mp > 250){
hadouken();
}
}
return 0;
}
else if(PHASE[self.num] == 1){
if(self.y == 0 && self.mp > 50 && movesTorwards(target, self) && abs(target.x_velocity) > 0 && distance() < 100 && sameZ()) {
evade();
}
if(target.type == 0 && self.state == 2 && movesTorwards(target, self) && abs(target.x_velocity) > 0 && distance() < 200 && sameZ()) {
J();
}
if(target.type == 0 && self.y > 0 && movesTorwards(self, target) && distance() < 200 && sameZ()) {
A();
}
if(target.x < self.x){
if(self.x + 200 > (mode==1?stage_bound:bg_width) || distance() > 500){
left(1, 0);
}
else{
right();
}
}
if(target.x > self.x){
if(self.x - 200 < 0 || distance() > 500){
right(1, 0);
}
else{
left();
}
}
if(target.z > bg_zwidth1+(bg_zwidth2-bg_zwidth1)/4*3){
up();
}
else if(target.z < bg_zwidth1+(bg_zwidth2-bg_zwidth1)/4){
down();
}
else {
if(target.z > self.z && abs(target.z-self.z) < 40){
up();
}
if(target.z < self.z && abs(target.z-self.z) < 40){
down();
}
}
return 1;
}
return 0;
}
void evade(){
if(self.x < bg_width/4){
DrJ();
}
else if(self.x > bg_width/4*3){
DlJ();
}
else {
dashAway();
}
}
bool sameZ(){
return abs(target.z-self.z) <= 12;
}
int distance(){
return abs(target.x-self.x);
}
int xyz_Distance(){
return abs(target.x-self.x) + abs(target.y-self.y) + abs(target.z-self.z);
}
void hadouken(){
if (target.x > self.x){
DrA();
}
else {
DlA();
}
}
void dashTo(){
if (target.x > self.x){
DrJ();
}
else {
DlJ();
}
}
void dashAway(){
if (target.x < self.x){
DrJ();
}
else {
DlJ();
}
}
bool movesTorwards(const Info @o1, const Info @o2){
return ((o1.x_velocity > 0 && o1.x-o2.x < 0) || (o1.x_velocity < 0 && o1.x - o2.x > 0));
}
bool facesTorwards(const Info @o1, const Info @o2){
return (o2.x > o1.x && !o1.facing) || (o2.x < o1.x && o1.facing);
}
![[Image: uMSShyX.png]](http://i.imgur.com/uMSShyX.png)
~Spy_The_Man1993~
Steiner v3.00 (outdated), Challenge Stage v1.51
Luigi's Easier Data-Editor, A-Man's Sprite Mirrorer
Working on the LF2 Rebalance mod.
Avatar styled by: prince_freeza