Solved I have a question about displaying damage numbers.

Question that is answered or resolved.

DD Tokki

Well-known member
C:
void number()
{
   void self = getlocalvar("self");
   void f;
   int damage = getlocalvar("damage");
   int x, z, a, t;
   int atkType    = getlocalvar("attacktype");
   if(damage > 0 && atkType != openborconstant("ATK_TIMEOVER"))
   {
      x = getentityproperty(self, "x")+4;
      z = getentityproperty(self, "z")+1;
      a = getentityproperty(self, "a")+40;
      setspawnentry("name", "number");
      while(damage)
      {
         t = damage % 10;
         f = spawn();
         changeentityproperty(f, "position", x,z,a);
         updateframe(f, t);
         damage/=10;
         x -= 8;
      }
   }
}


This is the script I'm currently using in my game.
When you deal damage to an enemy, a numerical graphic appears.
It's a style from the Kunio-kun series.
However, I have a question.
This script doesn't display the numbers when the enemy's health is depleted.
If the attack is done in a different way (like Grab), the calculation stops as soon as it reaches 0.
If an attack with 300 damage reaches 0, it won't even display 100.
I'm wondering if it's possible to display the damage until the attack ends, even after health reaches 0.
 
Last edited:
C:
void number()
{
   void self = getlocalvar("self");
   void f;
   int damage = getlocalvar("damage");
   int x, z, a, t;
   int atkType    = getlocalvar("attacktype");
   if(damage > 0 && atkType != openborconstant("ATK_TIMEOVER"))
   {
      x = getentityproperty(self, "x")+4;
      z = getentityproperty(self, "z")+1;
      a = getentityproperty(self, "a")+40;
      setspawnentry("name", "number");
      while(damage)
      {
         t = damage % 10;
         f = spawn();
         changeentityproperty(f, "position", x,z,a);
         updateframe(f, t);
         damage/=10;
         x -= 8;
      }
   }
}


This is the script I'm currently using in my game.
When you deal damage to an enemy, a numerical graphic appears.
It's a style from the Kunio-kun series.
However, I have a question.
This script doesn't display the numbers when the enemy's health is depleted.
If the attack is done in a different way (like Grab), the calculation stops as soon as it reaches 0.
If an attack with 300 damage reaches 0, it won't even display 100.
I'm wondering if it's possible to display the damage until the attack ends, even after health reaches 0.
Friend, we need more info about the script. Without knowing the whole flow, it's not possible to look for a solution.

1) In which event you are using this code (I mean didhit, takedamage, ondoattack, etc)?
2) Which method you are using to draw the numbers (drawstring, drawsprite, settextobj, entities, etc)?
 
Friend, we need more info about the script. Without knowing the whole flow, it's not possible to look for a solution.

1) In which event you are using this code (I mean didhit, takedamage, ondoattack, etc)?
2) Which method you are using to draw the numbers (drawstring, drawsprite, settextobj, entities, etc)?
takedamagescript data/scripts/num.c

"takedamage script" and number sprites are used.
 
Friend, we need more info about the script. Without knowing the whole flow, it's not possible to look for a solution.

1) In which event you are using this code (I mean didhit, takedamage, ondoattack, etc)?
2) Which method you are using to draw the numbers (drawstring, drawsprite, settextobj, entities, etc)?
C:
name        number
type        none
shadow        0
lifespan        0.5
setlayer        1000
antigravity    100
animationscript    data/scripts/script.c

anim spawn
     @script
    {
      dasher(0,0.4,0);
     }
     @end_script
   loop    0
   delay    -1
   offset    1 1
   frame   data/sprites/misc/num/0.gif
   frame   data/sprites/misc/num/1.gif
   frame   data/sprites/misc/num/2.gif
   frame   data/sprites/misc/num/3.gif
   frame   data/sprites/misc/num/4.gif
   frame   data/sprites/misc/num/5.gif
   frame   data/sprites/misc/num/6.gif
   frame   data/sprites/misc/num/7.gif
   frame   data/sprites/misc/num/8.gif
   frame   data/sprites/misc/num/9.gif

The number type is "none".
 
I'm wondering if it's possible to display the damage until the attack ends, even after health reaches 0.
I think this method may not work with dead characters, the takedamage event must have an alive opponent, plus dead entities don't have collisions enabled. You can try to migrate the script to the ondoattack event, which works before the takedamage, or maybe create a way to keep the opponent alive at least until the attacker ends his current move.

