Solved showing damage in numbers

Question that is answered or resolved.
Solution
ok, i've tested the script and it works!

i've made a "numflash" entity:

Code:
name	numflash
type	none
shadow	0
toflip 1
facing 1
setlayer	9999999
lifespan	1

palette data/chars/misc/numflash/numflash.gif #1

anim spawn
	loop	0		
	offset     225 201
	delay		1000
	frame	data/chars/misc/numflash/0.gif
	frame	data/chars/misc/numflash/1.gif
	frame	data/chars/misc/numflash/2.gif
	frame	data/chars/misc/numflash/3.gif
	frame	data/chars/misc/numflash/4.gif
	frame	data/chars/misc/numflash/5.gif
	frame	data/chars/misc/numflash/6.gif
	frame	data/chars/misc/numflash/7.gif

	delay		1000
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/8.gif
	frame	data/chars/misc/numflash/9.gif
	frame	data/chars/misc/numflash/minus.gif

anim idle
	loop	0
	offset...
You can do that, but it would require an insane amount of work, because you'd need a new flash for every single amount of damage. Instead, use the flash to trigger a timed textobject. You could use the update event to give the "float up and away" effect, but that's just gravy.


 
If you are using flash then just 2-3 of them will do the trick. Number 0-9, totally 10 frames, though you'll need a script to spawn them in one place and update to correct frames.

textobj should work better if you only want number, unless you need some special effect, giving you a headache to code them out.
 
It is not an easy solution.
First of all you need to make a number entity, for example, name it numflash, the spawn animation has 11 frames: number 0~9, minus symbol (-).
Give enough delay so it doesn't switch to next frame by itself, and give a proper lifespan.

Then you need to write a takedamagescript.


void main()
{
int damage = getlocalvar("damage");
void self = getlocalvar("self");
int x, z, a, t;
void f;
if(damage)
{
x = getentityproperty(self, "x");
z = getentityproperty(self, "z")+1;
a = getentityproperty(self, "a")-50;
setspawnentry("name", "numflash");
while(damage)
{
t = damage % 10;
f = spawn();
changeentityproperty(f, "position", x,z,a);
updateframe(f, t);
damage/=10;
x -= 12;
}
f = spawn();
changeentityproperty(f, "position", x,z,a);
updateframe(f, 10);
}
}
 
ok, i've tested the script and it works!

i've made a "numflash" entity:

Code:
name	numflash
type	none
shadow	0
toflip 1
facing 1
setlayer	9999999
lifespan	1

palette data/chars/misc/numflash/numflash.gif #1

anim spawn
	loop	0		
	offset     225 201
	delay		1000
	frame	data/chars/misc/numflash/0.gif
	frame	data/chars/misc/numflash/1.gif
	frame	data/chars/misc/numflash/2.gif
	frame	data/chars/misc/numflash/3.gif
	frame	data/chars/misc/numflash/4.gif
	frame	data/chars/misc/numflash/5.gif
	frame	data/chars/misc/numflash/6.gif
	frame	data/chars/misc/numflash/7.gif

	delay		1000
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/8.gif
	frame	data/chars/misc/numflash/9.gif
	frame	data/chars/misc/numflash/minus.gif

anim idle
	loop	0
	offset	30 30
	delay		5
	move		1000
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif

then i've made a takedamagescript and i've called it ndamage.c

Code:
void main()
{
   int damage = getlocalvar("damage");
   void self = getlocalvar("self");
   int x, z, a, t;
   void f;
   if(damage)
   {
      x = getentityproperty(self, "x");
      z = getentityproperty(self, "z")+1;
      a = getentityproperty(self, "a")-50;
      setspawnentry("name", "numflash");
      while(damage)
      {
         t = damage % 10;
         f = spawn();
         changeentityproperty(f, "position", x,z,a);
         updateframe(f, t);
         damage/=10;
         x -= 8;
      }
      f = spawn();
      changeentityproperty(f, "position", x,z,a);
      updateframe(f, 10);
   }
}

