Enemys heal me arggg

  • Well, It's a pity but today my neurons are asleep

    I have variables:

    PlayerLife: current hp of player

    Max_Player_life: maximum hp the player have.

    Defense: subtract from enemy damage a bit quantity.

    So if a bullet do as damage:

    subtract 5-Defense from PlayerLife[/code:2z0s05jl]
    
    If Defense is greater than 5, PlayerLife grows...  
    
    what would be your solution?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A really easy way is to make defense a percentage of damage reduction. ie, 10% and ugradable to 15%, 20% etc etc.

    Then you only need to do:

    Subtract (Damage * PlayerDefense) from PlayerLife.

    PlayerDefense default = 1.0 = no damage reduction. If you want 10%, then just make it 0.9 and the player will take only 90% of the damage.

    Otherwise you will have to add a trigger prior to doing that calculation.

    ie. If Damage < PlayerDefense = destroy bullet only, no damage calculation.

    Else, do the damage - defense calculation and subtract it from life.

    Edit: Both works, its what I do for my games. But the first method is better because it has one less event check, so it runs faster on mobiles.

  • 5 - (minus) Defense?

    Is "Defense" greater than 5?

    Because MINUS + MINUS = PLUS

  • Use the system expression clamp.

  • thanks very much!! I think percentage in damage reduction is a good choise

    Anyway I am using just now the clamp, testing it...

    thanks Kyatric

  • I remember the day I discovered clamp(), my life changed forever

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)