Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] loadtarget problem
#1
:thumbs up: 
MY GOALS:
Character 1 and Character 2 are on the same team and when they are both on same z axis and close to each other they both execute a move.

MY METHOD:
I am using loadtarget so I can make the ally a target for interaction.

MY PROBLEM:
When they aren't using the attack they aim their other attacks at each other. Particularly D>A and D>J they attempt to use those moves on each other because they are now marked as a target.

Is there a solution to this or an alternative method to execute a "team attack" without them trying to kill each other?

Here's my sh**** code if you want to look at it, idk if that will matter or help (Click to View)

edit: idk why I'm trying to hide it, it's so obvious what I'm trying to do.
Basically I want to make Goku and Vegeta AI's fuse into Vegito during certain conditions, I haven't exactly implemented them in the code above fully because I wanted to see if it works, but as I stated, they try to attack each other sometimes.

edit2: also make it so when you use the move, they will chase towards you and use it. Is that possible? I tried and failed miserably.
Reply
Thanks given by:
#2
Could you give a complete example?
You posted only a snippet of code, and I do not see any problems with it, so my guess is that your problem lies elsewhere.

Also, [code=ai] is a thing, and so are indentations:
    AI-Code:
for (int i = 0; i < 400; ++i)
{
    if (loadTarget(i) == 0 )
    {
        if (target.id==74 && target.team == self.team)
        {
            //2 COMs
            if (i > 8 && target.id==74 && (abs(self.z-target.z) < 5) && abs(self.x-target.x) > 75 && abs(self.x-target.x) < 400 && difficulty==-1)
            {
                DdA();
            }
            //Human + COM
            if (target.id == 74 && target.frame > 356 && target.frame < 369 &&  (abs(self.z-target.z) < 5) && abs(self.x-target.x) > 100 && abs(self.x-target.x) < 475) {
                DdA(); 
            }
        } 
    }
}
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.
Reply
Thanks given by:
#3
Oh true, I set it as C code but idk why it's not there anymore.

