User Tag List

Results 1 to 6 of 6

Thread: HP and MAXHP Problem

  1. #1
    No Products Registered

    Join Date
    Aug 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HP and MAXHP Problem

    Alright, I am trying to do something really simple, and it isn't working. :P

    Basically, I have a horizontal counter with a minimum value of 0, and a maximum of 100.

    I then have 2 Global Values of HP, and MAXHP. I set it up so that the counter will always be set to HP/MAXHP*100.

    This should return the percentage of HP they have left and allow me to change the maxhp as they progress through the game.

    The issue is, when I set HP to ANYTHING other than MAXHP, the counter will set itself to 0. Any ideas why?

    I also tried,

    (HP/MAXHP)*100 = Countervalue

    I get the same result.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module

    Join Date
    Jun 2006
    Location
    St. Ave France
    Posts
    1,166
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: HP and MAXHP Problem

    max HP times 100 will always be a massive number! HP divided by that massive number is going to be super close to zero (rounded down to zero if you're not using fractions)

    maybe you mean

    (HP/MAXHP)*100


  3. #3
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HP and MAXHP Problem

    Because you're dealing with integers, doing the division first will round the result to 0 (which, when multiplied by 100, will still be 0!) You should be able to see the right result if you do it the other way round, using (HP*100)/MAXHP.

  4. #4
    No Products Registered

    Join Date
    Aug 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HP and MAXHP Problem

    Thanks a ton David. That solves it. I was not aware that MMF2 could not handle decimals.

  5. #5
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HP and MAXHP Problem

    Well, it can - though you have to indicate to it (as in other languages) that you want to use them, by multiplying a value by 1.0 before using it, if it doesn't have a decimal fraction already.

  6. #6
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    JimJam's Avatar
    Join Date
    Jun 2006
    Location
    USA
    Posts
    353
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: HP and MAXHP Problem

    That is not the case. MMF can deal with decimals fine, as long as you define them as decimals.

    That is,

    100 / 3 = 33
    but,
    100 / 3.0 = 33.3333

    if you use all integers, then your answer will return an integer. But once you define a value as a decimal value, it will continue to use decimal fractions.

    To turn a decimal number back into an Integer, use the int() operator:
    int(100 / 3.0) = 33

    Here is a handy expression sheet that I've always kept in my bookmarks:
    http://mfgg.taloncrossing.com/wiki/index.php/Click_Expression_Reference

    If you can't read it (because of the wiki's new formatting) you can read it here:
    http://mfgg.taloncrossing.com/wiki/index.php?title=Click_Expression_Reference&printab le=yes

Similar Threads

  1. Pulling Problem and Shooting Problem
    By Duggabboo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 21st March 2010, 05:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •