How to grab enemy from back script?

For this, I highly recommend having custom scripted grab system before having grabbing from back
I have function to grab enemy from behind but after enemy is grabbed, player immediately enters backstab animation so there's no control until the move is done
I'll share it if you want to but I'm thinking that you actually want to be able to backgrab like in SoR series
 
O Ilusionista said:
backstab animation
Backstab?

I think BB says the script automatically send player to a custom slam.
There is no actual back grabbing system.
But, it still can be simulated.
If only I knew it when I created the roots of my game system. ???
 
Rear grabs are certainly doable, but AKAIK no one has crafted a complete system. The auto back-stab animation is a very good start though; you should be able to build upon that to get what you want. Really it just boils down to direction checking to decide what to do and a little positioning math for the binding.

DC
 
nedflandeurse said:
I think BB says the script automatically send player to a custom slam.
There is no actual back grabbing system.
But, it still can be simulated.
If only I knew it when I created the roots of my game system. ???

I know there is a "blockback", but not "backpain" right from the core. Its doable via script.

Really it just boils down to direction checking to decide what to do and a little positioning math for the binding.

Yes, its just a matter to check the self and damagetaker facing.
(and oh my, I forgot to add didhitscript to the manual...)
 
Bloodbane said:
For this, I highly recommend having custom scripted grab system before having grabbing from back
I have function to grab enemy from behind but after enemy is grabbed, player immediately enters backstab animation so there's no control until the move is done
I'll share it if you want to but I'm thinking that you actually want to be able to backgrab like in SoR series

To be honest, I don't know how to script very well. I understand the logic of scripting but I can't find good references and explanations on openbor scripting.  But I'll appreciate you sharing your code with me. At least I can try to mess around with it.

I was just thinking of having a script that changes grabbed enemy direction if grabbed during turn animation. I guess that wouldn't work?

Also, I'm having a problem with enemies going on top of walls when slammed right next to a wall. I tried antiwall script but maybe I'm using it wrong.
 
I think BB says the script automatically send player to a custom slam.
There is no actual back grabbing system.

Ah yes,  :-[ thanks for the clarification. I'm not sure what player will immediately do after grabbing from back so I just choose backstab as I've implemented in D&D mod we're working on

But you are correct about backpain, it's one reason why I recommended scripting custom grab system

I was just thinking of having a script that changes grabbed enemy direction if grabbed during turn animation. I guess that wouldn't work?

No. I once grabbed enemy from back using old OpenBoR in Crime Buster mod and as soon as grab started, grabbed enemy changes facing direction to hero's

I'm having a problem with enemies going on top of walls when slammed right next to a wall. I tried antiwall script but maybe I'm using it wrong.

You have to declare antiwall with proper values BEFORE releasing the grabbed enemy. Can we see your problematic slam animation?
 
Here is how I applied the code.
Code:
anim	grabbackward
	attackone	0
	loop	0
	offset	100 149
	sound	data/sounds/
	delay	30
	@cmd	slamstart
	 @cmd    antiwall -25 30 -1
	@cmd	position 0 5 20 0 -1
	flipframe	1
	frame	data/chars/norton/athrow1.gif
	 @cmd    antiwall -25 30 -1
	@cmd	position 1 5 40 0 1
	delay	15
	frame	data/chars/norton/throw2.gif
	 @cmd    antiwall -25 30 -1
	@cmd	position 2 50 30 0 1
	delay	15
	sound	data/sounds/punch1.wav
	frame	data/chars/norton/throw2.gif
	@cmd	depost 0
	@cmd	throw 15 3 1 2 0 0
	@cmd	clearL
	frame	data/chars/norton/throw2.gif

Can you send me the backstab script?

 
You set antiwall wrong, that's why it didn't work
You should pick 2nd parameter of last declared position function as reference
Example:

The last declared position is

@cmd position 2 50 30 0 1

So your antiwall function should be set like this:

@cmd antiwall 50 -50 1

or if you declare it twice, each should be like this:

@cmd antiwall 25 -25 1

@cmd antiwall 25 -25 1

HTH

Oh yes, backstab function I used in D&D mod is slightly complex than this (I removed couple unnecessary things):

Code:
void backstabber(void Ani , int RxMin, int RxMax, int Rz, int Flag)
{// Checks closest enemy's animation & range for Shannon's backstab
// If it's accepted, change animation
// Ani   : Animation to change to
// RxMin : Minimum x range
// RxMax : Maximum x range
// Rz    : z range
// Flag  : 0 = facing direction not necessary, 1 = facing direction must same, -1 = facing direction must be opposite

/*Originally smartbomb by
    Damon Vaughn Caskey
    07152008*/

    void self = getlocalvar("self");			//Caller.
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iType;                                         //Entity type.
    int  iMax      = openborvariant("ent_max");         //Entity count.
    int iHP;

     //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iType   = getentityproperty(vEntity, "type"); //Get target type.
      iHP   = getentityproperty(vEntity, "health"); //Get health

      //Enemy type?
      if (iType == openborconstant("TYPE_ENEMY") && iHP > 0){
        float Tx = getentityproperty(vEntity, "x");
	float Tz = getentityproperty(vEntity, "z");
        int Edir = getentityproperty(vEntity, "direction");

        float Disx = Tx - x;
        float Disz = Tz - z;

        if(Disz < 0){
          Disz = -Disz;
        }

        if(Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1){
          if((Flag == 1 && Edir == 1) || Flag == 0){
            changeentityproperty(self, "opponent", vEntity);
            performattack(self, openborconstant(Ani));
          }
     } else if(Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0){
          if((Flag == 1 && Edir == 0) || Flag == 0){
            changeentityproperty(self, "opponent", vEntity);
            performattack(self, openborconstant(Ani));
          }
        }
      }
    }
}

