Ace of Spades
Member
So I've been working on a new ABS for the community, and hit a little bump in the road, so was wondering if someone could help. Basically, the below code will check to see if any events projectile hit-box is overlapping the enemy. If so, it will return true and change the projectiles self switch D on if it's not passable. Here's my code thus far:
Sorry if it's messy, I'm not much of a scripter and I'm still learning. =) Anyways, because I'm calling this definition from the enemy events themselves, is there anyway I can tell the event what i equals? I mean, right now it returns true that it was hit by a projectile. My problem is that I don't know how to define which projectile has hit it, because obviously a arrow will do different damage and effects than a rocket. Can anyone with a better understanding of scripts help me? Thanks in advance.
Edit: I was also wondering if there's a better method than $game_map.events.keys.size to check how many events are on the map. As of now, it keeps adding one, so every time a projectile is fired, it checks another keeps adding one more event to check, even after the projectile is erased. Better yet, would there be a way to check just the projectiles instead of every event?
Code:
def projectile_overlaps_event(event)
 for i in 1..$game_map.events.keys.size
  if ($game_map.events[event].x + ($game_map.events[event].width / 2)) > $game_map.events[i].projectile_left_edge
   if ($game_map.events[event].x - ($game_map.events[event].width / 2)) < $game_map.events[i].projectile_right_edge
    if ($game_map.events[event].y - $game_map.events[event].height) < $game_map.events[i].projectile_lower_edge
      if ($game_map.events[event].y - $game_map.events[event].legs) > $game_map.events[i].projectile_upper_edge
        if $game_map.events[i].projectile_passable == false
         $game_self_switches[[$game_map.map_id, i, 'D']] = true
         $game_map.need_refresh = true
        end
        return true
      end
    end
   end Â
  end
 end
end
Sorry if it's messy, I'm not much of a scripter and I'm still learning. =) Anyways, because I'm calling this definition from the enemy events themselves, is there anyway I can tell the event what i equals? I mean, right now it returns true that it was hit by a projectile. My problem is that I don't know how to define which projectile has hit it, because obviously a arrow will do different damage and effects than a rocket. Can anyone with a better understanding of scripts help me? Thanks in advance.
Edit: I was also wondering if there's a better method than $game_map.events.keys.size to check how many events are on the map. As of now, it keeps adding one, so every time a projectile is fired, it checks another keeps adding one more event to check, even after the projectile is erased. Better yet, would there be a way to check just the projectiles instead of every event?