Bind to enemy position

NED

Well-known member
Hello,
I would like my player to bind at something like 20 pixels of enemy position.
This have to happen on first frame of the anim.

I'm pretty sure some script can do it.
But I can't remember which one??

Any clue?
Thanks
 
Thanks!
This is almost it, but it seems to make enemy falling. :-\
I would like to avoid enemy to fall.

Perhaps some teleport thing would make it.
Without actual contact. Player should not interfere with enemy action at this moment.
 
I finally try my chance and decided to re-edit the script.

I deleted damagenetity
deleted Y information and check (I don't need it)

This is the script:
Code:
void sososo(int dx, int dz)
{ // Slam Starter for nongrab slams
// Use finish or throw after using this
   void self = getlocalvar("self");
   void target = getlocalvar("Target" + self);

   if(target==NULL())
   {
     target = getentityproperty(self, "opponent");
     setlocalvar("Target" + self, target);
   }

   if(target!=NULL()){
     int Tx = getentityproperty(target, "x");
     int Tz = getentityproperty(target, "z");
     changeentityproperty(self, "position", Tx+dx, Tz+dz); //Teleport to target!
   }
}

I tested it.
It seems to work.

But don't hesitate to say me if the structure is weird or unlogic.

Thanks again

-------------------------------------------EDIT

OK,
There is one more problem.

I used the command this way:

@cmd xztelep -20 1# x z# Bind to enemy - teleport (adjust)


To bind close to enemy and displayed in front (layer)


The problem is the bind value works only when player is facing right (situation A)
If you're facing left, you will be teleported on 20 instead of -20 (situation B)

CsbO17a.jpg



BTW : I think the right value should be 20 and the bug is actually in situation A

Please, How can I fix it so player and enemy appears face to face?
 
This is the cause:

Code:
     changeentityproperty(self, "position", Tx+dx, Tz+dz);

This line will put self dx pixels to the right of target REGARDLESS of facing direction.

You need to get facing direction of target with this:

Code:
    int Tdir = getentityproperty(target,"direction");

Then flip dx based on that like this:

Code:
    if(Tdir==0){ // Facing left?
      dx = -dx ;
    }

Can't test it since I don't have the whole system
 
Thanks BB!
I tried to edit the script.
I have not deleted elements since the last step.

Only added these 2 red elements.
My structure might be wrong, there is nothing new ingame.



void xztelep(int dx, int dz)
{ // De moi - teleport en X et Z vers enemi (bind to enemy)
// Used pour shining wizard comfirm de Rachel
  void self = getlocalvar("self");
  void target = getlocalvar("Target" + self);
    int Tdir = getentityproperty(target,"direction");

    if(Tdir==0){ // Facing left?
      dx = -dx ;
    }


  if(target==NULL())
  {
    target = getentityproperty(self, "opponent");
    setlocalvar("Target" + self, target);
  }

  if(target!=NULL()){
    int Tx = getentityproperty(target, "x");
    int Tz = getentityproperty(target, "z");
    changeentityproperty(self, "position", Tx+dx, Tz+dz); //Teleport to target!
  }
}
 
You could add the z distance along with the x distance which Bloodbane input. You can do from this:

Code:
    if(Tdir==0){ // Facing left?
      dx = -dx ;
    }

..to this:

Code:
    if(Tdir==0){ // Facing left?
      dx = -dx ;
      dz = -dz;
    }

Not sure if it could work, to be honest, but I haven't tried doing the x-z teleportation animation script. But one thing I did was a velo script which DC made and it's very easy to use it. It's like jumpframe, but more flexible in movement.
 
ned, do you run other function aside of this one?

If not then the only possible cause is misoffseting of Mex which caused him to appear farther then he should be
 
First, thanks to both for your help.

There is no other function aside.
offset is OK.

The move have 2 anims:
Atempt and success.

Code:
anim	freespecial88# ATTEMPT
      followcond 2
      followanim 43
	forcedirection	-1
	delay	7
	loop	0
	fastattack	1
	jugglecost	1
	offset	96 177
	jumpframe	1 3.3 3.3
	landframe	7 dus
	bbox	66 92 78 64
	frame	data/chars/rachel/j01.gif
	delay	7
	sound	data/sounds/a2.wav
	frame	data/chars/rachel/j05.gif

	delay	9
	sound	data/chars/rachel/kiai1.wav
	frame	data/chars/rachel/jad1.gif

	delay	4#5
	frame	data/chars/rachel/jad3.gif

	delay	15#11
	forcedirection	-1
	hitfx	data/sounds/lightkik.wav
	otg 0
	attack2	92 120 72 42 0 0 1 1 28 0#(NO DAMAGE!!)
	frame	data/chars/rachel/jad3b.gif

	delay	5
	attack	0 0 0 0 0 0
	frame	data/chars/rachel/jad3b.gif

	delay	999
	frame	data/chars/rachel/jad4.gif

	delay	6#9
	frame	data/chars/rachel/j01.gif

	delay	11#10
	frame	data/chars/rachel/j01.gif
	delay	7#8
	frame	data/chars/rachel/j01.gif


anim	follow43#SUCCESS

	forcedirection	-1
	delay	2
	movez	1.5
	loop	0
	fastattack	1
	jugglecost	1
	offset	96 177
	jumpframe	2 2.5 2.1
	landframe	8 dus
	bbox	0 0 0 0#66 92 78 64
	frame	data/chars/rachel/shiwiz01.gif


	delay	10
@cmd xztelep -20 1# x z# Bind to enemy - teleport (adjust)
	frame	data/chars/rachel/shiwiz01.gif


	delay	7
	movez	0
	sound	data/sounds/a2.wav
	frame	data/chars/rachel/shiwiz02.gif

	delay	7
	sound	data/sounds/a2.wav
	forcedirection	-1
	hitfx	data/sounds/knee.wav
	otg 0
	attack1	97 102 22 45 10 0 1 0 19 0
	dropv	4 -1
	frame	data/chars/rachel/shiwiz03.gif

	delay	2
	sound	data/chars/rachel/kiai5.wav
	attack	0 0 0 0 0 0
	frame	data/chars/rachel/shiwiz04.gif

	delay	5
	forcedirection	-1
	hitfx	data/sounds/powhitt.wav
	otg 0
	attack1	90 101 38 46 25 1 1 0 35 0 35 43 20 1 1 0 35 0
	dropv	4 -1
	frame	data/chars/rachel/shiwiz04.gif

	delay	11
	attack	0 0 0 0 0 0
@cmd leaper 1.4 0.7 0
	frame	data/chars/rachel/shiwiz05.gif

	delay	999
	frame	data/chars/rachel/shiwiz06.gif

	 delay      10
	sound	data/sounds/fall02.wav
       frame      data/chars/rachel/btdrnew5.gif

	 delay      20
       frame      data/chars/rachel/btdrnew7.gif

	 delay      16
	bbox	66 92 78 64
       frame      data/chars/rachel/rise2.gif

	 delay      13
       frame      data/chars/rachel/j01.gif

@BB
So, the way I edited script (In red) is a correct stucture?
I just added the elements you suggered in places that looked logic to me.
But I might certainly be wrong.
 
I see...
Sorry perhaps my word is not good "bind"
I'm more talking about some teleport stuff, not really binding for a time.

The idea is just to teleport player 20 pixels in front of enemy. :)
 
