mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Rename Events to Messages.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.DisplayCrossbonesEvent'
|
||||
java_import 'org.apollo.game.message.impl.DisplayCrossbonesMessage'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
AREA_ACTIONS = {}
|
||||
@@ -56,12 +56,12 @@ end
|
||||
area_action :wilderness do
|
||||
|
||||
on_entry do |player|
|
||||
player.send(DisplayCrossbonesEvent.new(true))
|
||||
player.send(DisplayCrossbonesMessage.new(true))
|
||||
player.in_wilderness = true
|
||||
end
|
||||
|
||||
on_exit do |player|
|
||||
player.send(DisplayCrossbonesEvent.new(false))
|
||||
player.send(DisplayCrossbonesMessage.new(false))
|
||||
player.in_wilderness = false
|
||||
end
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@ class BankAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the object action event
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
if event.id == BANK_BOOTH_ID
|
||||
player.start_action(BankAction.new(player, event.position))
|
||||
# Intercepts the object action message
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
if message.id == BANK_BOOTH_ID
|
||||
player.start_action(BankAction.new(player, message.position))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_npc_action do |ctx, player, event|
|
||||
npc = $world.npc_repository.get(event.index)
|
||||
on :message, :second_npc_action do |ctx, player, message|
|
||||
npc = $world.npc_repository.get(message.index)
|
||||
if BANKER_NPCS.include?(npc.id)
|
||||
player.start_action(BankAction.new(player, npc.position))
|
||||
ctx.break_handler_chain
|
||||
|
||||
+28
-28
@@ -15,7 +15,7 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.command.CommandListener'
|
||||
java_import 'org.apollo.game.event.handler.EventHandler'
|
||||
java_import 'org.apollo.game.message.handler.MessageHandler'
|
||||
java_import 'org.apollo.game.login.LoginListener'
|
||||
java_import 'org.apollo.game.login.LogoutListener'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
@@ -77,18 +77,18 @@ class ProcLogoutListener
|
||||
end
|
||||
end
|
||||
|
||||
# An EventHandler which executes a Proc object with three arguments: the chain
|
||||
# context, the player and the event.
|
||||
class ProcEventHandler < EventHandler
|
||||
# An MessageHandler which executes a Proc object with three arguments: the chain
|
||||
# context, the player and the message.
|
||||
class ProcMessageHandler < MessageHandler
|
||||
def initialize(block, option)
|
||||
super() # required (with brackets!), see http://jira.codehaus.org/browse/JRUBY-679
|
||||
@block = block
|
||||
@option = option
|
||||
end
|
||||
|
||||
def handle(ctx, player, event)
|
||||
if (@option == 0 || @option == event.option)
|
||||
@block.call(ctx, player, event)
|
||||
def handle(ctx, player, message)
|
||||
if (@option == 0 || @option == message.option)
|
||||
@block.call(ctx, player, message)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -127,11 +127,11 @@ def schedule(*args, &block)
|
||||
end
|
||||
end
|
||||
|
||||
# Defines some sort of action to take upon an event. The following types of
|
||||
# event are currently valid:
|
||||
# Defines some sort of action to take upon an message. The following types of
|
||||
# message are currently valid:
|
||||
#
|
||||
# * :command
|
||||
# * :event
|
||||
# * :message
|
||||
# * :button
|
||||
# * :login
|
||||
# * :logout
|
||||
@@ -140,19 +140,19 @@ end
|
||||
# minimum rights level to use it). The minimum rights level defaults to
|
||||
# STANDARD. The block should have two arguments: player and command.
|
||||
#
|
||||
# An event takes no arguments. The block should have three arguments: the chain
|
||||
# context, the player and the event object.
|
||||
# An message takes no arguments. The block should have three arguments: the chain
|
||||
# context, the player and the message object.
|
||||
#
|
||||
# A button takes one argument (the id). The block should have one argument: the
|
||||
# player who clicked the button.
|
||||
def on(type, *args, &block)
|
||||
case type
|
||||
when :command then on_command(args, block)
|
||||
when :event then on_event(args, block)
|
||||
when :message then on_message(args, block)
|
||||
when :button then on_button(args, block)
|
||||
when :login then on_login(block)
|
||||
when :logout then on_logout(block)
|
||||
else raise 'Unknown event type.'
|
||||
else raise 'Unknown message type.'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,39 +162,39 @@ def on_button(args, proc)
|
||||
|
||||
id = args[0].to_i
|
||||
|
||||
on :event, :button do |ctx, player, event|
|
||||
proc.call(player) if event.widget_id == id
|
||||
on :message, :button do |ctx, player, message|
|
||||
proc.call(player) if message.widget_id == id
|
||||
end
|
||||
end
|
||||
|
||||
# Defines an action to be taken upon an event.
|
||||
# The event can either be a symbol with the lower-case underscored class name, or the class itself.
|
||||
def on_event(args, proc)
|
||||
raise 'Event must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
# Defines an action to be taken upon an message.
|
||||
# The message can either be a symbol with the lower-case underscored class name, or the class itself.
|
||||
def on_message(args, proc)
|
||||
raise 'Message must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
numbers = [ 'first', 'second', 'third', 'fourth', 'fifth' ]
|
||||
event = args[0]; option = 0
|
||||
message = args[0]; option = 0
|
||||
|
||||
numbers.each_index do |index|
|
||||
number = numbers[index]
|
||||
|
||||
if event.to_s.start_with?(number)
|
||||
if message.to_s.start_with?(number)
|
||||
option = index + 1
|
||||
event = event[number.length + 1, event.length].to_sym
|
||||
message = message[number.length + 1, message.length].to_sym
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if event.is_a?(Symbol)
|
||||
class_name = event.to_s.camelize.concat('Event')
|
||||
event = Java::JavaClass.for_name("org.apollo.game.event.impl.#{class_name}")
|
||||
if message.is_a?(Symbol)
|
||||
class_name = message.to_s.camelize.concat('Message')
|
||||
message = Java::JavaClass.for_name("org.apollo.game.message.impl.#{class_name}")
|
||||
end
|
||||
|
||||
$ctx.add_last_event_handler(event, ProcEventHandler.new(proc, option))
|
||||
$ctx.add_last_message_handler(message, ProcMessageHandler.new(proc, option))
|
||||
end
|
||||
|
||||
# Defines an action to be taken upon a command.
|
||||
def on_command(args, proc)
|
||||
raise 'Command event must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
raise 'Command message must have one or two arguments.' unless (1..2).include?(args.length)
|
||||
|
||||
rights = args.length == 2 ? args[1] : RIGHTS_STANDARD
|
||||
$ctx.add_command_listener(args[0].to_s, ProcCommandListener.new(rights, proc))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
java_import 'org.apollo.game.event.impl.SendFriendEvent'
|
||||
java_import 'org.apollo.game.message.impl.SendFriendMessage'
|
||||
|
||||
on :event, :privacy_option do |ctx, player, event|
|
||||
player.chat_privacy = event.chat_privacy
|
||||
player.friend_privacy = event.friend_privacy
|
||||
player.trade_privacy = event.trade_privacy
|
||||
on :message, :privacy_option do |ctx, player, message|
|
||||
player.chat_privacy = message.chat_privacy
|
||||
player.friend_privacy = message.friend_privacy
|
||||
player.trade_privacy = message.trade_privacy
|
||||
|
||||
update_friends(player, event.friend_privacy == PrivacyState::OFF ? 0 : player.world_id)
|
||||
update_friends(player, message.friend_privacy == PrivacyState::OFF ? 0 : player.world_id)
|
||||
end
|
||||
@@ -1,48 +1,48 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.FriendServerStatusEvent'
|
||||
java_import 'org.apollo.game.event.impl.SendFriendEvent'
|
||||
java_import 'org.apollo.game.message.impl.FriendServerStatusMessage'
|
||||
java_import 'org.apollo.game.message.impl.SendFriendMessage'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.setting.ServerStatus'
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
|
||||
# Processes an add friend event, updating the logged-in status of the player (and the person they added) if necessary.
|
||||
on :event, :add_friend do |ctx, player, event|
|
||||
friend_username = event.username
|
||||
# Processes an add friend message, updating the logged-in status of the player (and the person they added) if necessary.
|
||||
on :message, :add_friend do |ctx, player, message|
|
||||
friend_username = message.username
|
||||
player_username = player.username
|
||||
|
||||
player.add_friend(friend_username)
|
||||
friend = $world.get_player(friend_username)
|
||||
|
||||
if friend == nil # the friend the player added is offline
|
||||
player.send(SendFriendEvent.new(friend_username, 0))
|
||||
player.send(SendFriendMessage.new(friend_username, 0))
|
||||
elsif friend.friends_with(player_username) # new friend already has the player added
|
||||
friend.send(SendFriendEvent.new(player_username, player.world_id)) unless player.friend_privacy == PrivacyState::OFF # player's private chat state is not off, so notify the friend
|
||||
friend.send(SendFriendMessage.new(player_username, player.world_id)) unless player.friend_privacy == PrivacyState::OFF # player's private chat state is not off, so notify the friend
|
||||
|
||||
player.send(SendFriendEvent.new(friend_username, friend.world_id)) unless friend.friend_privacy == PrivacyState::OFF # new friend's private chat state is not off, so notify the player
|
||||
player.send(SendFriendMessage.new(friend_username, friend.world_id)) unless friend.friend_privacy == PrivacyState::OFF # new friend's private chat state is not off, so notify the player
|
||||
elsif friend.friend_privacy == PrivacyState::ON # new friend doesn't have the player added but their private chat state is on
|
||||
player.send(SendFriendEvent.new(friend_username, friend.world_id)) # so we can let the player know what world they're on
|
||||
player.send(SendFriendMessage.new(friend_username, friend.world_id)) # so we can let the player know what world they're on
|
||||
end
|
||||
end
|
||||
|
||||
# Processes a remove friend event, updating the logged-in status of the player if necessary.
|
||||
on :event, :remove_friend do |ctx, player, event|
|
||||
friend_username = event.username
|
||||
# Processes a remove friend message, updating the logged-in status of the player if necessary.
|
||||
on :message, :remove_friend do |ctx, player, message|
|
||||
friend_username = message.username
|
||||
player_username = player.username
|
||||
|
||||
player.remove_friend(friend_username)
|
||||
if ($world.is_player_online(friend_username))
|
||||
friend = $world.get_player(friend_username)
|
||||
friend.send(SendFriendEvent.new(player_username, 0)) if (friend.friends_with(player_username) && player.friend_privacy != PrivacyState::ON)
|
||||
friend.send(SendFriendMessage.new(player_username, 0)) if (friend.friends_with(player_username) && player.friend_privacy != PrivacyState::ON)
|
||||
end
|
||||
end
|
||||
|
||||
# Update the friend server status and send the friend/ignore lists of the player logging in.
|
||||
on :login do |player|
|
||||
player.send(FriendServerStatusEvent.new(ServerStatus::CONNECTING))
|
||||
player.send(IgnoreListEvent.new(player.ignored_usernames)) if player.ignored_usernames.size > 0
|
||||
player.send(FriendServerStatusMessage.new(ServerStatus::CONNECTING))
|
||||
player.send(IgnoreListMessage.new(player.ignored_usernames)) if player.ignored_usernames.size > 0
|
||||
|
||||
username = player.username
|
||||
world = $world
|
||||
@@ -52,10 +52,10 @@ on :login do |player|
|
||||
friend = world.get_player(friend_username)
|
||||
friend_world_id = (friend == nil || !viewable?(friend, username)) ? 0 : friend.world_id
|
||||
|
||||
player.send(SendFriendEvent.new(friend_username, friend_world_id))
|
||||
player.send(SendFriendMessage.new(friend_username, friend_world_id))
|
||||
end
|
||||
|
||||
player.send(FriendServerStatusEvent.new(ServerStatus::ONLINE))
|
||||
player.send(FriendServerStatusMessage.new(ServerStatus::ONLINE))
|
||||
update_friends(player, player.world_id)
|
||||
end
|
||||
|
||||
@@ -78,7 +78,7 @@ def update_friends(player, world=0)
|
||||
next if (!other.friends_with(username) || other == player)
|
||||
|
||||
world = viewable?(player, other.username) ? world : 0
|
||||
other.send(SendFriendEvent.new(username, world))
|
||||
other.send(SendFriendMessage.new(username, world))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
on :event, :add_ignore do |ctx, player, event|
|
||||
username = event.username
|
||||
on :message, :add_ignore do |ctx, player, message|
|
||||
username = message.username
|
||||
player.add_ignore(username)
|
||||
end
|
||||
|
||||
on :event, :remove_ignore do |ctx, player, event|
|
||||
username = event.username
|
||||
on :message, :remove_ignore do |ctx, player, message|
|
||||
username = message.username
|
||||
player.remove_ignore(username)
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||
java_import 'org.apollo.game.message.impl.ForwardPrivateChatMessage'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.setting.PrivacyState'
|
||||
|
||||
on :event, :private_message do |ctx, player, event|
|
||||
friend = $world.get_player(event.username)
|
||||
friend.send(ForwardPrivateMessageEvent.new(player.username, player.privilege_level, event.compressed_message)) if interaction_permitted(player, friend)
|
||||
on :message, :private_message do |ctx, player, message|
|
||||
friend = $world.get_player(message.username)
|
||||
friend.send(ForwardPrivateChatMessage.new(player.username, player.privilege_level, message.compressed_message)) if interaction_permitted(player, friend)
|
||||
end
|
||||
|
||||
# Checks if the sender is permitted to interact with the friend they have added:
|
||||
|
||||
@@ -22,6 +22,5 @@ on :command, :graphic, RIGHTS_MOD do |player, command|
|
||||
return
|
||||
end
|
||||
|
||||
player.send(DisplayCrossbonesEvent.new(true ))
|
||||
player.play_graphic(Graphic.new(args[0].to_i))
|
||||
end
|
||||
@@ -1,8 +1,5 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
|
||||
on :command, :filter do |player, command|
|
||||
player.send_message('Your message filter is now ' + (player.toggle_message_filter ? 'enabled.' : 'disabled.'))
|
||||
end
|
||||
@@ -53,11 +53,11 @@ class ConsumeAction < Action
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the first item option event and consumes the consumable, if necessary.
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
consumable = CONSUMABLES[event.id]
|
||||
# Intercepts the first item option message and consumes the consumable, if necessary.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
consumable = CONSUMABLES[message.id]
|
||||
unless consumable == nil
|
||||
player.start_action(ConsumeAction.new(player, event.slot, consumable))
|
||||
player.start_action(ConsumeAction.new(player, message.slot, consumable))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
# Intercepts the first npc action event.
|
||||
on :event, :npc_action do |ctx, player, event|
|
||||
if (event.option == 1)
|
||||
# TODO check if player is not in pvp area
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def dialogue(name, &block)
|
||||
|
||||
end
|
||||
|
||||
dialogue :banker_introduction do
|
||||
#
|
||||
end
|
||||
@@ -45,8 +45,8 @@ class DummyAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
if (event.id == DUMMY_ID)
|
||||
player.start_action(DummyAction.new(player, event.position))
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
if (message.id == DUMMY_ID)
|
||||
player.start_action(DummyAction.new(player, message.position))
|
||||
end
|
||||
end
|
||||
@@ -11,9 +11,9 @@ ANIMATIONS = {
|
||||
666 => Animation::GLASS_WALL, 168 => Animation::YES, 13383 => Animation::GOBLIN_BOW
|
||||
}
|
||||
|
||||
# Intercept the ButtonEvent
|
||||
on :event, :button do |ctx, player, event|
|
||||
anim = ANIMATIONS[event.widget_id]
|
||||
# Intercept the button message.
|
||||
on :message, :button do |ctx, player, message|
|
||||
anim = ANIMATIONS[message.widget_id]
|
||||
unless anim == nil
|
||||
player.play_animation(anim)
|
||||
ctx.break_handler_chain
|
||||
|
||||
@@ -65,7 +65,7 @@ class HerbIdentificationAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a herb to the InventoryItemEvent interception.
|
||||
# Appends a herb to the InventoryItemMessage interception.
|
||||
def append_herb(item_id, unidentified, level, experience)
|
||||
herb = Herb.new(item_id, unidentified, level, experience)
|
||||
append_herblore_item(herb, unidentified)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.SetWidgetItemModelEvent'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetItemModelMessage'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
HERBLORE_DIALOGUE = 4429
|
||||
@@ -25,15 +25,15 @@ module HerbloreMethod
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOnItemEvent handler for all Herblore-related functions.
|
||||
on :event, :item_on_item do |ctx, player, event|
|
||||
primary = event.id
|
||||
secondary = event.target_id
|
||||
# The ItemOnItemMessage handler for all Herblore-related functions.
|
||||
on :message, :item_on_item do |ctx, player, message|
|
||||
primary = message.id
|
||||
secondary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
|
||||
if hash == nil
|
||||
secondary = event.id
|
||||
primary = event.target_id
|
||||
secondary = message.id
|
||||
primary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
end
|
||||
|
||||
@@ -46,19 +46,19 @@ on :event, :item_on_item do |ctx, player, event|
|
||||
end
|
||||
end
|
||||
|
||||
# The ItemOptionEvent handler for all Herblore-related functions.
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
id = event.id
|
||||
# The ItemOptionMessage handler for all Herblore-related functions.
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
id = message.id
|
||||
method = HERBLORE_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
method.invoke(player, id, event.slot)
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
method = DRINK_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
method.invoke(player, id, event.slot)
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -83,7 +83,7 @@ def check_slot(player, slot, id, amount = 1)
|
||||
end
|
||||
|
||||
# Utility method for checking if a player's Herblore (maximum) level is at a required height. Also informs the player if this is not the case with use of the action
|
||||
# variable, like so: "You need a Herblore level of at least #{required.to_s} to #{action}."
|
||||
# variable, like so: "You need a Herblore level of at least #{required.to_s} to #{action}."
|
||||
def check_skill(player, required, action)
|
||||
if required > player.skill_set.skill(HERBLORE_SKILL_ID).current_level
|
||||
player.send_message("You need a Herblore level of at least #{required} to #{action}.")
|
||||
@@ -94,6 +94,6 @@ end
|
||||
|
||||
# Opens a 'make' dialogue for the specified player, displaying the specified item. Optionally, a listener can be used for the dialogue.
|
||||
def open_dialogue(player, item, listener = nil)
|
||||
player.send(SetWidgetItemModelEvent.new(1746, item, 170))
|
||||
player.send(SetWidgetItemModelMessage.new(1746, item, 170))
|
||||
player.interface_set.open_dialogue(listener, HERBLORE_DIALOGUE)
|
||||
end
|
||||
@@ -223,11 +223,11 @@ class GrindingAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a grinded ingredient to the ItemOnItemEvent handler interception.
|
||||
# Appends a ground ingredient to the ItemOnItemMessage handler interception.
|
||||
def append_ground(id, raw)
|
||||
grinded = GroundIngredient.new(id, raw)
|
||||
append_herblore_item(grinded, PESTLE_MORTAR, raw)
|
||||
return grinded
|
||||
ground = GroundIngredient.new(id, raw)
|
||||
append_herblore_item(ground, PESTLE_MORTAR, raw)
|
||||
return ground
|
||||
end
|
||||
|
||||
# Normal ingredients
|
||||
|
||||
@@ -310,14 +310,14 @@ class FinishedMixingAction < MixingAction
|
||||
end
|
||||
end
|
||||
|
||||
# Appends a finished potion to the ItemOnItemEvent handling interception.
|
||||
# Appends a finished potion to the ItemOnItemMessage handling interception.
|
||||
def append_finished_potion(item, unfinished, ingredient, level, experience)
|
||||
potion = FinishedPotion.new(item, [ unfinished, ingredient ], level, experience)
|
||||
append_herblore_item(potion, unfinished.item_id, ingredient.item_id)
|
||||
return potion
|
||||
end
|
||||
|
||||
# Appends an unfinished potion to the ItemOnItemEvent handling interception.
|
||||
# Appends an unfinished potion to the ItemOnItemMessage handling interception.
|
||||
def append_unfinished_potion(item, herb, level)
|
||||
potion = UnfinishedPotion.new(item, herb, level)
|
||||
append_herblore_item(potion, herb.item_id, WATER_VIAL_ID)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.action.Action'
|
||||
java_import 'org.apollo.game.event.impl.DisplayTabInterfaceEvent'
|
||||
java_import 'org.apollo.game.message.impl.DisplayTabInterfaceMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceEvent.new(6)
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceMessage.new(6)
|
||||
|
||||
class Spell
|
||||
attr_reader :level, :elements, :experience
|
||||
@@ -119,31 +119,31 @@ class ItemSpellAction < SpellAction
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the magic on item event.
|
||||
on :event, :magic_on_item do |ctx, player, event|
|
||||
spell = event.spell_id
|
||||
# Intercepts the magic on item message.
|
||||
on :message, :magic_on_item do |ctx, player, message|
|
||||
spell = message.spell_id
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
if alch != nil
|
||||
slot = event.slot
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(AlchemyAction.new(player, alch, slot, item))
|
||||
ctx.break_handler_chain
|
||||
return
|
||||
end
|
||||
|
||||
ench = ENCHANT_SPELLS[event.id]
|
||||
ench = ENCHANT_SPELLS[message.id]
|
||||
if ench != nil and ench.button == spell
|
||||
slot = event.slot
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the button event
|
||||
on :event, :button do |ctx, player, event|
|
||||
button = event.widget_id
|
||||
# Intercepts the button message
|
||||
on :message, :button do |ctx, player, message|
|
||||
button = message.widget_id
|
||||
|
||||
tele = TELEPORT_SPELLS[button]
|
||||
if tele != nil
|
||||
|
||||
@@ -141,18 +141,18 @@ class ProspectingAction < DistancedAction
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :first_object_action do |ctx, mob, event|
|
||||
ore = ORES[event.id]
|
||||
on :message, :first_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
mob.start_action(MiningAction.new(mob, event.position, ore))
|
||||
mob.start_action(MiningAction.new(mob, message.position, ore))
|
||||
end
|
||||
end
|
||||
|
||||
on :event, :second_object_action do |ctx, mob, event|
|
||||
ore = ORES[event.id]
|
||||
on :message, :second_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
mob.start_action(ProspectingAction.new(mob, event.position, ore))
|
||||
elsif EXPIRED_ORES[event.id] != nil
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, event.position))
|
||||
mob.start_action(ProspectingAction.new(mob, message.position, ore))
|
||||
elsif EXPIRED_ORES[message.id] != nil
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, message.position))
|
||||
end
|
||||
end
|
||||
@@ -42,11 +42,11 @@ class BuryBoneAction < Action
|
||||
|
||||
end
|
||||
|
||||
# Intercepts the first item option event,
|
||||
on :event, :first_item_option do |ctx, player, event|
|
||||
bone = BONES[event.id]
|
||||
# Intercepts the first item option message,
|
||||
on :message, :first_item_option do |ctx, player, message|
|
||||
bone = BONES[message.id]
|
||||
unless bone == nil
|
||||
player.start_action(BuryBoneAction.new(player, event.slot, bone))
|
||||
player.start_action(BuryBoneAction.new(player, message.slot, bone))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,19 +23,19 @@ class Altar
|
||||
end
|
||||
|
||||
|
||||
# Intercepts the item on object event.
|
||||
on :event, :item_on_object do |ctx, player, event|
|
||||
talisman = TALISMANS[event.id]; altar = ENTRANCE_ALTARS[event.object_id]
|
||||
# Intercepts the item on object message.
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
talisman = TALISMANS[message.id]; altar = ENTRANCE_ALTARS[message.object_id]
|
||||
if (talisman != nil && altar != nil)
|
||||
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
# Intercepts the first object action event.
|
||||
on :event, :object_action do |ctx, player, event|
|
||||
if (event.option == 1)
|
||||
object_id = event.id
|
||||
# Intercepts the first object action message.
|
||||
on :message, :object_action do |ctx, 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
|
||||
|
||||
@@ -29,9 +29,9 @@ def append_talisman(hash)
|
||||
TALISMANS[id] = Talisman.new(altar_position)
|
||||
end
|
||||
|
||||
# Intercepts the item option event.
|
||||
on :event, :fourth_item_option do |ctx, player, event|
|
||||
talisman = TALISMANS[event.id]
|
||||
# Intercepts the item option message.
|
||||
on :message, :fourth_item_option do |ctx, player, message|
|
||||
talisman = TALISMANS[message.id]
|
||||
if (talisman != nil)
|
||||
player.send_message(talisman.get_message(player.position))
|
||||
ctx.break_handler_chain
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.event.impl.ConfigEvent'
|
||||
java_import 'org.apollo.game.message.impl.ConfigMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
|
||||
@@ -26,13 +26,13 @@ class Tiara
|
||||
end
|
||||
|
||||
def send_config(player)
|
||||
player.send(ConfigEvent.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 1 << @bitshift))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def send_empty_config(player)
|
||||
player.send(ConfigEvent.new(CHANGE_ALTAR_OBJECT_CONFIG, 0))
|
||||
player.send(ConfigMessage.new(CHANGE_ALTAR_OBJECT_CONFIG, 0))
|
||||
end
|
||||
|
||||
# Appends a tiara to the list.
|
||||
@@ -43,7 +43,7 @@ def append_tiara(hash)
|
||||
TIARAS_BY_TALISMAN[talisman] = TIARAS_BY_ID[tiara_id] = TIARAS_BY_ALTAR[altar] = Tiara.new(tiara_id, altar, talisman, bitshift, experience)
|
||||
end
|
||||
|
||||
#Set the config upon login
|
||||
# Set the config upon login
|
||||
on :login do |player|
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
if hat != nil
|
||||
@@ -56,45 +56,45 @@ on :login do |player|
|
||||
send_empty_config(player)
|
||||
end
|
||||
|
||||
#Accesses the altar with 1 click when wielding the correct tiara.
|
||||
on :event, :second_object_action do |ctx, player, event|
|
||||
object_id = event.id
|
||||
# Access the altar with 1 click when wielding the correct tiara.
|
||||
on :message, :second_object_action do |ctx, player, message|
|
||||
object_id = message.id
|
||||
tiara = TIARAS_BY_ALTAR[object_id]
|
||||
if (tiara != nil)
|
||||
hat = player.equipment.get(EquipmentConstants::HAT)
|
||||
if (hat != nil && hat.id == tiara.tiara_id)
|
||||
altar = ENTRANCE_ALTARS[tiara.altar]
|
||||
if (altar != nil)
|
||||
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
|
||||
player.start_action(TeleportAction.new(player, message.position, 2, altar.entrance_position))
|
||||
end
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Equip tiara
|
||||
on :event, :second_item_option do |ctx, player, event|
|
||||
tiara = TIARAS_BY_ID[event.id]
|
||||
# Equip tiara
|
||||
on :message, :second_item_option do |ctx, player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
if (tiara != nil)
|
||||
tiara.send_config(player)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
#Unequip tiara
|
||||
on :event, :first_item_action do |ctx, player, event|
|
||||
tiara = TIARAS_BY_ID[event.id]
|
||||
# Unequip tiara
|
||||
on :message, :first_item_action do |ctx, player, message|
|
||||
tiara = TIARAS_BY_ID[message.id]
|
||||
if (tiara != nil)
|
||||
send_empty_config(player)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
#Create tiara
|
||||
on :event, :item_on_object do |ctx, player, event|
|
||||
tiara= TIARAS_BY_TALISMAN[event.id]; altar = CRAFTING_ALTARS[event.object_id]
|
||||
#C reate tiara
|
||||
on :message, :item_on_object do |ctx, player, message|
|
||||
tiara= TIARAS_BY_TALISMAN[message.id]; altar = CRAFTING_ALTARS[message.object_id]
|
||||
if (tiara != nil && altar != nil)
|
||||
player.start_action(CreateTiaraAction.new(player, event.position, tiara, altar))
|
||||
player.start_action(CreateTiaraAction.new(player, message.position, tiara, altar))
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user