@Bind script help

PS_VITA

Active member
Hi guys-

for some reason and randomly whenever player one performs a floor grab move
sometimes the enemy from across the screen is replaced (teleported) by the nearest enemy that I'm trying to floor grab.

Any hints or things on the code that look off are really appreciated


Here's the ani0020_actual.h bind code in the script

Code:
void bind(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void opp = getentityproperty(self, "opponent");
	if(null == 1)
	{
		bindentity(opp, self, x, z, y, dir, 0);
	}
	else if(null == 0)
	{
		bindentity(opp, NULL());
	}
}

and here's the players code:

Code:
                   # floor enemy attack





                   # floor enemy attack





anim follow15
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial12
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
 
I'm stabbing in the dark here, but do you remember when I asked you to disable clearL function in other thread before?
One of the effect of doing that is this issue you posted.

You can solve this by declaring @cmd clearL function at last frame of slam/throw/grab animation.
 
I have the same problem. I think another thread exists about this question but I don't know which one and I've never really read it yet.

Bloodbane said:
You can solve this by declaring @cmd clearL function at last frame of slam/throw/grab animation.
My grabs have this function declared but the problem occurs, anyway.
 
What I did was to replace "bind" with "position" when I had the same problem:

Code:
void position(int Frame, float dx, float dy, float dz, int face)
{ // Modify grabbed entity's position relative to grabber
   void self = getlocalvar("self");
   void target = getlocalvar("Target" + self);

   if(target==NULL())
   {
     target = getentityproperty(self, "grabbing");
     setlocalvar("Target" + self, target);
   }
   if(target!=NULL())
   {
     updateframe(target, Frame);
     bindentity(target, self, dx, dz, dy, face, 0);
   }
}

Then I summon the function with this and always finishing with @cmd clearL (numbers are examples):

Code:
	@cmd 	position 1 33 35 1 0

Although I'm not really sure if this is the exact problem. NOT my code, credits to the original mastermind.
 
Actually I don't use @cmd bind but like you do. I don't know what I have to change.

A example :
Code:
anim	grabbackward
	loop	0
	delay	10
	offset	74 102
	frame	data/chars/max/Grabatt101.png
	@cmd	slamstart
	@cmd	position 4 0 25 -1 -1
	frame	data/chars/max/slam01.png
	@cmd	depost
	@cmd	throw 35 1 3 2 0 0
	frame	data/chars/max/slam02.png
	frame	data/chars/max/slam02.png
	@cmd	clearL
	frame	data/chars/max/slam01.png
 
PS VITA said:
sometimes the enemy from across the screen is replaced (teleported) by the nearest enemy that I'm trying to floor grab.

On second thought, I realized that there could be another possible cause: grabbing script

My grabbing script set was originally coded for grabbing state, therefore the script acquires enemy from currently grabbed enemy. The script is stable cause if grabbed enemy can't change.
Grabbing script was expanded to allow grabbing enemy outside grabbing state. The script acquires enemy from current opponent instead. This script is effective but not stable cause current opponent can change.

That's the reason why replacing bind with position function could solve the issue. bind function acquires enemy from current opponent while position from currently grabbed enemy.

16-bit Fighter said:
I don't know what I have to change.

I didn't create bind function so I can't give you easy way. Copying offset values is easy but copying defined poses is not since slam system using bind function is different with one using position function.
 
Bloodbane said:
I didn't create bind function so I can't give you easy way. Copying offset values is easy but copying defined poses is not since slam system using bind function is different with one using position function.
Well, I'm kind of lost. Like I told and like I showed in my example, I don't use bind bind function, I do use position function while I have the same problem as PS VITA.
 
PS VITA said:
Hi guys-

for some reason and randomly whenever player one performs a floor grab move
sometimes the enemy from across the screen is replaced (teleported) by the nearest enemy that I'm trying to floor grab.

Any hints or things on the code that look off are really appreciated


Here's the ani0020_actual.h bind code in the script

Code:
void bind(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void opp = getentityproperty(self, "opponent");
	if(null == 1)
	{
		bindentity(opp, self, x, z, y, dir, 0);
	}
	else if(null == 0)
	{
		bindentity(opp, NULL());
	}
}

and here's the players code:

Code:
                   # floor enemy attack





                   # floor enemy attack





anim follow15
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial12
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

Hello PS VITA

I don't know exactly what you are trying to do, but speaking about scripted grabs I always suggest to not use entity properties directly ("opponent" in your case). I recommend saving the current "opponent" in a variable first, and after that you can work with him by calling this "opponent" by the variable name, no matter if you are saving in an entityvar/globalvar/localvar. As Bloodbane said, the entity property "opponent" is unstable and can change anytime.

