Wall damage script triggers in a strange way

NED

Well-known member
Hello,
My use of wall damage wall bounce edited script seems to cause problem.
This script triggers when a falling enemy is close to a wall (based on Magggas script)

It works perfectly, but the wall effect seems to triggers in an anwanted situation : when enemy falls from a particular custom slam.
Even when there is no wall around. I really don't understand why...
I used a debug sound to detect if the move is active. "0000debug.wav"
The problem never appears when enemy is killed by the actual slam move.

Any help is welcome.
Thanks


wall damage script

Code:
void walldam(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 (based on antiwall) envoie vers follow45
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   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 >= y)
   {
     changeentityproperty(self, "position", x, z-Distz);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }

   if(H >= y)
   {
     changeentityproperty(self, "position", x+Move);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }
}


wall damage anim

Code:
#-----------------WALL DAMAGE-----------------#wall damage

anim	follow45#basé sur regular fall (sans walldam script sans dam voice = remplacé par walldam snd) (avec jumpframe et spark)
      hitfx   data/sounds/indirect.wav
	loop	0
      jumpframe 0 2.7 1.4#0 2.6 1.2#0 3 2#0 2.5 -1.5#frame-Y-X-Z# for WALL DAMAGE
	landframe	2 dus
	forcedirection	1
	delay	15
      @cmd    spawn01 "flashshort" -36 64 1#x y z
	offset	96 177
	bbox	46 61 91 104
	attack	46 61 91 104 25 1 1 0 6 20
	sound	data/sounds/0000debug.wav#walldam.wav
     @cmd       spawnRandom "blu" -32 100 -1 40#30#25#x y z %de chance
	frame	data/chars/mex/fall1.gif
	bbox	38 84 124 73
	attack	38 84 124 73 25 1 1 0 6 20
	delay	300
     @cmd       spawnRandom "sweat" -32 100 -1 30#25#x y z %de chance
	frame	data/chars/mex/fall2.gif
	delay	40
	bbox	36 132 139 54
	attack	0 0 0 0
	sound	data/sounds/fall03.wav# new falls-246246
@cmd spawnDmg "bdrop" -55 6 3 0.1#0.99#--name x y z niv de life--
	frame	data/chars/mex/fall4.gif

#-----------------WALL DAMAGE-----------------#wall damage


exemple of fall anim that triggers wall damage anim on wall contact

Code:
anim fall

      followcond 1#-4#1#4#1#2
      followanim 45

      hitfx   data/sounds/indirect.wav
	loop	0
	landframe	2 dus
	forcedirection	1
	delay	15
	offset	96 177
	bbox	46 61 91 104
	attack	46 61 91 104 25 1 1 0 6 20
	sound	data/chars/mex/mex_dam1.wav
     @cmd       spawnRandom "blu" -32 100 -1 40#30#25#x y z %de chance
      @cmd    walldam -20 0 0
	frame	data/chars/mex/fall1.gif
	bbox	38 84 124 73
	attack	38 84 124 73 25 1 1 0 6 20
	delay	300
     @cmd       spawnRandom "sweat" -32 100 -1 30#25#x y z %de chance
      @cmd    walldam -20 0 0
	frame	data/chars/mex/fall2.gif
	delay	40
	bbox	36 132 139 54
	attack	0 0 0 0
	sound	data/sounds/fall03.wav# new falls-246246
@cmd spawnDmg "bdrop" -55 6 3 0.1#0.99#--name x y z niv de life--
	frame	data/chars/mex/fall4.gif


Last part of slam move from my player who causes problem.

