force attack only the front of the player helps

monomartin

Active member
hello continued with this problem, I manage not force a single enemy attack against my player , I want to avoid is to attack me from behind, if anyone can help me , if they know a script to make the enemy to a certain distance is forced to come face to face with the player and then attack him
http://www.subeimagenes.com/img/ejemplo-1424896.html
ejemplo-1424896.GIF

ejemplo-1424896.html
 
hi sorry for my bad English . I need help , I have solved the whole system of grip, I only need to force the enemy to attack ahead in making grip, and thought to modify this script , but I do not, someone can give me a hand . this has delayed me for months, and could not complete the game to share with you .


void riseattack3(int Rx, int Rz, void Ani)
{// Riseattack with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int Dir = getentityproperty(self,"direction");
    int TDir = getentityproperty(target,"direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;

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

      if( Disx <= Rx && Disz <= Rz && Dir == TDir) // Target within range?
      {
        changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
      }
    }
}

[attachment deleted by admin]
 
monomartin said:
hi sorry for my bad English . I need help , I have solved the whole system of grip, I only need to force the enemy to attack ahead in making grip, and thought to modify this script , but I do not, someone can give me a hand . this has delayed me for months, and could not complete the game to share with you .


void riseattack3(int Rx, int Rz, void Ani)
{// Riseattack with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int Dir = getentityproperty(self,"direction");
    int TDir = getentityproperty(target,"direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;

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

      if( Disx <= Rx && Disz <= Rz && Dir == TDir) // Target within range?
      {
        changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
      }
    }
}

I can help you but I need to know more infos:
1) riseattack3() is for player or enemy?
2) what do you want to make with a anim change?
3) what event you want to call riseattack3() for (script, animationscript, etc...)?

Ps. How do you have solved the hold grab? For my method I've worked 3 days  :'(
 
White Dragon hello thank you very much for the help, is something that has me blocked , this prblem , I have the whole system back gripping resolved. I just need another enemy force attacking from the front of the grip. modofocar try riseattack3 for enemies . without success , basically what I want is that williams attack me only from the front rather than back when I grab Roper.
I force attack williams this:  @cmd finisher2 "ANI_grabbed" "ANI_follow19" 39 40 1 2 0

name Williams
health 80
speed 6
type enemy
escapehits        2
gfxshadow 1
diesound data/sounds/die1.wav
dust  dust
paingrab 1
icon data/chars/williams/icon.gif
noquake 1
aimove Chase
aggression 80
throw    1.2 3.1
jumpheight 3
grabdistance 45
subject_to_wall 1
subject_to_hole 1
subject_to_obstacle 0
subject_to_platform 1
no_adjust_base 0
subject_to_screen 0
falldie 1
hostile player
candamage player


anim attack1

range  19 20
      rangez 0 1
#rangea  0 49
loop 0
delay 12
offset 62 133
bbox 61 80 11 33

@cmd finisher2 "ANI_grabbed" "ANI_follow20" 18 21 1 2 0
frame data/chars/williams/a201.gif
delay  8
bbox  62  76  16  30
attack12  74  87  22  8  10  0  0  0  0  12

@cmd finisher2 "ANI_grabbed" "ANI_follow20" 18 21 1 2 0

frame data/chars/williams/a202.gif
        attack  0 0 0 0 0
delay  18
@cmd finisher2 "ANI_grabbed" "ANI_follow20" 18 21 1 2 0

frame data/chars/williams/a203.gif
bbox  63  80  9  33
delay  15

frame  data/chars/williams/a203x.gif
        attack4  76 86 20 6 7  0  0  0  0  5
bbox  62  82  20  35
delay  8

frame data/chars/williams/a204.gif
attack  0 0 0 0 0
delay  18
bbox  62  77  11  31

frame data/chars/williams/a205.gif
delay  12

frame data/chars/williams/a201.gif
        attack3  80 88 15 3 8 1  0  0  0  10
delay  8
bbox  64  77  14  28

frame data/chars/williams/a202.gif
        attack  0 0 0 0 0
        delay  25
bbox  64  77  12  35
frame data/chars/williams/a203.gif

[attachment deleted by admin]
 
I tried to do with the script is that . a certain range "x range "
check if Williams is behind taking hold and if it is , walk up position in front of the decision made ​​by Roper grip to attack.
 
[hello magggas clear is just what the video shows, the entire system of grip back and I have done and working, I only need williams force at that time only attack the front of the grip
 
Ok, try this one..
I wrote this func untesting it... (missing time)

Code:
void riseattack3(void self, float rangex_min, float rangex_max, float rangez_min, float rangez_max, char atk_anim_name) { // Riseattack with range check
    void target = findtarget(self); // locked opponent
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self,"direction");

    if( target != NULL() && getentityproperty(target,"exists") ){
      float speed = getentityproperty(self,"speed");
      int tdir = getentityproperty(target,"direction");
      float tx = getentityproperty(target, "x");
      float tz = getentityproperty(target, "z");
      int tanim_id = getentityproperty(target,"animationid");
      int xfact = 1, zfact = 1;
      float t_dist = 12;

      // to fix the direction range
      if ( x < tx ) xfact *= -1;
      else {
	float tmp;
	tmp = rangex_min;
	rangex_min = rangex_max;
	rangex_max = tmp;
      }
      if ( z < tz ) zfact *= -1;
      else {
	float tmp;
	tmp = rangez_min;
	rangez_min = rangez_max;
	rangez_max = tmp;
      }

      if( tanim_id == openborconstant("ANI_GRABBED") ) {
	 if ( x >= tx+xfact*rangex_max && x <= tx+xfact*rangex_min && z >= tz+zfact*rangez_max && z <= tx+zfact*rangez_min ) {
		if ( tdir && x < tx+t_dist ) {
			changeentityproperty(self,"velocity",speed,NULL(),NULL());
		} else if ( !tdir && x > tx+t_dist ) {
			changeentityproperty(self,"velocity",-1*speed,NULL(),NULL());
		} else {
			changeentityproperty(self,"direction",!tdir);
			performattack(self,openborconstant(atk_anim_name),1);
		}
	 }

      } 
    }
}
 
White Dragon hello , but I'm trying script closes and sends me to the desktop . I think I'm misusing the script , do not understand the following,
atk_anim_name char ) ???? This part confuses me . you prune give me an example of use. Thank you very much for your help
 
