Update all plugins to conform to Rubocop.

This commit is contained in:
Major-
2015-08-27 18:17:58 +01:00
parent 424d2bda29
commit 8f3fd75b33
75 changed files with 1625 additions and 1537 deletions
+3 -2
View File
@@ -11,7 +11,6 @@ class Fish
@id = id
@level = level
@experience = experience
@name = name_of(:item, id)
end
@@ -19,7 +18,9 @@ end
# Appends a Fish to the hash.
def append_fish(name, hash)
fail 'Hash must contain an id, level, and experience.' unless hash.has_keys?(:id, :level, :experience)
unless hash.has_keys?(:id, :level, :experience)
fail 'Hash must contain an id, level, and experience.'
end
CATCHABLE_FISH[name] = Fish.new(hash[:id], hash[:level], hash[:experience])
end
+14 -15
View File
@@ -16,27 +16,27 @@ class FishingAction < DistancedAction
@tool = spot.tools[option - 1]
@options = (option == 1) ? spot.first_fish : spot.second_fish
@minimum_level = @options.map { |fish| fish.level }.min
@minimum_level = @options.map(&:level).min
end
# Returns whether or not a catch is successful.
def successful_catch(level, requirement)
return [level - requirement + 5, 30].min > rand(40)
[level - requirement + 5, 30].min > rand(40)
end
# Starts the fishing process.
def start_fishing()
def start_fishing
@started = true
mob.send_message(tool.message, true)
end
# Executes the action.
def executeAction()
def executeAction
skills = mob.skill_set
fishing_level = skills.get_skill(Skill::FISHING).current_level
mob.turn_to(position)
if (@minimum_level > fishing_level)
if @minimum_level > fishing_level
mob.send_message("You need a fishing level of #{@minimum_level} to fish at this spot.")
stop
return
@@ -62,12 +62,10 @@ class FishingAction < DistancedAction
return
end
unless @started
start_fishing
else
if @started
options = @options.reject { |fish| fish.level > fishing_level }
# Player may level up mid-action so reject here, not at initialisation.
fish = options.sample # TODO it's a ~70/30 chance, not 50/50
fish = options.sample # TODO: it's a ~70/30 chance, not 50/50
if successful_catch(fishing_level, fish.level)
inventory.remove(bait) unless bait.nil?
@@ -77,12 +75,14 @@ class FishingAction < DistancedAction
mob.send_message("You catch #{name.end_with?('s') ? 'some' : 'a'} #{name.downcase}.", true)
skills.add_experience(Skill::FISHING, fish.experience)
if (find_bait == -1)
if find_bait == -1
mob.send_message("You need more #{name_of(:item, bait).downcase}s to fish at this spot.")
stop
return
end
end
else
start_fishing
end
mob.play_animation(@tool.animation)
@@ -90,14 +90,13 @@ class FishingAction < DistancedAction
# Finds the id of the first piece of bait in the player's inventory, or nil if no bait is
# required, or -1 if the player's inventory does not contain any valid bait.
def find_bait()
def find_bait
baits = @tool.bait
if baits.empty? then nil else baits.find(-1) { |bait| mob.inventory.contains(bait) } end
baits.empty? ? nil : baits.find(-1) { |bait| mob.inventory.contains(bait) }
end
# Stops this action.
def stop()
def stop
super
mob.stop_animation
end
+1 -1
View File
@@ -23,4 +23,4 @@ end
append_spot(309, Spot.new([:fly_fishing_rod, :fishing_rod], [:trout, :salmon], [:pike]))
append_spot(312, Spot.new([:lobster_cage, :harpoon], [:lobster], [:tuna, :swordfish]))
append_spot(313, Spot.new([:big_net, :harpoon], [:mackerel, :cod], [:bass, :shark]))
append_spot(316, Spot.new([:small_net, :fishing_rod], [:shrimp, :anchovy], [:sardine, :herring]))
append_spot(316, Spot.new([:small_net, :fishing_rod], [:shrimp, :anchovy], [:sardine, :herring]))
+31 -18
View File
@@ -7,10 +7,10 @@ FISHING_TOOLS = {}
# A fishing tool.
class Tool
attr_reader :id, :bait, :animation, :message, :name
attr_reader :animation, :bait, :id, :message, :name
# Creates the tool.
def initialize(id, bait=[], animation, message)
def initialize(id, animation, message, bait)
@id = id
@bait = bait
@animation = Animation.new(animation)
@@ -21,27 +21,40 @@ class Tool
end
private
# Appends a tool with the specified name to the hash.
def append_tool(name, tool)
FISHING_TOOLS[name] = tool
def tool(name, hash)
unless hash.has_keys?(:id, :animation, :message)
fail 'Hash must contain an id, animation, and message.'
end
bait = hash[:bait] || []
FISHING_TOOLS[name] = Tool.new(hash[:id], hash[:animation], hash[:message], bait)
end
HARPOON_ANIMATION_ID = 618
CAGE_ANIMATION_ID = 619
NET_ANIMATION_ID = 620
ROD_ANIMATION_ID = 622
# The harpoon fishing animation id.
HARPOON_ANIMATION = 618
# TODO The other feathers that can be used
FISHING_ROD_BAIT = [ 313 ]
FLY_FISHING_ROD_BAIT = [ 314 ]
# The cage fishing animation id.
CAGE_ANIMATION = 619
append_tool(:lobster_cage, Tool.new(301, CAGE_ANIMATION_ID, 'You attempt to catch a lobster...'))
append_tool(:small_net, Tool.new(303, NET_ANIMATION_ID, 'You cast out your net...'))
append_tool(:big_net, Tool.new(305, NET_ANIMATION_ID, 'You cast out your net...'))
append_tool(:harpoon, Tool.new(311, HARPOON_ANIMATION_ID, 'You start harpooning fish...'))
# The net fishing animation id.
NET_ANIMATION = 620
append_tool(:fishing_rod, Tool.new(307, FISHING_ROD_BAIT, ROD_ANIMATION_ID, 'You attempt to catch a fish...'))
append_tool(:fly_fishing_rod, Tool.new(309, FLY_FISHING_ROD_BAIT, ROD_ANIMATION_ID, 'You attempt to catch a fish...'))
# The rod fishing animation id.
ROD_ANIMATION = 622
# TODO: The other feathers that can be used
FISHING_ROD_BAIT = [313]
FLY_FISHING_ROD_BAIT = [314]
tool :lobster_cage, id: 301, animation: CAGE_ANIMATION, message: 'You attempt to catch a lobster...'
tool :small_net, id: 303, animation: NET_ANIMATION, message: 'You cast out your net...'
tool :big_net, id: 305, animation: NET_ANIMATION, message: 'You cast out your net...'
tool :harpoon, id: 311, animation: HARPOON_ANIMATION, message: 'You start harpooning fish...'
tool :fishing_rod, id: 307, animation: ROD_ANIMATION, message: 'You attempt to catch a fish...',
bait: FISHING_ROD_BAIT
tool :fly_fishing_rod, id: 309, animation: ROD_ANIMATION, message: 'You attempt to catch a fish...',
bait: FLY_FISHING_ROD_BAIT
+17 -14
View File
@@ -10,13 +10,13 @@ class Herb < Ingredient
def initialize(item_id, unidentified, level, experience)
super item_id
@unidentified = unidentified
@level = level
@experience = experience
end
def invoke(player, id, slot)
def invoke(player, _id, slot)
item = player.inventory.get(slot)
player.start_action(HerbIdentificationAction.new(player, self, slot, item))
end
@@ -25,51 +25,54 @@ end
# An action that makes a player identify a herb.
class HerbIdentificationAction < Action
attr_reader :herb, :slot, :item, :pulses
def initialize(player, herb, slot, item)
super(0, true, player)
@herb = herb
@slot = slot
@item = item
@pulses = 0
end
def execute
if @pulses == 0
unless check_skill(mob, @herb.level, "identify this herb")
unless check_skill(mob, @herb.level, 'identify this herb')
stop
return
end
end
execute_action
@pulses += 1
end
def execute_action
player = mob
inventory = player.inventory
if inventory.remove_slot(@slot, 1) == 1
identified = @herb.item
inventory.add(identified)
player.skill_set.add_experience(HERBLORE_ID, @herb.experience)
player.send_message("You identify the herb as a #{identified.definition.name}.", true)
# TODO: 'as an' in some cases
end
stop
end
def equals(other)
return (get_class == other.get_class and slot == other.slot and herb == other.herb)
get_class == other.get_class && slot == other.slot && herb == other.herb
end
end
# 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)
return herb
append_herblore_item(herb, unidentified)
herb
end
# Herbs
@@ -87,4 +90,4 @@ SNAPDRAGON = append_herb(3000, 3051, 59, 11.8)
CADANTINE = append_herb(265, 215, 65, 12.5)
LANTADYME = append_herb(2481, 2485, 67, 13.1)
DWARF_WEED = append_herb(267, 217, 70, 13.8)
TORSTOL = append_herb(269, 219, 75, 15)
TORSTOL = append_herb(269, 219, 75, 15)
+15 -13
View File
@@ -1,4 +1,4 @@
# Thanks to Sillhouette <http://www.rune-server.org/members/silhouette/> for posting
# Thanks to Sillhouette <http://www.rune-server.org/members/silhouette> for posting
# a large amount of Herblore skill data which has been thankfully used in this plugin.
require 'java'
@@ -13,15 +13,14 @@ HERBLORE_ITEM_ON_ITEM = {}
DRINK_ITEM = {}
# A module which describes an invocable method of the Herblore skill.
module HerbloreMethod
def self.new
raise 'You cannot instantiate this module!'
fail 'You cannot instantiate this module!'
end
def invoke(player, primary, secondary)
raise NotImplementedError.new('You must implement the invocation of HerbloreMethod!')
def invoke(_player, _primary, _secondary)
fail 'You must implement the invocation of HerbloreMethod!'
end
end
@@ -76,25 +75,28 @@ def append_herblore_item(method, key, secondary = -1)
end
end
# Utility method for checking if a player's inventory has an item of the specified id, with optionally the specified amount (1 by default), at the specified slot.
# Utility method for checking if a player's inventory has a of the specified id, with optionally
# the specified amount (1 by default), at the specified slot.
def check_slot(player, slot, id, amount = 1)
item = player.inventory.get(slot)
return (!item.nil? and item.id == id and item.amount >= amount)
!item.nil? && item.id == id && item.amount >= amount
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}."
# Utility method for checking if a player's Herblore (maximum) level is at the required level. 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}."
def check_skill(player, required, action)
if (required > player.skill_set.get_skill(Skill::HERBLORE).current_level)
if required > player.skill_set.get_skill(Skill::HERBLORE).current_level
player.send_message("You need a Herblore level of at least #{required} to #{action}.")
return false
end
return true
true
end
# Opens a 'make' dialogue for the specified player, displaying the specified item. Optionally, a listener can be used for the dialogue.
# 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(SetWidgetItemModelMessage.new(1746, item, 170))
player.interface_set.open_dialogue(listener, HERBLORE_DIALOGUE)
end
end
+25 -27
View File
@@ -18,16 +18,15 @@ class Ingredient
@item = Item.new(item) # Share item instances.
end
# Checks if the specified player has the specified amount of this ingredient. Optionally, they can immediately be removed if that
# amount was indeed found.
# Checks if the specified player has the specified amount of this ingredient. Optionally, they
# can immediately be removed if that amount was indeed found.
def check_remove(player, amount, remove)
inventory = player.inventory
counter = 0
inventory.items.each do |inv_item|
break unless counter < amount
next if inv_item == nil
next if inv_item.nil?
id = inv_item.id
inventory_amount = inv_item.amount
@@ -47,7 +46,7 @@ class Ingredient
return true
end
return false
false
end
end
@@ -59,11 +58,10 @@ class GroundIngredient < Ingredient
def initialize(item_id, raw)
super(item_id)
@raw = raw
end
def invoke(player, pestle_mortar, ingredient)
def invoke(player, _pestle_mortar, _ingredient)
action = GrindingAction.new(player, self)
listener = GrindingDialogueListener.new(player, action)
@@ -71,7 +69,8 @@ class GroundIngredient < Ingredient
end
end
# A DialogueAdapter used for grinding ingredients. It is also used as an EnterAmountListener for the amount of grinding actions.
# A DialogueAdapter used for grinding ingredients. It is also used as an EnterAmountListener for
# the amount of grinding actions.
class GrindingDialogueListener < DialogueAdapter
include EnterAmountListener
@@ -79,7 +78,6 @@ class GrindingDialogueListener < DialogueAdapter
def initialize(player, action)
super()
@player = player
@action = action
end
@@ -103,7 +101,7 @@ class GrindingDialogueListener < DialogueAdapter
# Called when an amount of grinding actions has been entered.
def amountEntered(amount)
if amount <= 0 then return else execute(amount) end
execute(amount) if amount > 0
end
# Called to set the action(s) in motion.
@@ -129,7 +127,7 @@ class GrindingAction < Action
attr_reader :ingredient, :amount, :pulses, :slot, :listener
def initialize(player, ingredient)
super 0, true, player
super(0, true, player)
@ingredient = ingredient
@pulses = 0
@@ -145,7 +143,7 @@ class GrindingAction < Action
if @pulses == 0
mob.play_animation GRINDING_ANIM
elsif @pulses == 1
if not gather_materials
unless gather_materials
stop
return
end
@@ -159,45 +157,45 @@ class GrindingAction < Action
inventory.reset(@slot)
inventory.add(@ingredient.item)
set_delay(1)
elsif @pulses == 2
mob.stop_animation
continue()
continue
end
end
# Checks if the player has the required materials to perform the (next) action.
def gather_materials
items = mob.inventory.items
pst_mrt = false
ingr = false
raw = @ingredient.raw
(0...items.length).each do |slot|
item = items[slot]
next if item == nil
next if item.nil?
id = item.id
if id == PESTLE_MORTAR and !pst_mrt
if id == PESTLE_MORTAR && !pst_mrt
pst_mrt = true
elsif id == raw and !ingr
elsif id == raw && !ingr
ingr = true
@slot = slot
end
return true if pst_mrt and ingr
return true if pst_mrt && ingr
end
mob.send_message("You do not have any more #{name_of(raw).downcase}s.")
return false
false
end
# Either invokes the stop() method in Action to shut it down
# or continues to the next ingredient.
def continue
@amount -= 1
if @amount > 0
set_delay(0)
@pulses = -1
@@ -213,11 +211,11 @@ class GrindingAction < Action
def stop
super
mob.inventory.remove_listener(@listener) unless listener == nil
mob.inventory.remove_listener(@listener) unless listener.nil?
end
def equals(other)
return (get_class == other.get_class and @ingredient == other.ingredient)
get_class == other.get_class && @ingredient == other.ingredient
end
end
@@ -225,7 +223,7 @@ end
def append_ground(id, raw)
ground = GroundIngredient.new(id, raw)
append_herblore_item(ground, PESTLE_MORTAR, raw)
return ground
ground
end
# Normal ingredients
@@ -250,4 +248,4 @@ MAGIC_ROOTS = Ingredient.new(6051)
UNICORN_HORN_DUST = append_ground(235, 237)
DRAGON_SCALE_DUST = append_ground(241, 243)
CHOCOLATE_DUST = append_ground(1975, 1973)
# CRUSHED_NEST = append_ground(6693, 5075)
# CRUSHED_NEST = append_ground(6693, 5075) # TODO: only in 377
+83 -78
View File
@@ -13,25 +13,26 @@ EMPTY_VIAL_ID = 229
MIXING_ANIM = Animation.new(363)
# Represents an unfinished potion which can be invoked as a HerbloreMethod and used as an ingredient.
# Represents an unfinished potion which can be invoked as a HerbloreMethod and used as an
# ingredient.
class UnfinishedPotion < Ingredient
include HerbloreMethod
attr_reader :herb, :level
def initialize(item_id, herb, level)
super item_id
super(item_id)
@herb = herb
@level = level
end
def invoke(player, primary, secondary)
def invoke(player, _primary, _secondary)
action = UnfinishedMixingAction.new(player, self)
listener = UnfinishedMixingDialogueListener.new(player, action)
open_dialogue(player, @item_id, listener)
end
end
# Represents a finished potion which can be invoked as a HerbloreMethod.
@@ -51,11 +52,12 @@ class FinishedPotion
action = FinishedMixingAction.new(player, primary, secondary, self)
listener = FinishedMixingDialogueListener.new(player, action)
open_dialogue(player, @item.id, listener)
open_dialogue(player, @item.id, listener)
end
end
# A DialogueAdapter used for mixing potions. It is also used as an EnterAmountListener for the amount of mixing actions.
# A DialogueAdapter used for mixing potions. It is also used as an EnterAmountListener for the
# amount of mixing actions.
class MixingDialogueListener < DialogueAdapter
include EnterAmountListener
@@ -63,7 +65,7 @@ class MixingDialogueListener < DialogueAdapter
def initialize(player, action)
super()
@player = player
@action = action
end
@@ -71,7 +73,7 @@ class MixingDialogueListener < DialogueAdapter
# Called when a button has been clicked whilst the dialogue was opened.
def buttonClicked(button)
amount = get_amount(button)
return false if amount == 0
interfaces = @player.interface_set
@@ -85,12 +87,12 @@ class MixingDialogueListener < DialogueAdapter
amount = calculate_maximum if amount == -2
execute(amount)
return true
true
end
# Called when an amount of mixing actions has been entered.
def amountEntered(amount)
if amount <= 0 then return else execute(amount) end
execute(amount) if amount > 0
end
# Called to set the action(s) in motion.
@@ -99,7 +101,7 @@ class MixingDialogueListener < DialogueAdapter
@player.start_action(@action)
end
def calculate_maximum(code)
def calculate_maximum(_code)
# Override for potion-specific amount calculation.
end
@@ -118,18 +120,17 @@ end
# A MixingDialogueListener used for mixing unfinished potions.
class UnfinishedMixingDialogueListener < MixingDialogueListener
def calculate_maximum
inventory = @player.inventory
amount = inventory.get_amount(WATER_VIAL_ID)
return 0 if amount <= 0
herbs = inventory.get_amount(@action.potion.herb.item.id)
amount = herbs if amount > herbs
return amount
[herbs, amount].min
end
end
# A MixingDialogueListener used for mixing finished potions.
@@ -144,7 +145,7 @@ class FinishedMixingDialogueListener < MixingDialogueListener
amount = item_amount if amount > item_amount
end
return amount
amount
end
end
@@ -170,6 +171,7 @@ class MixingAction < Action
stop
return
end
@started = true
end
@@ -178,15 +180,17 @@ class MixingAction < Action
return
end
end
mob.play_animation(MIXING_ANIM)
execute_action
if (@amount -= 1) > 0 then @pulses = 0 else stop end
@amount -= 1
@amount > 0 ? @pulses = 0 : stop
end
def stop
super()
mob.inventory.remove_listener(@listener) unless @listener == nil
mob.inventory.remove_listener(@listener) unless @listener.nil?
end
def execute_action
@@ -195,7 +199,7 @@ class MixingAction < Action
def gather_materials
# Override for ingredient checking and gathering
return false
false
end
# Sets the amount of actions.
@@ -204,7 +208,7 @@ class MixingAction < Action
end
def equals(other)
return (get_class == other.get_class and @potion == other.potion)
get_class == other.get_class && @potion == other.potion
end
end
@@ -213,7 +217,7 @@ class UnfinishedMixingAction < MixingAction
attr_reader :slots
def initialize(player, potion)
super(player, potion, "use this herb.")
super(player, potion, 'use this herb.')
end
def execute_action
@@ -221,7 +225,9 @@ class UnfinishedMixingAction < MixingAction
player = mob
inventory = player.inventory
player.send_message("You put the #{name} in the water to make an unfinished #{name.sub(/ leaf$/, "")} potion.", true)
created = name.sub(/ leaf$/, '')
message = "You put the #{name} in the water to make an unfinished #{created} potion."
player.send_message(message, true)
@slots.each do |slot, amount|
unless inventory.remove_slot(slot, amount)
@@ -253,23 +259,23 @@ class UnfinishedMixingAction < MixingAction
@slots[vial_slot] = 1
@slots[herb_slot] = 1
return true
true
end
end
# A MixingAction which handles the execution of making FinishedPotions.
class FinishedMixingAction < MixingAction
attr_reader :unfinished, :ingredient, :slots
def initialize(player, unfinished, ingredient, potion)
super(player, potion, "mix this potion")
super(player, potion, 'mix this potion')
@unfinished = unfinished
@ingredient = ingredient
end
def execute_action
player = mob
def executeAction
player = mob
ingredient = name_of(@ingredient).downcase
name = @potion.item.definition.name.sub('(3)', '')
@@ -277,17 +283,17 @@ class FinishedMixingAction < MixingAction
player.skill_set.add_experience(HERBLORE_SKILL_ID, @potion.experience)
inventory = player.inventory
@slots.each do |slot, amount|
if not inventory.remove_slot(slot, amount)
unless inventory.remove_slot(slot, amount) # TODO: will this remove stuff incorrectly?
stop
return
end
end
inventory.add(@potion.item)
end
def gather_materials
@slots = {}
inventory = mob.inventory
@@ -297,70 +303,69 @@ class FinishedMixingAction < MixingAction
mob.send_message('You do not have enough unfinished potions.')
return false
end
ingredient_slot = inventory.slot_of(@ingredient)
if ingredient_slot == -1
mob.send_message('You do not have enough ingredients.')
return false
end
@slots[vial_slot] = 1
@slots[ingredient_slot] = 1
return true
true
end
end
# 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)
def 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
potion
end
# Appends an unfinished potion to the ItemOnItemMessage handling interception.
def append_unfinished_potion(item, herb, level)
def unfinished_potion(item, herb, level)
potion = UnfinishedPotion.new(item, herb, level)
append_herblore_item(potion, herb.item_id, WATER_VIAL_ID)
return potion
potion
end
# Unfinished potions
UNF_GUAM = append_unfinished_potion(91, GUAM_LEAF, 1) # 3
UNF_MARRENTILL = append_unfinished_potion(93, MARRENTILL, 5)
UNF_TARROMIN = append_unfinished_potion(95, TARROMIN, 12)
UNF_HARRALANDER = append_unfinished_potion(97, HARRALANDER, 22)
UNF_RANARR = append_unfinished_potion(99, RANARR, 30)
UNF_TOADFLAX = append_unfinished_potion(3002, TOADFLAX, 34)
UNF_IRIT = append_unfinished_potion(101, IRIT_LEAF, 45)
UNF_AVANTOE = append_unfinished_potion(103, AVANTOE, 50)
UNF_KWUARM = append_unfinished_potion(105, KWUARM, 55)
UNF_SNAPDRAGON = append_unfinished_potion(3004, SNAPDRAGON, 63)
UNF_CADANTINE = append_unfinished_potion(107, CADANTINE, 66)
UNF_LANTADYME = append_unfinished_potion(2483, LANTADYME, 69)
UNF_DWARF_WEED = append_unfinished_potion(109, DWARF_WEED, 72)
UNF_TORSTOL = append_unfinished_potion(111, TORSTOL, 78)
UNF_GUAM = unfinished_potion(91, GUAM_LEAF, 1) # 3
UNF_MARRENTILL = unfinished_potion(93, MARRENTILL, 5)
UNF_TARROMIN = unfinished_potion(95, TARROMIN, 12)
UNF_HARRALANDER = unfinished_potion(97, HARRALANDER, 22)
UNF_RANARR = unfinished_potion(99, RANARR, 30)
UNF_TOADFLAX = unfinished_potion(3002, TOADFLAX, 34)
UNF_IRIT = unfinished_potion(101, IRIT_LEAF, 45)
UNF_AVANTOE = unfinished_potion(103, AVANTOE, 50)
UNF_KWUARM = unfinished_potion(105, KWUARM, 55)
UNF_SNAPDRAGON = unfinished_potion(3004, SNAPDRAGON, 63)
UNF_CADANTINE = unfinished_potion(107, CADANTINE, 66)
UNF_LANTADYME = unfinished_potion(2483, LANTADYME, 69)
UNF_DWARF_WEED = unfinished_potion(109, DWARF_WEED, 72)
UNF_TORSTOL = unfinished_potion(111, TORSTOL, 78)
# Finished potions
ATTACK_POT = append_finished_potion(121, UNF_GUAM, EYE_NEWT, 1, 25) # 3, 25
ANTIPOISON_POT = append_finished_potion(175, UNF_MARRENTILL, UNICORN_HORN_DUST, 5, 37.5)
STRENGTH_POT = append_finished_potion(115, UNF_TARROMIN, LIMPWURT_ROOT, 12, 50)
RESTORE_POT = append_finished_potion(127, UNF_HARRALANDER, RED_SPIDERS_EGGS, 18, 62.5)
ENERGY_POT = append_finished_potion(3010, UNF_HARRALANDER, CHOCOLATE_DUST, 26, 67.5)
DEFENCE_POT = append_finished_potion(133, UNF_RANARR, WHITE_BERRIES, 30, 75)
AGILITY_POT = append_finished_potion(3034, UNF_TOADFLAX, TOADS_LEGS, 34, 80)
PRAYER_POT = append_finished_potion(139, UNF_RANARR, SNAPE_GRASS, 38, 87.5)
SUPER_ATTACK_POT = append_finished_potion(145, UNF_IRIT, EYE_NEWT, 45, 100)
SUPER_ANTIPOISON_POT = append_finished_potion(181, UNF_IRIT, UNICORN_HORN_DUST, 48, 106.3)
FISHING_POT = append_finished_potion(151, UNF_AVANTOE, SNAPE_GRASS, 50, 112.5)
SUPER_ENERGY_POT = append_finished_potion(3018, UNF_AVANTOE, MORT_MYRE_FUNGI, 52, 117.5)
SUPER_STRENGTH_POT = append_finished_potion(157, UNF_KWUARM, LIMPWURT_ROOT, 55, 125)
WEAPON_POISON = append_finished_potion(187, UNF_KWUARM, DRAGON_SCALE_DUST, 60, 137.5)
SUPER_RESTORE_POT = append_finished_potion(3026, UNF_SNAPDRAGON, RED_SPIDERS_EGGS, 63, 142.5)
SUPER_DEFENCE_POT = append_finished_potion(163, UNF_CADANTINE, WHITE_BERRIES, 66, 150)
ANTIFIRE_POT = append_finished_potion(2428, UNF_LANTADYME, DRAGON_SCALE_DUST, 69, 157.5)
RANGING_POT = append_finished_potion(169, UNF_DWARF_WEED, WINE_ZAMORAK, 72, 162.5)
MAGIC_POT = append_finished_potion(3042, UNF_LANTADYME, POTATO_CACTUS, 76, 172.5)
ZAMORAK_BREW = append_finished_potion(189, UNF_TORSTOL, JANGERBERRIES, 78, 175)
ATTACK_POT = finished_potion(121, UNF_GUAM, EYE_NEWT, 1, 25) # 3
ANTIPOISON_POT = finished_potion(175, UNF_MARRENTILL, UNICORN_HORN_DUST, 5, 37.5)
STRENGTH_POT = finished_potion(115, UNF_TARROMIN, LIMPWURT_ROOT, 12, 50)
RESTORE_POT = finished_potion(127, UNF_HARRALANDER, RED_SPIDERS_EGGS, 18, 62.5)
ENERGY_POT = finished_potion(3010, UNF_HARRALANDER, CHOCOLATE_DUST, 26, 67.5)
DEFENCE_POT = finished_potion(133, UNF_RANARR, WHITE_BERRIES, 30, 75)
AGILITY_POT = finished_potion(3034, UNF_TOADFLAX, TOADS_LEGS, 34, 80)
PRAYER_POT = finished_potion(139, UNF_RANARR, SNAPE_GRASS, 38, 87.5)
SUPER_ATTACK_POT = finished_potion(145, UNF_IRIT, EYE_NEWT, 45, 100)
SUPER_ANTIPOISON_POT = finished_potion(181, UNF_IRIT, UNICORN_HORN_DUST, 48, 106.3)
FISHING_POT = finished_potion(151, UNF_AVANTOE, SNAPE_GRASS, 50, 112.5)
SUPER_ENERGY_POT = finished_potion(3018, UNF_AVANTOE, MORT_MYRE_FUNGI, 52, 117.5)
SUPER_STRENGTH_POT = finished_potion(157, UNF_KWUARM, LIMPWURT_ROOT, 55, 125)
WEAPON_POISON = finished_potion(187, UNF_KWUARM, DRAGON_SCALE_DUST, 60, 137.5)
SUPER_RESTORE_POT = finished_potion(3026, UNF_SNAPDRAGON, RED_SPIDERS_EGGS, 63, 142.5)
SUPER_DEFENCE_POT = finished_potion(163, UNF_CADANTINE, WHITE_BERRIES, 66, 150)
ANTIFIRE_POT = finished_potion(2428, UNF_LANTADYME, DRAGON_SCALE_DUST, 69, 157.5)
RANGING_POT = finished_potion(169, UNF_DWARF_WEED, WINE_ZAMORAK, 72, 162.5)
MAGIC_POT = finished_potion(3042, UNF_LANTADYME, POTATO_CACTUS, 76, 172.5)
ZAMORAK_BREW = finished_potion(189, UNF_TORSTOL, JANGERBERRIES, 78, 175)
+44 -29
View File
@@ -2,57 +2,50 @@ require 'java'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Graphic'
java_import 'org.apollo.game.model.entity.Skill'
ALCHEMY_SPELLS = {}
LOW_ALCH_ANIM = Animation.new(712)
LOW_ALCH_GRAPHIC = Graphic.new(112, 0, 100)
LOW_ALCH_MULTIPLIER = 0.4
HIGH_ALCH_ANIM = Animation.new(713)
HIGH_ALCH_GRAPHIC = Graphic.new(113, 0, 100)
HIGH_ALCH_MULTIPLIER = 0.6
ILLEGAL_ALCH_ITEMS = [ 995, 6529, 6306, 6307, 6308, 6309, 6310 ]
ILLEGAL_ALCH_ITEMS = [995, 6529, 6306, 6307, 6308, 6309, 6310]
# A spell that alchemises an item.
class AlchemySpell < Spell
attr_reader :high, :animation, :graphic, :multiplier, :experience, :delay
def initialize(level, elements, high, animation, graphic, multiplier, experience, delay)
super(level, elements, experience)
@high = high
attr_reader :animation, :graphic, :multiplier, :experience
def initialize(level, elements, experience, animation, graphic, multiplier)
super(level, elements, experience)
@animation = animation
@graphic = graphic
@multiplier = multiplier
@delay = delay
end
end
# An Action that performs an AlchemySpell.
class AlchemyAction < ItemSpellAction
def initialize(player, alchemy, slot, item)
super(player, alchemy, slot, item)
end
def illegal_item?
return ILLEGAL_ALCH_ITEMS.include?(@item.id)
ILLEGAL_ALCH_ITEMS.include?(@item.id)
end
def execute_action
def executeAction
if @pulses == 0
mob.play_animation(@spell.animation)
mob.play_graphic(@spell.graphic)
mob.send(DISPLAY_SPELLBOOK)
inventory = mob.inventory
gold = (item.definition.value * @spell.multiplier) + 1
inventory.remove(inventory.get(@slot).id, 1)
inventory.add(995, gold)
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
set_delay(@spell.delay)
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
set_delay(ALCHEMY_DELAY)
elsif @pulses == 1
mob.stop_animation
mob.stop_graphic
@@ -62,9 +55,31 @@ class AlchemyAction < ItemSpellAction
end
def append_alchemy(button, level, elements, high, animation, graphic, multiplier, experience, delay)
ALCHEMY_SPELLS[button] = AlchemySpell.new(level, elements, high, animation, graphic, multiplier, experience, delay)
private
# The delay of an alchemy spell.
ALCHEMY_DELAY = 4
# The height of the graphic.
GRAPHIC_HEIGHT = 100
# Inserts an `AlchemySpell` into the hash of available alchemy spells.
def alchemy(_name, hash)
unless hash.has_keys?(:button, :level, :runes, :animation, :graphic, :multiplier, :experience)
fail 'Hash must have button, level, runes, animation, graphic, multiplier, experience keys.'
end
id, multiplier = hash[:button], hash[:multiplier]
level, runes, experience = hash[:level], hash[:runes], hash[:experience]
animation = Animation.new(hash[:animation])
graphic = Graphic.new(hash[:graphic], 0, GRAPHIC_HEIGHT)
ALCHEMY_SPELLS[id] = AlchemySpell.new(level, runes, experience, animation, graphic, multiplier)
end
append_alchemy(1162, 21, { FIRE => 3, NATURE => 1 }, false, LOW_ALCH_ANIM, LOW_ALCH_GRAPHIC, 0.48, 31, 1) # Low level alchemy
append_alchemy(1178, 55, { FIRE => 5, NATURE => 1 }, true, HIGH_ALCH_ANIM, HIGH_ALCH_GRAPHIC, 0.72, 65, 4) # High level alchemy
alchemy :low_level, button: 1_162, level: 21, runes: { FIRE => 3, NATURE => 1 }, animation: 712,
graphic: 112, multiplier: 0.48, experience: 31
alchemy :high_level, button: 1_178, level: 55, runes: { FIRE => 5, NATURE => 1 }, animation: 713,
graphic: 113, multiplier: 0.72, experience: 65
+24 -22
View File
@@ -3,6 +3,7 @@ require 'java'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Graphic'
java_import 'org.apollo.game.model.Item'
java_import 'org.apollo.game.model.entity.Skill'
CONVERT_SPELLS = {}
BONES_ID = 526
@@ -10,21 +11,23 @@ BONES_ID = 526
CONVERT_ANIM = Animation.new(722)
CONVERT_GRAPHIC = Graphic.new(141, 0, 100)
# A `Spell` for converting items.
class ConvertSpell < Spell
attr_reader :reward
def initialize(level, elements, experience, reward)
super(level, elements, experience)
super(level, elements, experience)
@reward = Item.new(reward)
end
end
# A `SpellAction` for a `ConvertSpell`.
class ConvertingAction < SpellAction
attr_reader :slots
def initialize(player, spell, slots)
super(player, spell)
super(player, spell)
@slots = slots
end
@@ -32,27 +35,25 @@ class ConvertingAction < SpellAction
if @pulses == 0
mob.play_animation(CONVERT_ANIM)
mob.play_graphic(CONVERT_GRAPHIC)
inventory = mob.inventory
firing = (@slots.length * 2) < inventory.capacity
inventory.stop_firing_events unless firing # In the case of many changes, wait with firing events
inventory.stop_firing_events unless firing # In case of many changes, wait with firing events
reward = @spell.reward
@slots.each do |slot|
inventory.set(slot, reward) # Share the instance
end
@slots.each { |slot| inventory.set(slot, reward) }
unless firing # If we waited with firing events, restore it now and force a refresh
inventory.start_firing_events
inventory.force_refresh
end
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
set_delay(2)
elsif @pulses == 1
mob.stop_animation
mob.stop_graphic
mob.stop_graphic
stop
end
end
@@ -63,24 +64,25 @@ def bone_slots(player)
inventory = player.inventory
items = inventory.items
size = inventory.size
counter = 0
slots = []
(0...inventory.capacity).each do |slot|
break unless counter <= size
item = items[slot]
slots << slot if (item != nil and item.id == BONES_ID)
slots << slot if !item.nil? && item.id == BONES_ID
counter += 1
end
return slots
slots
end
def append_convert(button, level, elements, experience, reward)
def convert(button, level, elements, experience, reward)
CONVERT_SPELLS[button] = ConvertSpell.new(level, elements, experience, reward)
end
append_convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
#append_convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
# convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
+35 -40
View File
@@ -29,36 +29,35 @@ MUD_RUNE = 4698
STEAM_RUNE = 4694
LAVA_RUNE = 4699
# An element of a spell.
class Element
attr_reader :runes, :staffs, :name
def initialize(runes, staffs, name="Null")
def initialize(runes, staffs, name = 'Null')
@runes = runes
@staffs = staffs
@name = name
end
def check_remove(player, amount, remove)
weapon = player.equipment.get(EquipmentConstants::WEAPON)
if @staffs != nil && weapon != nil
@staffs.each do |staff|
return true if weapon.id == staff
end
unless @staffs.nil? || weapon.nil?
@staffs.each { |staff| return true if weapon.id == staff }
end
inventory = player.inventory
found = {}
counter = 0
inventory.items.each do |item|
break unless counter < amount
next if item == nil
next if item.nil?
amt = item.amount
@runes.each do |rune|
break unless counter < amount
id = item.id
if id == rune
if amt >= amount
@@ -71,42 +70,38 @@ class Element
end
end
end
if counter >= amount
if remove
found.each do |id, amt|
inventory.remove(id, amt)
end
end
found.each { |id, amt| inventory.remove(id, amt) } if remove
return true
end
return false
false
end
end
AIR_RUNES = [ 556, 4695, 4696, 4697 ]
WATER_RUNES = [ 555, 4695, 4698, 4694 ]
EARTH_RUNES = [ 557, 4696, 4697, 4698 ]
FIRE_RUNES = [ 554, 4697, 4694, 4699 ]
AIR_RUNES = [556, 4695, 4696, 4697]
WATER_RUNES = [555, 4695, 4698, 4694]
EARTH_RUNES = [557, 4696, 4697, 4698]
FIRE_RUNES = [554, 4697, 4694, 4699]
AIR_STAFFS = [ 1381, 1397, 1405 ]
WATER_STAFFS = [ 1383, 1395, 1403 ]
EARTH_STAFFS = [ 1385, 1399, 1407, 3053, 3054 ]
FIRE_STAFFS = [ 1387, 1393, 1401, 3053, 3054 ]
AIR_STAFFS = [1381, 1397, 1405]
WATER_STAFFS = [1383, 1395, 1403]
EARTH_STAFFS = [1385, 1399, 1407, 3053, 3054]
FIRE_STAFFS = [1387, 1393, 1401, 3053, 3054]
AIR = Element.new(AIR_RUNES, AIR_STAFFS, "Air rune")
WATER = Element.new(WATER_RUNES, WATER_STAFFS, "Water rune")
EARTH = Element.new(EARTH_RUNES, EARTH_STAFFS, "Earth rune")
FIRE = Element.new(FIRE_RUNES, FIRE_STAFFS, "Fire rune")
AIR = Element.new(AIR_RUNES, AIR_STAFFS, 'Air rune')
WATER = Element.new(WATER_RUNES, WATER_STAFFS, 'Water rune')
EARTH = Element.new(EARTH_RUNES, EARTH_STAFFS, 'Earth rune')
FIRE = Element.new(FIRE_RUNES, FIRE_STAFFS, 'Fire rune')
MIND = Element.new([MIND_RUNE], nil, "Mind rune")
CHAOS = Element.new([CHAOS_RUNE], nil, "Chaos rune")
DEATH = Element.new([DEATH_RUNE], nil, "Death rune")
BLOOD = Element.new([BLOOD_RUNE], nil, "Blood rune")
MIND = Element.new([MIND_RUNE], nil, 'Mind rune')
CHAOS = Element.new([CHAOS_RUNE], nil, 'Chaos rune')
DEATH = Element.new([DEATH_RUNE], nil, 'Death rune')
BLOOD = Element.new([BLOOD_RUNE], nil, 'Blood rune')
COSMIC = Element.new([COSMIC_RUNE], nil, "Cosmic rune")
LAW = Element.new([LAW_RUNE], nil, "Law rune")
NATURE = Element.new([NATURE_RUNE], nil, "Nature rune")
SOUL = Element.new([SOUL_RUNE], nil, "Soul rune")
COSMIC = Element.new([COSMIC_RUNE], nil, 'Cosmic rune')
LAW = Element.new([LAW_RUNE], nil, 'Law rune')
NATURE = Element.new([NATURE_RUNE], nil, 'Nature rune')
SOUL = Element.new([SOUL_RUNE], nil, 'Soul rune')
+29 -31
View File
@@ -8,7 +8,7 @@ ENCHANT_SPELLS = {}
ENCHANT_ITEMS = {}
RING_GFX = Graphic.new(238, 0, 100)
RING_ANIM = Animation.new(713) # TODO: No way we need one of the alchemy anims for enchanting...
RING_ANIM = Animation.new(713) # TODO: an alchemy animation for enchanting?
LOW_NECK_GFX = Graphic.new(114, 0, 100)
LOW_NECK_ANIM = Animation.new(719)
@@ -21,11 +21,12 @@ HIGH_NECK_ANIM = Animation.new(721)
ONYX_NECK_GFX = Graphic.new(452, 0, 100)
# A `Spell` for enchanting an item.
class EnchantSpell < Spell
attr_reader :button, :animation, :graphic, :delay
def initialize(button, level, elements, animation, graphic, delay, experience)
super(level, elements, experience)
super(level, elements, experience)
@button = button
@animation = animation
@graphic = graphic
@@ -34,38 +35,39 @@ class EnchantSpell < Spell
end
# A `SpellAction` for an `EnchantSpell`.
class EnchantAction < ItemSpellAction
attr_reader :reward
def initialize(player, enchant, slot, item, reward)
super(player, enchant, slot, item)
super(player, enchant, slot, item)
@reward = Item.new(reward)
end
def illegal_item?
return ENCHANT_ITEMS[@item.id] == nil
ENCHANT_ITEMS[@item.id].nil?
end
def execute_action
def executeAction
if @pulses == 0
mob.play_animation(@spell.animation)
mob.play_graphic(@spell.graphic)
mob.send(DISPLAY_SPELLBOOK)
mob.inventory.set(@slot, @reward)
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
set_delay(@spell.delay)
elsif @pulses == 1
mob.stop_animation
mob.stop_graphic
mob.stop_graphic
stop
end
end
end
def append_enchant(button, level, elements, item, animation, graphic, delay, experience, reward)
def enchant(button, level, elements, item, animation, graphic, delay, experience, reward)
enchant = EnchantSpell.new(button, level, elements, animation, graphic, delay, experience)
ENCHANT_SPELLS[item] = enchant
ENCHANT_ITEMS[item] = reward
@@ -79,31 +81,27 @@ DSTONE_ELEMENTS = { WATER => 15, EARTH => 15, COSMIC => 1 }
ONYX_ELEMENTS = { EARTH => 20, FIRE => 20, COSMIC => 1 }
# Sapphire
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1637, RING_ANIM, RING_GFX, 2, 17.5, 2550 # Ring
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1656, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 3853 # Necklace
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1692, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 1727 # Amulet
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1637, RING_ANIM, RING_GFX, 2, 17.5, 2550 # Ring
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1656, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 3853 # Necklace
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1692, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 1727 # Amulet
# Emerald
append_enchant 1165, 27, EMERALD_ELEMENTS, 1639, RING_ANIM, RING_GFX, 2, 37, 2552 # Ring
append_enchant 1165, 27, EMERALD_ELEMENTS, 1658, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 5521 # Necklace
append_enchant 1165, 27, EMERALD_ELEMENTS, 1696, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 1729 # Amulet
enchant 1165, 27, EMERALD_ELEMENTS, 1639, RING_ANIM, RING_GFX, 2, 37, 2552 # Ring
enchant 1165, 27, EMERALD_ELEMENTS, 1658, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 5521 # Necklace
enchant 1165, 27, EMERALD_ELEMENTS, 1696, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 1729 # Amulet
# Ruby
append_enchant 1176, 49, RUBY_ELEMENTS, 1641, RING_ANIM, RING_GFX, 2, 59, 2568 # Ring
# append_enchant 1176, 49, RUBY_ELEMENTS, 1660, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, # Necklace - not found in 317 or 377
append_enchant 1176, 49, RUBY_ELEMENTS, 1698, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, 1725 # Amulet
enchant 1176, 49, RUBY_ELEMENTS, 1641, RING_ANIM, RING_GFX, 2, 59, 2568 # Ring
enchant 1176, 49, RUBY_ELEMENTS, 1698, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, 1725 # Amulet
# Diamond
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1643, RING_ANIM, RING_GFX, 2, 67, 2570 # Ring
# append_enchant 1180, 57, DIAMOND_ELEMENTS, 1662, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, # Necklace - not found in 317 or 377
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1700, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, 1731 # Amulet
enchant 1180, 57, DIAMOND_ELEMENTS, 1643, RING_ANIM, RING_GFX, 2, 67, 2570 # Ring
enchant 1180, 57, DIAMOND_ELEMENTS, 1700, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, 1731 # Amulet
# Dragonstone
append_enchant 1187, 68, DSTONE_ELEMENTS, 1645, RING_ANIM, RING_GFX, 2, 78, 2572 # Ring
# append_enchant 1187, 68, DSTONE_ELEMENTS, 1664, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, # Necklace - not found in 317 or 377
append_enchant 1187, 68, DSTONE_ELEMENTS, 1702, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, 1712 # Amulet
enchant 1187, 68, DSTONE_ELEMENTS, 1645, RING_ANIM, RING_GFX, 2, 78, 2572 # Ring
enchant 1187, 68, DSTONE_ELEMENTS, 1702, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, 1712 # Amulet
# Onyx
append_enchant 6003, 87, ONYX_ELEMENTS, 6575, RING_ANIM, RING_GFX, 2, 97, 6583 # Ring
# append_enchant 6003, 87, ONYX_ELEMENTS, 6577, HIGH_NECK_ANIM, ONYX_NECK_GFX, 3, 97, # Necklace - not found in 317 or 377
append_enchant 6003, 87, ONYX_ELEMENTS, 6581, HIGH_NECK_ANIM, ONYX_NECK_GFX, 2, 97, 6585 # Amulet
enchant 6003, 87, ONYX_ELEMENTS, 6575, RING_ANIM, RING_GFX, 2, 97, 6583 # Ring
enchant 6003, 87, ONYX_ELEMENTS, 6581, HIGH_NECK_ANIM, ONYX_NECK_GFX, 2, 97, 6585 # Amulet
+38 -29
View File
@@ -5,11 +5,13 @@ java_import 'org.apollo.game.message.impl.DisplayTabInterfaceMessage'
java_import 'org.apollo.game.model.entity.EquipmentConstants'
java_import 'org.apollo.game.model.entity.Skill'
# A `Message` to display the magic spellbook.
DISPLAY_SPELLBOOK = DisplayTabInterfaceMessage.new(6)
# A spell that can be cast.
class Spell
attr_reader :level, :elements, :experience
def initialize(level, elements, experience)
@level = level
@elements = elements
@@ -18,71 +20,72 @@ class Spell
end
# An `Action` for casting a `Spell`.
class SpellAction < Action
attr_reader :spell, :pulses
def initialize(mob, spell)
super(0, true, mob)
@spell = spell
@pulses = 0
end
def execute
if @pulses == 0
unless (check_skill and process_elements)
unless check_skill && process_elements
stop
return
end
end
execute_action
@pulses += 1
end
def execute_action
stop
end
def check_skill
required = @spell.level
if required > mob.skill_set.skill(Skill::MAGIC).maximum_level
mob.send_message("You need a Magic level of at least #{required} to cast this spell.")
return false
end
return true
true
end
def process_elements
elements = @spell.elements
elements.each do |element, amount|
unless element.check_remove(mob, amount, false)
mob.send_message("You do not have enough #{element.name}s to cast this spell.")
return false
end
end
elements.each { |element, amount| element.check_remove(mob, amount, true) }
return true
true
end
def equals(other)
return (get_class == other.get_class and @spell == other.spell)
get_class == other.get_class && @spell == other.spell
end
end
# A `SpellAction` that verifies an input `Item` is legal.
class ItemSpellAction < SpellAction
attr_reader :slot, :item
def initialize(mob, spell, slot, item)
super(mob, spell)
super(mob, spell)
@slot = slot
@item = item
end
# We override SpellAction#execute to implement an illegal item check (e.g. coins for alchemy)
def execute
if @pulses == 0
@@ -91,9 +94,9 @@ class ItemSpellAction < SpellAction
stop
next
end
id = @item.id
# TODO: There has to be a better way to do this.
@spell.elements.each do |element, amount|
element.runes.each do |rune|
@@ -106,13 +109,13 @@ class ItemSpellAction < SpellAction
end
end
super
end
def illegal_item?
# Override this method if necessary
return false
false
end
end
@@ -120,7 +123,7 @@ end
# Intercepts the magic on item message.
on :message, :magic_on_item do |player, message|
spell = message.spell_id
alch = ALCHEMY_SPELLS[spell]
unless alch.nil?
slot = message.slot
@@ -129,9 +132,9 @@ on :message, :magic_on_item do |player, message|
message.terminate
return
end
ench = ENCHANT_SPELLS[message.id]
if !ench.nil? and ench.button == spell
if !ench.nil? && ench.button == spell
slot = message.slot
item = player.inventory.get(slot)
player.start_action(EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id]))
@@ -149,12 +152,18 @@ on :message, :button do |player, message|
message.terminate
return
end
conv = CONVERT_SPELLS[button]
unless conv.nil?
slots = bone_slots player
slots = bone_slots(player)
if slots.length == 0
player.send_message("You can't convert these bones!")
else
player.start_action(ConvertingAction.new(player, conv, slots))
end
if slots.length == 0 then player.send_message("You can't convert these bones!") else player.start_action(ConvertingAction.new(player, conv, slots)) end
message.terminate
end
end
end
+38 -28
View File
@@ -1,10 +1,12 @@
# Thanks to phl0w <http://www.rune-server.org/members/phl0w/> for providing
# Thanks to phl0w <http://www.rune-server.org/members/phl0w> for providing
# the correct destination coordinates of the ancient teleports.
require 'java'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Graphic'
java_import 'org.apollo.game.model.Position'
java_import 'org.apollo.game.model.entity.Skill'
TELEPORT_SPELLS = {}
@@ -16,9 +18,10 @@ ANCIENT_TELE_END_GRAPHIC = Graphic.new(455)
ANCIENT_TELE_ANIM = Animation.new(1979)
ANCIENT_TELE_GRAPHIC = Graphic.new(392)
# A `Spell` that teleports a `Player` to another `Position`.
class TeleportSpell < Spell
attr_reader :ancient, :destination, :experience, :name
def initialize(ancient, level, elements, destination, experience, name)
super(level, elements, experience)
@ancient = ancient
@@ -28,67 +31,74 @@ class TeleportSpell < Spell
end
# A `SpellAction` for a `TeleportSpell`.
class TeleportingAction < SpellAction
def initialize(mob, spell)
super(mob, spell)
end
def execute_action
@spell.ancient ? execute_ancient : execute_modern
end
def execute_modern
if @pulses == 0
mob.play_animation(MODERN_TELE_ANIM)
elsif @pulses == 1
mob.play_graphic(MODERN_TELE_GRAPHIC)
delay = 1
set_delay(1)
elsif @pulses == 2
mob.stop_graphic
mob.play_animation(MODERN_TELE_END_ANIM)
mob.play_animation(MODERN_TELE_END_ANIM)
mob.teleport(@spell.destination)
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
stop
end
end
def execute_ancient
if @pulses == 0
mob.play_graphic(ANCIENT_TELE_GRAPHIC)
mob.play_animation(ANCIENT_TELE_ANIM)
delay = 2
set_delay(2)
elsif @pulses == 2
mob.stop_graphic
mob.stop_animation
mob.teleport(@spell.destination)
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
stop
end
end
end
def append_tele(ancient, button, level, elements, x, y, experience, name)
TELEPORT_SPELLS[button] = TeleportSpell.new(ancient, level, elements, Position.new(x, y), experience, name)
def tele(ancient = false, button, level, elements, x, y, experience, name)
position = Position.new(x, y)
TELEPORT_SPELLS[button] = TeleportSpell.new(ancient, level, elements, position, experience, name)
end
def ancient_tele(*args)
tele(true, *args)
end
# Modern teleports
append_tele(false, 1164, 25, { FIRE => 1, AIR => 3, LAW => 1 }, 3213, 3424, 35, "Varrock")
append_tele(false, 1167, 31, { EARTH => 1, AIR => 3, LAW => 1 }, 3222, 3219, 41, "Lumbridge")
append_tele(false, 1170, 37, { WATER => 1, AIR => 3, LAW => 1 }, 2965, 3379, 47, "Falador")
append_tele(false, 1174, 45, { AIR => 5, LAW => 1 }, 2757, 3478, 55.5, "Camelot")
append_tele(false, 1540, 51, { WATER => 2, LAW => 2 }, 2662, 3306, 61, "Ardougne")
append_tele(false, 1541, 58, { EARTH => 2, LAW => 2 }, 2549, 3114, 68, "the Watchtower")
append_tele(false, 7455, 61, { FIRE => 2, LAW => 2 }, 2871, 3590, 68, "Trollheim")
append_tele(false, 18470, 64, { FIRE => 2, WATER => 2, LAW => 2, Element.new([1963], nil, "Banana") => 1 }, 2754, 2785, 76, "Ape Atoll")
tele 1_164, 25, { FIRE => 1, AIR => 3, LAW => 1 }, 3213, 3424, 35, 'Varrock'
tele 1_167, 31, { EARTH => 1, AIR => 3, LAW => 1 }, 3222, 3219, 41, 'Lumbridge'
tele 1_170, 37, { WATER => 1, AIR => 3, LAW => 1 }, 2965, 3379, 47, 'Falador'
tele 1_174, 45, { AIR => 5, LAW => 1 }, 2757, 3478, 55.5, 'Camelot'
tele 1_540, 51, { WATER => 2, LAW => 2 }, 2662, 3306, 61, 'Ardougne'
tele 1_541, 58, { EARTH => 2, LAW => 2 }, 2549, 3114, 68, 'the Watchtower'
tele 7_455, 61, { FIRE => 2, LAW => 2 }, 2871, 3590, 68, 'Trollheim'
tele 18_470, 64, { FIRE => 2, WATER => 2, LAW => 2, Element.new([1963], nil, 'Banana') => 1 },
2_754, 2_785, 76, 'Ape Atoll'
# Ancient teleports
append_tele(true, 13035, 54, { LAW => 2, FIRE => 1, AIR => 1 }, 3098, 9882, 64, "Paddewwa")
append_tele(true, 13045, 60, { LAW => 2, SOUL => 2 }, 3320, 3338, 70, "Senntisten")
append_tele(true, 13053, 66, { LAW => 2, BLOOD => 1 }, 3493, 3472, 76, "Kharyll")
append_tele(true, 13061, 72, { LAW => 2, WATER => 4 }, 3003, 3470, 82, "Lassar")
append_tele(true, 13069, 78, { LAW => 2, FIRE => 3, AIR => 2 }, 2966, 3696, 88, "Dareeyak")
append_tele(true, 13079, 84, { LAW => 2, SOUL => 2 }, 3163, 3664, 94, "Carrallangar")
append_tele(true, 13087, 90, { LAW => 2, BLOOD => 2 }, 3287, 3883, 100, "Annakarl")
append_tele(true, 13095, 96, { LAW => 2, WATER => 8 }, 2972, 3873, 106, "Ghorrock")
ancient_tele 13_035, 54, { LAW => 2, FIRE => 1, AIR => 1 }, 3098, 9882, 64, 'Paddewwa'
ancient_tele 13_045, 60, { LAW => 2, SOUL => 2 }, 3320, 3338, 70, 'Senntisten'
ancient_tele 13_053, 66, { LAW => 2, BLOOD => 1 }, 3493, 3472, 76, 'Kharyll'
ancient_tele 13_061, 72, { LAW => 2, WATER => 4 }, 3003, 3470, 82, 'Lassar'
ancient_tele 13_069, 78, { LAW => 2, FIRE => 3, AIR => 2 }, 2966, 3_696, 88, 'Dareeyak'
ancient_tele 13_079, 84, { LAW => 2, SOUL => 2 }, 3163, 3664, 94, 'Carrallangar'
ancient_tele 13_087, 90, { LAW => 2, BLOOD => 2 }, 3287, 3883, 100, 'Annakarl'
ancient_tele 13_095, 96, { LAW => 2, WATER => 8 }, 2972, 3873, 106, 'Ghorrock'
+6 -5
View File
@@ -1,5 +1,6 @@
GEMSTONES = {}
# A gemstone that can be received when mining.
class Gemstone
attr_reader :id, :chance
@@ -9,11 +10,11 @@ class Gemstone
end
end
def append_gem(gem)
def gem(gem)
GEMSTONES[gem.id] = gem
end
append_gem(Gemstone.new(1623, 0)) # uncut sapphire
append_gem(Gemstone.new(1605, 0)) # uncut emerald
append_gem(Gemstone.new(1619, 0)) # uncut ruby
append_gem(Gemstone.new(1617, 0)) # uncut diamond
gem(Gemstone.new(1623, 0)) # uncut sapphire
gem(Gemstone.new(1605, 0)) # uncut emerald
gem(Gemstone.new(1619, 0)) # uncut ruby
gem(Gemstone.new(1617, 0)) # uncut diamond
+25 -21
View File
@@ -8,6 +8,7 @@ PROSPECT_PULSES = 3
ORE_SIZE = 1
# TODO: finish implementing this
# A `DistancedAction` for mining ore.
class MiningAction < DistancedAction
attr_reader :position, :ore, :counter, :started
@@ -21,9 +22,11 @@ class MiningAction < DistancedAction
def find_pickaxe
weapon = mob.equipment.get(EquipmentConstants::WEAPON)
PICKAXE_IDS.each { |id| return PICKAXES[id] if (!weapon.nil? && weapon.id == id) || mob.inventory.contains(id) }
PICKAXE_IDS.each do |id|
return PICKAXES[id] if (!weapon.nil? && weapon.id == id) || mob.inventory.contains(id)
end
return nil
nil
end
# starts the mining animation, sets counters/flags and turns the mob to
@@ -42,7 +45,7 @@ class MiningAction < DistancedAction
mob.turn_to(@position)
# verify the mob can mine with their pickaxe
unless (!pickaxe.nil? and level >= pickaxe.level)
if pickaxe.nil? || level < pickaxe.level
mob.send_message('You do not have a pickaxe for which you have the level to use.')
stop
return
@@ -56,9 +59,7 @@ class MiningAction < DistancedAction
end
# check if we need to kick start things
unless @started
start_mine(pickaxe)
else
if @started
# count down and check if we can have a chance at some ore now
if @counter == 0
# TODO: calculate the chance that the player can actually get the rock
@@ -73,16 +74,20 @@ class MiningAction < DistancedAction
stop
end
@counter -= 1
end
@counter -= 1
else
start_mine(pickaxe)
end
end
def equals(other)
return (get_class == other.get_class and @position == other.position and @ore == other.ore)
get_class == other.get_class && @position == other.position && @ore == other.ore
end
end
# A `DistancedAction` for a rock with no available ore.
class ExpiredProspectingAction < DistancedAction
attr_reader :position
@@ -96,11 +101,12 @@ class ExpiredProspectingAction < DistancedAction
end
def equals(other)
return (get_class == other.get_class and @position == other.position)
get_class == other.get_class && @position == other.position
end
end
# A `DistancedAction` for prospecting a rock.
class ProspectingAction < DistancedAction
attr_reader :position, :ore
@@ -112,22 +118,22 @@ class ProspectingAction < DistancedAction
end
def executeAction
unless @started
@started = true
mob.send_message('You examine the rock for ores...')
mob.turn_to(@position)
else
if @started
ore_def = ItemDefinition.lookup(@ore.id)
name = ore_def.name.sub(/ ore$/, '').downcase
mob.send_message("This rock contains #{name}.")
stop
else
@started = true
mob.send_message('You examine the rock for ores...')
mob.turn_to(@position)
end
end
def equals(other)
return (get_class == other.get_class and @position == other.position and @ore == other.ore)
get_class == other.get_class && @position == other.position && @ore == other.ore
end
end
@@ -135,9 +141,7 @@ end
on :message, :first_object_action do |mob, message|
ore = ORES[message.id]
unless ore.nil?
mob.start_action(MiningAction.new(mob, message.position, ore))
end
mob.start_action(MiningAction.new(mob, message.position, ore)) unless ore.nil?
end
on :message, :second_object_action do |mob, message|
@@ -148,4 +152,4 @@ on :message, :second_object_action do |mob, message|
elsif !EXPIRED_ORES[message.id].nil?
mob.start_action(ExpiredProspectingAction.new(mob, message.position))
end
end
end
+35 -36
View File
@@ -7,6 +7,7 @@
ORES = {}
EXPIRED_ORES = {}
# An ore that can be mined.
class Ore
attr_reader :id, :objects, :level, :exp, :respawn
@@ -27,70 +28,68 @@ def append_ore(ore)
end
CLAY_OBJECTS = {
2180 => 450 , 2109 => 451 , 14904 => 14896, 14905 => 14897
2180 => 450, 2109 => 451, 14_904 => 14_896, 14_905 => 14_897
}
COPPER_OBJECTS = {
11960 => 11555, 11961 => 11556, 11962 => 11557, 11936 => 11552,
11937 => 11553, 11938 => 11554, 2090 => 450 , 2091 => 451 ,
14906 => 14898, 14907 => 14899, 14856 => 14832, 14857 => 14833,
14858 => 14834
11_960 => 11_555, 11_961 => 11_556, 11_962 => 11_557, 11_936 => 11_552,
11_937 => 11_553, 11_938 => 11_554, 2090 => 450, 2091 => 451,
14_906 => 14_898, 14_907 => 14_899, 14_856 => 14_832, 14_857 => 14_833,
14_858 => 14_834
}
TIN_OBJECTS = {
11597 => 11555, 11958 => 11556, 11959 => 11557, 11933 => 11552,
11934 => 11553, 11935 => 11554, 2094 => 450 , 2095 => 451 ,
14092 => 14894, 14903 => 14895
11_597 => 11_555, 11_958 => 11_556, 11_959 => 11_557, 11_933 => 11_552,
11_934 => 11_553, 11_935 => 11_554, 2094 => 450, 2095 => 451,
14_092 => 14_894, 14_903 => 14_895
}
IRON_OBJECTS = {
11954 => 11555, 11955 => 11556, 11956 => 11557, 2092 => 450 ,
2093 => 451 , 14900 => 14892, 14901 => 14893, 14913 => 14915,
14914 => 14916
11_954 => 11_555, 11_955 => 11_556, 11_956 => 11_557, 2092 => 450,
2093 => 451, 14_900 => 14_892, 14_901 => 14_893, 14_913 => 14_915,
14_914 => 14_916
}
COAL_OBJECTS = {
11963 => 11555, 11964 => 11556, 11965 => 11557, 11930 => 11552,
11931 => 11553, 11932 => 11554, 2096 => 450 , 2097 => 451 ,
14850 => 14832, 14851 => 14833, 14852 => 14834
11_963 => 11_555, 11_964 => 11_556, 11_965 => 11_557, 11_930 => 11_552,
11_931 => 11_553, 11_932 => 11_554, 2096 => 450, 2097 => 451,
14_850 => 14_832, 14_851 => 14_833, 14_852 => 14_834
}
SILVER_OBJECTS = {
11948 => 11555, 11949 => 11556, 11950 => 11557, 2100 => 450 ,
2101 => 451
11_948 => 11_555, 11_949 => 11_556, 11_950 => 11_557, 2100 => 450, 2101 => 451
}
GOLD_OBJECTS = {
11951 => 11555, 11952 => 11556, 11953 => 11557, 2098 => 450 ,
2099 => 451
11_951 => 11_555, 11_952 => 11_556, 11_953 => 11_557, 2098 => 450, 2099 => 451
}
MITHRIL_OBJECTS = {
11945 => 11555, 11946 => 11556, 11947 => 11557, 11942 => 11552,
11943 => 11553, 11944 => 11554, 2102 => 450 , 2103 => 451 ,
14853 => 14832, 14854 => 14833, 14855 => 14834
11_945 => 11_555, 11_946 => 11_556, 11_947 => 11_557, 11_942 => 11_552,
11_943 => 11_553, 11_944 => 11_554, 2102 => 450, 2103 => 451,
14_853 => 14_832, 14_854 => 14_833, 14_855 => 14_834
}
ADAMANT_OBJECTS = {
11939 => 11552, 11940 => 11553, 11941 => 11554, 2104 => 450 ,
2105 => 451 , 14862 => 14832, 14863 => 14833, 14864 => 14834
11_939 => 11_552, 11_940 => 11_553, 11_941 => 11_554, 2104 => 450,
2105 => 451, 14_862 => 14_832, 14_863 => 14_833, 14_864 => 14_834
}
RUNITE_OBJECTS = {
2106 => 450 , 2107 => 451 , 14859 => 14832, 14860 => 14833,
14861 => 14834
2106 => 450, 2107 => 451, 14_859 => 14_832, 14_860 => 14_833,
14_861 => 14_834
}
append_ore Ore.new(434, CLAY_OBJECTS, 1, 5, 3 ) # clay
append_ore Ore.new(436, COPPER_OBJECTS, 1, 17.5, 6 ) # copper ore
append_ore Ore.new(438, TIN_OBJECTS, 1, 17.5, 6 ) # tin ore
append_ore Ore.new(440, IRON_OBJECTS, 15, 35, 16 ) # iron ore
append_ore Ore.new(453, COAL_OBJECTS, 30, 50, 100 ) # coal
append_ore Ore.new(444, GOLD_OBJECTS, 40, 65, 200 ) # gold ore
append_ore Ore.new(442, SILVER_OBJECTS, 20, 40, 200 ) # silver ore
append_ore Ore.new(447, MITHRIL_OBJECTS, 55, 80, 400 ) # mithril ore
append_ore Ore.new(449, ADAMANT_OBJECTS, 70, 95, 800 ) # adamant ore
append_ore Ore.new(451, RUNITE_OBJECTS, 85, 125, 2500) # runite ore
append_ore Ore.new 434, CLAY_OBJECTS, 1, 5, 3 # clay
append_ore Ore.new 436, COPPER_OBJECTS, 1, 17.5, 6 # copper ore
append_ore Ore.new 438, TIN_OBJECTS, 1, 17.5, 6 # tin ore
append_ore Ore.new 440, IRON_OBJECTS, 15, 35, 16 # iron ore
append_ore Ore.new 453, COAL_OBJECTS, 30, 50, 100 # coal
append_ore Ore.new 444, GOLD_OBJECTS, 40, 65, 200 # gold ore
append_ore Ore.new 442, SILVER_OBJECTS, 20, 40, 200 # silver ore
append_ore Ore.new 447, MITHRIL_OBJECTS, 55, 80, 400 # mithril ore
append_ore Ore.new 449, ADAMANT_OBJECTS, 70, 95, 800 # adamant ore
append_ore Ore.new 451, RUNITE_OBJECTS, 85, 125, 2500 # runite ore
# TODO: rune essence object id = 2491
# level 1, exp 5, rune ess = 1436, pure ess = 7936
# level 1, exp 5, rune ess = 1436, pure ess = 7936
+2 -1
View File
@@ -5,6 +5,7 @@ java_import 'org.apollo.game.model.Animation'
PICKAXES = {}
PICKAXE_IDS = []
# A pickaxe that can be mined with.
class Pickaxe
attr_reader :id, :level, :animation, :pulses
@@ -29,4 +30,4 @@ append_pickaxe(Pickaxe.new(1273, 21, 629, 5)) # mithril pickaxe
append_pickaxe(Pickaxe.new(1271, 31, 628, 4)) # adamant pickaxe
append_pickaxe(Pickaxe.new(1275, 41, 624, 3)) # rune pickaxe
PICKAXE_IDS.reverse!
PICKAXE_IDS.reverse!
+1 -1
View File
@@ -13,4 +13,4 @@
# pulses down where appropriate.
def respawn_pulses(base, players)
base - players * base / ($world.player_repository.size * 2)
end
end
+32 -29
View File
@@ -4,12 +4,12 @@ java_import 'org.apollo.game.action.Action'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.entity.Skill'
BURY_BONE_ANIMATION = 827
BURY_BONE_ANIMATION = Animation.new(827)
BONES = {}
# A bone with an id and experience value.
class Bone
attr_reader :id, :experience
attr_reader :id, :experience
def initialize(id, experience)
@id = id
@@ -18,42 +18,45 @@ class Bone
end
# An action where a bone in a player's inventory is buried.
class BuryBoneAction < Action
attr_reader :slot, :bone
def initialize(mob, slot, bone)
super(1, true, mob)
@slot = slot
@bone = bone
@executions = 0
end
def execute
if @executions == 0
mob.send_message('You dig a hole in the ground...')
@executions += 1
elsif @executions == 1
if mob.inventory.get(@slot).id == @bone.id
mob.play_animation(Animation.new(BURY_BONE_ANIMATION))
mob.play_animation(BURY_BONE_ANIMATION)
mob.send_message('You bury the bones.')
mob.inventory.reset(@slot)
mob.skill_set.add_experience(Skill::PRAYER, @bone.experience)
end
stop
end
end
def equals(other)
return (get_class == other.get_class and @bone == other.bone)
get_class == other.get_class && @bone == other.bone
end
end
# Intercepts the first item option message.
on :message, :first_item_option do |player, message|
bone = BONES[message.id]
unless bone == nil
unless bone.nil?
player.start_action(BuryBoneAction.new(player, message.slot, bone))
message.terminate
end
@@ -61,28 +64,28 @@ end
# Appends a bone to the array
def append_bone(hash)
raise 'Hash must contain an id and an experience value.' unless hash.has_key?(:id) && hash.has_key?(:experience)
fail 'Hash must contain an id and an experience value.' unless hash.has_keys?(:id, :experience)
id = hash[:id]
BONES[id] = Bone.new(id, hash[:experience])
end
append_bone :name => :regular_bones, :id => 526, :experience => 5
append_bone :name => :burnt_bones, :id => 528, :experience => 5
append_bone :name => :bat_bones, :id => 530, :experience => 4
append_bone :name => :big_bones, :id => 532, :experience => 45
append_bone :name => :babydragon_bones, :id => 534, :experience => 30
append_bone :name => :dragon_bones, :id => 536, :experience => 72
append_bone :name => :wolf_bones, :id => 2859, :experience => 14
append_bone :name => :shaikahan_bones, :id => 3123, :experience => 25
append_bone :name => :jogre_bones, :id => 3125, :experience => 15
append_bone :name => :burnt_zogre_bones, :id => 3127, :experience => 25
append_bone :name => :monkey_bones, :id => 3179, :experience => 14 # smallish
append_bone :name => :monkey_bones, :id => 3180, :experience => 14 # medium
append_bone :name => :monkey_bones, :id => 3181, :experience => 14 # quite large
append_bone :name => :monkey_bones, :id => 3182, :experience => 14 # quite large
append_bone :name => :monkey_bones, :id => 3183, :experience => 14 # small
append_bone :name => :shaking_bones, :id => 3187, :experience => 14
append_bone :name => :zogre_bones, :id => 4812, :experience => 23
append_bone :name => :fayrg_bones, :id => 4830, :experience => 84
append_bone :name => :raurg_bones, :id => 4832, :experience => 96
append_bone :name => :ourg_bones, :id => 4834, :experience => 140
append_bone name: :regular_bones, id: 526, experience: 5
append_bone name: :burnt_bones, id: 528, experience: 5
append_bone name: :bat_bones, id: 530, experience: 4
append_bone name: :big_bones, id: 532, experience: 45
append_bone name: :babydragon_bones, id: 534, experience: 30
append_bone name: :dragon_bones, id: 536, experience: 72
append_bone name: :wolf_bones, id: 2859, experience: 14
append_bone name: :shaikahan_bones, id: 3123, experience: 25
append_bone name: :jogre_bones, id: 3125, experience: 15
append_bone name: :burnt_zogre_bones, id: 3127, experience: 25
append_bone name: :monkey_bones, id: 3179, experience: 14 # smallish
append_bone name: :monkey_bones, id: 3180, experience: 14 # medium
append_bone name: :monkey_bones, id: 3181, experience: 14 # quite large
append_bone name: :monkey_bones, id: 3182, experience: 14 # quite large
append_bone name: :monkey_bones, id: 3183, experience: 14 # small
append_bone name: :shaking_bones, id: 3187, experience: 14
append_bone name: :zogre_bones, id: 4812, experience: 23
append_bone name: :fayrg_bones, id: 4830, experience: 84
append_bone name: :raurg_bones, id: 4832, experience: 96
append_bone name: :ourg_bones, id: 4834, experience: 140
+53 -54
View File
@@ -4,86 +4,85 @@ java_import 'org.apollo.game.message.impl.ConfigMessage'
# Declares the active prayer attribute.
declare_attribute(:active_prayer, -1, :persistent)
# The hash of button ids to prayers.
PRAYERS = {}
# Intercept the ButtonMessage to toggle a prayer.
on :message, :button do |player, message|
button = message.widget_id
prayer = PRAYERS[button]
button = message.widget_id
prayer = PRAYERS[button]
unless prayer.nil?
if (prayer.level > player.skill_set.get_maximum_level(Skill::PRAYER))
update_setting(player, prayer, :off)
next
end
player.send_message("after level check")
previous = player.active_prayer
unless previous == -1
update_setting(player, PRAYERS[previous], :off)
end
if previous != button
player.send_message("Previous: #{previous}, new: #{button}.")
update_setting(player, prayer, :on)
player.active_prayer = button
end
unless prayer.nil?
if prayer.level > player.skill_set.get_maximum_level(Skill::PRAYER)
update_setting(player, prayer, :off)
next
end
player.send_message('after level check')
previous = player.active_prayer
update_setting(player, PRAYERS[previous], :off) unless previous == -1
if previous != button
player.send_message("Previous: #{previous}, new: #{button}.")
update_setting(player, prayer, :on)
player.active_prayer = button
end
end
end
private
# A Prayer that can be activated by a player.
class Prayer
attr_reader :name, :level, :button, :setting, :drain
attr_reader :name, :level, :button, :setting, :drain
def initialize(name, level, button, setting, drain)
@name = name
@level = level
@button = button
@setting = setting
@drain = drain
end
def initialize(name, level, button, setting, drain)
@name = name
@level = level
@button = button
@setting = setting
@drain = drain
end
end
def update_setting(player, prayer, state)
value = (state == :on) ? 1 : 0
player.send_message("Toggling prayer #{prayer.name}, state: #{state}.")
player.send(ConfigMessage.new(prayer.setting, value))
value = (state == :on) ? 1 : 0
player.send_message("Toggling prayer #{prayer.name}, state: #{state}.")
player.send(ConfigMessage.new(prayer.setting, value))
end
# Appends a Prayer to the hash.
def append_prayer(properties)
raise 'Error: prayer properties hash must contain a name, level, button, setting, and drain.' unless properties.has_keys?(:name, :level, :button, :setting, :drain)
def append_prayer(name, hash)
unless hash.has_keys?(:level, :button, :setting, :drain)
fail 'Error: prayer hash hash must contain a level, button, setting, and drain.'
end
button = properties[:button]
PRAYERS[button] = Prayer.new(properties[:name], properties[:level], button, properties[:setting], properties[:drain])
button = hash[:button]
PRAYERS[button] = Prayer.new(name, hash[:level], button, hash[:setting], hash[:drain])
end
# Don't deal with the actual effect here to avoid mess (TODO do it, but with attributes?).
append_prayer name: :thick_skin, level: 1, button: 5609, setting: 83, drain: 0.01
append_prayer name: :burst_of_strength, level: 4, button: 5610, setting: 84, drain: 0.01
append_prayer name: :clarity_of_thought, level: 7, button: 5611, setting: 85, drain: 0.01
append_prayer name: :rock_skin, level: 10, button: 5612, setting: 86, drain: 0.04
append_prayer name: :superhuman_strength, level: 13, button: 5613, setting: 87, drain: 0.04
append_prayer name: :improved_reflexes, level: 16, button: 5614, setting: 88, drain: 0.04
append_prayer :thick_skin, level: 1, button: 5609, setting: 83, drain: 0.01
append_prayer :burst_of_strength, level: 4, button: 5610, setting: 84, drain: 0.01
append_prayer :clarity_of_thought, level: 7, button: 5611, setting: 85, drain: 0.01
append_prayer :rock_skin, level: 10, button: 5612, setting: 86, drain: 0.04
append_prayer :superhuman_strength, level: 13, button: 5613, setting: 87, drain: 0.04
append_prayer :improved_reflexes, level: 16, button: 5614, setting: 88, drain: 0.04
append_prayer name: :rapid_restore, level: 19, button: 5615, setting: 89, drain: 0.01
append_prayer name: :rapid_heal, level: 22, button: 5615, setting: 90, drain: 0.01
append_prayer name: :protect_item, level: 25, button: 5617, setting: 91, drain: 0.01
append_prayer :rapid_restore, level: 19, button: 5615, setting: 89, drain: 0.01
append_prayer :rapid_heal, level: 22, button: 5615, setting: 90, drain: 0.01
append_prayer :protect_item, level: 25, button: 5617, setting: 91, drain: 0.01
append_prayer name: :steel_skin, level: 28, button: 5618, setting: 92, drain: 0.1
append_prayer name: :ultimate_strength, level: 31, button: 5619, setting: 93, drain: 0.1
append_prayer name: :incredible_reflexes, level: 34, button: 5620, setting: 94, drain: 0.1
append_prayer :steel_skin, level: 28, button: 5618, setting: 92, drain: 0.1
append_prayer :ultimate_strength, level: 31, button: 5619, setting: 93, drain: 0.1
append_prayer :incredible_reflexes, level: 34, button: 5620, setting: 94, drain: 0.1
append_prayer name: :protect_from_magic, level: 37, button: 5621, setting: 95, drain: 0.15
append_prayer name: :protect_from_missiles, level: 40, button: 5622, setting: 96, drain: 0.15
append_prayer name: :protect_from_melee, level: 43, button: 5633, setting: 97, drain: 0.15
append_prayer :protect_from_magic, level: 37, button: 5621, setting: 95, drain: 0.15
append_prayer :protect_from_missiles, level: 40, button: 5622, setting: 96, drain: 0.15
append_prayer :protect_from_melee, level: 43, button: 5633, setting: 97, drain: 0.15
append_prayer name: :retribution, level: 46, button: 683, setting: 98, drain: 0.15
append_prayer name: :redemption, level: 49, button: 684, setting: 99, drain: 0.15
append_prayer name: :smite, level: 52, button: 685, setting: 100, drain: 0.2
append_prayer :retribution, level: 46, button: 683, setting: 98, drain: 0.15
append_prayer :redemption, level: 49, button: 684, setting: 99, drain: 0.15
append_prayer :smite, level: 52, button: 685, setting: 100, drain: 0.2
+68 -30
View File
@@ -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]
+27 -21
View File
@@ -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
+12 -8
View File
@@ -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
+27 -25
View File
@@ -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]
+52 -44
View File
@@ -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