Enemy grabbed check

dantedevil

Well-known member
I just detected after multiple tests, that in some rare cases, my system of double grab has a bug with the enemies that have paingrab 1.
The bug consists when the duoble grab fails to catch the enemy with paingrab 1, but in sometimes the enemy is stuck in the player, and passes all the sprites of the FALL7 (slam sprites).

I think the solution would be to include a scripts in the fall7, which can check if the enemy is in a slam, seized by the player or not. And if it is not, you should go to the idle.

I suppose it should be something similar to this script, but I do not know what the exact term should be instead of "grabbing".
Code:
void grabcheck()
{// Prevents hero from performing the slam if he/she's not grabbing anyone
   void self = getlocalvar("self");
   void target = getentityproperty(self, "grabbing");

   if(target==NULL())
   {
     setidle(self); //Don't perform the slam.
   }
}

Here my FALL7:
Code:
anim fall7
	delay   1000
	offset	84 175
	frame	data/chars/gang1/bee/pain.png#0
	frame	data/chars/gang1/bee/pain2.png#1
	frame	data/chars/gang1/bee/pain3.png#2
	frame	data/chars/gang1/bee/pain4.png#3
	frame	data/chars/gang1/bee/pain5.png#4
	offset	82 177
	frame	data/chars/gang1/bee/pain8.png#5 
	offset	85 127
	frame	data/chars/gang1/bee/pain10.png#6
	offset	80 96
	frame	data/chars/gang1/bee/pain12.png#7
	offset	93 183
	frame	data/chars/gang1/bee/fthrow01b.png#8 
	offset	73 135
	frame	data/chars/gang1/bee/fthrow02.png#9 
	offset	82 177
	frame	data/chars/gang1/bee/fall1.png#10 
	frame	data/chars/gang1/bee/fall2.png#11
	frame	data/chars/gang1/bee/fall3.png#12
	frame	data/chars/gang1/bee/fall4.png#13
	offset	84 175
	frame	data/chars/gang1/bee/pain14.png#14 
	frame	data/chars/gang1/bee/pain15.png#15 
	offset	84 175
	frame	data/chars/gang1/bee/pain16.png#16 
	offset	82 177
	frame	data/chars/gang1/bee/pain17.png#17
 
The bug consists when the duoble grab fails to catch the enemy with paingrab 1, but in sometimes the enemy is stuck in the player, and passes all the sprites of the FALL7

Sounds like the grab attempt was successful but somehow it ends there
Can I see the double grab animation and script related to it?
 
My system use simple scripts, but it's some complex in the use.

In the grab walk forward, I have set the box attacks in the back part of my hero, then go to the follow2 to check the type of entity with the grabcheckW.
Code:
anim grabwalk
        followanim 2
        followcond 2
	cancel 	0 99 0    d d a3   freespecial35
	cancel 	0 99 0    d u a3   freespecial36
	cancel 	0 99 0    a2       freespecial6
	cancel 	0 99 0    a3       freespecial20
	cancel 	0 99 0    d u a    freespecial9
	loop	1
	delay	15
	offset	82 177
	bbox	66 64 35 116
        attackone 0
        hitfx   data/sounds/empty.wav
        grabin  1 -50
        forcedirection -1
        attack6  70 153 23 26 0 0 1 1 0   
	frame	data/chars/midas/wg1.png
	frame	data/chars/midas/wg2.png
	frame	data/chars/midas/wg3.png
	frame	data/chars/midas/wg4.png
	frame	data/chars/midas/wg5.png
	frame	data/chars/midas/wg6.png

anim follow2
	loop	0
	delay	1
	offset	82 177
	bbox	0 0 0 0
	frame	data/chars/midas/wg1.png
        @cmd    grabcheckW "ANI_FREESPECIAL15" "ANI_FREESPECIAL15" "ANI_FREESPECIAL24" "ANI_FREESPECIAL15"
	frame	data/chars/midas/wg1.png

