mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Add support for banker npcs.
This commit is contained in:
@@ -1,21 +1,26 @@
|
|||||||
require 'java'
|
require 'java'
|
||||||
|
|
||||||
java_import 'org.apollo.game.action.DistancedAction'
|
java_import 'org.apollo.game.action.DistancedAction'
|
||||||
java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
||||||
|
|
||||||
BANK_BOOTH_ID = 2213
|
BANK_BOOTH_ID = 2213
|
||||||
BANK_BOOTH_SIZE = 1
|
BANK_BOOTH_SIZE = 1
|
||||||
|
|
||||||
|
# The npcs with a 'bank' menu action.
|
||||||
|
BANKER_NPCS = [ 166, 494, 495, 496, 497, 498, 499, 1036, 1360, 1702, 2163, 2164, 2354, 2355, 2568, 2569, 2570 ]
|
||||||
|
|
||||||
|
# A distanced action to open a new bank.
|
||||||
class BankAction < DistancedAction
|
class BankAction < DistancedAction
|
||||||
attr_reader :position
|
attr_reader :position
|
||||||
|
|
||||||
def initialize(character, position)
|
def initialize(mob, position)
|
||||||
super 0, true, character, position, BANK_BOOTH_SIZE
|
super(0, true, mob, position, BANK_BOOTH_SIZE)
|
||||||
@position = position
|
@position = position
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
mob.turn_to @position
|
mob.turn_to(@position)
|
||||||
BankUtils.open_bank mob
|
BankUtils.open_bank(mob)
|
||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -24,10 +29,20 @@ class BankAction < DistancedAction
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Intercepts the object action event
|
||||||
on :event, :object_action do |ctx, player, event|
|
on :event, :object_action do |ctx, player, event|
|
||||||
if event.option == 2 and event.id == BANK_BOOTH_ID
|
if (event.option == 2 and event.id == BANK_BOOTH_ID)
|
||||||
player.startAction BankAction.new(player, event.position)
|
player.start_action(BankAction.new(player, event.position))
|
||||||
|
ctx.break_handler_chain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: when we have NPCs/dialogue, also respond to clicking on them
|
on :event, :npc_action do |ctx, player, event|
|
||||||
|
if (event.option == 2)
|
||||||
|
npc = World.world.npc_repository.get(event.index)
|
||||||
|
if (BANKER_NPCS.include?(npc.id))
|
||||||
|
player.start_action(BankAction.new(player, npc.position))
|
||||||
|
ctx.break_handler_chain
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user