“increases with” does not work properly on “hero health value”

Welcome Forums Bugs “increases with” does not work properly on “hero health value”

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #35363
    Marby
    Participant

    The “increases with” operator does not calculate the correct new health values! I tried it out by creating an actor as a “HealthMachine”:

    HealthMachine gives choices for "What can I do for you?"
    in case "Nothing"
    in case "Set my health to 5."
        hero health value becomes 5
    in case "Heal 20 HP of my health."
        hero health value increases with 20
    in case "Heal 40 HP of my health."
        hero health value increases with 40
    
    if hero health value = 5
        HealthMachine says "Your health is: 5"
    if hero health value = 10
        HealthMachine says "Your health is: 10"
    if hero health value = 15
        HealthMachine says "Your health is: 15"
    if hero health value = 20
        HealthMachine says "Your health is: 20"
    if hero health value = 25
        HealthMachine says "Your health is: 25"
    if hero health value = 30
        HealthMachine says "Your health is: 30"
    if hero health value = 35
        HealthMachine says "Your health is: 35"
    if hero health value = 40
        HealthMachine says "Your health is: 40"
    if hero health value = 45
        HealthMachine says "Your health is: 45"
    if hero health value = 50
        HealthMachine says "Your health is: 50"
    

    After that, I started the game and tested it:

    What can I do for you?
    => Set my health to 5.
    Your health is: 5
    
    What can I do for you?
    => Heal 20 HP of my health.
    Your health is: 50
    

    You wouldn’t have expected that as the result, would you? Neither did I. Better you try this also for “decreases with” – I not tried this yet. 😉

    0
    #35365
    Comprehensible
    Moderator

    Hey Marby! Yeah, that’s not the output I would expect!

    My guess is that you need some “else” statements thrown in there. Like this:

    and so on and so on.

    Let me know how it goes!

    0
    #35366
    Marby
    Participant

    I have no doubt the current output is correct. Sure, I’m also merely a human and sometimes making my mistakes. But this time you can trust me: As an old programmer I say you it is the calculation, not the output. Try it yourself, if you don’t believe me. Your code will give us the same output.

    Do you know the real difference between my and your approach?
    Your code is slighly faster than mine if the HP is low. Because, if the HP is low, the computer does not need to process all the if statements. However, since computers are that fast, we’ll not notice, even if they have to process my way of coding here. I chose this implementation, because of the better readability.

    Also, I’ve been wondering for a while how many nested scopes RPG Playground can take. At some point, if you do it the way you do, it’s going to end. With my way of coding, on the other hand, I can go on like this for several A4 pages if I enjoy it, without RPG Playground running out of steam.

    Thank you for trying to help. But this time, I’m pretty sure we need deWiTTERS to fix this.

    0
    #35374
    Marby
    Participant

    I found an easier way to clearly show the “increases with” operator does not work properly. Try this:

    hero health value decreases with 20
    hero says "HP = 50 - 20 = 30"
    hero health value becomes 1
    hero says "HP = 1"
    hero health value increases with 10
    hero says "HP = 11"
    

    Just have a closer look to the health bar while executing this. The maximum health of my test hero is 50. After the last line the health bar is full.

    The decreasing seems to work properly. I also tried the increasing with just 1 HP. This will restore about 10 HP I would guess from the health bar.

    0
    #35551
    Marby
    Participant

    Hello @deWiTTERS,
    I’m going to use the “increases with” operator as it is now in order to proceed with the creation of my game. I would appreciate if you could fix this bug later so that healing items can heal the correct amount of HP later. I will create my healing items already with the correct values so that they will work properly as soon the bug has been fixed.

    +1
    #35887
    deWiTTERS
    Keymaster

    Yes indeed, I noticed this with increasing the speed, and have a task for that: https://trello.com/c/NVJn10h1

    Will also add this one, since it’s easier to test. I’ll fix that bug as soon as possible.

    +1
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.