S
Sabotage
Guest
Hello,
I'm an artist who is attempting to create a game, and this is my first time delving into the world of coding. I've been at this for about 2 weeks, and started off with some open-source code which was already doing some of the things I wanted to accomplish.
All that to say, I know nothing of complicated coding practices but am growing more and more familiar with GML and simpler code.
So where I'm at now is that I've got collision working (via a script and parent object.)
I've got an HP bar. I've got health deterioration and I've got player death.
What I want to do is create a system alike to Halo or Call of Duty (i think?), where they have a delayed regeneration after not receiving damage for a time.
At the moment I'm struggling to understand alarm events and wonder if there is an easier way to do this or if someone could explain / post the code to make this work.
Currently I have something which is completely wrong but might show you where my mind is at;
takedamage = currentHP-- (this variable is in the create event)
//wait to check if HP is still going down
if takedamage == false
{
alarm[0] = 3*room_speed;
HPregen = true
}
//initialize regen
if currentHP < maxHP
{
currentHP += HPregen
}
What I want to happen is this; While the player is receiving damage (health is actively deteriorating) there is no HPregen. When the player is no longer receiving damage, wait 3 seconds, activate HPregen (until max health.)
This would need to be interruptable via receiving damage again.
I'm an artist who is attempting to create a game, and this is my first time delving into the world of coding. I've been at this for about 2 weeks, and started off with some open-source code which was already doing some of the things I wanted to accomplish.
All that to say, I know nothing of complicated coding practices but am growing more and more familiar with GML and simpler code.
So where I'm at now is that I've got collision working (via a script and parent object.)
I've got an HP bar. I've got health deterioration and I've got player death.
What I want to do is create a system alike to Halo or Call of Duty (i think?), where they have a delayed regeneration after not receiving damage for a time.
At the moment I'm struggling to understand alarm events and wonder if there is an easier way to do this or if someone could explain / post the code to make this work.
Currently I have something which is completely wrong but might show you where my mind is at;
takedamage = currentHP-- (this variable is in the create event)
//wait to check if HP is still going down
if takedamage == false
{
alarm[0] = 3*room_speed;
HPregen = true
}
//initialize regen
if currentHP < maxHP
{
currentHP += HPregen
}
What I want to happen is this; While the player is receiving damage (health is actively deteriorating) there is no HPregen. When the player is no longer receiving damage, wait 3 seconds, activate HPregen (until max health.)
This would need to be interruptable via receiving damage again.