1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 quick question about removing health from healthbar...

Discussion in 'Programming' started by EZTALES, Feb 2, 2019.

Tags:
  1. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    hey yall,
    its been a while but i have picked up my project again, and i had a question for anyone, lets say i had a script
    (below) and when you press enter it will do 10 damage to the enemy (code below) was wondering how to write that as i have forgotten and cant seem to find a video online for my probelm.
    any suggestions would be great!
    thanks for your time and regards,
    EZ
    Code:
    scr_attack
    ///placeholder
    switch (mpos)
    {
    
    case 0:
    {
    // <----------- this is where it would go.
    break;
    }
    
    case 1:
    {
    room_goto(battle_room);
    break;
    }
    }
    Code:
    obj_foe_1
    create:
    image_speed = 0.3;
    hp = 100;
    Code:
    step event for foe:
    if hp <= 0
    {
    room_goto(rm_bedroom)
    instance_destroy(self)
    }
    Code:
    draw event for foe:
    draw_self();
    draw_healthbar(x,y,x+50,y+6,hp,c_black,c_gray,c_white,0,true,true);
    Code:
    draw event for foe:
    draw_self();
    draw_healthbar(x,y,x+50,y+6,hp,c_black,c_gray,c_white,0,true,true);
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    Code:
    obj_foe_1.hp -= 10;
     
    EZTALES likes this.
  3. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,149
    What's your rate the hour?
     
  4. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    sorry, i don't quite understand the question, can you please explain better?
     
  5. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    works, thanks!
     
  6. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    That question was directed to me.
    I guess because my reply looked like a lazy reply.

    Glad to hear it!
     
  7. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,149
    I am not being a content-cop, my intention was directed at how simple the solution was and that you took the time to solve it.
     
  8. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    1,188
    Of course, EZTALES might run into a problem if there's more than 1 instance of obj_foe_1, but depends on how they've set up their game.
     
  9. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    thats true, but there most likely will not be more than 1 in the case im using.
     
    RefresherTowel 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