Checking if hit (Solved)


I have a bomb exploding, and enemies in it's range.
I want the bomb to do damage only once to each enemy so that it doesn't keep subtracting from the enemies health.
I wrote this:
(this is in the bomb)
damage = .5;
hit = [];
//Collision with enemy
var not_hit = true;
for (var i = 0; i < array_length(hit); i++) {
    if (hit[i] = other) {
        not_hit = false;
if (not_hit) {
    other.hlth -= damage;
    hit[array_length(hit)] = other;
I also have code that destroys the bomb after exploding, so the array doesn't do anything else.
But when I play the game, the bomb doesn't show signs of doing any damage.
Is there any way to keep track of what enemies this bomb has hit, so that it does not repeatedly take damage from the enemy?

Simon Gust

A single time event is one of the easier scenarios for this problem.
The bomb can be destroyed on detonation and not hit anything else after that.
A with() statement loops through every object of choice.

collision with enemy
// create local variables, so you do not need "other".
var bomb_x = x;
var bomb_y = y;
var bomb_damage = damage;

// check every enemy
with (obj_enemy)
    // check if enemy is in range
    if (point_distance(bomb_x, bomb_y, x, y) < 100) 
        // deal damage to enemy
        hlth = max(0, hlth - bomb_damage);

// destroy bomb