In addition, I suggest checking if it happens only with custom grabs, maybe it's related to how the script deals damage to the opponents. Example, if the script uses health property subtraction instead of using damageentity, it will not trigger the takedamage event.
 
I think this method may not work with dead characters, the takedamage event must have an alive opponent, plus dead entities don't have collisions enabled. You can try to migrate the script to the ondoattack event, which works before the takedamage, or maybe create a way to keep the opponent alive at least until the attacker ends his current move.

In addition, I suggest checking if it happens only with custom grabs, maybe it's related to how the script deals damage to the opponents. Example, if the script uses health property subtraction instead of using damageentity, it will not trigger the takedamage event.
My current attack settings are set to "nokill," but it seems like enemies are still being treated as having zero HP. Is there a way to add extra HP when a certain HP is reached, and then kill the enemy when the grapple attack is released?
 
I think this method may not work with dead characters, the takedamage event must have an alive opponent, plus dead entities don't have collisions enabled. You can try to migrate the script to the ondoattack event, which works before the takedamage, or maybe create a way to keep the opponent alive at least until the attacker ends his current move.

In addition, I suggest checking if it happens only with custom grabs, maybe it's related to how the script deals damage to the opponents. Example, if the script uses health property subtraction instead of using damageentity, it will not trigger the takedamage event.
I'm not sure, but is there a way to create a random fixed value only when the player attempts a grab attack, and then reset it to its original value only when finishing off an enemy?

If the value is fixed to 1, I'm not sure if the displayed damage will also be 1, but I'd like to try scripting or other methods.
 
Is there a way to add extra HP when a certain HP is reached, and then kill the enemy when the grapple attack is released?
You can try the ondoattack event, which works before the damage is confirmed. So, you can filter per animation and then add a health amount before it's subtracted by the takedamage, not allowing you to kill the opponent until this move reaches the last hit.

I'm not sure, but is there a way to create a random fixed value only when the player attempts a grab attack, and then reset it to its original value only when finishing off an enemy?

If the value is fixed to 1, I'm not sure if the displayed damage will also be 1, but I'd like to try scripting or other methods.
I would like to see a visual example of this issue to understand better.
I don't know if you got this code from another project, but to be honest I prefer a different way to print damage on the screen.

Usually I spawn an entity as a text panel and then I use the drawstring inside this entity. This way I can write the whole damage text using just 1 entity instead of spawning multiple text entities and then changing frames to form an entire text.
 
You can try the ondoattack event, which works before the damage is confirmed. So, you can filter per animation and then add a health amount before it's subtracted by the takedamage, not allowing you to kill the opponent until this move reaches the last hit.


I would like to see a visual example of this issue to understand better.
I don't know if you got this code from another project, but to be honest I prefer a different way to print damage on the screen.

Usually I spawn an entity as a text panel and then I use the drawstring inside this entity. This way I can write the whole damage text using just 1 entity instead of spawning multiple text entities and then changing frames to form an entire text.

1768614501263.png

I actually tested the method I proposed.
The problem started with "When an enemy's HP reaches 0, the damage number doesn't display."

Before starting, I considered the grab value. If an enemy's HP is 100, it's actually set to 9100, and when they spawn, it's reduced by 9000 to 100.

When an enemy is grabbed by a player, the player temporarily adds HP to the enemy.
Enemy HP:100 > (grab) Enemy HP:9100

Once the player's grab attack ends, the added HP is removed from the enemy.
(grab) Enemy HP:9100 > Enemy HP:100

The result was a successful attack. Damage was displayed as a number until the enemy was defeated, as long as the player maintained the attack.

The problem was that while enemies without a lifebar were fine, entities with a lifebar, such as bosses or player characters, would see their lifebar gauge change when they were attacked by the same enemy.
This is so ugly that I'm thinking of finding another way or just giving up.

I wish I had recorded a video, but I reverted the attack test I was attempting to the original, so I'll have to recreate it and record a video to see the test.
Since you add 9000 to your stamina, it will subtract 9000 from your starting life bar, so if you have a life bar, it will appear as if you have taken damage.
 
Last edited:
Back
Top Bottom