As you see in this grab, I use the move script to teleport the player to a new position.
It is very important to accompany the move script with antiall script to avoid errors.

anim grabforward
loop 0
delay 1
offset 82 177
bbox 0 0 0 0
        attackone 0
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grab.png
delay  4
        @cmd    slamstart
        @cmd    position 0 45 0 -1 0
        frame  data/chars/orchid/spawn11.png
        @cmd    dasher 4 0 0
        @cmd    position 0 45 0 -1 0
        frame  data/chars/orchid/spawn12.png
        @cmd    position 0 30 0 -1 0
        frame  data/chars/orchid/spawn13.png
        @cmd    position 0 15 0 -1 0
        frame  data/chars/orchid/spawn14.png
        @cmd    position 0 5 0 -1 0
        frame  data/chars/orchid/spawn15.png
        @cmd    position 0 -15 0 -1 0
        frame  data/chars/orchid/spawn16b.png
        @cmd    stop
        @cmd    position 0 -30 0 -1 0
        frame  data/chars/orchid/spawn17b.png
delay  1
        @cmd    move -11 0 0
        @cmd    antiwall -11 11 -1

        @cmd    position 0 -35 0 -1 -1
        frame  data/chars/orchid/backat12.png
delay  5
        @cmd    stop
        @cmd    position 0 -35 0 -1 -1
        frame  data/chars/orchid/backat12.png
        frame  data/chars/orchid/backat13.png