then i've added the line to the enemy's header and ta daaan!

264i3va.png


now, i will try to implement the "float up and away" effect like damon suggested, i've already in mind how to do it....
 
Solution
ok, i'm trying to implement a float up effect for the damage numbers but it doesn't seems to work...
this is what i've done:

i've made a new animationscript called dasher, and put it in the numflash header:

Code:
name	numflash
type	none
shadow	0
toflip 1
facing 1
setlayer	9999999
lifespan	1
animationscript    data/scripts/spawn/dasher.c

palette data/chars/misc/numflash/numflash.gif #1

anim spawn
	loop	0		
	offset     225 201

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/0.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/1.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/2.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/3.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/4.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/5.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/6.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/7.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/8.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/9.gif

	delay		100
	@cmd	dasher 0 0 -0.3
	frame	data/chars/misc/numflash/minus.gif

anim idle
	loop	0
	offset	30 30
	delay		5
	move		1000
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif
		frame		data/chars/misc/empty.gif

and this is the dasher.c:

Code:
void dasher( float Vx, float Vy, float Vz)
{
    void self = getlocalvar("self");
    int dir = getentityproperty(self,"direction");

    if(dir==0){ 
      Vx = -Vx ;
    }

    changeentityproperty(self, "velocity", Vx, Vz, Vy);
}

then i've put for every frame if the numflash, the command "@cmd dasher 0 0 -0.3", but it doesn't seems to work.

any clues?
 
Oh man. I'm going to have to try this... I too did the old "a hitflash for every damage" thing, and I ended up having well over 40-some different hitflashes. This might be handy.
 
just tested with my hp script and it floated up just fine try like this :

name numflash
type none
shadow 0
toflip 1
facing 1
setlayer 99999999
lifespan 1
animationscript    data/scripts/spawn/dasher.c

palette data/chars/misc/numflash/numflash.gif #1

anim spawn
loop 0
offset    225 201
delay -1
@script
{
dasher(0,0.2,0);
}
@end_script
frame data/chars/misc/numflash/0.gif
frame data/chars/misc/numflash/1.gif
frame data/chars/misc/numflash/2.gif
frame data/chars/misc/numflash/3.gif
frame data/chars/misc/numflash/4.gif
frame data/chars/misc/numflash/5.gif
frame data/chars/misc/numflash/6.gif
frame data/chars/misc/numflash/7.gif
frame data/chars/misc/numflash/8.gif
frame data/chars/misc/numflash/9.gif
frame data/chars/misc/numflash/minus.gif

anim idle


let me know if that worked for you !
 
name numflash
type none
shadow 0
toflip 1
facing 1
antigravity 100
setlayer 99999999
lifespan 1
animationscript    data/scripts/spawn/dasher.c

palette data/chars/misc/numflash/numflash.gif #1

anim spawn
loop 0
offset    225 201
delay -1
@script
{
dasher(0,0.2,0);
}
@end_script
frame data/chars/misc/numflash/0.gif
frame data/chars/misc/numflash/1.gif
frame data/chars/misc/numflash/2.gif
frame data/chars/misc/numflash/3.gif
frame data/chars/misc/numflash/4.gif
frame data/chars/misc/numflash/5.gif
frame data/chars/misc/numflash/6.gif
frame data/chars/misc/numflash/7.gif
frame data/chars/misc/numflash/8.gif
frame data/chars/misc/numflash/9.gif
frame data/chars/misc/numflash/minus.gif

anim idle


try again this one has the "antigravity 100" forgot to add that last time !
 
this is so cool!
i have added it to my fantastic four project and it give some cool flavor to it! thanks

Happy to help  the hp bar I made is quite similar to what your making so I was a bit enthusiastic about this.
did you have created some mini hp bar that pop up on enemies head? this sounds very cool too!
 
Back
Top Bottom