diff --git a/data/plugins/entity/spawning/npc-spawn.rb b/data/plugins/entity/spawning/npc-spawn.rb index f5e86397..e8490e38 100644 --- a/data/plugins/entity/spawning/npc-spawn.rb +++ b/data/plugins/entity/spawning/npc-spawn.rb @@ -16,7 +16,7 @@ java_import 'org.apollo.game.model.entity.Npc' # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: # :face - the direction the npc should face when it spawns. Supported options are :north, :north_east, :east, :south_east, :south, :south_west, :west, and :north_west -# :bounds - the rectangular bound that the npc can wander about in. Order is [top-left x-coordinate, top-left y-coordinate, bottom-right x-coordinate, bottom-right y-coordinate] +# :bounds - the rectangular bound that the npc can wander about in. Order is [bottom-left x-coordinate, bottom-left y-coordinate, top-right x-coordinate, top-right y-coordinate] # :delta_bounds - the rectangular bound that the npc can wander about in, as a difference from the spawn point. Order is [x-delta, y-delta]. Should not be used with :bounds. # :spawn_animation - the animation that will be played when the npc spawns. # :spawn_graphic - the graphic that will be played when the npc spawns. @@ -71,11 +71,16 @@ def decode_hash(position, hash) when :face decoded[:face] = direction_to_position(value, position) when :delta_bounds + raise ':delta_bounds must have two values.' unless value.length == 2 dx, dy, x, y, z = value[0], value[1], position.x, position.y, position.height raise 'Delta values cannot be less than 0.' if (dx < 0 || dy < 0) - decoded[:boundary] = [ Position.new(x + dx, y, z), Position.new(x, y + dy, z), Position.new(x - dx, y, z), Position.new(x, y - dy, z) ] - when :bounds then decoded[:boundary] = value + decoded[:boundary] = [ Position.new(x - dx, y - dy, z), Position.new(x + dx, y + dy, z) ] + when :bounds + raise ':bounds must have four values.' unless value.length == 4 + min_x, min_y, max_x, max_y = value[0], value[1], value[2], value[3] + + decoded[:boundary] = [ Position.new(min_x, min_y), Position.new(max_x, max_y) ] when :spawn_animation then decoded[:spawn_animation] = Animation.new(value) when :spawn_graphic then decoded[:spawn_graphic ] = Graphic.new(value) else raise "Unrecognised key #{key} - value #{value}." diff --git a/data/plugins/location/al-kharid/npcs.rb b/data/plugins/location/al-kharid/npcs.rb index d61324ae..f5d48346 100644 --- a/data/plugins/location/al-kharid/npcs.rb +++ b/data/plugins/location/al-kharid/npcs.rb @@ -6,7 +6,7 @@ # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: # :face - the direction the npc should face when it spawns. Supported options are :north, :north_east, :east, :south_east, :south, :south_west, :west, and :north_west -# :bounds - the rectangular bound that the npc can wander about in. Order is [top-left x-coordinate, top-left y-coordinate, bottom-right x-coordinate, bottom-right y-coordinate] +# :bounds - the rectangular bound that the npc can wander about in. Order is [bottom-left x-coordinate, bottom-left y-coordinate, top-right x-coordinate, top-right y-coordinate] # :delta_bounds - the rectangular bound that the npc can wander about in, as a difference from the spawn point. Order is [x-delta, y-delta]. Should not be used with :bounds. # :spawn_animation - the animation that will be played when the npc spawns. # :spawn_graphic - the graphic that will be played when the npc spawns. diff --git a/data/plugins/location/edgeville/npcs.rb b/data/plugins/location/edgeville/npcs.rb index 36cb4eb0..f8dbd14c 100644 --- a/data/plugins/location/edgeville/npcs.rb +++ b/data/plugins/location/edgeville/npcs.rb @@ -6,7 +6,7 @@ # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: # :face - the direction the npc should face when it spawns. Supported options are :north, :north_east, :east, :south_east, :south, :south_west, :west, and :north_west -# :bounds - the rectangular bound that the npc can wander about in. Order is [top-left x-coordinate, top-left y-coordinate, bottom-right x-coordinate, bottom-right y-coordinate] +# :bounds - the rectangular bound that the npc can wander about in. Order is [bottom-left x-coordinate, bottom-left y-coordinate, top-right x-coordinate, top-right y-coordinate] # :delta_bounds - the rectangular bound that the npc can wander about in, as a difference from the spawn point. Order is [x-delta, y-delta]. Should not be used with :bounds. # :spawn_animation - the animation that will be played when the npc spawns. # :spawn_graphic - the graphic that will be played when the npc spawns. diff --git a/data/plugins/location/lumbridge/npcs.rb b/data/plugins/location/lumbridge/npcs.rb index 12dfc1d0..73f15689 100644 --- a/data/plugins/location/lumbridge/npcs.rb +++ b/data/plugins/location/lumbridge/npcs.rb @@ -6,7 +6,7 @@ # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: # :face - the direction the npc should face when it spawns. Supported options are :north, :north_east, :east, :south_east, :south, :south_west, :west, and :north_west -# :bounds - the rectangular bound that the npc can wander about in. Order is [top-left x-coordinate, top-left y-coordinate, bottom-right x-coordinate, bottom-right y-coordinate] +# :bounds - the rectangular bound that the npc can wander about in. Order is [bottom-left x-coordinate, bottom-left y-coordinate, top-right x-coordinate, top-right y-coordinate] # :delta_bounds - the rectangular bound that the npc can wander about in, as a difference from the spawn point. Order is [x-delta, y-delta]. Should not be used with :bounds. # :spawn_animation - the animation that will be played when the npc spawns. # :spawn_graphic - the graphic that will be played when the npc spawns. diff --git a/data/plugins/location/tutorial-island/npcs.rb b/data/plugins/location/tutorial-island/npcs.rb index 7d377be1..ee49851d 100644 --- a/data/plugins/location/tutorial-island/npcs.rb +++ b/data/plugins/location/tutorial-island/npcs.rb @@ -6,7 +6,7 @@ # :y - the y coordinate where the npc will spawn. # Optional arguments are as follows: # :face - the direction the npc should face when it spawns. Supported options are :north, :north_east, :east, :south_east, :south, :south_west, :west, and :north_west -# :bounds - the rectangular bound that the npc can wander about in. Order is [top-left x-coordinate, top-left y-coordinate, bottom-right x-coordinate, bottom-right y-coordinate] +# :bounds - the rectangular bound that the npc can wander about in. Order is [bottom-left x-coordinate, bottom-left y-coordinate, top-right x-coordinate, top-right y-coordinate] # :delta_bounds - the rectangular bound that the npc can wander about in, as a difference from the spawn point. Order is [x-delta, y-delta]. Should not be used with :bounds. # :spawn_animation - the animation that will be played when the npc spawns. # :spawn_graphic - the graphic that will be played when the npc spawns. diff --git a/src/org/apollo/game/model/entity/Npc.java b/src/org/apollo/game/model/entity/Npc.java index 66532a96..fc0deb19 100644 --- a/src/org/apollo/game/model/entity/Npc.java +++ b/src/org/apollo/game/model/entity/Npc.java @@ -101,7 +101,7 @@ public final class Npc extends Mob { * @param boundary The boundary. */ public void setBoundary(Position[] boundary) { - Preconditions.checkArgument(boundary.length == 4, "Boundary count must be 4."); + Preconditions.checkArgument(boundary.length == 2, "Boundary count must be 2."); this.boundary = boundary.clone(); }