delay  12
        @cmd    position 0 -35 0 -1 -1
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grabf01.png
        sound  data/sounds/beat.wav
@cmd    hurt2 4
delay  16
        @cmd    position 0 -37 0 -1 -1
        frame  data/chars/orchid/grabf02.png
delay  12
        @cmd    position 0 -35 0 -1 -1
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grabf01.png
        sound  data/sounds/beat.wav
@cmd    hurt2 4
delay  16
        @cmd    position 0 -37 0 -1 -1
        frame  data/chars/orchid/grabf02.png
delay  12
        @cmd    position 0 -35 0 -1 -1
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grabf01.png
        sound  data/sounds/beat.wav
@cmd    hurt2 4
delay  16
        @cmd    position 0 -37 0 -1 -1
        frame  data/chars/orchid/grabf02.png
        @cmd    position 0 -35 0 -1 -1
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grabf01.png
        sound  data/sounds/beat.wav
@cmd    hurt2 4
delay  16
        @cmd    position 0 -37 0 -1 -1
        frame  data/chars/orchid/grabf02.png
delay  12
        @cmd    position 0 -35 0 -1 -1
        sound  data/chars/orchid/at0.wav
        frame  data/chars/orchid/grabf01.png
        sound  data/sounds/beat.wav
@cmd    hurt2 4
delay  16
        @cmd    position 0 -37 0 -1 -1
        frame  data/chars/orchid/grabf02.png
delay  6
        frame  data/chars/orchid/backat12.png
delay  5
        frame  data/chars/orchid/backat13.png
delay  1
        @cmd    flip
        @cmd    position 0 37 0 -1 0
frame data/chars/orchid/grabat01.png
delay 4
        sound  data/chars/orchid/at3.wav
frame data/chars/orchid/grabat01.png
frame data/chars/orchid/grabat02.png
        sound  data/chars/orchid/at.wav
        @cmd  spawn01 "flash3" 20 100 1
frame data/chars/orchid/grabat03.png
        delay  1
        sound  data/sounds/beat2.wav
@cmd depost 0
        @cmd  finish 15 1 2 2 0 1
frame data/chars/orchid/grabat03.png
        delay  4
frame data/chars/orchid/grabat04.png
delay 20
frame data/chars/orchid/grabat05.png
delay 6
frame data/chars/orchid/grabat06.png
delay 4
frame data/chars/orchid/spawn12.png
frame data/chars/orchid/spawn11.png
frame data/chars/orchid/spawn10.png
frame data/chars/orchid/spawn9.png
frame data/chars/orchid/spawn8.png


An here the script move:

Code:
void move(int dx, int dz,int da)
{ // Moves entity freely and ignores obstacles
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getentityproperty(self,"a"); //Get character's a coordinate
    int dir = getentityproperty(self,"direction"); //Get character's facing direction

     if(dir==0){ // Facing left?
      changeentityproperty(self, "position", x-dx, z+dz, a+da); //Move
     }
     else if(dir==1){ // Facing right?
      changeentityproperty(self, "position", x+dx, z+dz, a+da); //Move
     }
}

Antiwall scrit:

Code:
void antiwall(int Dist, int Move, int Distz)
{// Checks if there is wall at defined distance
// If there is wall, entity will be moved away with defined movement
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   float H;
   float Hz;
   float Hw;

   if(Direction == 0){ //Is entity facing left?                  
      Dist = -Dist; //Reverse Dist to match facing
      Move = -Move; //Reverse Move to match facing
   }

   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);
   Hw = checkwall(x+Dist,z-Distz);

   if(Hz > y && Hw <= y)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }

   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
   }
}
 
Thanks for explaining the move/teleport script.
But I still don't know how to define the place player will go (depending on enemy)

I never thought this movement would be so complex to script/code.

Perhaps I'll go for a "bind to x = 0" value this time, since the command cannot be fixed.
This way in good situation it will bind to 0, and in bad/buggy situation it will bind to "-0"
Even it it looks really wrong on screen. :-\
 
I tried one more time to edit the script and trying to add enemy orientation detect.
But the game is even more unstable with it, so I'll give up on it.

I'll keep X value as "x = 0"
The only way to use this custom command without weird effect on screen.

The binding is really weird, but the move works in a descent way.
So...
 
Back
Top Bottom