Code:
//Vegeta (Buu) int ego(){ if (target.team == self.team) { print ("The character is on my team"); } /* int k = target.num; for (int i = 0; i < 400; ++i) { if (loadTarget(i) == 0 && target.id==74 && target.team==self.team) { k = i; } } */ for (int i = 0; i < 400; ++i) { if (loadTarget(i) == 0 && target.id==74 && target.team == self.team ) { //2 COMs if (i > 8 && target.id==74 && (abs(self.z-target.z) < 5) && abs(self.x-target.x) > 75 && abs(self.x-target.x) < 400 && difficulty==-1) { DdA(); } //Human + COM if (target.id == 74 && target.frame > 356 && target.frame < 369 &&  (abs(self.z-target.z) < 5) && abs(self.x-target.x) > 100 && abs(self.x-target.x) < 475) { //DdA(); } } } if (self.frame > 356 && self.frame < 378) { A(1,0); } //if target not on same plane during ki blasts change direction if (self.frame > 239 && self.frame < 251 && abs(self.z-target.z) > 8) { if ( rand(3) == 1) up(1,0); else if (rand(3) == 2) down(1,0); else left(1,0); } //easy if (difficulty == 2) { //Super Saiyan if ((abs(self.x-target.x) > 250) && self.hp < 100) { DJA(); J(1,0); } //Double Galick Cannon if ((abs(self.z-target.z) < 5) && ((self.x-target.x) < 100) && ((self.x-target.x) > 50) && self.mp > 450) {  DdJ(); }   //Ki Blasts 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 && self.mp > 125){  int randomval = rand(10);  if (self.x-target.x > 0 && randomval > 8){ DlA(); //D<A A(1,0);  }   else if (self.x-target.x < 0 && randomval > 8){  DrA(); //D>A  A(1,0);  }  else if (self.x-target.x > 0 && randomval < 1){ DlA(); //D<A D(1,0);  }      else if (self.x-target.x > 0 && randomval < 1){ DrA(); //D>A D(1,0);  }   } } //normal else if (difficulty == 1) { //Super Saiyan if ((abs(self.x-target.x) > 250) && self.hp < 275) { DJA(); J(1,0); } //Charge Ki else if ((abs(self.x-target.x) > 500) && self.mp < 400 ) { DJA(); A(1,0); } //Double Galick Cannon Caught if (self.frame==121 && self.mp > 400) {   DdJ(); } //Double Galick Cannon if ((abs(self.z-target.z) < 5) && ((self.x-target.x) < 100) && ((self.x-target.x) > 50) && self.mp > 375) {  DdJ(); }   //Tele Counter Attack if ( ((self.x-target.x) < 60) && ((self.x-target.x) > 20) && self.frame==111) {  A(1,0); } //Kick Counter Attack if (((self.x-target.x) < 40) && ((self.x-target.x) > 0) && self.frame==111) {  J(1,0); } //Ki Blasts 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 && self.mp > 125){  int randomval = rand(5);  if (self.x-target.x > 0 && randomval > 3){ DlA(); //D<A A(1,0);  }   else if (self.x-target.x < 0 && randomval > 3){  DrA(); //D>A  A(1,0);  }  else if (self.x-target.x > 0 && randomval < 1){ DlA(); //D<A D(1,0);  }      else if (self.x-target.x > 0 && randomval < 1){ DrA(); //D>A D(1,0);  }   } } //difficult else if (difficulty == 0) { //Super Saiyan if ((abs(self.x-target.x) > 250) && self.mp > 225 && self.hp < 350) { DJA(); J(1,0); } //Charge Ki else if ((abs(self.x-target.x) > 500) && self.mp < 500 ) { DJA(); A(1,0); } //Double Galick Cannon Caught if (self.frame==121 && self.mp > 300) {   DdJ(); } //Double Galick Cannon if ((abs(self.z-target.z) < 5) && ((self.x-target.x) < 100) && ((self.x-target.x) > 50) && self.mp > 250) {  DdJ(); }   //Tele Counter Attack if ( ((self.x-target.x) < 60) && ((self.x-target.x) > 20) && self.frame==111) {  A(1,0); } //Kick Counter Attack if (((self.x-target.x) < 40) && ((self.x-target.x) > 0) && self.frame==111) {  J(1,0); } if (target.state==50) { if (self.x-target.x > 0) { right(1,0); D(1,0); } else if (self.x-target.x < 0) { left(1,0); D(1,0); } } //Ki Blasts 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 && self.mp > 125){  int randomval = rand(5);  if (self.x-target.x > 0 && randomval > 3){ DlA(); //D<A A(1,0);  }   else if (self.x-target.x < 0 && randomval > 3){  DrA(); //D>A  A(1,0);  }  else if (self.x-target.x > 0 && randomval < 1){ DlA(); //D<A D(1,0);  }      else if (self.x-target.x > 0 && randomval < 1){ DrA(); //D>A D(1,0);  }   } } //crazy else if (difficulty == -1) { //MAJIN if ((abs(self.x-target.x) > 250) && self.mp > 400 && self.hp < 250) { DJA(); D(1,0); } //Super Saiyan else if ((abs(self.x-target.x) > 250) && self.mp > 225 && self.hp < 450) { DJA(); J(1,0); } //Charge Ki else if ((abs(self.x-target.x) > 500) && self.mp < 500 ) { DJA(); A(1,0); } //Double Galick Cannon Caught if (self.frame==121 && self.mp > 250) {   DdJ(); } //Double Galick Cannon if ((abs(self.z-target.z) < 5) && ((self.x-target.x) < 100) && ((self.x-target.x) > 50) && self.mp > 200) {  DdJ(); }   //Tele Counter Attack if ( ((self.x-target.x) < 60) && ((self.x-target.x) > 20) && self.frame==111) {  A(1,0); } //Kick Counter Attack if (((self.x-target.x) < 40) && ((self.x-target.x) > 0) && self.frame==111) {  J(1,0); } //Ki Blasts 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 && self.mp > 125){  int randomval = rand(5);  if (self.x-target.x > 0 && randomval > 2){ DlA(); //D<A A(1,0);  }   else if (self.x-target.x < 0 && randomval > 2){  DrA(); //D>A  A(1,0);  }  else if (self.x-target.x > 0 && randomval < 1){ DlA(); //D<A D(1,0);  }      else if (self.x-target.x > 0 && randomval < 1){ DrA(); //D>A D(1,0);  }   } } return 0; }

edit: THANKS YINYIN!
Reply
Thanks given by:
#4
Pretty simple:
remember the original target.

int target = target.num;

//do team move stuff

loadtarget(target);

//do other stuff
Reply
Thanks given by: bashscrazy
#5
(05-22-2015, 12:55 PM)YinYin Wrote:  Pretty simple:
remember the original target.

int target = target.num;

//do team move stuff

loadtarget(target);

//do other stuff
Probably should not call the variable target, as you would be overwriting the global variable target, which will cause things to go weird.
Other than that, then yes, this is the solution.
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.
Reply
Thanks given by: YinYin , bashscrazy




Users browsing this thread: 1 Guest(s)