write this one in a file called enemy_atk.c
and copy:
Code:
void main() {
  void self = getlocalvar("self");

  attack_grabbed_player(self,-80,80,-40,40,"ANI_FOLLOW20",12);
}

void attack_grabbed_player(void self, float rangex_min, float rangex_max, float rangez_min, float rangez_max, char atk_anim_name, int t_dist) {
    void target = findtarget(self); // locked opponent
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self,"direction");

    if( target != NULL() && getentityproperty(target,"exists") ){
      int anim_id = getentityproperty(self,"animationid");
      float speed = getentityproperty(self,"speed");
      int tdir = getentityproperty(target,"direction");
      float tx = getentityproperty(target, "x");
      float tz = getentityproperty(target, "z");
      int tanim_id = getentityproperty(target,"animationid");
      int xfact = 1, zfact = 1;

      if ( t_dist == NULL() ) t_dist = 12;

      // to fix the direction range
      if ( x < tx ) xfact *= -1;
      else {
	float tmp;
	tmp = rangex_min;
	rangex_min = rangex_max;
	rangex_max = tmp;
      }
      if ( z < tz ) zfact *= -1;
      else {
	float tmp;
	tmp = rangez_min;
	rangez_min = rangez_max;
	rangez_max = tmp;
      }

      if( tanim_id == openborconstant("ANI_GRABBED") ) {
	 if ( x >= tx+xfact*rangex_max && x <= tx+xfact*rangex_min && z >= tz+zfact*rangez_max && z <= tx+zfact*rangez_min ) {
		if ( tdir && x < tx+t_dist ) {
			if ( anim_id != openborconstant("ANI_WALK") ) changeentityproperty(self,"animation",openborconstant("ANI_WALK"));
			changeentityproperty(self,"velocity",speed,NULL(),NULL());
		} else if ( !tdir && x > tx+t_dist ) {
			if ( anim_id != openborconstant("ANI_WALK") ) changeentityproperty(self,"animation",openborconstant("ANI_WALK"));
			changeentityproperty(self,"velocity",-1*speed,NULL(),NULL());
		} else {
			changeentityproperty(self,"direction",!tdir);
			performattack(self,openborconstant(atk_anim_name),1);
		}
	 }

      } 
    }
}

then in enemy.txt entity write
script enemy_atk.c
or
animationscript enemy_atk.c
 
White Dragon many works perfect !!! thank you very much , it is helpful , months ago I'm with this problem and could not find the solution , thank you very much for your help and speed of your response .. I am at your service as you can help , thank you very much friend !!!!
 
monomartin said:
White Dragon many works perfect !!! thank you very much , it is helpful , months ago I'm with this problem and could not find the solution , thank you very much for your help and speed of your response .. I am at your service as you can help , thank you very much friend !!!!

;) ;) ;) ;) ;) ;) ;)
 
White Dragon hello found a script fails . It works fine, but when you add the attack or the desktop will follow . I tried it on my mod and the DDMini and the problem is the same, any suggestions .

attack_grabbed_player(self,-80,80,-40,40,"ANI_FOLLOW20",12);    ---- Here the problem arises
 
Back
Top Bottom