mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Update all plugins to conform to Rubocop.
This commit is contained in:
@@ -9,11 +9,12 @@ CRAFTING_ALTARS = {}
|
||||
|
||||
# Represents a runecrafting altar.
|
||||
class Altar
|
||||
attr_reader :entrance_altar, :crafting_altar, :portal_id, :entrance_position, :exit_position, :crafting_centre
|
||||
attr_reader :entrance_altar, :crafting, :portal_id, :entrance, :exit, :crafting_centre
|
||||
|
||||
def initialize(entrance_altar, crafting_altar, portal_id, entrance_position, exit_position,crafting_centre)
|
||||
def initialize(entrance_altar, crafting, portal_id, entrance_position, exit_position,
|
||||
crafting_centre)
|
||||
@entrance_altar = entrance_altar
|
||||
@altar = crafting_altar
|
||||
@altar = crafting
|
||||
@portal_id = portal_id
|
||||
@entrance_position = entrance_position
|
||||
@exit_position = exit_position
|
||||
@@ -22,11 +23,12 @@ class Altar
|
||||
|
||||
end
|
||||
|
||||
|
||||
# Intercepts the item on object message.
|
||||
on :message, :item_on_object do |player, message|
|
||||
talisman = TALISMANS[message.id]; altar = ENTRANCE_ALTARS[message.object_id]
|
||||
unless (talisman.nil? || altar.nil?)
|
||||
talisman = TALISMANS[message.id]
|
||||
altar = ENTRANCE_ALTARS[message.object_id]
|
||||
|
||||
unless talisman.nil? || altar.nil?
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
message.terminate
|
||||
end
|
||||
@@ -34,22 +36,27 @@ end
|
||||
|
||||
# Intercepts the first object action message.
|
||||
on :message, :object_action do |player, message|
|
||||
if (message.option == 1)
|
||||
if message.option == 1
|
||||
object_id = message.id
|
||||
|
||||
if (altar = PORTALS[object_id]) != nil # Get the altar associated with this exit portal.
|
||||
player.start_action(TeleportAction.new(player, altar.entrance_position, 1, altar.exit_position))
|
||||
|
||||
if PORTALS.key?(object_id)
|
||||
altar = PORTALS[object_id]
|
||||
entrance = altar.entrance_position
|
||||
|
||||
player.start_action(TeleportAction.new(player, entrance, 1, altar.exit_position))
|
||||
message.terminate
|
||||
elsif (rune = RUNES[object_id]) != nil # Get the rune associated with this altar.
|
||||
elsif RUNES.key?(object_id)
|
||||
rune = RUNES[object_id]
|
||||
altar = CRAFTING_ALTARS[object_id]
|
||||
|
||||
player.start_action(RunecraftingAction.new(player, rune, altar.crafting_centre))
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# An action that causes a mob to teleport when it comes within the specified distance of a specified position.
|
||||
# An action that causes a mob to teleport when it comes within the specified distance of a
|
||||
# specified position.
|
||||
class TeleportAction < DistancedAction
|
||||
attr_reader :teleport_position
|
||||
|
||||
@@ -64,28 +71,59 @@ class TeleportAction < DistancedAction
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class && mob == other.mob && @teleport_position == other.teleport_position)
|
||||
get_class == other.get_class && mob == other.mob &&
|
||||
@teleport_position == other.teleport_position
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Appends an altar to the list.
|
||||
def append_altar(hash)
|
||||
#raise 'Hash must contain an entrance altar id, crafting altar id, entrance portal position, and altar centre position.'
|
||||
entrance_altar = hash[:entrance_altar]; crafting_altar = hash[:crafting_altar]; portal_id = hash[:exit_portal]; entrance_position = hash[:entrance_position]; exit_position = hash[:exit_position]; altar_centre = hash[:altar_centre]
|
||||
def altar(name, hash)
|
||||
unless hash.has_keys?(:entrance_altar, :crafting, :portal, :entrance, :exit, :altar_centre)
|
||||
fail "#{name} is missing one of: entrance altar id, crafting altar id, entrance portal position, "\
|
||||
"and altar centre position."
|
||||
end
|
||||
|
||||
PORTALS[portal_id] = ENTRANCE_ALTARS[entrance_altar] = CRAFTING_ALTARS[crafting_altar] = Altar.new(entrance_altar, crafting_altar, portal_id, Position.new(*entrance_position), Position.new(*exit_position), Position.new(*altar_centre))
|
||||
entrance_altar, crafting = hash[:entrance_altar], hash[:crafting]
|
||||
portal_id = hash[:portal]
|
||||
|
||||
entrance = Position.new(*hash[:entrance])
|
||||
exit_position = Position.new(*hash[:exit])
|
||||
centre = Position.new(*hash[:altar_centre])
|
||||
|
||||
altar = Altar.new(entrance_altar, crafting, portal_id, entrance, exit_position, centre)
|
||||
PORTALS[portal_id] = ENTRANCE_ALTARS[entrance_altar] = CRAFTING_ALTARS[crafting] = altar
|
||||
end
|
||||
|
||||
# Appends an altar to the list.
|
||||
append_altar :name => :air_altar, :entrance_altar => 2452, :crafting_altar => 2478, :exit_portal => 2465, :entrance_position => [ 2841, 4829 ], :exit_position => [ 2983, 3292 ], :altar_centre => [ 2844, 4834 ]
|
||||
append_altar :name => :mind_altar, :entrance_altar => 2453, :crafting_altar => 2479, :exit_portal => 2466, :entrance_position => [ 2793, 4828 ], :exit_position => [ 2980, 3514 ], :altar_centre => [ 2786, 4841 ]
|
||||
append_altar :name => :water_altar, :entrance_altar => 2454, :crafting_altar => 2480, :exit_portal => 2467, :entrance_position => [ 2726, 4832 ], :exit_position => [ 3187, 3166 ], :altar_centre => [ 2716, 4836 ]
|
||||
append_altar :name => :earth_altar, :entrance_altar => 2455, :crafting_altar => 2481, :exit_portal => 2468, :entrance_position => [ 2655, 4830 ], :exit_position => [ 3304, 3474 ], :altar_centre => [ 2658, 4841 ]
|
||||
append_altar :name => :fire_altar, :entrance_altar => 2456, :crafting_altar => 2482, :exit_portal => 2469, :entrance_position => [ 2574, 4849 ], :exit_position => [ 3311, 3256 ], :altar_centre => [ 2585, 4838 ]
|
||||
append_altar :name => :body_altar, :entrance_altar => 2457, :crafting_altar => 2483, :exit_portal => 2470, :entrance_position => [ 2524, 4825 ], :exit_position => [ 3051, 3445 ], :altar_centre => [ 2525, 4832 ]
|
||||
append_altar :name => :cosmic_altar, :entrance_altar => 2458, :crafting_altar => 2484, :exit_portal => 2471, :entrance_position => [ 2142, 4813 ], :exit_position => [ 2408, 4379 ], :altar_centre => [ 2142, 4833 ]
|
||||
append_altar :name => :law_altar, :entrance_altar => 2459, :crafting_altar => 2485, :exit_portal => 2472, :entrance_position => [ 2464, 4818 ], :exit_position => [ 2858, 3379 ], :altar_centre => [ 2464, 4832 ]
|
||||
append_altar :name => :nature_altar, :entrance_altar => 2460, :crafting_altar => 2486, :exit_portal => 2473, :entrance_position => [ 2400, 4835 ], :exit_position => [ 2867, 3019 ], :altar_centre => [ 2400, 4841 ]
|
||||
append_altar :name => :chaos_altar, :entrance_altar => 2461, :crafting_altar => 2487, :exit_portal => 2474, :entrance_position => [ 2268, 4842 ], :exit_position => [ 3058, 3591 ], :altar_centre => [ 2271, 4842 ]
|
||||
append_altar :name => :death_altar, :entrance_altar => 2462, :crafting_altar => 2488, :exit_portal => 2475, :entrance_position => [ 2208, 4830 ], :exit_position => [ 3222, 3222 ], :altar_centre => [ 2205, 4836 ]
|
||||
altar :air, entrance_altar: 2452, crafting: 2478, portal: 2465,
|
||||
entrance: [2841, 4829], exit: [2983, 3292], altar_centre: [2844, 4834]
|
||||
|
||||
altar :mind, entrance_altar: 2453, crafting: 2479, portal: 2466,
|
||||
entrance: [2793, 4828], exit: [2980, 3514], altar_centre: [2786, 4841]
|
||||
|
||||
altar :water, entrance_altar: 2454, crafting: 2480, portal: 2467,
|
||||
entrance: [2726, 4832], exit: [3187, 3166], altar_centre: [2716, 4836]
|
||||
|
||||
altar :earth, entrance_altar: 2455, crafting: 2481, portal: 2468,
|
||||
entrance: [2655, 4830], exit: [3304, 3474], altar_centre: [2658, 4841]
|
||||
|
||||
altar :fire, entrance_altar: 2456, crafting: 2482, portal: 2469,
|
||||
entrance: [2574, 4849], exit: [3311, 3256], altar_centre: [2585, 4838]
|
||||
|
||||
altar :body, entrance_altar: 2457, crafting: 2483, portal: 2470,
|
||||
entrance: [2524, 4825], exit: [3051, 3445], altar_centre: [2525, 4832]
|
||||
|
||||
altar :cosmic, entrance_altar: 2458, crafting: 2484, portal: 2471,
|
||||
entrance: [2142, 4813], exit: [2408, 4379], altar_centre: [2142, 4833]
|
||||
|
||||
altar :law, entrance_altar: 2459, crafting: 2485, portal: 2472,
|
||||
entrance: [2464, 4818], exit: [2858, 3379], altar_centre: [2464, 4832]
|
||||
|
||||
altar :nature, entrance_altar: 2460, crafting: 2486, portal: 2473,
|
||||
entrance: [2400, 4835], exit: [2867, 3019], altar_centre: [2400, 4841]
|
||||
|
||||
altar :chaos, entrance_altar: 2461, crafting: 2487, portal: 2474,
|
||||
entrance: [2268, 4842], exit: [3058, 3591], altar_centre: [2271, 4842]
|
||||
|
||||
altar :death, entrance_altar: 2462, crafting: 2488, portal: 2475,
|
||||
entrance: [2208, 4830], exit: [3222, 3222], altar_centre: [2205, 4836]
|
||||
|
||||
@@ -6,7 +6,7 @@ RUNES = {}
|
||||
# Represents a rune that can be crafted.
|
||||
class Rune
|
||||
attr_reader :name, :id, :level, :experience
|
||||
|
||||
|
||||
def initialize(id, level, experience, multiplier)
|
||||
@id = id
|
||||
@name = name_of(:item, id)
|
||||
@@ -15,32 +15,38 @@ class Rune
|
||||
@multiplier = multiplier
|
||||
end
|
||||
|
||||
def multiplier(level)
|
||||
return @multiplier.call(level)
|
||||
def equals(other)
|
||||
get_class == other.get_class && id == other.id
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class && id == other.id)
|
||||
def multiplier(level)
|
||||
@multiplier.call(level)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Appends a rune to the list.
|
||||
def append_rune(hash)
|
||||
raise 'Hash must contain an id, level, experience, and multiplier.' unless hash.has_keys?(:id, :level, :experience, :multiplier)
|
||||
id = hash[:id]; altar = hash[:altar]; level = hash[:level]; experience = hash[:experience]; multiplier = hash[:multiplier]
|
||||
|
||||
RUNES[altar] = Rune.new(id, level, experience, multiplier)
|
||||
def rune(name, hash)
|
||||
unless hash.has_keys?(:altar, :id, :level, :reward)
|
||||
fail "#{name} is missing one of id, altar, level, or reward."
|
||||
end
|
||||
|
||||
id, altar, level, experience = hash[:id], hash[:altar], hash[:level], hash[:reward]
|
||||
bonus = hash[:bonus] || ->(_) { 1 }
|
||||
|
||||
RUNES[altar] = Rune.new(id, level, experience, bonus)
|
||||
end
|
||||
|
||||
append_rune(:name => :air_rune, :altar => 2478, :id => 556, :level => 1, :experience => 5, :multiplier => lambda { |level| (level / 11).floor + 1 })
|
||||
append_rune(:name => :mind_rune, :altar => 2479, :id => 558, :level => 1, :experience => 5.5, :multiplier => lambda { |level| (level / 14).floor + 1 })
|
||||
append_rune(:name => :water_rune, :altar => 2480, :id => 555, :level => 5, :experience => 6, :multiplier => lambda { |level| (level / 19).floor + 1 })
|
||||
append_rune(:name => :earth_rune, :altar => 2481, :id => 557, :level => 9, :experience => 6.5, :multiplier => lambda { |level| (level / 26).floor + 1 })
|
||||
append_rune(:name => :fire_rune, :altar => 2482, :id => 554, :level => 14, :experience => 7, :multiplier => lambda { |level| (level / 35).floor + 1 })
|
||||
append_rune(:name => :body_rune, :altar => 2483, :id => 559, :level => 20, :experience => 7.5, :multiplier => lambda { |level| (level / 46).floor + 1 })
|
||||
append_rune(:name => :cosmic_rune, :altar => 2484, :id => 564, :level => 27, :experience => 8, :multiplier => lambda { |level| level >= 59 ? 2 : 1 })
|
||||
append_rune(:name => :chaos_rune, :altar => 2487, :id => 562, :level => 35, :experience => 8.5, :multiplier => lambda { |level| level >= 74 ? 2 : 1 })
|
||||
append_rune(:name => :nature_rune, :altar => 2486, :id => 561, :level => 44, :experience => 9, :multiplier => lambda { |level| level >= 91 ? 2 : 1 })
|
||||
append_rune(:name => :law_rune, :altar => 2485, :id => 563, :level => 54, :experience => 9.5, :multiplier => lambda { |level| 1 })
|
||||
append_rune(:name => :death_rune, :altar => 2488, :id => 560, :level => 65, :experience => 10, :multiplier => lambda { |level| 1 })
|
||||
rune :air, altar: 2478, id: 556, level: 1, reward: 5, bonus: ->(level) { (level / 11).floor + 1 }
|
||||
rune :mind, altar: 2479, id: 558, level: 1, reward: 5.5, bonus: ->(level) { (level / 14).floor + 1 }
|
||||
rune :water, altar: 2480, id: 555, level: 5, reward: 6, bonus: ->(level) { (level / 19).floor + 1 }
|
||||
rune :earth, altar: 2481, id: 557, level: 9, reward: 6.5,
|
||||
bonus: ->(level) { (level / 26).floor + 1 }
|
||||
rune :fire, altar: 2482, id: 554, level: 14, reward: 7, bonus: ->(level) { (level / 35).floor + 1 }
|
||||
rune :body, altar: 2483, id: 559, level: 20, reward: 7.5,
|
||||
bonus: ->(level) { (level / 46).floor + 1 }
|
||||
rune :cosmic, altar: 2484, id: 564, level: 27, reward: 8, bonus: ->(level) { level >= 59 ? 2 : 1 }
|
||||
rune :chaos, altar: 2487, id: 562, level: 35, reward: 8.5, bonus: ->(level) { level >= 74 ? 2 : 1 }
|
||||
rune :nature, altar: 2486, id: 561, level: 44, reward: 9, bonus: ->(level) { level >= 91 ? 2 : 1 }
|
||||
rune :law, altar: 2485, id: 563, level: 54, reward: 9.5
|
||||
rune :death, altar: 2488, id: 560, level: 65, reward: 10
|
||||
|
||||
@@ -25,11 +25,11 @@ class RunecraftingAction < DistancedAction
|
||||
def executeAction
|
||||
runecrafting_level = @player.skill_set.get_skill(Skill::RUNECRAFT).current_level
|
||||
|
||||
if (runecrafting_level < @rune.level)
|
||||
if runecrafting_level < @rune.level
|
||||
@player.send_message("You need a runecrafting level of #{@rune.level} to craft this rune.")
|
||||
stop
|
||||
elsif !@player.inventory.contains(RUNE_ESSENCE_ID)
|
||||
@player.send_message('You need rune essence to craft runes.')
|
||||
@player.send_message('You need rune essence to craft runes.')
|
||||
stop
|
||||
elsif @executions == 0
|
||||
@player.turn_to(@position)
|
||||
@@ -37,18 +37,22 @@ class RunecraftingAction < DistancedAction
|
||||
@player.play_graphic(RUNECRAFTING_GRAPHIC)
|
||||
@executions += 1
|
||||
elsif @executions == 1
|
||||
removed = @player.inventory.remove(RUNE_ESSENCE_ID, @player.inventory.get_amount(RUNE_ESSENCE_ID))
|
||||
added = removed * @rune.multiplier(runecrafting_level)
|
||||
@player.inventory.add(@rune.id, added)
|
||||
inventory = @player.inventory
|
||||
removed = inventory.remove(RUNE_ESSENCE_ID, inventory.get_amount(RUNE_ESSENCE_ID))
|
||||
|
||||
added = removed * @rune.multiplier(runecrafting_level)
|
||||
inventory.add(@rune.id, added)
|
||||
|
||||
name = added > 1 ? 'some ' + @rune.name + 's' : 'an ' + @rune.name
|
||||
@player.send_message("Your craft the rune essence into #{name}.", true)
|
||||
|
||||
@player.send_message("Your craft the rune essence into #{added > 1 ? 'some ' + @rune.name + 's' : 'an ' + @rune.name}.", true)
|
||||
@player.skill_set.add_experience(Skill::RUNECRAFT, removed * @rune.experience)
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class && @player == other.player && @rune == other.rune)
|
||||
get_class == other.get_class && @player == other.player && @rune == other.rune
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,41 +12,43 @@ class Talisman
|
||||
@locate_position = entrance_altar_position
|
||||
end
|
||||
|
||||
def get_message(player_position)
|
||||
return 'Your talisman glows brightly.' if player_position.is_within_distance(@locate_position, 10)
|
||||
def get_message(position)
|
||||
return 'Your talisman glows brightly.' if position.is_within_distance(@locate_position, 10)
|
||||
|
||||
direction = (player_position.y > @locate_position.y ? 'North' : 'South') + '-' + (player_position.x > @locate_position.x ? 'East' : 'West')
|
||||
return "The talisman pulls toward the #{direction}."
|
||||
direction = (position.y > @locate_position.y ? 'North' : 'South') + '-'
|
||||
direction += (position.x > @locate_position.x ? 'East' : 'West')
|
||||
|
||||
"The talisman pulls toward the #{direction}."
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Appends a talisman to the list.
|
||||
def append_talisman(hash)
|
||||
raise 'Hash must contain an id and an altar position.' unless hash.has_key?(:id) && hash.has_key?(:altar)
|
||||
id = hash[:id]; altar_position = Position.new(*hash[:altar])
|
||||
|
||||
TALISMANS[id] = Talisman.new(altar_position)
|
||||
end
|
||||
|
||||
# Intercepts the item option message.
|
||||
on :message, :fourth_item_option do |player, message|
|
||||
talisman = TALISMANS[message.id]
|
||||
if (talisman != nil)
|
||||
|
||||
unless talisman.nil?
|
||||
player.send_message(talisman.get_message(player.position))
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Appends talismans to the list.
|
||||
append_talisman :name => :air_talisman, :id => 1438, :altar => [ 2985, 3292 ]
|
||||
append_talisman :name => :earth_talisman, :id => 1440, :altar => [ 3306, 3474 ]
|
||||
append_talisman :name => :fire_talisman, :id => 1442, :altar => [ 3313, 3255 ]
|
||||
append_talisman :name => :water_talisman, :id => 1444, :altar => [ 3185, 3165 ]
|
||||
append_talisman :name => :body_talisman, :id => 1446, :altar => [ 3053, 3445 ]
|
||||
append_talisman :name => :mind_talisman, :id => 1448, :altar => [ 2982, 3514 ]
|
||||
append_talisman :name => :chaos_talisman, :id => 1452, :altar => [ 3059, 3590 ]
|
||||
append_talisman :name => :cosmic_talisman, :id => 1454, :altar => [ 2408, 4377 ]
|
||||
append_talisman :name => :death_talisman, :id => 1456, :altar => [ 0, 0 ]
|
||||
append_talisman :name => :law_talisman, :id => 1458, :altar => [ 2858, 3381 ]
|
||||
append_talisman :name => :nature_talisman, :id => 1462, :altar => [ 2869, 3019 ]
|
||||
# Appends a talisman to the list.
|
||||
def talisman(name, hash)
|
||||
fail 'Hash must contain an id and an altar position.' unless hash.has_keys?(:id, :altar)
|
||||
id, altar_position = hash[:id], Position.new(*hash[:altar])
|
||||
|
||||
TALISMANS[id] = Talisman.new(altar_position)
|
||||
end
|
||||
|
||||
talisman :air_talisman, id: 1438, altar: [2985, 3292]
|
||||
talisman :earth_talisman, id: 1440, altar: [3306, 3474]
|
||||
talisman :fire_talisman, id: 1442, altar: [3313, 3255]
|
||||
talisman :water_talisman, id: 1444, altar: [3185, 3165]
|
||||
talisman :body_talisman, id: 1446, altar: [3053, 3445]
|
||||
talisman :mind_talisman, id: 1448, altar: [2982, 3514]
|
||||
talisman :chaos_talisman, id: 1452, altar: [3059, 3590]
|
||||
talisman :cosmic_talisman, id: 1454, altar: [2408, 4377]
|
||||
talisman :death_talisman, id: 1456, altar: [0, 0]
|
||||
talisman :law_talisman, id: 1458, altar: [2858, 3381]
|
||||
talisman :nature_talisman, id: 1462, altar: [2869, 3019]
|
||||
|
||||
@@ -4,27 +4,27 @@ java_import 'org.apollo.game.message.impl.ConfigMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
|
||||
# The list of tiaras.
|
||||
# The hash of tiaras.
|
||||
TIARAS_BY_ALTAR = {}
|
||||
TIARAS_BY_ID = {}
|
||||
TIARAS_BY_TALISMAN = {}
|
||||
|
||||
# A tiara will make an altar accessible with 1 click
|
||||
# A tiara will make an altar accessible with a single click.
|
||||
class Tiara
|
||||
attr_reader :altar, :bitshift, :tiara_id, :experience, :talisman
|
||||
|
||||
def initialize(tiara_id, altar, talisman, bitshift, experience)
|
||||
@tiara_id = tiara_id
|
||||
@name = name_of(:item, tiara_id)
|
||||
@altar = altar
|
||||
@talisman = talisman
|
||||
@bitshift = bitshift
|
||||
@experience = experience
|
||||
@tiara_id = tiara_id
|
||||
@name = name_of(:item, tiara_id)
|
||||
@altar = altar
|
||||
@talisman = talisman
|
||||
@bitshift = bitshift
|
||||
@experience = experience
|
||||
end
|
||||
|
||||
# Sends a config message to change the altar object.
|
||||
def send_config(player)
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
end
|
||||
|
||||
end
|
||||
@@ -42,26 +42,18 @@ def send_empty_config(player)
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 0))
|
||||
end
|
||||
|
||||
# Appends a tiara to the list.
|
||||
def append_tiara(hash)
|
||||
raise 'Hash must contain a tiara id, altar id, talisman id, a bitshift number, and experience.' unless hash.has_keys?(:altar, :bitshift, :experience, :talisman, :tiara_id)
|
||||
tiara_id = hash[:tiara_id]; altar = hash[:altar]; talisman = hash[:talisman]; bitshift = hash[:bitshift]; experience = hash[:experience]
|
||||
|
||||
TIARAS_BY_TALISMAN[talisman] = TIARAS_BY_ID[tiara_id] = TIARAS_BY_ALTAR[altar] = Tiara.new(tiara_id, altar, talisman, bitshift, experience)
|
||||
end
|
||||
|
||||
# Sets the correct config upon login, if the player is wearing a tiara.
|
||||
on :login do |event, player|
|
||||
player = event.player
|
||||
on :login do |_event, player|
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
|
||||
|
||||
unless hat.nil?
|
||||
tiara = TIARAS_BY_ID[hat]
|
||||
if tiara.nil? then send_empty_config(player) else tiara.send_config end
|
||||
tiara.nil? ? send_empty_config(player) : tiara.send_config
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the SecondObjectAction message to support left-click access to the altar when wielding the correct tiara.
|
||||
# Intercepts the SecondObjectAction message to support left-click access to the altar when wielding
|
||||
# the correct tiara.
|
||||
on :message, :second_object_action do |player, message|
|
||||
object_id = message.id
|
||||
tiara = TIARAS_BY_ALTAR[object_id]
|
||||
@@ -69,11 +61,13 @@ on :message, :second_object_action do |player, message|
|
||||
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
|
||||
if (!hat.nil? && hat.id == tiara.tiara_id)
|
||||
if !hat.nil? && hat.id == tiara.tiara_id
|
||||
altar = ENTRANCE_ALTARS[tiara.altar]
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position)) unless altar.nil?
|
||||
|
||||
message.terminate
|
||||
|
||||
unless altar.nil?
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -99,14 +93,15 @@ end
|
||||
|
||||
# Intercepts the ItemOnObject message to create the tiara.
|
||||
on :message, :item_on_object do |player, message|
|
||||
tiara= TIARAS_BY_TALISMAN[message.id]; altar = CRAFTING_ALTARS[message.object_id]
|
||||
return if (tiara.nil? || altar.nil?)
|
||||
tiara, altar = TIARAS_BY_TALISMAN[message.id], CRAFTING_ALTARS[message.object_id]
|
||||
return if tiara.nil? || altar.nil?
|
||||
|
||||
player.start_action(CreateTiaraAction.new(player, message.position, tiara, altar))
|
||||
message.terminate
|
||||
end
|
||||
|
||||
# An action lets the player create a tiara when it comes within the specified distance of a specified position.
|
||||
# An action lets the player create a tiara when it comes within the specified distance of a
|
||||
# specified position.
|
||||
# noinspection JRubyImplementInterfaceInspection
|
||||
class CreateTiaraAction < DistancedAction
|
||||
|
||||
@@ -122,7 +117,7 @@ class CreateTiaraAction < DistancedAction
|
||||
inventory = @player.inventory
|
||||
|
||||
if inventory.contains_all(TIARA_ITEM_ID, @tiara.talisman)
|
||||
if (@tiara.altar == @altar.entrance_altar)
|
||||
if @tiara.altar == @altar.entrance_altar
|
||||
inventory.remove(@tiara.talisman, TIARA_ITEM_ID)
|
||||
inventory.add(@tiara.tiara_id)
|
||||
|
||||
@@ -130,30 +125,43 @@ class CreateTiaraAction < DistancedAction
|
||||
@player.play_animation(RUNECRAFTING_ANIMATION)
|
||||
@player.play_graphic(RUNECRAFTING_GRAPHIC)
|
||||
else
|
||||
@player.send_message("You can't use that talisman on this altar.")
|
||||
@player.send_message('You can\'t use that talisman on this altar.')
|
||||
end
|
||||
else
|
||||
@player.send_message("You need to have a talisman and blank tiara to enchant a tiara.")
|
||||
@player.send_message('You need to have a talisman and blank tiara to enchant a tiara.')
|
||||
end
|
||||
|
||||
stop
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class && @player == other.player && @tiara == other.tiara)
|
||||
get_class == other.get_class && @player == other.player && @tiara == other.tiara
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
append_tiara :name => :air_tiara, :tiara_id => 5527, :altar => 2452, :talisman => 1438, :bitshift => 0, :experience => 25
|
||||
append_tiara :name => :mind_tiara, :tiara_id => 5529, :altar => 2453, :talisman => 1448, :bitshift => 1, :experience => 27.5
|
||||
append_tiara :name => :water_tiara, :tiara_id => 5531, :altar => 2454, :talisman => 1444, :bitshift => 2, :experience => 30
|
||||
append_tiara :name => :body_tiara, :tiara_id => 5533, :altar => 2457, :talisman => 1446, :bitshift => 5, :experience => 37.5
|
||||
append_tiara :name => :earth_tiara, :tiara_id => 5535, :altar => 2455, :talisman => 1440, :bitshift => 3, :experience => 32.5
|
||||
append_tiara :name => :fire_tiara, :tiara_id => 5537, :altar => 2456, :talisman => 1442, :bitshift => 4, :experience => 35
|
||||
append_tiara :name => :cosmic_tiara, :tiara_id => 5539, :altar => 2458, :talisman => 1454, :bitshift => 6, :experience => 40
|
||||
append_tiara :name => :nature_tiara, :tiara_id => 5541, :altar => 2460, :talisman => 1462, :bitshift => 8, :experience => 45
|
||||
append_tiara :name => :chaos_tiara, :tiara_id => 5543, :altar => 2461, :talisman => 1452, :bitshift => 9, :experience => 42.5
|
||||
append_tiara :name => :law_tiara, :tiara_id => 5545, :altar => 2459, :talisman => 1458, :bitshift => 7, :experience => 47.5
|
||||
append_tiara :name => :death_tiara, :tiara_id => 5548, :altar => 2462, :talisman => 1456, :bitshift => 10, :experience => 50
|
||||
# TODO there are 2 other altars, which probably just aren't spawned on the map
|
||||
# Appends a tiara to the list.
|
||||
def tiara(_name, hash)
|
||||
unless hash.has_keys?(:altar, :bitshift, :experience, :talisman, :tiara_id)
|
||||
fail 'Hash must contain a tiara id, altar id, talisman id, a bitshift number, and experience.'
|
||||
end
|
||||
|
||||
tiara_id, altar, talisman = hash[:tiara_id], hash[:altar], hash[:talisman]
|
||||
bitshift, experience = hash[:bitshift], hash[:experience]
|
||||
|
||||
tiara = Tiara.new(tiara_id, altar, talisman, bitshift, experience)
|
||||
TIARAS_BY_TALISMAN[talisman] = TIARAS_BY_ID[tiara_id] = TIARAS_BY_ALTAR[altar] = tiara
|
||||
end
|
||||
|
||||
tiara :air_tiara, tiara_id: 5527, altar: 2452, talisman: 1438, bitshift: 0, experience: 25
|
||||
tiara :mind_tiara, tiara_id: 5529, altar: 2453, talisman: 1448, bitshift: 1, experience: 27.5
|
||||
tiara :water_tiara, tiara_id: 5531, altar: 2454, talisman: 1444, bitshift: 2, experience: 30
|
||||
tiara :body_tiara, tiara_id: 5533, altar: 2457, talisman: 1446, bitshift: 5, experience: 37.5
|
||||
tiara :earth_tiara, tiara_id: 5535, altar: 2455, talisman: 1440, bitshift: 3, experience: 32.5
|
||||
tiara :fire_tiara, tiara_id: 5537, altar: 2456, talisman: 1442, bitshift: 4, experience: 35
|
||||
tiara :cosmic_tiara, tiara_id: 5539, altar: 2458, talisman: 1454, bitshift: 6, experience: 40
|
||||
tiara :nature_tiara, tiara_id: 5541, altar: 2460, talisman: 1462, bitshift: 8, experience: 45
|
||||
tiara :chaos_tiara, tiara_id: 5543, altar: 2461, talisman: 1452, bitshift: 9, experience: 42.5
|
||||
tiara :law_tiara, tiara_id: 5545, altar: 2459, talisman: 1458, bitshift: 7, experience: 47.5
|
||||
tiara :death_tiara, tiara_id: 5548, altar: 2462, talisman: 1456, bitshift: 10, experience: 50
|
||||
# TODO: there are 2 other altars, which probably just aren't spawned on the map
|
||||
|
||||
Reference in New Issue
Block a user