mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Update existing plugins to use the new utils plugin.
This commit is contained in:
@@ -35,7 +35,7 @@ end
|
|||||||
|
|
||||||
# Creates a new area and registers it with the supplied coordinates.
|
# Creates a new area and registers it with the supplied coordinates.
|
||||||
def area(hash)
|
def area(hash)
|
||||||
raise 'Hash must contain a name, coordinates, and actions pair.' unless hash.has_key?(:name) && hash.has_key?(:coordinates) && hash.has_key?(:actions)
|
raise 'Hash must contain a name, coordinates, and actions pair.' unless hash.has_keys?(:name, :coordinates, :actions)
|
||||||
name = hash[:name]; coordinates = hash[:coordinates]; actions = hash[:actions]
|
name = hash[:name]; coordinates = hash[:coordinates]; actions = hash[:actions]
|
||||||
|
|
||||||
AREAS << Area.new(name, coordinates, actions.is_a?(Symbol) ? [actions] : actions)
|
AREAS << Area.new(name, coordinates, actions.is_a?(Symbol) ? [actions] : actions)
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ java_import 'org.apollo.game.model.Graphic'
|
|||||||
# Makes the player perform the animation with the specified id.
|
# Makes the player perform the animation with the specified id.
|
||||||
on :command, :animate, RIGHTS_MOD do |player, command|
|
on :command, :animate, RIGHTS_MOD do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::animate [animation-id]')
|
||||||
player.send_message('Invalid syntax - ::animate [animation-id]')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
player.play_animation(Animation.new(args[0].to_i))
|
player.play_animation(Animation.new(args[0].to_i))
|
||||||
end
|
end
|
||||||
@@ -17,10 +14,7 @@ end
|
|||||||
# Makes the player perform the graphic with the specified id.
|
# Makes the player perform the graphic with the specified id.
|
||||||
on :command, :graphic, RIGHTS_MOD do |player, command|
|
on :command, :graphic, RIGHTS_MOD do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::graphic [graphic-id]')
|
||||||
player.send_message('Invalid syntax - ::graphic [graphic-id]')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
player.play_graphic(Graphic.new(args[0].to_i))
|
player.play_graphic(Graphic.new(args[0].to_i))
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
require 'java'
|
require 'java'
|
||||||
|
|
||||||
java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
||||||
|
|
||||||
|
# Opens the player's bank.
|
||||||
on :command, :bank, RIGHTS_ADMIN do |player, command|
|
on :command, :bank, RIGHTS_ADMIN do |player, command|
|
||||||
BankUtils.open_bank player
|
BankUtils.open_bank(player)
|
||||||
end
|
end
|
||||||
@@ -2,13 +2,10 @@ require 'java'
|
|||||||
|
|
||||||
java_import 'org.apollo.game.model.def.ItemDefinition'
|
java_import 'org.apollo.game.model.def.ItemDefinition'
|
||||||
|
|
||||||
# Adds the specified item to the player's own inventory.
|
# Adds the specified item to the player's inventory.
|
||||||
on :command, :item, RIGHTS_ADMIN do |player, command|
|
on :command, :item, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless (1..2).include? args.length
|
next unless valid_arg_length(args, (1..2), player, 'Invalid syntax - ::item [id] [amount]')
|
||||||
player.send_message('Invalid syntax - ::item [id] [amount]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
id = args[0].to_i
|
id = args[0].to_i
|
||||||
amount = args.length == 2 ? args[1].to_i : 1
|
amount = args.length == 2 ? args[1].to_i : 1
|
||||||
@@ -20,13 +17,10 @@ on :command, :item, RIGHTS_ADMIN do |player, command|
|
|||||||
player.inventory.add(id, amount)
|
player.inventory.add(id, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes the specified item from the player's own inventory.
|
# Removes the specified item from the player's inventory.
|
||||||
on :command, :remove, RIGHTS_MOD do |player, command|
|
on :command, :remove, RIGHTS_MOD do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless (1..2).include? args.length
|
next unless valid_arg_length(args, (1..2), player, 'Invalid syntax - ::remove [id] [amount]')
|
||||||
player.send_message('Invalid syntax - ::remove [id] [amount]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
id = args[0].to_i
|
id = args[0].to_i
|
||||||
amount = args.length == 2 ? args[1].to_i : 1
|
amount = args.length == 2 ? args[1].to_i : 1
|
||||||
@@ -38,14 +32,12 @@ on :command, :remove, RIGHTS_MOD do |player, command|
|
|||||||
player.inventory.remove(id, amount)
|
player.inventory.remove(id, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Clears the player's own inventory.
|
# Clears the player's inventory.
|
||||||
on :command, :empty, RIGHTS_MOD do |player, command|
|
on :command, :empty, RIGHTS_MOD do |player, command|
|
||||||
player.inventory.clear
|
player.inventory.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gives the player one thousand of each rune.
|
# Gives the player 1,000 of each rune.
|
||||||
on :command, :runes, RIGHTS_ADMIN do |player, command|
|
on :command, :runes, RIGHTS_ADMIN do |player, command|
|
||||||
(554..566).each do |i|
|
(554..566).each { |item| player.inventory.add(item, 1000) }
|
||||||
player.inventory.add(i, 1000)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -9,13 +9,10 @@ java_import 'org.apollo.game.model.entity.Player'
|
|||||||
|
|
||||||
on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments.to_a
|
args = command.arguments.to_a
|
||||||
unless args.length > 1
|
next unless valid_arg_length(args, (1..10), player, 'Invalid syntax - ::lookup [npc/object/item] [name]')
|
||||||
player.send_message('Invalid syntax - ::lookup [npc/object/item] [name]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
type = args.shift.downcase
|
type = args.shift.downcase
|
||||||
limit = args.first.to_i != 0 ? args.shift.to_i : 5
|
limit = args.first.to_i == 0 ? 5 : args.shift.to_i;
|
||||||
name = args.join(' ').downcase
|
name = args.join(' ').downcase
|
||||||
|
|
||||||
if ['npc', 'object', 'item'].index(type) == nil
|
if ['npc', 'object', 'item'].index(type) == nil
|
||||||
@@ -25,22 +22,19 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
|||||||
|
|
||||||
ids = find_entities(type, name, limit).join(', ')
|
ids = find_entities(type, name, limit).join(', ')
|
||||||
|
|
||||||
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}."
|
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids for \"#{name}\" are: #{ids}."
|
||||||
player.send_message(message)
|
player.send_message(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends the user a message with information about the item with the specified id.
|
# Sends the user a message with information about the item with the specified id.
|
||||||
on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::iteminfo [item id]')
|
||||||
player.send_message('Invalid syntax - ::iteminfo [item id]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
id = args[0].to_i
|
id = args[0].to_i
|
||||||
definition = ItemDefinition.lookup(id)
|
definition = ItemDefinition.lookup(id)
|
||||||
|
|
||||||
members = definition.is_members_only ? 'members' : 'not members'
|
members = definition.is_members_only ? 'members' : 'not members'
|
||||||
|
|
||||||
player.send_message("Item #{id} is called #{definition.name}, is #{members} only, and has a team of #{definition.team}.")
|
player.send_message("Item #{id} is called #{definition.name}, is #{members} only, and has a team of #{definition.team}.")
|
||||||
player.send_message("Its description is \"#{definition.description}\".")
|
player.send_message("Its description is \"#{definition.description}\".")
|
||||||
end
|
end
|
||||||
@@ -48,15 +42,12 @@ end
|
|||||||
# Sends the user a message with information about the npc with the specified id.
|
# Sends the user a message with information about the npc with the specified id.
|
||||||
on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::npcinfo [npc id]')
|
||||||
player.send_message('Invalid syntax - ::npcinfo [npc id]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
id = args[0].to_i
|
id = args[0].to_i
|
||||||
definition = NpcDefinition.lookup(id)
|
definition = NpcDefinition.lookup(id)
|
||||||
|
|
||||||
is_combative = definition.has_combat_level ? "has a combat level of #{definition.combat_level}" : "does not have a combat level"
|
is_combative = definition.has_combat_level ? "has a combat level of #{definition.combat_level}" : "does not have a combat level"
|
||||||
|
|
||||||
player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.")
|
player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.")
|
||||||
player.send_message("Its description is \"#{definition.description}\".")
|
player.send_message("Its description is \"#{definition.description}\".")
|
||||||
end
|
end
|
||||||
@@ -64,10 +55,7 @@ end
|
|||||||
# Sends the user a message with information about the object with the specified id.
|
# Sends the user a message with information about the object with the specified id.
|
||||||
on :command, :objectinfo, RIGHTS_ADMIN do |player, command|
|
on :command, :objectinfo, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
next unless valid_arg_length(args, 1, player, 'Invalid syntax - ::objectinfo [npc id]')
|
||||||
player.send_message('Invalid syntax - ::objectinfo [npc id]')
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
id = args[0].to_i
|
id = args[0].to_i
|
||||||
definition = ObjectDefinition.lookup(id)
|
definition = ObjectDefinition.lookup(id)
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ blacklist = []
|
|||||||
# Spawns a non-blacklisted npc in the specified position, or the player's position if both 'x' and 'y' are not supplied.
|
# 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|
|
on :command, :spawn, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless [1, 3].include? args.length and (id = args[0].to_i) > -1
|
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]')
|
player.send_message('Invalid syntax - ::spawn [npc id] [optional-x] [optional-y]')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if blacklist.include? id
|
if blacklist.include?(id)
|
||||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -33,7 +33,7 @@ on :command, :mass, RIGHTS_ADMIN do |player, command|
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if blacklist.include? id
|
if blacklist.include?(id)
|
||||||
player.send_message("Sorry, npc #{id} is blacklisted!")
|
player.send_message("Sorry, npc #{id} is blacklisted!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -56,9 +56,6 @@ end
|
|||||||
|
|
||||||
# Unregisters all npcs from the world npc repository.
|
# Unregisters all npcs from the world npc repository.
|
||||||
on :command, :clearnpcs, RIGHTS_ADMIN do |player, command|
|
on :command, :clearnpcs, RIGHTS_ADMIN do |player, command|
|
||||||
iterator = $world.npc_repository.iterator
|
$world.npc_repository.each { |npc| $world.unregister(npc) }
|
||||||
while iterator.has_next
|
|
||||||
$world.unregister(iterator.next)
|
|
||||||
end
|
|
||||||
player.send_message('Unregistered all npcs from the world.')
|
player.send_message('Unregistered all npcs from the world.')
|
||||||
end
|
end
|
||||||
@@ -10,10 +10,7 @@ end
|
|||||||
# Teleports the player to the specified position.
|
# Teleports the player to the specified position.
|
||||||
on :command, :tele, RIGHTS_ADMIN do |player, command|
|
on :command, :tele, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless (2..3).include?(args.length)
|
next unless valid_arg_length(args, (2..3), player, 'Invalid syntax - ::tele [x] [y] [optional-z]')
|
||||||
player.send_message('Invalid syntax - ::tele [x] [y] [optional-z]')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
x = args[0].to_i
|
x = args[0].to_i
|
||||||
y = args[1].to_i
|
y = args[1].to_i
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ end
|
|||||||
|
|
||||||
# Appends a food item to the list of consumables.
|
# Appends a food item to the list of consumables.
|
||||||
def append_food(hash)
|
def append_food(hash)
|
||||||
raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_key?(:name) && hash.has_key?(:id) && hash.has_key?(:restoration))
|
raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_keys?(:name, :id, :restoration))
|
||||||
name = hash[:name]; id = hash[:id]; restoration = hash[:restoration]
|
name = hash[:name]; id = hash[:id]; restoration = hash[:restoration]
|
||||||
|
|
||||||
append_consumable(Food.new(name, id, restoration))
|
append_consumable(Food.new(name, id, restoration))
|
||||||
|
|||||||
@@ -56,11 +56,10 @@ end
|
|||||||
|
|
||||||
# Returns the parameters for the potion, as an array. Raises if any of the specified keys do not exist
|
# Returns the parameters for the potion, as an array. Raises if any of the specified keys do not exist
|
||||||
def get_parameters(hash, keys)
|
def get_parameters(hash, keys)
|
||||||
|
raise "Hash must contain the following keys: #{ keys.join(", ") }." unless hash.has_keys?(*keys)
|
||||||
|
|
||||||
parameters = []
|
parameters = []
|
||||||
keys.each do |key|
|
keys.each { |key| parameters << hash[key] }
|
||||||
raise "Hash must contain key #{key}." unless hash.has_key?(key)
|
|
||||||
parameters << hash[key]
|
|
||||||
end
|
|
||||||
|
|
||||||
return parameters
|
return parameters
|
||||||
end
|
end
|
||||||
@@ -71,7 +70,7 @@ def append_potion(hash)
|
|||||||
|
|
||||||
unless (hash.size == 2)
|
unless (hash.size == 2)
|
||||||
keys << :skills << :boost
|
keys << :skills << :boost
|
||||||
class_name.insert(0, 'Boosting')
|
class_name.prepend('Boosting')
|
||||||
end
|
end
|
||||||
|
|
||||||
parameters = get_parameters(hash, keys)
|
parameters = get_parameters(hash, keys)
|
||||||
@@ -84,9 +83,9 @@ end
|
|||||||
|
|
||||||
# Some frequently-used boosts and skills
|
# Some frequently-used boosts and skills
|
||||||
# Lambda parameters are | maximum_skill_level, current_skill_level |
|
# Lambda parameters are | maximum_skill_level, current_skill_level |
|
||||||
basic_combat_boost = lambda { |m, l| l * 1.08 + 1 }
|
basic_combat_boost = lambda { |max, level| level * 1.08 + 1 }
|
||||||
super_combat_boost = lambda { |m, l| l * 1.12 + 2 }
|
super_combat_boost = lambda { |max, level| level * 1.12 + 2 }
|
||||||
non_combat_boost = lambda { |m, l| l + 3 }
|
non_combat_boost = lambda { |max, level| level + 3 }
|
||||||
|
|
||||||
all_skills = (ATTACK_SKILL_ID..RUNECRAFT_SKILL_ID).to_a
|
all_skills = (ATTACK_SKILL_ID..RUNECRAFT_SKILL_ID).to_a
|
||||||
combat_skills = [ ATTACK_SKILL_ID, STRENGTH_SKILL_ID, DEFENCE_SKILL_ID, MAGIC_SKILL_ID, RANGED_SKILL_ID ]
|
combat_skills = [ ATTACK_SKILL_ID, STRENGTH_SKILL_ID, DEFENCE_SKILL_ID, MAGIC_SKILL_ID, RANGED_SKILL_ID ]
|
||||||
@@ -100,11 +99,10 @@ append_potion :name => :defence, :doses => [ 2432, 133, 135, 137 ], :skills
|
|||||||
|
|
||||||
append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost
|
append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost
|
||||||
append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost
|
append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost
|
||||||
|
append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |max, level| level / 4 + 7 }
|
||||||
|
|
||||||
append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |m, l| l / 4 + 7 }
|
append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |max, level| [ level * 1.3 + 10, max ].min }
|
||||||
|
append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |max, level| [ level * 1.25 + 8, max ].min }
|
||||||
append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |m, l| [ l * 1.3 + 10, m ].min }
|
|
||||||
append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |m, l| [ l * 1.25 + 8, m ].min }
|
|
||||||
|
|
||||||
append_potion :name => :super_attack, :doses => [ 2436, 145, 147, 149 ], :skills => ATTACK_SKILL_ID, :boost => super_combat_boost
|
append_potion :name => :super_attack, :doses => [ 2436, 145, 147, 149 ], :skills => ATTACK_SKILL_ID, :boost => super_combat_boost
|
||||||
append_potion :name => :super_strength, :doses => [ 2440, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => super_combat_boost
|
append_potion :name => :super_strength, :doses => [ 2440, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => super_combat_boost
|
||||||
|
|||||||
@@ -46,7 +46,5 @@ class DummyAction < DistancedAction
|
|||||||
end
|
end
|
||||||
|
|
||||||
on :message, :second_object_action do |ctx, player, message|
|
on :message, :second_object_action do |ctx, player, message|
|
||||||
if (message.id == DUMMY_ID)
|
player.start_action(DummyAction.new(player, message.position)) if message.id == DUMMY_ID
|
||||||
player.start_action(DummyAction.new(player, message.position))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -11,7 +11,7 @@ java_import 'org.apollo.game.model.entity.Npc'
|
|||||||
# Information about npc spawning
|
# Information about npc spawning
|
||||||
#
|
#
|
||||||
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
||||||
# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
||||||
# :x - the x coordinate where the npc will spawn.
|
# :x - the x coordinate where the npc will spawn.
|
||||||
# :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:
|
||||||
@@ -25,7 +25,7 @@ java_import 'org.apollo.game.model.entity.Npc'
|
|||||||
|
|
||||||
# Spawns an npc with the properties specified in the hash.
|
# Spawns an npc with the properties specified in the hash.
|
||||||
def spawn_npc(hash)
|
def spawn_npc(hash)
|
||||||
raise 'A name (or id), x coordinate, and y coordinate must be specified to spawn an npc.' unless (hash.has_key?(:name) || hash.has_key?(:id)) && hash.has_key?(:x) && hash.has_key?(:y)
|
raise 'A name (or id), x coordinate, and y coordinate must be specified to spawn an npc.' unless (hash.has_key?(:name) || hash.has_key?(:id)) && hash.has_keys?(:x, :y)
|
||||||
npc = get_npc(hash)
|
npc = get_npc(hash)
|
||||||
spawn(npc, hash)
|
spawn(npc, hash)
|
||||||
end
|
end
|
||||||
@@ -41,7 +41,7 @@ end
|
|||||||
|
|
||||||
# Returns an npc with the id and position specified by the hash.
|
# Returns an npc with the id and position specified by the hash.
|
||||||
def get_npc(hash)
|
def get_npc(hash)
|
||||||
id = hash.delete(:id) || lookup_npc(hash.delete(:name))
|
id = lookup_npc(hash.delete(:name))
|
||||||
|
|
||||||
z = hash.delete(:z)
|
z = hash.delete(:z)
|
||||||
position = Position.new(hash.delete(:x), hash.delete(:y), z == nil ? 0 : z)
|
position = Position.new(hash.delete(:x), hash.delete(:y), z == nil ? 0 : z)
|
||||||
@@ -64,14 +64,14 @@ end
|
|||||||
# Parses the remaining key-value pairs in the hash.
|
# Parses the remaining key-value pairs in the hash.
|
||||||
def decode_hash(position, hash)
|
def decode_hash(position, hash)
|
||||||
decoded = {}
|
decoded = {}
|
||||||
|
|
||||||
hash.each do |key, value|
|
hash.each do |key, value|
|
||||||
case key
|
case key
|
||||||
when :face
|
when :face
|
||||||
facing_position = direction_to_position(value, position)
|
decoded[:face] = direction_to_position(value, position)
|
||||||
decoded[:face] = facing_position
|
|
||||||
when :delta_bounds
|
when :delta_bounds
|
||||||
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, 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
|
when :bounds then decoded[:boundary] = value
|
||||||
@@ -80,6 +80,7 @@ def decode_hash(position, hash)
|
|||||||
else raise "Unrecognised key #{key} - value #{value}."
|
else raise "Unrecognised key #{key} - value #{value}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return decoded
|
return decoded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Information about npc spawning
|
# Information about npc spawning
|
||||||
#
|
#
|
||||||
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
||||||
# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
||||||
# :x - the x coordinate where the npc will spawn.
|
# :x - the x coordinate where the npc will spawn.
|
||||||
# :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:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Information about npc spawning
|
# Information about npc spawning
|
||||||
#
|
#
|
||||||
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
||||||
# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
||||||
# :x - the x coordinate where the npc will spawn.
|
# :x - the x coordinate where the npc will spawn.
|
||||||
# :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:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Information about npc spawning
|
# Information about npc spawning
|
||||||
#
|
#
|
||||||
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
||||||
# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
||||||
# :x - the x coordinate where the npc will spawn.
|
# :x - the x coordinate where the npc will spawn.
|
||||||
# :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:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Information about npc spawning
|
# Information about npc spawning
|
||||||
#
|
#
|
||||||
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
# Npcs are passed to spawn npc as a hash. Every key and every non-integer value must be a Symbol. Every hash must implement the following:
|
||||||
# :name or :id - the name or the id of the npc. Use of :name is recommended. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
# :name - the name of the npc. If this npc shares its name with another, append the specific id after the name (e.g. :woman_4)
|
||||||
# :x - the x coordinate where the npc will spawn.
|
# :x - the x coordinate where the npc will spawn.
|
||||||
# :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:
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
# :spawn_graphic - the graphic that will be played when the npc spawns.
|
||||||
|
|
||||||
|
|
||||||
|
# Functional npcs
|
||||||
|
|
||||||
# 'Above-ground' npcs
|
# 'Above-ground' npcs
|
||||||
|
|
||||||
spawn_npc :name => :runescape_guide, :x => 3093, :y => 3107
|
spawn_npc :name => :runescape_guide, :x => 3093, :y => 3107
|
||||||
@@ -31,6 +33,17 @@ spawn_npc :name => :combat_instructor, :x => 3104, :y => 9506
|
|||||||
# Non-humanoid npcs
|
# Non-humanoid npcs
|
||||||
|
|
||||||
spawn_npc :name => :fishing_spot_316, :x => 3102, :y => 3093
|
spawn_npc :name => :fishing_spot_316, :x => 3102, :y => 3093
|
||||||
|
|
||||||
|
spawn_npc :name => :chicken, :x => 3140, :y => 3095
|
||||||
|
spawn_npc :name => :chicken, :x => 3140, :y => 3093
|
||||||
|
spawn_npc :name => :chicken, :x => 3138, :y => 3092
|
||||||
|
spawn_npc :name => :chicken, :x => 3137, :y => 3094
|
||||||
|
spawn_npc :name => :chicken, :x => 3138, :y => 3095
|
||||||
|
|
||||||
|
|
||||||
|
# 'Below-ground' npcs
|
||||||
|
# Note: They aren't actually on a different plane, they're just in a different location that pretends to be underground.
|
||||||
|
|
||||||
spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9514
|
spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9514
|
||||||
spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9517
|
spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9517
|
||||||
spawn_npc :name => :giant_rat_87, :x => 3106, :y => 9514
|
spawn_npc :name => :giant_rat_87, :x => 3106, :y => 9514
|
||||||
@@ -39,8 +52,3 @@ spawn_npc :name => :giant_rat_87, :x => 3105, :y => 9519
|
|||||||
spawn_npc :name => :giant_rat_87, :x => 3109, :y => 9516
|
spawn_npc :name => :giant_rat_87, :x => 3109, :y => 9516
|
||||||
spawn_npc :name => :giant_rat_87, :x => 3108, :y => 9520
|
spawn_npc :name => :giant_rat_87, :x => 3108, :y => 9520
|
||||||
spawn_npc :name => :giant_rat_87, :x => 3102, :y => 9517
|
spawn_npc :name => :giant_rat_87, :x => 3102, :y => 9517
|
||||||
spawn_npc :name => :chicken_41, :x => 3140, :y => 3095
|
|
||||||
spawn_npc :name => :chicken_41, :x => 3140, :y => 3093
|
|
||||||
spawn_npc :name => :chicken_41, :x => 3138, :y => 3092
|
|
||||||
spawn_npc :name => :chicken_41, :x => 3137, :y => 3094
|
|
||||||
spawn_npc :name => :chicken_41, :x => 3138, :y => 3095
|
|
||||||
@@ -3,9 +3,15 @@
|
|||||||
def valid_arg_length(args, length, player, message)
|
def valid_arg_length(args, length, player, message)
|
||||||
valid = length.kind_of?(Range) ? length.include?(args.length) : length == args.length
|
valid = length.kind_of?(Range) ? length.include?(args.length) : length == args.length
|
||||||
|
|
||||||
if (!valid)
|
player.send_message(message) if !valid
|
||||||
player.send_message(message)
|
return valid
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Add a has_keys? method to hash
|
||||||
|
class Hash
|
||||||
|
|
||||||
|
def has_keys?(*keys)
|
||||||
|
keys.each { |key| return false unless has_key?(key) }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user