Solved I have a question about Grab height.

Question that is answered or resolved.

DD Tokki

Well-known member
When the player approaches an enemy, it changes to a Grab action. At this time, I would like to know how to change the location of the captured enemy depending on the player's height.
 
There's no native height adjustment, so you'll need to use scripted binding.

First thing you'll need to do is either set an entity level variable for the grabber's height, or read the native height or animation height properly.

From there, you can adjust your Y axis.

HTH,
DC
 
1723716371569.png

Hello, I'm back after being busy for a while.

When the player grabs an enemy and uses the Grab action, I want to change the height at which the enemy is lifted based on the character's height. I've tried several methods but haven't been able to solve it.

Is there a good way to change the height of "anim grab"?
 
For the normal grab, I would make it to grab the enemy on the ground, on the same position for everyone. It would be simpler that way.

This would save you work and you can let this for the other moves, like grab forward or backward
 
For the normal grab, I would make it to grab the enemy on the ground, on the same position for everyone. It would be simpler that way.

This would save you work and you can let this for the other moves, like grab forward or backward
I want to make it so that the position of the enemy caught by the player is the same, but the player's height is different, so I want to make it so that it is caught and lifted.
 
I want to make it so that the position of the enemy caught by the player is the same, but the player's height is different, so I want to make it so that it is caught and lifted.
Yes, I got it. I am just trying to make your life easier :)
For example, it would be weird to see Kisarah lifting someone like that while standing still.
 
@DD Tokki I was doing some tests found a way to simulate it by detecting the opponent height and changing between animations with different offsets.


Code:
void checkHeight()
{//Changes animation according to opponent height
    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");
  
    if(target != NULL()){
        int height = getentityproperty(target, "height");
      
        if(height >= 70 && height < 80){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
        }else
        if(height >= 80 && height < 90){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
        }
    }
}

Code:
anim grabbed
    loop    0
    delay    8
    offset    141 172 # GROUND
    bbox    130 113 26 61
    @cmd checkHeight
    frame    data/chars/enemies/galsia/sor2/grabbed00.png

anim follow1
    loop    0
    delay    8
    offset    141 182 # HEIGHT 70-79
    bbox    130 113 26 61
    frame    data/chars/enemies/galsia/sor2/grabbed00.png

anim follow2
    loop    0
    delay    8
    offset    141 192 # HEIGHT 80-89
    bbox    130 113 26 61
    frame    data/chars/enemies/galsia/sor2/grabbed00.png
 
Last edited:
@DD Tokki I was doing some tests found a way to simulate it by detecting the opponent height and changing between animations with different offsets.


Code:
void checkHeight()
{//Changes animation according to opponent height
    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");
  
    if(target != NULL()){
        int height = getentityproperty(target, "height");
      
        if(height >= 70 && height < 79){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
        }else
        if(height >= 80 && height < 89){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
        }
    }
}

Code:
anim grabbed
    loop    0
    delay    8
    offset    141 172 # GROUND
    bbox    130 113 26 61
    @cmd checkHeight
    frame    data/chars/enemies/galsia/sor2/grabbed00.png

anim follow1
    loop    0
    delay    8
    offset    141 182 # HEIGHT 70-79
    bbox    130 113 26 61
    frame    data/chars/enemies/galsia/sor2/grabbed00.png

anim follow2
    loop    0
    delay    8
    offset    141 192 # HEIGHT 80-89
    bbox    130 113 26 61
    frame    data/chars/enemies/galsia/sor2/grabbed00.png

1723750278579.png

The current enemy is not detecting the player's height. I'm wondering if I missed something.

C:
anim    grab (player)
    loop    0
    cancel    0 1 0 u a2 freespecial6
    cancel    0 1 0 d a2 freespecial8
    cancel    0 1 0 f a2 freespecial7
    cancel    0 1 0 b a2 freespecial7
    cancel    0 1 0 a2 freespecial5
    cancel    0 1 0 a3 freespecial10   
    delay    1
    offset    38 107
    bbox    17 0 45 103
    attack    0 0 0 0 0 0 0 0 0 0
    @cmd    degravity    -0.5
    frame    data/sprites/sprite/chara/01r/grab.gif

C:
anim    grabbed (enemy)
    loop    0
    delay    100
    offset    22 75
    bbox    -3 0 50 76
    @cmd    degravity    -0.5
    @cmd    nograb 0
    @cmd    depost 0
    @cmd    finishP 0 1 2 2 0 1
    @cmd     checkHeight
    @cmd     clearL
    movez    -1
    frame    data/sprites/sprite/chara/e01tn/pain-b03.gif
    movez    0
    frame    data/sprites/sprite/chara/e01tn/pain-b03.gif
 
You need to define the height in each character header, like the image below. Usually I define the value based on the idle sprite size.

View attachment 8923

View attachment 8922

Code:
void checkHeight()
{//Changes animation according to opponent height
    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");
   
    if(target != NULL()){
        int height = getentityproperty(target, "height");
       
        if(height >= 70 && height < 79){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW200"));
        }else
        if(height >= 80 && height < 89){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW201"));
        }else
        if(height >= 90 && height < 99){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW202"));
        }else
        if(height >= 100 && height < 109){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW203"));
        }else
        if(height >= 110 && height < 119){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW204"));
        }else
        if(height >= 120 && height < 129){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW205"));
        }else
        if(height >= 130 && height < 139){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW206"));
        }else
        if(height >= 140 && height < 149){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW207"));
        }else
        if(height >= 150 && height < 159){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW208"));
        }else
        if(height >= 160 && height < 169){
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW209"));
        }
    }
}

animationscript data/scripts/script.c

I wrote and applied the script like this, but I'm wondering if there's anything wrong.

name 01R
type Player
health 280
mpset 200 0 0 2 0 0
speed 15.2
running 37.6 3.5 2 1
jumpspeed 17.2
jumpheight 5
risetime 140
jugglepoints 20
makeinv 3
riseinv 1
grabdistance 42
grabforce 1
antigrab 1
antigravity -50
height 109
falldie 2
gfxshadow 1 0
noquake 1
candamage enemy obstacle
hostile enemy
weapons none none none none none none none none none none
 
I don't wanna sound mad or harsh, but why is this part only less than 79?

height >= 70 && height < 79

You're telling it to detect its height numbers between 70 and 78, not 79. You're just leaving 79 out of it. This less than < symbol means one value is smaller than that particular value. If you were to put height 79 in the character header of the player, the enemy will only default to play its anim grabbed instead of anim follow200 from your code.

Example:
One less than two. (e.g. 1 < 2) One is smaller than two. It cannot be two less than two because they are the same numbers. (e.g. 2 < 2)

The better way to do this, since you only added it less than <, try to add less than or equal to symbol <= like this.

Example:
height >= 70 && height <= 79

The less than or equal to symbol is what can equal the same number OR have one number smaller than the other since it has two conditions. Less than or equal to.

That way, you can detect it with a given number there. Just be careful with the symbols.

Otherwise, you can copy one example from @Kratus which he put < 80 above. This one here reads from 70-79 below.

height >= 70 && height < 80

Can you tell the difference?
 
Last edited:
I don't wanna sound mad or harsh, but why is this part only less than 79?



You're telling it to detect its height numbers between 70 and 78, not 79. You're just leaving 79 out of it. This less than < symbol means one value is smaller than that particular value. If you were to put height 79 in the character header of the player, the enemy will only default to play its anim grabbed instead of anim follow200 from your code.

Example:
One less than two. (e.g. 1 < 2) One is smaller than two. It cannot be two less than two because they are the same numbers. (e.g. 2 < 2)

The better way to do this, since you only added it less than <, try to add less than or equal to symbol <= like this.

Example:


The less than or equal to symbol is what can equal the same number OR have one number smaller than the other since it has two conditions. Less than or equal to.

That way, you can detect it with a given number there. Just be careful with the symbols.

Otherwise, you can copy one example from @Kratus which he put < 80 above. This one here reads from 70-79 below.



Can you tell the difference?
There are many mistakes in the test. I will correct the numbers.
 
KoR - 0105.png
for Robert and Yuri, I would use this on his header:

grabback {bi}

  • If set to 1, when grabbing, this entity will be displayed behind the other entity being grabbed.
 
Good work. I know it's already solved, but here's a piece of advice. It's not just about symbols and numbers. It's about understanding the logic of using operators.

Available operators:

  1. +
  2. -
  3. *
  4. /
  5. %
  6. =
  7. +=
  8. -=
  9. /=
  10. *=
  11. %=
  12. ! (it works for constants too from r4340+)
  13. ==
  14. ||
  15. &&
  16. !=
  17. >
  18. <
  19. >=
  20. <=
  21. ~ (from r4316+)
  22. ^
  23. |
  24. &
  25. <<
  26. >>
  27. <<= (from r4316+)
  28. >>= (from r4316+)
  29. &= (from r4316+)
  30. |= (from r4316+)
  31. ^= (from r4316+)
For your case, here's a basic difference between < and <=.


Here's more info of available operators from the playlist you can watch.

 
Back
Top Bottom