Here's an example about how you can use your bind function with variables:
Code:
void bind(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void target = getlocalvar("target"+self);

	if(target == NULL()){
		target = getentityproperty(self, "opponent");
		setlocalvar("target"+self, target);
	}
	
	target = getlocalvar("target"+self);
	
	if(target != NULL()){
		if(null == 1)
		{
			bindentity(target, self, x, z, y, dir, 0);
		}
		else if(null == 0)
		{
			bindentity(target, NULL());
			clearlocalvar();
		}
	}
}

In addition, the function @cmd clearL will not clear the entity property "opponent". This function was developed to clear local variables, so if you use clearL with no variables in your scripts, this function will not clear anything.

Please let me know if it worked
 
Kratus said:
PS VITA said:
Hi guys-

for some reason and randomly whenever player one performs a floor grab move
sometimes the enemy from across the screen is replaced (teleported) by the nearest enemy that I'm trying to floor grab.

Any hints or things on the code that look off are really appreciated


Here's the ani0020_actual.h bind code in the script

Code:
void bind(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void opp = getentityproperty(self, "opponent");
	if(null == 1)
	{
		bindentity(opp, self, x, z, y, dir, 0);
	}
	else if(null == 0)
	{
		bindentity(opp, NULL());
	}
}

and here's the players code:

Code:
                   # floor enemy attack





                   # floor enemy attack





anim follow15
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial12
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

Hello PS VITA

I don't know exactly what you are trying to do, but speaking about scripted grabs I always suggest to not use entity properties directly ("opponent" in your case). I recommend saving the current "opponent" in a variable first, and after that you can work with him by calling this "opponent" by the variable name, no matter if you are saving in an entityvar/globalvar/localvar. As Bloodbane said, the entity property "opponent" is unstable and can change anytime.

Here's an example about how you can use your bind function with variables:
Code:
void bind(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void target = getlocalvar("target"+self);

	if(target == NULL()){
		target = getentityproperty(self, "opponent");
		setlocalvar("target"+self, target);
	}
	
	target = getlocalvar("target"+self);
	
	if(target != NULL()){
		if(null == 1)
		{
			bindentity(target, self, x, z, y, dir, 0);
		}
		else if(null == 0)
		{
			bindentity(target, NULL());
			clearlocalvar();
		}
	}
}

In addition, the function @cmd clearL will not clear the entity property "opponent". This function was developed to clear local variables, so if you use clearL with no variables in your scripts, this function will not clear anything.

Please let me know if it worked

I'll have some time this weekend to test it,
I myself. Thanks in advance.
 
Two members posted same problem in same thread but I'm not sure if the cause of both is the same. I'll examine them one by one.

16-bit Fighter : Can we see slamstart function you are using?

PS VITA : You have posted your bind function, however you haven't posted forceanim yet. Can we see it?

PS VITA said:
whenever player one performs a floor grab move

Hmmm... I might also need to see how actually player finds enemy to be floorgrabbed. I've coded something similar before; the script to find that enemy works in conjunction with grabbing script and it uses same variable to store enemy. That's how I ensure floorgrabbing stability.
 
Bloodbane said:
Two members posted same problem in same thread but I'm not sure if the cause of both is the same. I'll examine them one by one.

16-bit Fighter : Can we see slamstart function you are using?
Thanks Bloodbane , here is the code:

Code:
void slamstart() // Slam Starter for Cody/Guy grabbackward
{ // 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())
   {
     damageentity(target, self, 0, 1, openborconstant("ATK_NORMAL4")); // Slam Starter
   }
}
 
Hmmm.... if you use slamstart only in GRAB animations, you could change "opponent" to "grabbing". But if you use that function in non-GRAB animations, you might need to modify the function to use flag input to define where opponent is acquired.
 
Kratus said:
Please let me know if it worked

Hello Kratus

it didn't - as in I'm still teleporting faraway enemies into my floor grab move instead of my closest target.

Here's the script I'm using  that you gave us which teleports enemies like 75% of the time as opposed to the old script that
would teleport enemies with a 15 % chance. - But I could be wrong

Code:
void bind3(int null, float x, float z, float y, int dir){
	void self = getlocalvar("self");
	void target = getlocalvar("target"+self);

	if(target == NULL()){
		target = getentityproperty(self, "opponent");
		setlocalvar("target"+self, target);
	}
	
	target = getlocalvar("target"+self);
	
	if(target != NULL()){
		if(null == 1)
		{
			bindentity(target, self, x, z, y, dir, 0);
		}
		else if(null == 0)
		{
			bindentity(target, NULL());
			clearlocalvar();
		}
	}
}


Here's the code to initiate the floor grab attack

