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

GMS 2 [SOLVED] Burn Damage

Discussion in 'Programming' started by ArcherRanger, Jul 18, 2017.

  1. ArcherRanger

    ArcherRanger Member

    Joined:
    Jul 18, 2017
    Posts:
    8
    I've been searching google and the forums to no avail. I'm trying to make an on burn effect that only lasts 3-5 seconds. I have used alarms, if statements, case statements, for loops, but have only managed to get the effect to run once or constantly without stopping. I might be going slightly insane.
     
  2. Gardevoir

    Gardevoir Guest

    have you tried assigning states? i've used numbers

    like the enemy having
    0 for normal state - codes are running normally

    if (status != 0)
    {
    //1 for poisoned state - hp reduced
    if (status == 1) alarm [0] = 600; // duration of state
    // other codes like hp reduction or reduced atk power

    if (status == 2) //burned state
    if (status == 3) paralyzed
    }

    in the alarm, reset the player/enemy state to normal
     
  3. NeoShade

    NeoShade Member

    Joined:
    Jun 21, 2016
    Posts:
    166
    Rather than using a whole lot of if statements, you could use a switch statement instead:

    Code:
    switch(status)
    {
        case 0: // Normal State
            break;
    
        case 1: // Poisoned
            alarm[0] = 600; // Duration of state
            // Other poison-related code
            break;
    
        case 2: // Burned
            // Burn-related code
            break;
    
        case 3: // Paralyzed
            // Paralasis-related code
            break;
    }

    This works the same as Gardevoir's code, but is a bit neater and a lot faster.
     
  4. Turkish Coffee

    Turkish Coffee Member

    Joined:
    Nov 25, 2016
    Posts:
    559
    If you want a basic code,

    Code:
    //Step Event
    
    if (burning = 1)
     {
      alarm[0] = 1;
     }
    
    if (alarm[0] > -1)
     {
      objPlayer.hp-=damageValue;
     }
    
    that code above will to continous damage and not like getting damage every 2 seconds. For that,
    Code:
    //Step Event
    
    if (burning = 1 && alarm[0] =-1)
     {
      alarm[0] = room_speed*2; //burns every 2 seconds
     }
    
    //Alarm 0
    objPlayer.hp-=damageValue;
     
  5. ArcherRanger

    ArcherRanger Member

    Joined:
    Jul 18, 2017
    Posts:
    8
    This actually helps a lot with my coding process, thank you. But i'm still needing to have an enemy or player take, lets say 5 damage, every second for 5 seconds. The way i'm doing it either makes it so they take all the damage instantly or it happens every second to no end with alarm loops. I just need to effect to tick every second and stop after set seconds.
     
  6. John Andrews

    John Andrews Living Enigma

    Joined:
    Oct 28, 2016
    Posts:
    277
    There is an easy way to do this, not even needing alarms, just the step event and some variables: Here's an example of what I'd do
    CREATE:
    Code:
    hp=100//just example
    burn=0//general timer alarm or whatever
    keepburning=0//how many times the "alarm" will be set off
    STEP:
    Code:
    if burn = 0 && keepburning>0
    {
         hp-=damage//you are damaged
         keepburning--//One less burn state
         burn=room_speed*1//This means it will be set to a second
    }
    if burn>0
         burn--
    UPON CONTACT WITH BURNING THING THAT MAKES YOU GET FIRE DAMAGE:
    Code:
    keepburning=5
    This should be what you are looking for

    Hope I was helpful! :D
     
  7. ArcherRanger

    ArcherRanger Member

    Joined:
    Jul 18, 2017
    Posts:
    8
    THANK YOU SO MUCH! That is what I needed and more.
     
  8. John Andrews

    John Andrews Living Enigma

    Joined:
    Oct 28, 2016
    Posts:
    277
    Remember to leave a like and to prefix this post with a [SOLVED] :D You're welcome!
     
    RichHopefulComposer 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