User Tag List

Results 1 to 5 of 5

Thread: Percents help

  1. #1
    No Products Registered

    Join Date
    Jul 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Percents help

    Ok say I have two counters that are like this.

    current hp = 5
    max hp = 20

    I want to make it so that I can add a percentage to the current hp.(like, add 20%.) I tried looking up many ways but when adding to the current hp, it always goes over the max hp.

    something like, if your current hp is 5, add 20% to your current hp but it should still be lower than your max. the higher then current hp is to the max hp, the lower the percents will add. is there a way to do this?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Percents help

    Hey.

    A pretty easy formula to add less % the more HP you have is

    Health = Health+(Max-Health)/2.0


    The half of the difference between HP and max HP is added.
    As the HP increase, the difference decreases.

  3. #3
    No Products Registered

    Join Date
    Sep 2006
    Location
    Germany
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Percents help

    under special "compare two general values"

    current hp > max hp

    --> set current hp to max hp

    this way whenever you go over the max hp it will always be set to the max hp

  4. #4
    No Products Registered

    Join Date
    Jul 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Percents help

    Quote Originally Posted by Looki
    Hey.

    A pretty easy formula to add less % the more HP you have is

    Health = Health+(Max-Health)/2.0


    The half of the difference between HP and max HP is added.
    As the HP increase, the difference decreases.
    so i'd do something like this to add percents:

    upon pressing space
    ...add value( "current hp" )+(maxvalue( "current hp" )-value( "current hp" ))/2.0

    my current hp is 5
    my max is 20

    when I try doing that, for some reason it goes to 17.5

    this way whenever you go over the max hp it will always be set to the max hp
    yeah that works too, but it doesn't solve the problem of the percents value decreasing with the difference.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Percents help

    Oh, yes it does. I see, you don't want to add more than 100% of the original score?

    value( "current hp" )+(maxvalue( "current hp" )-value( "current hp" ))*1.0/maxvalue( "current hp" )*value( "current hp" )

    Try this!

Posting Permissions

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