Fixing Air grab check script?

NED

Well-known member
Hello,
I would like to fix this airgrab check script.

The command
Code:
        @cmd    grabcheckA "ANI_FOLLOW20" "ANI_FOLLOW60" "ANI_FOLLOW60"#success miss miss

The script
Code:
void grabcheckA(void Ani1, void Ani2, void Ani3)
{ // Hero's airgrab checker
// This script prevents hero from grabbing ground enemies, bikers, jetpacks, special enemies and non-enemy entities
//  Ani1 = Grab animation to play
//  Ani2 = Animation to play if hit enemy are bikers or jetpacks
//  Ani3 = Animation to play if hit opponent are not airborne enemies

    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");

    if(target!=NULL()){

      if(getentityproperty(target, "a") > getentityproperty(target, "base")){
        int Check = checkgrab(target);

        if(Check == 0)
        { 
          changeentityproperty(self, "animation", openborconstant(Ani2));
        } else if(Check == 1){
          setlocalvar("Target" + self, target);
          changeentityproperty(self, "animation", openborconstant(Ani1));
        }
      } else {
        changeentityproperty(self, "animation", openborconstant(Ani3));
      }

    }
}

I would like to tweak the script to ignore anim2 and anim3

I would like the anima to change to a desired animation only if it hits airborne enemies
And if not (jetpacks,bikers,non airborne enemies...) it continues the animation ongoing.

Is this possible? How can it be fixed to allow this?
Thanks :)
 
I tried to edit the script myself. (with my limited knowledge of script logic)

These is no effect at all, but no crash.
What is wrong? Am I right to simply delete ani2 and ani3 choice in the script structure?

Code:
void grabchzz(void Ani1)
{ // Hero's airgrab checker
// This script prevents hero from grabbing ground enemies, bikers, jetpacks, special enemies and non-enemy entities
//  Ani1 = Grab animation to play
//  Ani2 = Animation to play if hit enemy are bikers or jetpacks
//  Ani3 = Animation to play if hit opponent are not airborne enemies

    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");

    if(target!=NULL()){

      if(getentityproperty(target, "a") > getentityproperty(target, "base")){
        int Check = checkgrab(target);

        if(Check == 0){
          setlocalvar("Target" + self, target);
          changeentityproperty(self, "animation", openborconstant(Ani1));
        }
      }

    }
}

EDIT-
A 2nd problem I have (I hesitate to create a 2nd topic for it, but I prefer avoid to spam the new threads)

How can you freeze an entity in mid air for one or 2 frames of animation?
I'm coding and anti air move with Rachel grabbing airborne enemy.
On hit she stay in mid air for 3 frames of animation then start to drop down.

I tried to overwrite velocities with this script(dasher), but it seems not to work well  :-\
Code:
@cmd dasher 0 0 0#(x y z)----immobiliser en l'air
 
There's still outdated checkgrab(target) function which might have blocked the air grab attempt
I say outdated cause it can simply be replaced by checking to-be-grabbed enemy's antigrab value then compare it with certain value

OTOH if you don't have any ungrabbable enemy in your mod, you can just remove the check into this:

Code:
if(target!=NULL()){
      if(getentityproperty(target, "a") > getentityproperty(target, "base")){
          setlocalvar("Target" + self, target);
          changeentityproperty(self, "animation", openborconstant(Ani1));
      }
    }

How can you freeze an entity in mid air for one or 2 frames of animation?

To prevent entity from falling down for some time, you can use this function:
Code:
void floater( int Time )
{// Floats in Time centiseconds
    void self = getlocalvar("self");
    int eTime = openborvariant("elapsed_time");

    changeentityproperty(self, "tosstime", eTime + 2*Time);
}

This function doesn't stop movements in x and z axis though
 
Thanks Bloodbane.
Now, I remember this floater function. (you suggested me to use it for wall jump before)
I finally used both dasher and floater. To stop x velocity ant to make entity floating.


Code:
@cmd dasher 0 0 0#1.4 0 0#(x y z)----mouvement (pour remplacer la velocité)
@cmd floater 20#----flotter en l'air pdt un temps defini

It seems to works well! :)


About my first problem,
Sorry I don't understand at all.
I don't have ungrabbable enemies for the moment, but it might change in the future.

Just to be sure I'll explain differently. (my english is not perfect)

I have a starter anim (anti air grab attempt)
If the starter contacts airborn enemies, it goes to a follow anim.
If not, it continues the attempt anim. (if the opponent is standing or biker or similar...)
 
I tried it anyway to see if I can fix it with your ideas.

The game launches, but when the move connects it crashes

The command
Code:
        @cmd    grabair "ANI_FOLLOW61"

The edited script
Code:
void grabair(void Ani1, void Ani2, void Ani3)
{ // Hero's airgrab checker
// grab air enemies only

    void self = getlocalvar("self");
    void target = getentityproperty(self, "opponent");

if(target!=NULL()){
      if(getentityproperty(target, "a") > getentityproperty(target, "base")){
          setlocalvar("Target" + self, target);
          changeentityproperty(self, "animation", openborconstant(Ani1));
      }
    }
}
 
Bloodbane, you was right!
I forgot to delete "void" for ani2 and 3.
Now it works. (I thik this is what the log said)

Thanks again for your help friend! :)
 
Back
Top Bottom