I should mention that this function only checks if player is qualified for backstab. The scripts for backstab, suplex etc are declared in the animation to change to

Usage example is:

anim attack1
(offset, bbox etc)
@cmd backstab "ANI_FOLLOW2" 0 25 10 1
frame ...

In this example, when player performs attack, the script will check if player is behind enemy or not. If he/she is, animation will be changed to FOLLOW2
 
Sorry for the late response, I got the antiwall script to work now. Can you tell me what each parameter means?  Thanks for the backstab script. I'll try messing around with it.
 
Let's review the code:

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 z = getentityproperty(self, "z");
   float H;
   float Hz;

   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);

   if(Hz > 0)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }

   if(H > 0)
   {
     changeentityproperty(self, "position", x+Move);
   }
}

The first parameter is checking distance. If you set 50, you are checking if there's any wall 50 pixels in front of character. Negative value is accepted to check walls behind character
2nd parameter defines how far character will be moved IF wall is found in checked distance. Normally the set value for this is the negative of value set in 1st parameter. However if checked distance is too big such as 50 or 80, character will be moved that much instantly by this function. So to smoothen the 'movement', antiwall is declared multiple times.

Example:

@cmd antiwall 80 -80 1
frame ...

is not good due to instant 80 pixel jump so it's broken into 4 functions like this:

@cmd antiwall 80 -20 1
frame ...
@cmd antiwall 80 -20 1
frame ...
@cmd antiwall 80 -20 1
frame ...
@cmd antiwall 80 -20 1
frame ...

The last parameter is checking distance for z axis. Unlike the previous parameters, it also defines moved distance if wall is found in checked z distance

HTH
 
Thanks. That's exactly what I needed to know.

I tried using your backstab script but it crashes. Is it an animation script?
 
It is a function to be added in animation script you are using
As for crash, how exactly you use this function and what did log say? (the real error message is somewhere above end line so you need to look for it)
 
You mean:
grabflip {value}

~This command sets how grabber faces grabbed target
1 = Grabber will flip to face target
2 = Target will flip to face grabber
3 = Combination of 1 & 2 (default)
~Use this together with grab ability of course

Could be if you're using default, but again as BB said, a custom grab&throw system is recommended. The default grab&throw is not as flexible as it seems.
 
grabflip {value}

~This command sets how grabber faces grabbed target
1 = Grabber will flip to face target
2 = Target will flip to face grabber
3 = Combination of 1 & 2 (default)
~Use this together with grab ability of course


THANK YOU! That is exactly what I'm looking for! I tested it when the enemy does an attack that leaves them open, I grabbed them from behind. Now is their a way to make the enemy turn a little slower?

Bloodbane said:
It is a function to be added in animation script you are using
As for crash, how exactly you use this function and what did log say? (the real error message is somewhere above end line so you need to look for it)

I solved it. It was because I put backstab instead of backstabber in the command.
 
Joshiro said:
Now is their a way to make the enemy turn a little slower?

That's where a custom grab and throw comes in. The enemy by default would use the pain animation to stop whenever they are grabbed and the flip is instantaneous. With a custom grab and throw, you would have the option to let the character use another animation to turn and then another to stop.

Not that I want to discourage, but that's mostly the recommended approach if you were to have more than you want, even the guys here suggest that.
 
I meant when the enemy turns around to face the player after the player goes to other side of them. Not when you grab them. I tried using turn animation and turn delay but it didn't seem like it did anything.
 
Back
Top Bottom