Displaying the health of an object?

Discussion in 'Mapping Questions & Discussion' started by Kyv'thil'hurum, Aug 16, 2013.

  1. Kyv'thil'hurum

    Kyv'thil'hurum L1: Registered

    Messages:
    14
    Positive Ratings:
    2
    I am working on a new map (Not gonna say exactly what, bit of a secret, but I will be uploading it here when I am done :p) and it relies heavily on func_breakable objects. Is there any way to create some sort of a counter displaying the health of one of these objects?

    Any help will be greatly appreciated, thanks in advance! :)
     
  2. Fish 2.0

    Fish 2.0 L6: Sharp Member

    Messages:
    324
    Positive Ratings:
    116
    bit of a secret

    relies heavily on func_breakable objects



    dont tell anyone, I think you may have struck some gold

    I'm not sure there is. If there is a damage output trigger, like onHit or something.
     
    • Thanks Thanks x 1
  3. Valkyrie

    aa Valkyrie

    Messages:
    138
    Positive Ratings:
    112
    You might be able to with onHit and then math_counters
     
    • Thanks Thanks x 1
  4. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,521
    func_breakable provides OnHealthChanged which outputs a decimal value representing the current health where 1 is full health and 0 is dead. It's up to you how you want to use/display this value depending on what you are doing. My own "secret project" from a couple years ago died because I couldn't display it the way I wanted, so good luck.
     
    • Thanks Thanks x 2
  5. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,102
    Positive Ratings:
    5,991
    There are various ways to display a counter- env_sprites with the material set to the "number" overlays work reasonably well, though look funny at times. Methods to make a brushwork "health bar" have been suggested, and can be found elsewhere on the site.

    You'll need to change the decimal value to an integer (i'm not sure how- booj?) but when that's done you can send the integer to a logic_case. This allows you to get a range of outputs based on the integer you put in- let me grab some screenshots of the one i'm using in my buildables list.

    [​IMG]
    [​IMG]

    Alright, this logic_case is set up so that as the integer input to the case increases, the "case number" decreases. Each case activates a different sprite- when 4 is input, the number 1 appears. I have another output that disables ALL the sprites just before one is enabled- this prevents more than one activating at once.
     
    • Thanks Thanks x 1
  6. Kyv'thil'hurum

    Kyv'thil'hurum L1: Registered

    Messages:
    14
    Positive Ratings:
    2
    For some reason, the screenshots aren't showing up for me. Your idea sounds like it would work but it would be much easier for me to follow if the screenshots worked. :p
     
  7. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,102
    Positive Ratings:
    5,991
    Sorry, puush is down. Check back later, or add me on steam as LeSwordfish and i'll help you tomorrow.
     
    • Thanks Thanks x 1
  8. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,521
    Easier said than done. It's a decimal out to about 5 places and the only feasible way to convert it to integers would be to set up a series of logic_compare operations to check when it falls past a given value and then send a corresponding integer.
     
  9. henke37

    aa henke37

    Messages:
    1,837
    Positive Ratings:
    420
    Or you could just use math_remap.
     
  10. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,521
    No... you couldn't. Logic_case requires individual specific values to match up with it's cases. Math_remap supports decimals so feeding it a 5 digit decimal will effectively always get you a 5 digit decimal out the other end. Hence the need for a compare to merely check when it has passed a specific integer, because there is no way to convert the decimals to integers.
     
  11. Kyv'thil'hurum

    Kyv'thil'hurum L1: Registered

    Messages:
    14
    Positive Ratings:
    2
    I took a short break, getting back to mapping now so I can test some stuff out. Also, if it will help anyone, I have 4 objects with a Strength value of 7500 and 2 objects with a Strength value of 15000.

    Edit 1: Right off the bat, I notices this "OnTakeDamage" output... maybe some sort of brush based healthbar could be made off of this? Will certainly work on it.
    Edit 2: Nevermind that, it won't work because it doesn't read how much damage the func_breakable takes, just whether or not it has taken damage.
    Edit 3: I found a workaround that, while not solving the problem of how to create a health bar, does roundabout the same sort of thing I wanted the health bars to do. Essentially, I needed the health bars to indicate that you should be shooting some object and as a way to display how much health that particular object has. Rather than using a health bar to indicate that you should be shooting this object, I am using trigger_multiple fields that activate game_text entities. Sadly, this doesn't accomplish the goal of displaying the object's health, but if a sign tells you "Shoot this a lot to make things happen", hopefully people will be bright enough to do just that. It would be nice to see some way to make a health bar work, but at the very least a big part of what I needed was accomplished.
     
    Last edited: Aug 18, 2013
  12. mint onion

    mint onion L3: Member

    Messages:
    101
    Positive Ratings:
    38
    maybe you can contact the guy that made cp_redship or download it and see how he managed it.
     
    • Thanks Thanks x 1
    Last edited: Aug 19, 2013
  13. Kyv'thil'hurum

    Kyv'thil'hurum L1: Registered

    Messages:
    14
    Positive Ratings:
    2
    I took a look at the map, decompiled it to have a quick peek around... the thing is a maze. I have no clue what anything does, I will keep looking around but I doubt that I will be able to find anything in here. However, the video did indeed show a health bar of some sort related to the shield, so there is hope yet I suppose.

    Edit 1: I did learn something - apparently there is an entity called game_text_tf. I've never seen it before, but it apparently can be used to display those text boxes instead of just having text on the screen. It could be very useful.
     
    Last edited: Aug 19, 2013
  14. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,102
    Positive Ratings:
    5,991
    Warning, though: it doesnt display to anyone with Minmode HUD on.
     
  15. Kyv'thil'hurum

    Kyv'thil'hurum L1: Registered

    Messages:
    14
    Positive Ratings:
    2
    I did a search for a way to create a health bar instead of a way to create a number counter and I did find something: http://forums.tf2maps.net/showthread.php?t=16271

    The thread I linked to says to use the output OnHealthChanged to set a func_movelinear's SetPosition input. The thread also mentions how to fix a small bug where the health bar moves in the wrong direction, emptying out the health bar completely when the func_breakable is hit, and filling up until the func_breakable is broken. Switching the func_movelinear's start position to 1 and switching the move direction (i.e. I originally had the move direction set to "down", so I changed the start position to 1 and set the move direction to "up") fixes the issue.

    There is still one issue: The health bar stays at the fully opened position until the func_breakable is hit, making the health bar appear empty. Is there any way to use an input to damage the func_breakable? I see a SetHealth input, but I dunno if that would work, I just get the feeling it wouldn't be considered "damage". I will try it out and post my results.

    Edit 1: I used a logic_auto to set the health of the Func_breakable on map spawn, and that worked to change the position of the func_movelinear. Looking back on it, the output for the Func_breakable is "OnHealthChanged" so I guess it makes sense.

    When I get the chance, I will put together a quick prefab to show off how to make a health bar. Thanks for the help, everyone!
     
    • Thanks Thanks x 2
    Last edited: Aug 22, 2013
  16. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,521
    You're overcomplicating it, just directly set the position of the movelinear with the auto.