mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Format.
This commit is contained in:
@@ -4,57 +4,61 @@ java_import 'org.apollo.game.model.Npc'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
# An array of npcs that cannot be spawned.
|
||||
blacklist = []
|
||||
|
||||
# Spawns a non-blacklisted npc in the specified position, or the player's position if both 'x' and 'y' are not supplied.
|
||||
on :command, :spawn, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless [1, 3].include? args.length and (id = args[0].to_i) > -1
|
||||
player.send_message("Invalid syntax - ::spawn [npc id] [x] [y]")
|
||||
return
|
||||
end
|
||||
args = command.arguments
|
||||
unless [1, 3].include? args.length and (id = args[0].to_i) > -1
|
||||
player.send_message('Invalid syntax - ::spawn [npc id] [optional-x] [optional-y]')
|
||||
return
|
||||
end
|
||||
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, that npc is blacklisted!")
|
||||
return
|
||||
end
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||
return
|
||||
end
|
||||
|
||||
position = args.length == 1 ? player.position : Position.new(args[1].to_i, args[2].to_i, player.position.height)
|
||||
position = args.length == 1 ? player.position : Position.new(args[1].to_i, args[2].to_i, player.position.height)
|
||||
|
||||
World.world.register(Npc.new(id, position))
|
||||
World.world.register(Npc.new(id, position))
|
||||
end
|
||||
|
||||
|
||||
# Mass spawns npcs around the player.
|
||||
on :command, :mass, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2 and (id = args[0].to_i) > -1 and (1..5).include? (range = args[1].to_i)
|
||||
player.send_message("Invalid syntax - ::spawn [npc id] [range (1-5)]")
|
||||
return
|
||||
end
|
||||
args = command.arguments
|
||||
unless args.length == 2 and (id = args[0].to_i) > -1 and (1..5).include? (range = args[1].to_i)
|
||||
player.send_message('Invalid syntax - ::spawn [npc id] [range (1-5)]')
|
||||
return
|
||||
end
|
||||
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, that npc is blacklisted!")
|
||||
return
|
||||
end
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||
return
|
||||
end
|
||||
|
||||
center_position = player.position
|
||||
center_position = player.position
|
||||
|
||||
minX = center_position.x - range
|
||||
minY = center_position.y - range
|
||||
maxX = center_position.x + range
|
||||
maxY = center_position.y + range
|
||||
minX = center_position.x - range
|
||||
minY = center_position.y - range
|
||||
maxX = center_position.x + range
|
||||
maxY = center_position.y + range
|
||||
z = center_position.height
|
||||
|
||||
for x in minX..maxX do
|
||||
for y in minY..maxY do
|
||||
World.world.register(Npc.new(id, Position.new(x, y, center_position.height)))
|
||||
end
|
||||
end
|
||||
player.send_message("Mass spawning npcs with id #{id}.")
|
||||
for x in minX..maxX do
|
||||
for y in minY..maxY do
|
||||
World.world.register(Npc.new(id, Position.new(x, y, z)))
|
||||
end
|
||||
end
|
||||
player.send_message("Mass spawning npcs with id #{id}.")
|
||||
end
|
||||
|
||||
# Unregisters all npcs from the world npc repository.
|
||||
on :command, :clearnpcs, RIGHTS_ADMIN do |player, command|
|
||||
iterator = World.world.npc_repository.iterator
|
||||
while iterator.has_next
|
||||
World.world.unregister(iterator.next)
|
||||
end
|
||||
player.send_message("All npcs removed.")
|
||||
iterator = World.world.npc_repository.iterator
|
||||
while iterator.has_next
|
||||
World.world.unregister(iterator.next)
|
||||
end
|
||||
player.send_message('Unregistered all npcs from the world.')
|
||||
end
|
||||
Reference in New Issue
Block a user