diff --git a/data/plugins/areas/actions.rb b/data/plugins/areas/actions.rb index d875f841..aeaaa6ea 100644 --- a/data/plugins/areas/actions.rb +++ b/data/plugins/areas/actions.rb @@ -32,18 +32,18 @@ class AreaAction end # Called when the player has entered an area this action is registered to. - def entered(player) - @on_enter.call(player) unless @on_enter.nil? + def entered(player, position) + @on_enter.call(player, position) unless @on_enter.nil? end # Called while the player is in area this action is registered to. - def inside(player) - @while_in.call(player) unless @while_in.nil? + def inside(player, position) + @while_in.call(player, position) unless @while_in.nil? end # Called when the player has exited an area this action is registered to. - def exited(player) - @on_exit.call(player) unless @on_exit.nil? + def exited(player, position) + @on_exit.call(player, position) unless @on_exit.nil? end end diff --git a/data/plugins/areas/areas.rb b/data/plugins/areas/areas.rb index 4a77230d..7d7c83ae 100644 --- a/data/plugins/areas/areas.rb +++ b/data/plugins/areas/areas.rb @@ -51,18 +51,18 @@ class Area end # Called when the player has entered the area. - def entered(player) - @actions.each { |action| action.entered(player) } + def entered(player, position) + @actions.each { |action| action.entered(player, position) } end # Called when the player has moved, but is still inside the area (and was in the area before). - def inside(player) - @actions.each { |action| action.inside(player) } + def inside(player, position) + @actions.each { |action| action.inside(player, position) } end # Called when the player has exited the area. - def exited(player) - @actions.each { |action| action.exited(player) } + def exited(player, position) + @actions.each { |action| action.exited(player, position) } end end @@ -73,14 +73,15 @@ on :mob_position_update do |event| next unless mob.entity_type == EntityType::PLAYER old = mob.position + updated = event.next @areas.each do |area| was_inside = old.inside(area) - next_inside = event.next.inside(area) + next_inside = updated.inside(area) if was_inside - next_inside ? area.inside(mob) : area.exited(mob) + next_inside ? area.inside(mob, updated) : area.exited(mob, updated) else - area.entered(mob) if next_inside + area.entered(mob, updated) if next_inside end end end diff --git a/data/plugins/combat/wilderness.rb b/data/plugins/combat/wilderness.rb index 266058a4..e62989e4 100644 --- a/data/plugins/combat/wilderness.rb +++ b/data/plugins/combat/wilderness.rb @@ -17,14 +17,14 @@ module WildernessConstants end -# Determines the wilderness level for the specified player's position -def wilderness_level(player) - ((player.position.y - 3520) / 8).ceil + 1 +# Determines the wilderness level for the specified position +def wilderness_level(position) + ((position.y - 3520) / 8).ceil + 1 end area_action :wilderness_level do - on_entry do |player| - player.wilderness_level = wilderness_level(player) + on_entry do |player, position| + player.wilderness_level = wilderness_level(position) player.interface_set.open_overlay(WildernessConstants::OVERLAY_INTERFACE_ID) id = WildernessConstants::LEVEL_STRING_ID @@ -32,9 +32,9 @@ area_action :wilderness_level do show_action(player, ATTACK_ACTION) end - while_in do |player| + while_in do |player, position| current = player.wilderness_level - updated = wilderness_level(player) + updated = wilderness_level(position) if current != updated player.wilderness_level = updated @@ -44,7 +44,7 @@ area_action :wilderness_level do end end - on_exit do |player| + on_exit do |player, position| player.wilderness_level = 0 player.interface_set.close