PDA

View Full Version : Nice Feature



xGTx
24-07-2004, 11:40 PM
Hello. There is a certian feature i'd like to implement into my MMORPG system, but am not sure how to do it. I'm hoping someone has a general idea on how it is done. But anyway, when a character hits another character or NPC, i want a number (the hit damage number) to float up from the character and fade away. You can see what i mean from this WC3 screen shot:

http://www.gtrpg.com/images/wc3ss.jpg

Im hoping one of you has an idea, thanks!

Mrwb
25-07-2004, 12:20 AM
The way I would do it, was to simply create a tex-out method, and do the "NPC Takes Hit" method like this:

1. Deal the damage
2. Do all other stuff
3. Print the current health of the NPC at a specific offset of the NPC's position

The text-out method could simply print some text at a given screen location, and fade it after it's been on the screen for the desired amount of time. You would have to keep track of all text currently beeing printed though, to be able to fade it.

The easiest way of doing this (and slowest) would be to go through every text object, fade and print them. For instance, you could have an array of a structure like the one below and simply decrease the color/alpha value after a given time, and then applying the color/alpha, and print the text.


type
THitDamageText=record;
Color: single; //use in alpha or something to get a smooth fade
X: integer;
Y: integer;
Text: string;
Fade: boolean; //shall we fade the text?
Time: integer; //substract each time the render loop is executed, when 0, start fade.
end;


Keep track of the number of hit damages currently displaying by adding/substracting an integer variable, if the number = 0, then no need to execute print loop etc.

Off course, the above is kind off slow, but maybe it will give you an idea or something ;)

xGTx
25-07-2004, 03:15 AM
Well that was already my idea, i was hoping for a faster way. And also a little explination on the best way to fade.

Harry Hunt
25-07-2004, 06:56 AM
Mrwb's idea is pretty good. I doubt that you will ever have more than 10 text outputs on the screen at the same time so speed won't be a problem. Since you'll have to deal with an arbitrary number of text outputs, you should use a dynamic array/linked list/TList to keep track of the records. Arrays might not work so well because deleting records (after they have faded out) would be relatively complicated.

As for the actual fading: I don't know which API/Headers/Components you use... i'm sure you mentioned it before but I forgot :P
A very easy way of doing what you're after would be to draw the text on a separate off-screen buffer and then alpha-blit it onto your back-buffer. Alternatively you could write your own text-out method which draws the text pixel by pixel.

xGTx
26-07-2004, 01:31 AM
I'm using DelphiX right now. Can you explain to me LinkedList i've never heard of these before.

Harry Hunt
26-07-2004, 06:37 AM
http://www.ibrtses.com/delphi/dllist.html

If you haven't worked with pointers before, this might be a bit hard to understand.
Alternatively you could use a TList which is a bit easier

http://www.delphibasics.co.uk/RTL.asp?Name=TList

xGTx
26-07-2004, 08:25 AM
Thanks harry, your the best!