* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 15, 2017, 10:35:24 PM

Login with username, password and session length

[SOLVED] Blast vs knockdowncount bug

  • 23 Replies
  • 1392 Views
*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
[SOLVED] Blast vs knockdowncount bug
« on: August 06, 2017, 11:32:38 PM »
EDIT: Bloodbane found the solution. It's not a bug with versus damage, but with "blast" against knockdown count. The solution is here: http://www.chronocrash.com/forum/index.php?topic=3482.msg48043#msg48043

Guys, I am having a strange bug on my game and I need to check if its a coding bug or an engine bug.
There is an issue which let one player hit the other.

See the video bellow  - right after Tiger Shark (enemy) hits Hulk (p2), Hulk can hit Red Hulk (p1) - and you can confirm by looking at the enemy life bar at top left. After Hulk knocksdown the enemy, everything returns to normal:


I've double checked everything:
- Versus damage is disabled
- Candamage of all characters are ok

Any clue of what could be happening? It's a so serious bug that If I can't fix it, I will cancel the project because it simply ruins everything.

I really would like to have some help here.
Thanks.
« Last Edit: August 15, 2017, 03:35:38 PM by O Ilusionista »

*

Offline Damon Caskey

  • Administrator
  • Hero Member
  • *****
  • 1809
    • DC Current
Re: Versus Damage Bug?
« Reply #1 on: August 07, 2017, 10:10:47 AM »
Vs. damage hasn't been changed in years, so while it could be an engine bug, it's more likely to be a well hidden script conflict. What scripts are running at that time? Is there anything special about the stage? Anything that controls grappling, flashes, etc.? When a weird issue like this strikes, I have two main approaches. Neither are fun.

1. Start logging everything. Fill your scripts up with log(), so that you have a print out of virtually every variable and condition going on. For instance, the candamage variable before, during, and after hit would tell a lot. This can help even if your module doesn't have much script at all.

2. For very heavily scripted issues, I'd start disabling the the most likely culprit scripts and keep going until the problem stops. When it does stop, then I re-enable bits of the script one at a time until I can identify where the problem is at. If we get to a point there's no script running and the problem is still occurring, then it may be an engine bug.

Sometimes it takes a combination of both. It's a lot of tedium, but I'm afraid that's pretty much the only way to ferret out these sorts of things.

DC
« Last Edit: August 07, 2017, 10:20:14 AM by Damon Caskey »
Projects in progress are now available here: https://github.com/DCurrent

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #2 on: August 07, 2017, 10:33:32 PM »
Thanks. I suspect its something related to Plombo's import truck. Since I've started to use it, I noticed some issues - for example, there is something with random().

I remember I´ve changed the takedamagescript to that trick:

Code: [Select]
#import "data/scripts/blinkhulk_actual.c"

void main()
{
    actual_main();
}

And it imports the actual file:
Code: [Select]
void actual_main()
{// Blink effect script + avoid palette change against freeze
    void self = getlocalvar("self"); //Get calling entity.
    void Health = getentityproperty(self,"health");
int Type = getlocalvar("attacktype");

if(Type != openborconstant("ATK_NORMAL4")){
if(Type != openborconstant("ATK_FREEZE")){
if (Health > 0){

changeentityproperty(self, "colourmap", 6);
changeentityproperty(self, "maptime", 20 + openborvariant("elapsed_time"));

}
}
}

}

But I am sure this happens even on characters without it.

I will see what I can do. Thanks.