Code:
...
	offset	100 177##shake +4
      delay	4#5
      @cmd    position 37 5 -1 0 -1#0
	frame	data/chars/rachel/supB19.gif#

	offset	94 177##shake -2
      delay	4#5
      @cmd    position 37 -1 -1 0 -1#0
	frame	data/chars/rachel/supB19.gif#

	offset	98 177##shake +2
      delay	4#5
      @cmd    position 37 3 -1 0 -1#0
	frame	data/chars/rachel/supB19.gif#

	offset	96 177
      delay	5#4#15#25#10#55#40
      @cmd    position 37 1 -1 0 -1#0
	frame	data/chars/rachel/supB19b.gif#

	offset	96 177
      delay	3#4#15#25#10#55#40
      @cmd    position 37 1 -1 0 -1#0
	frame	data/chars/rachel/supB19.gif#
	offset	96 177
      delay	5#4#15#25#10#55#40
      @cmd    position 37 1 -1 0 -1#0
	frame	data/chars/rachel/supB19b.gif#

	offset	96 177
      delay	3#5#*##50#45#55#40
      @cmd    position 37 1 -1 0 -1#0
	frame	data/chars/rachel/supB19.gif#

      delay	5#*##11#17#25#20
      @cmd    position 35 1 -1 0 -1#0
	frame	data/chars/rachel/supB20.gif

      delay	5#1#*##20#30#35#40#16
	frame	data/chars/rachel/supB99.gif#supB20.gif#supB99.gif

      delay	1
      @cmd    depost 0
      @cmd    finish 1 1 -1 3 0 -1#1#-1
	frame	data/chars/rachel/supB21.gif#supB20.gif#supB99.gif

      @cmd    anichange "ANI_FOLLOW10"

	frame	data/chars/rachel/supB99.gif#supB10.gif


Finish script I use for slams

Code:
void finish(int Damage, int Type, int x, int y, int z, int Face)
{ // Damage as slam or throw finisher
   void self = getlocalvar("self");
   void target = getlocalvar("Target" + self);
   int SDir = getentityproperty(target,"direction");
   int MDir;

   if(Face==0){ // Same facing?
       MDir = SDir;
   }

   if(Face==1){ // Opposite facing?

     if(SDir==0){ // Facing left?
       MDir = 1;
     } else { MDir = 0;}
   }

   if(target==NULL())
   {
     target = getentityproperty(self, "grabbing");
     setlocalvar("Target" + self, target);
   }
   if(target!=NULL())
   {
     int dir = getentityproperty(target,"direction"); //Get opponent's facing direction
     if(dir==0){ // Facing left?
       x = -x;
     }

     if(Type==1){
       damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL")); // 1st Finisher
     } else if(Type==2){
       damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL9")); // 2nd Finisher
     } else if(Type==3){
       damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL2")); // 3rd Finisher
     } else if(Type==4){
       damageentity(target, self, Damage, 1, openborconstant("ATK_NORMAL34")); // 4th Finisher
       changeentityproperty(target, "staydown", "rise", -300);
     }

     tossentity(target, y, x, z); // Toss opponent ;)
     changeentityproperty(target, "direction", MDir);
   }
}
 
Hmmm... I think you need to fix your walldam function

Code:
void walldam(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 (based on antiwall) envoie vers follow45
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   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 > y)
   {
     changeentityproperty(self, "position", x, z-Distz);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }

   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }
}

FYI checkwall function returns 0 if it doesn't find any wall on defined coordinates. This could cause the function to be run if the function is run when entity is exactly on ground even when there were no wall at all. Therefore I removed = to ensure that the detected wall must be higher than entity's altitude

BTW antiwall checks and moves entity twice if it find wall at back and left/right. This edited function will do checks twice too meaning the animation change will occur if the wall is at back instead of left/right. Is this what you want?
 
I used your updated script.
I completely understand the logic of it.
It wasn't not changing anything first.

But I finally edited the last  "@cmd position" before the depost to a higher Y value
-1 changed to 1
Code:
@cmd    position 35 1 1 0 -1
And it finally works.

About wall facing or not facing edit.
I'm not really sure for the moment.
I might make the wall bounce too for some slam fall anims
And sometimes entity might be facing the wall when falling... so...


Anyway. thanks a LOT for helping me fixing it out, BB!
 
Back
Top Bottom