1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Command for viewing calulations in debug

Discussion in 'Programming' started by Nezun, Nov 8, 2019 at 11:03 PM.

  1. Nezun

    Nezun Member

    Joined:
    Mar 28, 2019
    Posts:
    3
    Howdy! I'm currently working on some RPG elements and I'm struggling to figure out a solution for smooth damage progression. One of these hitches is that I currently do not have a visual representation of the damage the player character is dealing, outside of the enemy HP bar.

    So the question I implore is: can I display the damage calculation in the debug window using the show_debug_message() command?

    Thanks for any and all help!
     
  2. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,611
    Just concatenate a string showing the info you want.
    If you want to mix text and numbers you need to wrap the number values in string() when outputting them with show_debug_message()

    Code:
    attack_value = 10;
    multiplier_value = 3;
    random_buff = irandom(5);
    damage = (attack_value * multiplier_value) + random_buff;
    
    show_debug_message("damage = ( attack(" + string(attack_value) + ") * multiplier(" + string(multiplier_value) + ") ) + random_buff(" + string(random_buff) + ")");
    show_debug_message("damage = (" + string(attack_value) + " * " + string(multiplier_value) + ") + " + string(random_buff));
    show_debug_message("damage = " + string(damage));
    
    Would output:
    Code:
    damage = ( attack(10) * multiplier(3) ) + random_buff(5)
    damage = (10 * 3) + 5
    damage = 35
    
    Would probably be easier to store the values at the point of the damage calculation, and then draw the values to the screen though.
     
    Nezun likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice