Damage Display [SOLVED>PROBLEM WITH AZU]

This forum is currently in read-only mode.
0 favourites
From the Asset Store
This sound pack features 117 game sounds : Axe,Punch Swing & Hit & Damage. This is a perfect collection for your game.
  • Hello everyone !

    Can someone help me ? I want to make a damage display like this game :

    http://youtu.be/EIIWQ-E2MVM

    Here is the numbers picture to use :

    <img src="http://img233.imageshack.us/img233/2239/numbers.png">

    I have a global variable called "Factor".

    When "Factor" is equal to 1.0, to 0.75 or 1.25 -> Normal damage

    When "Factor" is equal to 2.0 -> Critical damage

    When "Factor" is equal to -1.0 -> Healing damage

    First line is for normal damage

    Second line is for critical damage

    Third line is for "healing" damage

    I also have a global variable called "Damage".

  • So your main problem is how to use your bitmap font in the game to display the actual damage? I suppose you might have heard of the SpriteFont plugin, which does a good job in many cases, but it sometimes also does crash I'm afraid.

    I would suggest you do it simply with events. Using some text expressions and a comparison string it's not that hard to get a custom bitmap font working (check this older thread).

    When you are dealing only with numbers, you could do it even simpler. Just iterate over the individual characters, and spawn the number sprite on the respective frame.

    Like that for example: DMG 135, taken apart to 1, 3, 5. Now you could just create three instances of the number sprite in order. One on frame 2, the second on frame 4 and the third on frame 6. Assuming you have your frames in order 0, 1, 2, 3, 4... which you should have of course. You have to add +1 cause frames aren't 0-based and start with the first frame on 1.

    I realize this probably sounds terribly theoretical. If needed I will cook up a proper example of what I mean when I have time later.

  • Actually, I don't get it . It looks complicated... Can you make a cap file with using my bitmap font please ? The MAX Damage is 999999 (6 digits).

  • Actually, I don't get it . It looks complicated... Can you make a cap file with using my bitmap font please ? The MAX Damage is 999999 (6 digits).

    No worries, I'll make an example cap for you. Just be a little patient, this weekend seems to be a bit busy.

  • Okay, I decided to make this into another blog post. This one was particularly exhausting, I didn't realize there was so much to explain, haha.

    We Construct Blog - Forum rescue #004: Bitmap font damage

    I hope you'll be able to grasp the concept from this (cap files are included).

  • Yes ! Thanks a lot ! It works perfectly . I also join your blog as a member (Shiru). You're a god !

    You should add your tutorial to the Tutorial List here :

  • Wouldn't you have to make different loops per enemy?

    Also, I tired typing in numbers instead of the what the edit box says And it didn't work=/

    + MouseKeyboard: On Left Clicked on BadGuy

    -> Function: Add parameter 12

    -> Function: Call function "DMG" (and Forget picked objects)

  • My pc went to nirwana so I can't use Construct, but from what I saw on the blog, the function expects a string, not a number. Do

    -> Function: Add parameter "12"

    EDIT: And if you intend to use numbers instead of text, inside the function "DMG" just replace every

    Function.param(1)

    with

    str(Function.param(1))

  • Worked, but what about creating on different enemies? Would I have to make different "bmg" functions per enemy?

  • No.

    All that the function needs is a position to start at. In the example it is the horizontal center of BadGuy and the vertical top.

    To make this function work independent of BadGuy, just add 2 parameters to the function, the x and y of the starting point. Let's say you have a sprite named "anotherBadGuy". When calling the function, do this:

    -> Function: Add Parameter someDamage

    -> Function: Add Parameter anotherBadGuy.Left + anotherBadGuy.Width / 2

    -> Function: Add Parameter anotherBadGuy.Top

    -> Function: Call function "DMG"

    Now change the function itself to work with the new parameters.

    Change the following:

    -> System: Create object "numbers" on layer 1 at (BadGuy.Left+BadGuy.Width/2-Global('width')/2+Global('temp'), BadGuy.Top)

    into:

    -> System: Create object "numbers" on layer 1 at (Function.param(2) - Global('width') / 2 + Global('temp'), Function.param(3))

    Whenever you want to display damage near an object, just pass an x and y value as parameters 2 and 3 like in the "anotherBadGuy" example above.

  • Tulamide answered all questions perfectly. It was probably a bit shortsighted to make the example "hardcoded" with the 'BadGuy'-Sprite. I was mostly concerned with the method of displaying the numbers correctly.

    But yes, Tulamide said it all.

  • Actually, I managed to do that with Families. It's very useful ! You can put the damage on Enemy (family) position and not the "badboy" itself. Then of course, you have to put every enemies with the "Enemy"family.

    I have several global variables for that :

    Target_X

    Target_Y

    TargetHealth

    TargetHealthMAX

    TargetPower

    TargetResist

    TargetState

    TargetWeakness

    TargetEXP

    TargetMoney

    Here is some screens from my cap file :

  • Families are also a good way to solve this. Eventually you won't be able to put everything that is supposed to have damage displayed into the same family though, or you just plain don't like to bother with families. Personally I'd probably prefer to simply pass parameteres of whatever is being damaged to the function. But you know, whatever works.

    The way you used a lot of globals there though confuses me a little to be honest. You use them to temporarily store the data of the current enemy? Of course I don't see the whole picture here, as there are only snippets of the event sheet, but I think you could be more efficient about it.

    The enemy being attacked is going to be picked anyway, why is there the need to temporarily store its stats in globals and calculate the actual damage from that? It seems like an unnecessary step.

  • I haven't think about this when I first code everything. I'm still a beginner with Construct ^^'. But thanks for the advice, I'll change it immedialty. But I'll keep "Target_X" and "Target_Y" because I need them for other things .

    Azu, I hope that you've solved your problem !

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry to double post... but I still have a problem .

    It seems that negative value (-5 for example) or float value (0.3 for example) will make strange things...

    It will look like this :

    I try to fix this with that condition :

    <img src="http://img822.imageshack.us/img822/3652/bugdamagecond.png">

    Here is my damage formula:

    round(((Hero.Value('Power')*1.2)-Enemy.Value('Resist')+random(15))*global('Factor'))+1
    [/code:3avyqf8o]
    
    [( (Power*1.2)-EnemyResist+random(0...14) )*Factor]+1
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)