mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Rebase the MessageHandler, MessageHandlerChain and MessageHandlerChainSet
Rebased several other pieces of code
This commit is contained in:
@@ -100,12 +100,12 @@ class FishingAction < DistancedAction
|
||||
end
|
||||
|
||||
# Intercepts the NpcAction message to determine whether or not a clicked npc was a fishing spot.
|
||||
on :message, :npc_action do |ctx, player, message|
|
||||
on :message, :npc_action do |player, message|
|
||||
npc = $world.npc_repository.get(message.index)
|
||||
spot = FISHING_SPOTS[npc.id]
|
||||
|
||||
unless spot.nil?
|
||||
player.start_action(FishingAction.new(player, npc.position, spot, message.option))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
@@ -25,8 +25,8 @@ module HerbloreMethod
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOnItemMessage handler for all Herblore-related functions.
|
||||
on :message, :item_on_item do |ctx, player, message|
|
||||
# The ItemOnItemMessage listener for all Herblore-related functions.
|
||||
on :message, :item_on_item do |player, message|
|
||||
primary = message.id
|
||||
secondary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
@@ -41,25 +41,25 @@ on :message, :item_on_item do |ctx, player, message|
|
||||
method = hash[secondary]
|
||||
unless method.nil?
|
||||
method.invoke(player, primary, secondary)
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOptionMessage handler for all Herblore-related functions.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
# The ItemOptionMessage listener for all Herblore-related functions.
|
||||
on :message, :first_item_option do |player, message|
|
||||
id = message.id
|
||||
method = HERBLORE_ITEM[id]
|
||||
|
||||
unless method.nil?
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
method = DRINK_ITEM[id]
|
||||
|
||||
unless method.nil?
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ class GrindingAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a ground ingredient to the ItemOnItemMessage handler interception.
|
||||
# Appends a ground ingredient to the ItemOnItemMessage listener interception.
|
||||
def append_ground(id, raw)
|
||||
ground = GroundIngredient.new(id, raw)
|
||||
append_herblore_item(ground, PESTLE_MORTAR, raw)
|
||||
|
||||
@@ -118,7 +118,7 @@ class ItemSpellAction < SpellAction
|
||||
end
|
||||
|
||||
# Intercepts the magic on item message.
|
||||
on :message, :magic_on_item do |ctx, player, message|
|
||||
on :message, :magic_on_item do |player, message|
|
||||
spell = message.spell_id
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
@@ -126,7 +126,7 @@ on :message, :magic_on_item do |ctx, player, message|
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(AlchemyAction.new(player, alch, slot, item))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
return
|
||||
end
|
||||
|
||||
@@ -135,18 +135,18 @@ on :message, :magic_on_item do |ctx, player, message|
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id]))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the button message
|
||||
on :message, :button do |ctx, player, message|
|
||||
on :message, :button do |player, message|
|
||||
button = message.widget_id
|
||||
|
||||
tele = TELEPORT_SPELLS[button]
|
||||
unless tele.nil?
|
||||
player.start_action(TeleportingAction.new(player, tele))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
return
|
||||
end
|
||||
|
||||
@@ -155,6 +155,6 @@ on :message, :button do |ctx, player, message|
|
||||
slots = bone_slots player
|
||||
|
||||
if slots.length == 0 then player.send_message("You can't convert these bones!") else player.start_action(ConvertingAction.new(player, conv, slots)) end
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
@@ -134,7 +134,7 @@ class ProspectingAction < DistancedAction
|
||||
|
||||
end
|
||||
|
||||
on :message, :first_object_action do |ctx, mob, message|
|
||||
on :message, :first_object_action do |mob, message|
|
||||
ore = ORES[message.id]
|
||||
|
||||
unless ore.nil?
|
||||
@@ -142,7 +142,7 @@ on :message, :first_object_action do |ctx, mob, message|
|
||||
end
|
||||
end
|
||||
|
||||
on :message, :second_object_action do |ctx, mob, message|
|
||||
on :message, :second_object_action do |mob, message|
|
||||
ore = ORES[message.id]
|
||||
|
||||
if !ore.nil?
|
||||
|
||||
@@ -51,11 +51,11 @@ class BuryBoneAction < Action
|
||||
end
|
||||
|
||||
# Intercepts the first item option message.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
on :message, :first_item_option do |player, message|
|
||||
bone = BONES[message.id]
|
||||
unless bone == nil
|
||||
player.start_action(BuryBoneAction.new(player, message.slot, bone))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ declare_attribute(:active_prayer, -1, :persistent)
|
||||
PRAYERS = {}
|
||||
|
||||
# Intercept the ButtonMessage to toggle a prayer.
|
||||
on :message, :button do |ctx, player, message|
|
||||
on :message, :button do |player, message|
|
||||
button = message.widget_id
|
||||
prayer = PRAYERS[button]
|
||||
|
||||
|
||||
@@ -24,26 +24,26 @@ end
|
||||
|
||||
|
||||
# Intercepts the item on object message.
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
on :message, :item_on_object do |player, message|
|
||||
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))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the first object action message.
|
||||
on :message, :object_action do |ctx, player, message|
|
||||
on :message, :object_action do |player, message|
|
||||
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))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
elsif (rune = RUNES[object_id]) != nil # Get the rune associated with this altar.
|
||||
altar = CRAFTING_ALTARS[object_id]
|
||||
player.start_action(RunecraftingAction.new(player, rune, altar.crafting_centre))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,11 +30,11 @@ def append_talisman(hash)
|
||||
end
|
||||
|
||||
# Intercepts the item option message.
|
||||
on :message, :fourth_item_option do |ctx, player, message|
|
||||
on :message, :fourth_item_option do |player, message|
|
||||
talisman = TALISMANS[message.id]
|
||||
if (talisman != nil)
|
||||
player.send_message(talisman.get_message(player.position))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ on :login do |event, player|
|
||||
end
|
||||
|
||||
# Intercepts the SecondObjectAction message to support left-click access to the altar when wielding the correct tiara.
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
on :message, :second_object_action do |player, message|
|
||||
object_id = message.id
|
||||
tiara = TIARAS_BY_ALTAR[object_id]
|
||||
next if tiara.nil?
|
||||
@@ -73,37 +73,37 @@ on :message, :second_object_action do |ctx, player, message|
|
||||
altar = ENTRANCE_ALTARS[tiara.altar]
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position)) unless altar.nil?
|
||||
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the SecondItemAction message to allow for config sending.
|
||||
on :message, :second_item_option do |ctx, player, message|
|
||||
on :message, :second_item_option do |player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
|
||||
unless tiara.nil?
|
||||
tiara.send_config(player)
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the FirstItemAction message to allow for config sending.
|
||||
on :message, :first_item_action do |ctx, player, message|
|
||||
on :message, :first_item_action do |player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
|
||||
unless tiara.nil?
|
||||
send_empty_config(player)
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the ItemOnObject message to create the tiara.
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
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?)
|
||||
|
||||
player.start_action(CreateTiaraAction.new(player, message.position, tiara, altar))
|
||||
ctx.break_handler_chain
|
||||
message.terminate
|
||||
end
|
||||
|
||||
# An action lets the player create a tiara when it comes within the specified distance of a specified position.
|
||||
|
||||
Reference in New Issue
Block a user