*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #3 on: August 08, 2017, 03:48:22 PM »
Hmm, I don't see anything in that script that should behave differently after applying the import trick. Can you be more specific about what's going on with random(), though? That sounds interesting.
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #4 on: August 10, 2017, 02:36:07 PM »
Hi Plombo, I was going to contact you about your trick.
If you try my game (http://gamejolt.com/games/avengers-united-battle-force/14591) you will notice somethings. It will be a long reply so sorry for that (and for my crap english):

1- I have a file with codes from other people (DC, BB, uTunnels, WD, etc) and a file called ilu.h, where I put all my codes. This helps me better tracking of what I do.

The animationscript file is called grabscript.c where I was using
Code: [Select]
#include "data/scripts/ilu.h"
#import  "data/scripts/library/ani0020.h"
#import "data/scripts/randsound.c"
#import "data/scripts/grabscript_actual.c"

The 1st is my library, the 2nd is a DC library (works ok), the 3rd has some random codes (talk more about this later) and the actual main animationscript file - grabscript_actual.c. Notice that I use INCLUDE and not IMPORT (talk more about this later too).

in the grabscript_actual.c I was calling those files:
Code: [Select]
#include "data/scripts/ilu.h"
#import  "data/scripts/library/ani0020.h"

I know I was stupid for calling the same file two times (I was testing the import/include and I forgot to remove). If I tried to IMPORT ilu.h, the log says it can't find a script inside grascript_actual.c (and I dont understand why.) and everytime I call a function from randsound, it says It can't find that script too. If I change to INLCUDE, it works - but It won't use that trick and will consume more RAM that it should (around 140MB).

The randsound.c has simply random sound scripts like this, nothing too fancy:

Code: [Select]
void randSound0(char s1,char s2)
{
   int r = rand()%100;
   char sound;
   if (r<=0)
   {
      sound=s1;
   }else{
      sound=s2;
   }
   playSound("data/"+sound);
}

void playSound(void file)
{
   if(!file||file==""){return;}else{}
   int sfx=loadsample(file);
   playsample(sfx, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
}

2- So I had to stick with INCLUDE. But right after I use your trick, some rand() based functions started to act very strangely, suffering a lot from the First Frame Bug.

I can give an example (you will need to download my game to see it):
- Pick Hulk, go to any stage and press the SPECIAL button. You will see some effects ("crack", on the floor and "stompfx" which is an impact effect). "stompfx" calls some random debris (debris1, debris2, debris3 and debris4) on the screen. now pay attention to those debris - you will see that some are called from here Hulk is and some are called...from the edge of the screen.

Here is the stompfx file:

Quote
name stompfx
type   none
shadow   0
Antigravity 100
lifespan 0.24

palette data/chars/misc/stompfx/pal.png

animationscript data/scripts/grabscript.c

load debris1
load debris2
load debris3
load debris4

anim   idle
   loop   0
   delay   6
   offset   80 45
   sound   data/sounds/bigland.wav
   quakeframe   0 2 20
   @cmd   spawnRandEnt "debris1" "debris2" "debris3" "debris4" 0 0 0
   @cmd   spawnRandEnt "debris1" "debris2" "debris3" "debris4" 0 0 0
   frame   data/chars/misc/stompfx/stomp_4771-0.png

   offset   88 57
   @cmd   spawnRandEnt "debris1" "debris2" "debris3" "debris4" 0 0 0
   @cmd   spawnRandEnt "debris1" "debris2" "debris3" "debris4" 0 0 0
   frame   data/chars/misc/stompfx/stomp_4771-1.png
   offset   94 56
   frame   data/chars/misc/stompfx/stomp_4771-2.png
   offset   102 59
   frame   data/chars/misc/stompfx/stomp_4771-3.png

Pay attention that I am calling my custom function on the first frame, using this code
Code: [Select]
void spawnRandEnt(void vName1,void vName2,void vName3,void vName4,int vx, int vy, int vz )
// Spawn Random entities at random places
// 03/02/2014 - Douglas Baldan - O Ilusionista
{
// int Xr = rand()%vx; // Random X pos
// int Yr = rand()%vy; // Random Y pos
// int Zr = rand()%vz; // Random Z pos

int Sr = rand()%4+4;

if(Sr == 0){
        spawn000(vName1,vx,vy,vz);
       }
   
else if(Sr == 1){
        spawn000(vName2,vx,vy,vz);
       }
else if(Sr == 2){
        spawn000(vName3,vx,vy,vz);
       }
else {
        spawn000(vName4,vx,vy,vz);
       }

}
"spawn000" is just DC's spawn01 function without direction.
How I solved this? I just changed the code to the second frame...and it works. This wasn't needed before I changed to the IMPORT trick.

Right now, I am using a combined file (which has "grabscript_actual" + "ilu.h") to reduce the RAM usage, using IMPORT
Code: [Select]
#import  "data/scripts/library/ani0020.h"
#import "data/scripts/grabscript_complete.c"

And it works. But I still would need my ilu.h file splited into a separated file. If I remove my code from that file and use
Code: [Select]
#import "data/scripts/ilu.h"The engine returns the error:
Quote
Script compile error: can't find function 'spawn01'

Script compile error in 'data/scripts/ilu.h': spawn01 line 784, column 0
Script error: failed to import 'data/scripts/ilu.h': failed to compile
Script error: failed to import 'data/scripts/grabscript_complete.c': failed to compile
Which doesn't makes sense, since "spawn01" function is inside the grabscript_complete.c file...

Any help would be good.
PS: sorry if I made any noob mistake. I am trying to learn so if I did something wrong, please point me to the best solution. I am totally open to feedback.
« Last Edit: August 10, 2017, 02:58:38 PM by O Ilusionista »

*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #5 on: August 10, 2017, 02:59:22 PM »
Thanks for that very detailed explanation! It looks like I'll need to download your game and mess around with it myself to figure out what's going on.
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #6 on: August 10, 2017, 03:00:38 PM »
PLEASE. I would love to.

*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #7 on: August 10, 2017, 04:15:43 PM »
I do have one question first. It's been a while since I last wrote a script using rand(), but this line of your spawnRandEnt function looks strange:

Code: [Select]
int Sr = rand()%4+4;
Does this not give Sr a value between 1 and 7, inclusive? The code below looks like it expects Sr to be between 0 and 3, inclusive.

This might not be enough to cause the "first frame issue", it's just something that jumped out at me.
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #8 on: August 10, 2017, 04:36:35 PM »
As far as I know, rand() in C includes the negative values, so it will output a random number from -4 to 4

First Frame Bug isn't caused by my code - its a long term bug in OpenBOR. Search for this phrase here and you will see people talking about it since long time (afaik, since Lavalit era).

*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #9 on: August 10, 2017, 09:02:22 PM »
As far as I know, rand() in C includes the negative values, so it will output a random number from -4 to 4

Yes, rand() can return negative values, but:

rand() -> integer in the range [-231, 231-1]
rand() % 4 -> range [-3, 0] if random number is negative, range [0, 3] if number is positive -> range [-3, 3] overall
rand() % 4 + 4 -> range [-3 + 4, 3 + 4] = range [1, 7]

First Frame Bug isn't caused by my code - its a long term bug in OpenBOR. Search for this phrase here and you will see people talking about it since long time (afaik, since Lavalit era).

*slams head into desk*

...How on earth did I forget about that?
« Last Edit: August 10, 2017, 09:07:30 PM by Plombo »
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #10 on: August 10, 2017, 09:16:38 PM »
Quote
rand() % 4 + 4 -> range [-3 + 4, 3 + 4] = range [1, 7]
You are right on this one. Most of times, I simply multiply the value to -1 if I want a positive value (do OpenBOR scripts support ABS?). But I got this from someone's code (I think it was mtrain) to make the values positive.



*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #11 on: August 10, 2017, 09:54:31 PM »
I don't think there's an "abs" builtin function in OpenBOR, but it's not hard to write one yourself:

Code: [Select]
int abs(int x)
{
    if (x < 0) return -x;
    else return x;
}

But yeah, modulo+addition is not the way to go for clamping random numbers to a range. Best to use either an abs function like the one above, or the fancier one-line method of int Sr = (rand() & 0x7fffffff) % 4 to safely get a random number in the range [0, 3].
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #12 on: August 10, 2017, 10:00:00 PM »
Bitwise? Cool. 0x7fffffff stand for 2,147,483,647 right? Its the top most virtual address?

Here is the way I use
Code: [Select]
     if (Yr <0){ // If the Y is negative,
Yr = Yr*-1; // Make it positive
      }

*

Offline Plombo

  • Administrator
  • Sr. Member
  • *****
  • 404
Re: Versus Damage Bug?
« Reply #13 on: August 10, 2017, 11:05:28 PM »
Bitwise? Cool. 0x7fffffff stand for 2,147,483,647 right? Its the top most virtual address?

The relation to virtual memory is actually a coincidence. 0x7fffffff is the 32-bit number with all of the bits except the highest one set to 1. Computers represent negative numbers using two's complement format, where the highest bit is set to 1 for negative numbers and to 0 for positive numbers. So doing a bitwise AND with 0x7fffffff forces the number's "negative flag" to off.

It's worth noting that (x & 0x7fffffff) is not the same as the absolute value of x, but it's good for making a random number non-negative.

Quote
Here is the way I use
Code: [Select]
     if (Yr <0){ // If the Y is negative,
Yr = Yr*-1; // Make it positive
      }

Yeah, that'll do it. I think the negation operator is a bit prettier than multiplying by -1, but both will do the same thing.
I now have a Twitter that you can follow if you like.

If my reply to you seems needlessly terse, I probably typed it from my phone. I'm not trying to be rude.

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 5050
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Versus Damage Bug?
« Reply #14 on: August 11, 2017, 08:58:49 PM »
Bloodbane found what is going on. And yes, its an engine bug:

 This bug is best named knockdowncount vs blast bug instead of versus damage bug cause that's what actually happened
 Some of Tigershark's attacks use blast which knocks down opponent and activate projectile status of the opponent. Projectile status is when knocked down entity hits other entity while falling. This status is usually resetted when that entity lands on ground after falling. However against characters with knockdowncount aka knockdown immunity, there's a conflict i.e engine applies the projectile status when blast hits them even though they aren't knocked down. This causes that status to remain and allowed Hulk to hit Red Hulk and vice versa

 There are multiple solutions for this:
1. Change enemy's blast to regular attack + dropv. I don't see attackbox in Avengers' FALL
animation so this won't be a problem ;)
2. Set projectilehit enemy obstacle in all Avengers header text. That command controls which entity type which can be hit during projectile status
3. Add a line in blinkhulk_actual.c like this:

Code: [Select]
void actual_main()
{// Blink effect script + avoid palette change against freeze
    void self = getlocalvar("self"); //Get calling entity.
    void Health = getentityproperty(self,"health");
int Type = getlocalvar("attacktype");

if(Type != openborconstant("ATK_NORMAL4")){
if(Type != openborconstant("ATK_FREEZE")){
if (Health > 0){

changeentityproperty(self, "colourmap", 6);
changeentityproperty(self, "maptime", 20 + openborvariant("elapsed_time"));
changeentityproperty(self, "projectile", 0); // added line

}
}
}

}

 The added line cancels projectile status when Hulks are hit
 (Still, I think this is engine bug which should be fixed)

I remember that someone, long time ago (back to the Lavalit era), said that "blast" had some strange issues. And a friend of mine, Lagarto, confirmed that this issue happens - at least - since 2009.

Thanks for the help everyone.
« Last Edit: August 11, 2017, 09:01:10 PM by O Ilusionista »

 

Recent

Members
Stats
  • Total Posts: 47530
  • Total Topics: 3262
  • Online Today: 49
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 1
Guests: 21
Total: 22