Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Event location detection from a different event.

Hi all!

I'm assuming the script required is going to be very complicated, but I could be wrong. I googled and check previous posts, yet I couldn't find anything relevant to my question.

Ok, I would like event B (Guard) to attack event A (Goblin) if event A enters within a certian range of event B.

I actually just want event B to run to event A and play a SE and event A to erase.

I'm not sure where to start, but I was searching for a "move-to coordinate" function, but couldn't find one, but I'm assuming I'll need something like that, and probably a parralell loop reading off event B's coordinates.

I appreciate any help on this matter, and if someone knows of a script that has part of this functionality, I'd be super gratefull to aquire such a gem.

Thanks in advance,

-Webgovernor
 
Well, how I would do it (which is probably wrong) is:

-paste a square of 'Player Touch' events all around the area, then have the event, when touched turn on a switch. For example call it 'start attack'

-then I would have the goblin event and the guard event.

-and then set the guard to when 'start attack is on' and then set route so that it will walk over to the goblin. 'Wait for move's completion'. Play SE: 'HIT' and then, turn on another switch 'goblin killed'

-then set a new page on the goblin, to when 'goblin killed' is ON, and have a blank image (or a dead pose)

Hope that helps!
 
Thanks for all the reply's.

I just downloaded the Near's view range script, and I took a quick look at it, unfortunately I'm going to work, so I couldn't find any appropriate follow up questions right away.

Thanks again.

-Webgovernor
 
Hi again,

I've edited Near's view_range script for demonstration purposes, I've gotten this to work IF I know the intruding event's ID (Goblin)

So far, the Goblin is detected when in range of the Guard, and it's returned to it's original location. That works, but I'm afraid that I need away to detect multiple goblins based off of their event location, this is going to be tough, as I won't know the ID of a specific goblin when there are 30-40 of them on a map.

Here's a quick edit of near's script:

PHP:
#==============================================================================
#   Event Range Script
#------------------------------------------------------------------------------
#    By: Near Fantastica
#    Edited by: Webgovernor 
#    Date: 06.09.06
#==============================================================================

class Event_Range
  #--------------------------------------------------------------------------
  # ● Range system works by sereching the area of a circle for the Player's xy
  #    The Veiw is set in each event and is the radius of the circle
  #    The Eaquation used is (Px-EX)^2 + (Py-Ey)^2 = radius^2
  #    If the Radius is less than or equal to the View the Player is inside the circle
  #--------------------------------------------------------------------------
  def initialize
  
  end
  #--------------------------------------------------------------------------
  def in_range?(element, object, range)
    x = (element.x - object.x) * (element.x - object.x)
    y = (element.y - object.y) * (element.y - object.y)
    r = x + y
    if r <= (range * range)
       return true
    else
      return false
    end
  end

   #--------------------------------------------------------------------------
  def event_view(event_id, entering_event_id, event_range, switch_id)
    event = $game_map.events[event_id]
    entering_event = $game_map.events[entering_event_id]
    if in_range?(event, entering_event, event_range)
      $game_switches[switch_id] = true
    end
  end
  #--------------------------------------------------------------------------
  def enemies_view(event_id, entering_event_id, event_range, switch_id)
    event = $game_map.events[event_id]
    entering_event = $game_map.events[entering_event_id]
    if event.direction == 2
      if entering_event.y >= event.y
        if in_range?(event, entering_event, event_range)
          $game_switches[switch_id] = true
        end
      end
    end
    if event.direction == 4
      if entering_event.x <= event.x
        if in_range?(event, entering_event, event_range)
          $game_switches[switch_id] = true
        end
      end
    end
    if event.direction == 6
      if entering_event.x >= event.x
        if in_range?(event, entering_event, event_range)
          $game_switches[switch_id] = true
        end
      end
    end
    if event.direction == 8
      if entering_event.y <= event.y
        if in_range?(event, entering_event, event_range)
          $game_switches[switch_id] = true
        end
      end
    end
  end
end

#======================================
# â–  Scene Title
#======================================

class Scene_Title
  #--------------------------------------------------------------------------
  alias vr_scene_title_update update
  #--------------------------------------------------------------------------
 def update
   $event_range = Event_Range.new
   vr_scene_title_update
 end
end

#======================================
# â–  Scene Load
#======================================

class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  alias vr_scene_load_read_save_data read_save_data
  #--------------------------------------------------------------------------
  def read_save_data(file)
    vr_scene_load_read_save_data(file)
    $event_range = Event_Range.new
  end
end

Anyway, my question IS:
Does anyone know of a way to check for moving events and return the event ID of a moving event IF it's in the range of the guard?

Thanks again,

-Webgovernor
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top