nothing.
in_radius() and check_for_events() are functions declared to be used within that event, when needed.
the one thing you need, is an answer to the question of "is anyone within range?".... that's what the condition is there to process.
the answer to that question requires two parameters: what range, and within whose reach.... and "within whose reach", in this case, requires another process, because "who" is an event, and events are stored in a collection of events, and from that collection you need both one very specific event, and a lot of specific events from a potentially larger lot which is of no interest to you.
grab the lot.
from the lot, grab the range of events you care about
$game_map.events is a hash, so if you call events[X], it'll return [event], an array of length 1, so you go directly to the part of the hash storing the events, and pull out the container, whole: $game_map.events.values.
from there, filter by ID.
Code:
$game_map.events.values.select{|event| event.id.between?(2, 50)}
with the filtered lot, check for the range.
Code:
$game_map.events.values.select{|event| event.id.between?(2, 50)}.any?{|event| in_radius?(self, event, radius)}
"self" will center the check on the event being triggered (because all the instructions are written at event level), but you want a very specific event: event nº 1, from the lot of events.
Code:
$game_map.events.values.select{|event| event.id.between?(2, 50)}.any?{|event| in_radius?($game_map.events[1][0], event, radius)}
you can compact $game_map.events in it's own object, since it's *the same* object.
Code:
eventhash.values.select{|event| event.id.between?(2, 50)}.any?{|event| in_radius?(eventhash[1][0], event, radius)}
that returns a true/false, because of the any?() block, but there's no way *that* will fit in the conditional, so pack it as a function.
Code:
def check_for_event(eventhash, radius)
eventhash.values.select{|event| event.id.between?(2, 50)}.any?{|event| in_radius?(eventhash[1][0], event, radius)}
end
and pass the objects you replaced, as parameters.
Code:
Conditional Branch: Script: check_for_event($game_map.events, 5)
>
Else
>
End
Code:
check_for_event(batch, value)
-> def check_for_event(eventhash = batch, radius = value)
-> |event| in_radius?(eventhash[1][0], event, radius)
-> def in_radius(orig = eventhash[1][0], targ = event, rad = radius)
-> targ.position - orig.position < radius? -> return boolean
-> return boolean
->return boolean
->return boolean
check_for_event(batch, value) => boolean.
whatever the value of boolean is, it's decided by in_radius(), based on batch and value, passed down from way above.