Here the grabcheckW:
Code:
void grabcheckW(void Ani1, void Ani2, void Ani3, void Ani4)
{ // Hero's groundgrab checker
// This script prevents hero from grabbing Bosses with the incorrect animation.
//  Ani1 = Animation to play if enemie is BODYGUARD, DOMINATRIX, DOMINATRIXS, ETC.
 //  Ani2 = Animation to play if enemie is KIMOKAHN
//  Ani3 = Animation to play if enemy but not anyone on the mentioned characters
//  Ani4 = Animation to play if not enemy

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

    if(target!=NULL()){

      if(getentityproperty(target, "a") == 0){
        int Check = checkgrab2(target);

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

    }
}

void checkgrab2(void target)
{ // Opponent Checker
// This script checks hero's current opponent. If he/she/it is Simple Boss, returns 1, if he's Final Boss entity this function returns 0
// If he/she/it's just another enemy return 2, Otherwise it returns 3.

    if(getentityproperty(target, "type") == openborconstant("TYPE_ENEMY")){
      char Tname = getentityproperty(target, "defaultname");

      if(Tname == "KIMOKAHN" )
      { // Final Boss
        return 0;
      } else if(Tname == "BODYGUARD" || Tname == "DOMINATRIX" || Tname == "DOMINATRIXS" || Tname == "ESCORT" || Tname == "HUNTER" || Tname == "BALROG" ||
 Tname == "BOMBERMAN" || Tname == "BOMBERMANb" || Tname == "CHAINMAN" || Tname == "ZANGIEF" || Tname == "MADMAN" || Tname == "HEATMAN" || Tname == "SMASHER" ||
 Tname == "CAPTAIN_WOLF" || Tname == "CAP_WOLFb" )
      { // Special Bosses
        return 1;
      } else {
        return 2;
      }
    } else {
      return 3;
    }
}

The FREESPECIAL15 is the cancel animation:
Code:
anim freespecial15
#cancelgrab#
	loop	0
        landframe 3
	offset	82 177
	bbox	0 0 0 0
        sound   data/sounds/m5hm.wav
	delay	8
        @cmd    leaper -2 0.5 0
	frame	data/chars/midas/slab.png
	frame	data/chars/midas/sp02.png
	delay	999
	frame	data/chars/midas/grabsp01.png
        delay   12
	frame	data/chars/midas/grabsp01.png

If the cjeck is ok, the go to the follow24 and spawn the entity to grab the other enemy:
Code:
anim freespecial24
	loop	0
        fastattack 1
        attackone 1
	delay	1
	offset	82 177
	bbox	0 0 0 0
        @cmd    stop
        @cmd    cancelgrab
	frame	data/chars/midas/select.png
        sound    data/sounds/grab.wav
        @cmd    spawn01  "grabm" 10 0 0
	frame	data/chars/midas/select.png
        @cmd    slamstart
        @cmd    position 8 -45 25 1 1
	frame	data/chars/midas/select.png
	delay	4
        @cmd    antiwall -25 5 -1
        @cmd    position 8 -45 25 1 1
	frame	data/chars/midas/select.png
	delay	36
	frame	data/chars/midas/select.png
	delay	8
        @cmd    antiwall -25 5 -1
        @cmd    position 8 -40 60 1 1
	frame	data/chars/midas/special3.png
        @cmd    position 8 -20 65 1 0
	delay	4
	frame	data/chars/midas/mfat04.png
        @cmd    spawn01  "flash" 0 135 1
        @cmd    antiwall -25 15 -1
        @cmd    position 8 -20 65 1 0
	frame	data/chars/midas/mfat04.png
        sound   data/sounds/indirect.wav
        @cmd    depost 0
        @cmd    finish 30 1 -1 1 0 0
	frame	data/chars/midas/mfat04.png
	frame	data/chars/midas/mfat04.png
	delay	3
	frame	data/chars/midas/mfat04.png
	delay	9
	frame	data/chars/midas/special3.png
	delay	25
	frame	data/chars/midas/select.png

And here the entity:
Code:
name	grabm
health	1
nolife  1
type	none
hostile enemy obstacle
candamage enemy 
speed	0
nomove 1 1
noquake 1
shadow	0
remove 0


animationscript data/scripts/script.h 


anim idle

	loop	0
        fastattack 1
        attackone 1
	delay	1
	offset	30 13
        hitfx   data/sounds/empty.wav
        attack  30 0 29 27 0 0 1 1 0
	frame	data/chars/misc/empty.png
	attack  0 0 0 0
        @cmd    cancelgrab
	frame	data/chars/misc/empty.png
	delay	2
        @cmd    slamstart2
        @cmd    position 8 35 25 1 -1
	frame	data/chars/misc/empty.png
	delay	4
        @cmd    antiwall 20 5 -1 
        @cmd    position 8 35 25 1 -1
	frame	data/chars/misc/empty.png
	delay	36
	frame	data/chars/misc/empty.png
	delay	8
        @cmd    antiwall 20 5 -1 
        @cmd    position 8 30 60 1 -1
	frame	data/chars/misc/empty.png
        @cmd    position 8 15 65 1 -1
	delay	4
	frame	data/chars/misc/empty.png
        @cmd    antiwall 20 10 -1 
        @cmd    position 8 15 65 1 -1
	frame	data/chars/misc/empty.png
        @cmd    depost 0
        @cmd    finish 30 1 -1 1 0 0
	frame	data/chars/misc/empty.png
	delay   1
	frame	data/chars/misc/empty.png
        @cmd    killentity getlocalvar("self")
 	frame	data/chars/misc/empty.png



anim freespecial15
	loop	0
	delay   1
	frame	data/chars/misc/empty.png
        @cmd    killentity getlocalvar("self")
 	frame	data/chars/misc/empty.png

 
It seems that I found the error. Recently I changed the name of some enemies and forgot to update it in the checkgrab2.
I have done some tests now and everything seems to work correctly.
 
Back
Top Bottom