but what if i want to make it so that each hit regardless of the time between them takes -1 from the hp?
You've got options in that case.
No matter what you want, you should model it out each time.The problem you're battling is that the HP is subtracting on collision, but collision happens at 30/60frames per second which means its impossible to know how much damage an enemy is doing to you in a particular time frame unless you flag it, count it, or make a timestep.
If your model says the same enemy can keep damaging the player, you'd probably want to keep track of when
THAT enemy last hit and when it is allowed to hit again. If your model says multiple enemies can hit the player, and the timeframe between each hit doesn't matter, as long as it's a different enemy, then you'll need to be tracking multiple enemies and the conditions allowed for them to attack. You can't use a timeframe, like alarms or counters or markers like I showed, if multiple enemies are able to hit in the same step (but not more than once every certain condition).
You'll have to start letting enemies decide how they want to damage the player, in this case, as that would be easiest.
Here's how every enemy can damage the player ONCE in their life
Enemy creation event:
Code:
damage = 1
can_attack = true
Player Event - collides with enemy:
Code:
// other is enemy, self is player
if other.can_attack and not khealth == 0 begin
other.can_attack = false // other (enemy) can't attack us anymore
khealth -= other.damage // damaged once, but can't again
if khealth == 0 then situ = kstates.dead
switch situ begin
case kstates.kdead:
sprite_index = kdeath
break
end
end
If you wanted to make it so that an enemy can attack the player again under some condition, you'd just flip the enemy's flag.