Code:
anim attack1
	loop	0
	delay	2
	offset	77 178
	bbox	60 65 40 100
@cmd ani0020 openborconstant("ANI_FOLLOW13") openborconstant("ANI_FOLLOW80")
      throwframe 0 0
      custknife Empty2
      @cmd    antiwall3 35 -31 0
	frame	data/chars/billy/ball/w4.png
      delay   20
      bbox	0 0 0 0
      @cmd	shooter2 "ball1" 30 120 0 1.5 1 0
	frame	data/chars/billy/rock/wua.png
      delay   2
      offset	77 170 #166
      frame	data/chars/billy/idle.png



Here's the rest of the code

with the new @bind3 code implemented that you gave us.
( Thanks for any input you may have)

Code:
                   # floor enemy attack

anim follow13
@script
    void self = getlocalvar("self");

    if(frame==0){
      changelevelproperty("scrollspeed", 0);
    }
@end_script
      loop	0
      range -40 40
      rangez -21 13
	delay	2
      offset	85 170
      otg 2
      followcond 2
      followanim 15
      attackone 1
      hitfx   data/sounds/goo.wav 
      @cmd    conditionalflip2
      frame	data/chars/billy/ball/gr00.png
      attack3  45 140 60 39 0 0 1 1 10 21
      forcedirection 99
      noreflect 1
      nokill 1
      delay	9
      frame	data/chars/billy/ball/gr00.png
      delay	11
      attack3  0 0 0 0 0 0
      frame	data/chars/billy/ball/gr0.png
      frame	data/chars/billy/ball/gr0.png
      frame	data/chars/billy/ball/gr0.png

anim follow14
      loop	0
      delay	8
      offset	85 170
      @cmd    slamstart4 1 1 0 
      @cmd    position 8 0 1 0 0
      frame	data/chars/billy/ball/gr00.png
      delay	16
      @cmd    position 8 0 1 0 0
      frame	data/chars/billy/ball/gr0.png
      @cmd    anichange "ANI_FOLLOW15"
      frame	data/chars/billy/ball/gr3.png

anim follow15
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial12
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind3 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW77")
      @cmd bind3 8 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

anim freespecial12
      loop	0
      delay	9
      offset	85 170
      @cmd    slamstart3
      @cmd    position 8 0 1 0 0
      frame	data/chars/billy/ball/gr1.png
      delay	8
      @cmd    position 9 0 1 0 0
      frame	data/chars/billy/ball/gr2.png
      delay	4
      frame	data/chars/billy/ball/gr3.png
      #@cmd    hurt9 0
      @cmd    anichange "ANI_FOLLOW16"
      frame	data/chars/billy/ball/gr2.png
      frame	data/chars/billy/ball/gr2.png

anim follow16
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial13
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW78")
      @cmd bind3 9 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW78")
      @cmd bind3 9 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

anim freespecial13
      loop	0
      delay	9
      offset	85 170
      @cmd    slamstart3
      @cmd    position 9 0 1 0 0
      frame	data/chars/billy/ball/gr1.png
      delay	8
      @cmd    position 10 0 1 0 0
      frame	data/chars/billy/ball/gr2.png
      delay	4
      frame	data/chars/billy/ball/gr3.png
      #@cmd    hurt9 0
      @cmd    anichange "ANI_FOLLOW17"
      frame	data/chars/billy/ball/gr3b.png
      frame	data/chars/billy/ball/gr3.png

anim follow17
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial14
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW79")
      @cmd bind3 10 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW79")
      @cmd bind3 10 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

anim freespecial14
      loop	0
      delay	9
      offset	85 170
      @cmd    slamstart3
      @cmd    position 10 0 1 0 0
      frame	data/chars/billy/ball/gr1.png
      delay	8
      @cmd    position 9 0 1 0 0
      frame	data/chars/billy/ball/gr2.png
      delay	4
      frame	data/chars/billy/ball/gr3.png
      @cmd    anichange "ANI_FOLLOW18"
      frame	data/chars/billy/ball/gr3b.png
      frame	data/chars/billy/ball/gr3.png

anim follow18
      loop	1
	delay	9
      offset	85 170
      cancel 0 1 0 A freespecial15
      cancel 0 1 0 B freespecial16
      @cmd forceanim openborconstant("ANI_FOLLOW78")
      @cmd bind3 9 0 0 1 0
      frame	data/chars/billy/ball/gr0.png
      @cmd forceanim openborconstant("ANI_FOLLOW78")
      @cmd bind3 9 0 0 1 0
      frame	data/chars/billy/ball/gr0.png

