coordinates target then jump !!!

jonsilva

New member
hello
i whanted to make an enemy target a certain coordinates in the level
then move or jump to those coordinates
and then spawn another entity once is there...
spawning the entity is getting complicated because of the panel movement...!!!

i got this script from contra
void target0(float Velx, float Vely, float Tx, float Ty, float dx, float dy, void Vel, int Flip)
{// Basic Targetting certain coordinate before dashing
// Velx = Desired x Velocity
// Vely = Desired y Velocity
// Tx = target x coordinate
// Ty = target y coordinate
// dx = x added distance
// dy = y added distance
// Vel = Desired output

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;
    float Vy;

    if(Flip == 1){
      if(Tx < x){
        changeentityproperty(self, "direction", 0);
      } else {
        changeentityproperty(self, "direction", 1);
      }
    }

    x = x+dx;
    y = y+dy;
    float Disx = Tx - x;
    float Disy = Ty - y;

//Set both distance as positive value
    if(Disx < 0){
      Disx = -Disx;
    }

    if(Disy < 0){
      Disy = -Disy;
    }

// Calculate velocity for targetting
    if(Disy < Disx)
    {
      if(Tx < x){
        Vx = -Velx;
      } else { Vx = Velx; }

      Vy = Velx*(Ty-y)/Disx;
    } else {
      if(Ty < y){
        Vy = -Vely;
      } else { Vy = Vely; }

      Vx = Vely*(Tx-x)/Disy;
    }

    if(Vel == "x"){
      return Vx;
    }
    if(Vel == "y"){
      return Vy;
    }
}

i still havent use it
does anyone know if it will work on the level coordinates !!!

this is might explain better what iam trying to do....
explain.jpg



sorry about the darwing confusion i used the mouse to make this
 
....(huuuu) !!!

just got it working with (targetPos) !!!

@cmd targetPos 1 3030 525
@cmd leap 1

and the coordinates are working for the entire level size (3500x700) just like i needded !!!

---------//----------
Anyone can tell me in theres an (@cmd targetPos)
that works just for the level camera position range (instead of the entire level coordinates)
i needed it for a pervious level i have 
 
That script you quoted above is for targetting certain coordinate. I use basic form like that instead cause there are couple targetting functions which targets slave and position not just player.

Now back to question,

To spawn inscreen, you need to add camera position which is gained by:

  int XPos = openborvariant("xpos"); //Get screen edge's position
  int YPos = openborvariant("ypos"); // Get camera position

The former for X and the latter for Y.
I can't add those right away cause I need to find the function targetPos 1st :)
 
thanks
i got the targetpos script from chrono crash here
http://www.chronocrash.com/forum/index.php?topic=23.msg77#msg77

void targetPos(float Vy, int Tx, int Tz)
{// Targetting certain position before leaping there
//  Vy : Leaping speed
//  Tx : Leaping destination x coordinate
//  Tz : Leaping destination z coordinate
// Used with 'leap' or 'toss2'
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x"); // Get entity's x coordinate
    float z = getentityproperty(self, "z"); // Get entity's z coordinate

    if(Tx < x){
      changeentityproperty(self, "direction", 0); // Face left
    } else {
      changeentityproperty(self, "direction", 1); // Face right
    }
    setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
    setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable
}

could it work just by replacing the variables (Tx)(Tz)
for (XPos)(YPos) ?

-----///----

its giving me the script error Can't compile script! / theres an execption
i dont want to risk getting it work for now i could take a day or 2 or more... i have a lot of animations to finish.........

can you tell me how to do it ?

 
What I meant by adding is by adding this:

Code:
  int XPos = openborvariant("xpos"); //Get screen edge's position
  int YPos = openborvariant("ypos"); // Get camera position
 Tx=Tx+XPos;
 Tz=Tz+YPos;

between variable declaration and if(Tx<x) stuff.
 
thanks
it workes i dindnt had to alter the (Tx<x)
hes jumping to the centre of the screen during the death animation...


void targetCam(float Vy, int Tx, int Tz)
{// Targetting certain position before leaping there
//  Vy : Leaping speed
//  Tx : Leaping destination x coordinate
//  Tz : Leaping destination z coordinate
// Used with 'leap' or 'toss2'
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x"); // Get entity's x coordinate
    float z = getentityproperty(self, "z"); // Get entity's z coordinate
    int XPos = openborvariant("xpos"); //Get screen edge's position
    int YPos = openborvariant("ypos"); // Get camera position
    Tx=Tx+XPos;
    Tz=Tz+YPos;


    if(Tx < x){
      changeentityproperty(self, "direction", 0); // Face left
    } else {
      changeentityproperty(self, "direction", 1); // Face right
    }
    setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
    setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable
}

@cmd targetCam 5 320 120 
@cmd leap 5

##--- iam using video 1 the 320 is because of the velocity (*20)

level z
z          170 350 570
 
Back
Top Bottom