mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Change the functionality of :bounds.
This commit is contained in:
@@ -16,7 +16,7 @@ java_import 'org.apollo.game.model.entity.Npc'
|
|||||||
# :y - the y coordinate where the npc will spawn.
|
# :y - the y coordinate where the npc will spawn.
|
||||||
# Optional arguments are as follows:
|
# 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
|
# :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.
|
# :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_animation - the animation that will be played when the npc spawns.
|
||||||
# :spawn_graphic - the graphic 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
|
when :face
|
||||||
decoded[:face] = direction_to_position(value, position)
|
decoded[:face] = direction_to_position(value, position)
|
||||||
when :delta_bounds
|
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
|
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)
|
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) ]
|
decoded[:boundary] = [ Position.new(x - dx, y - dy, z), Position.new(x + dx, y + dy, z) ]
|
||||||
when :bounds then decoded[:boundary] = value
|
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_animation then decoded[:spawn_animation] = Animation.new(value)
|
||||||
when :spawn_graphic then decoded[:spawn_graphic ] = Graphic.new(value)
|
when :spawn_graphic then decoded[:spawn_graphic ] = Graphic.new(value)
|
||||||
else raise "Unrecognised key #{key} - value #{value}."
|
else raise "Unrecognised key #{key} - value #{value}."
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# :y - the y coordinate where the npc will spawn.
|
# :y - the y coordinate where the npc will spawn.
|
||||||
# Optional arguments are as follows:
|
# 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
|
# :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.
|
# :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_animation - the animation that will be played when the npc spawns.
|
||||||
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# :y - the y coordinate where the npc will spawn.
|
# :y - the y coordinate where the npc will spawn.
|
||||||
# Optional arguments are as follows:
|
# 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
|
# :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.
|
# :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_animation - the animation that will be played when the npc spawns.
|
||||||
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# :y - the y coordinate where the npc will spawn.
|
# :y - the y coordinate where the npc will spawn.
|
||||||
# Optional arguments are as follows:
|
# 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
|
# :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.
|
# :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_animation - the animation that will be played when the npc spawns.
|
||||||
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# :y - the y coordinate where the npc will spawn.
|
# :y - the y coordinate where the npc will spawn.
|
||||||
# Optional arguments are as follows:
|
# 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
|
# :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.
|
# :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_animation - the animation that will be played when the npc spawns.
|
||||||
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public final class Npc extends Mob {
|
|||||||
* @param boundary The boundary.
|
* @param boundary The boundary.
|
||||||
*/
|
*/
|
||||||
public void setBoundary(Position[] 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();
|
this.boundary = boundary.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user