anim freespecial15
      loop	0
      delay	9
      offset	85 170
      @cmd    slamstart3
      @cmd    position 9 0 1 0 0
      sound data/sounds/ballhit.wav
      frame	data/chars/billy/ball/gr3c.png
      sound data/sounds/maxhit.wav
      delay	4
      @cmd    position 10 0 1 0 0
      quakeframe 1 10 5
      frame	data/chars/billy/ball/gr2b.png
      #spawnframe {frame} {x} {z} {a} {relative}
        spawnframe 2 77 -12 0 0
        custentity blood4
      frame	data/chars/billy/ball/gr2c.png
      frame	data/chars/billy/ball/gr2d.png
      frame	data/chars/billy/ball/gr2e.png
      frame	data/chars/billy/ball/gr2f.png
      frame	data/chars/billy/ball/gr2g.png
      @cmd    hurt9 80
      delay	6
      frame	data/chars/billy/ball/gr2g.png
      frame	data/chars/billy/ball/gr2h.png
      frame	data/chars/billy/ball/gr3.png
      delay	8
      frame	data/chars/billy/ball/gr0.png
      delay	8
      @cmd    depost 0
      frame	data/chars/billy/ball/j0.png

anim freespecial16
      loop	0
      delay	12
      offset	85 170
      @cmd bind3 0 0 0 0 0
      frame	data/chars/billy/ball/gr0.png
      offset	77 170
      delay	9
      frame	data/chars/billy/ball/j0.png
 
Bloodbane said:
Two members posted same problem in same thread but I'm not sure if the cause of both is the same. I'll examine them one by one.

16-bit Fighter : Can we see slamstart function you are using?

PS VITA : You have posted your bind function, however you haven't posted forceanim yet. Can we see it?

PS VITA said:
whenever player one performs a floor grab move

Hmmm... I might also need to see how actually player finds enemy to be floorgrabbed. I've coded something similar before; the script to find that enemy works in conjunction with grabbing script and it uses same variable to store enemy. That's how I ensure floorgrabbing stability.

Bloodbane
sorry - I've missed this post ... here's the forceanim scipt you asked about...

Code:
void forceanim(int anim){
	void self = getlocalvar("self");
	void opp = getentityproperty(self, "opponent");
	changeentityproperty(opp, "animation", anim);
}

 
PS VITA

Would be good to see a video showing an example of what move you are trying to develop, because it has too many animations.

According to what I've seen in the code, the unique atbox is inside the "follow13" animation and it is the only moment a "opponent" will be registered in the entity property. After that, the first script to run is the "slamstart4".
So, you need to register the grabbed entity inside the "slamstart4" script and don't change the target variable again until the entire move is completed, otherwise you may have problems during the move.

I suggest to remove this part of the code in the "bind3" script, and maybe can be good to remove it for all other script that came after the "slamstart4":
Code:
if(target == NULL()){
		target = getentityproperty(self, "opponent");
		setlocalvar("target"+self, target);
	}
	
	target = getlocalvar("target"+self);

This part of the code will register the target variable again. If the "opponent" property changes before this code runs, the target will change too.
I need to see all other scripts before to confirm it, and maybe this is the cause of the teleported enemies.
 
Kratus said:
PS VITA

Would be good to see a video showing an example of what move you are trying to develop, because it has too many animations.

According to what I've seen in the code, the unique atbox is inside the "follow13" animation and it is the only moment a "opponent" will be registered in the entity property. After that, the first script to run is the "slamstart4".
So, you need to register the grabbed entity inside the "slamstart4" script and don't change the target variable again until the entire move is completed, otherwise you may have problems during the move.

I suggest to remove this part of the code in the "bind3" script, and maybe can be good to remove it for all other script that came after the "slamstart4":
Code:
if(target == NULL()){
		target = getentityproperty(self, "opponent");
		setlocalvar("target"+self, target);
	}
	
	target = getlocalvar("target"+self);

This part of the code will register the target variable again. If the "opponent" property changes before this code runs, the target will change too.
I need to see all other scripts before to confirm it, and maybe this is the cause of the teleported enemies.

Thanks Kratus

For now here's the missing script

Code:
void slamstart4(int dx, int dy, 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");
     int Ty = getentityproperty(target, "a");
     changeentityproperty(self, "position", Tx+dx, Tz+dz, Ty+dy); //Teleport to target!
     damageentity(target, self, 0, 1, openborconstant("ATK_NORMAL8")); // Slam Starter
   }
}

It's hard to test this over and over - but I will eventually get around this and confirm.

 
msmalik681 said:
I made a simple bind script when working with localvars it was unstable but when i switched to entityvars it became more stable.
It's true buddy, thanks to remember that. Like you, I changed all my grab scripts to entityvars too. I had no more problems after these changes.
 
Back
Top Bottom