mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Fix various skills (broken in cf7a742).
This commit is contained in:
@@ -31,15 +31,15 @@ on :message, :item_on_item do |ctx, player, message|
|
||||
secondary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
|
||||
if hash == nil
|
||||
if hash.nil?
|
||||
secondary = message.id
|
||||
primary = message.target_id
|
||||
hash = HERBLORE_ITEM_ON_ITEM[primary]
|
||||
end
|
||||
|
||||
if hash != nil
|
||||
unless hash.nil?
|
||||
method = hash[secondary]
|
||||
if method != nil
|
||||
unless method.nil?
|
||||
method.invoke(player, primary, secondary)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
@@ -51,13 +51,13 @@ on :message, :first_item_option do |ctx, player, message|
|
||||
id = message.id
|
||||
method = HERBLORE_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
unless method.nil?
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
method = DRINK_ITEM[id]
|
||||
|
||||
if method != nil
|
||||
unless method.nil?
|
||||
method.invoke(player, id, message.slot)
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
@@ -69,7 +69,7 @@ def append_herblore_item(method, key, secondary = -1)
|
||||
HERBLORE_ITEM[key] = method
|
||||
else
|
||||
hash = HERBLORE_ITEM_ON_ITEM[key]
|
||||
hash = {} if hash == nil
|
||||
hash = {} if hash.nil?
|
||||
|
||||
hash[secondary] = method
|
||||
HERBLORE_ITEM_ON_ITEM[key] = hash
|
||||
@@ -79,16 +79,17 @@ 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.
|
||||
def check_slot(player, slot, id, amount = 1)
|
||||
item = player.inventory.get(slot)
|
||||
return (item != nil and item.id == id and item.amount >= amount)
|
||||
return (!item.nil? and item.id == id and 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}."
|
||||
def check_skill(player, required, action)
|
||||
if required > player.skill_set.skill(HERBLORE_SKILL_ID).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
|
||||
end
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class SpellAction < Action
|
||||
|
||||
def check_skill
|
||||
required = @spell.level
|
||||
if required > mob.skill_set.skill(MAGIC_SKILL_ID).maximum_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
|
||||
@@ -63,9 +63,7 @@ class SpellAction < Action
|
||||
end
|
||||
end
|
||||
|
||||
elements.each do |element, amount|
|
||||
element.check_remove(mob, amount, true)
|
||||
end
|
||||
elements.each { |element, amount| element.check_remove(mob, amount, true) }
|
||||
|
||||
return true
|
||||
end
|
||||
@@ -124,7 +122,7 @@ on :message, :magic_on_item do |ctx, player, message|
|
||||
spell = message.spell_id
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
if alch != nil
|
||||
unless alch.nil?
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(AlchemyAction.new(player, alch, slot, item))
|
||||
@@ -133,7 +131,7 @@ on :message, :magic_on_item do |ctx, player, message|
|
||||
end
|
||||
|
||||
ench = ENCHANT_SPELLS[message.id]
|
||||
if ench != nil and ench.button == spell
|
||||
if !ench.nil? and ench.button == spell
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id]))
|
||||
@@ -146,16 +144,17 @@ on :message, :button do |ctx, player, message|
|
||||
button = message.widget_id
|
||||
|
||||
tele = TELEPORT_SPELLS[button]
|
||||
if tele != nil
|
||||
unless tele.nil?
|
||||
player.start_action(TeleportingAction.new(player, tele))
|
||||
ctx.break_handler_chain
|
||||
return
|
||||
end
|
||||
|
||||
conv = CONVERT_SPELLS[button]
|
||||
if conv != nil
|
||||
unless conv.nil?
|
||||
slots = bone_slots player
|
||||
if slots.length == 0 then player.send_message("You cant 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
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,7 @@ require 'java'
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
java_import 'org.apollo.game.model.def.ItemDefinition'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
PROSPECT_PULSES = 3
|
||||
ORE_SIZE = 1
|
||||
@@ -20,14 +21,8 @@ class MiningAction < DistancedAction
|
||||
end
|
||||
|
||||
def find_pickaxe
|
||||
PICKAXE_IDS.each do |id|
|
||||
weapon = mob.equipment.get(EquipmentConstants::WEAPON)
|
||||
if (weapon != nil && weapon.id == id)
|
||||
return PICKAXES[id]
|
||||
end
|
||||
|
||||
return PICKAXES[id] if mob.inventory.contains(id)
|
||||
end
|
||||
weapon = mob.equipment.get(EquipmentConstants::WEAPON)
|
||||
PICKAXE_IDS.each { |id| return PICKAXES[id] if (!weapon.nil? && weapon.id == id) || mob.inventory.contains(id) }
|
||||
|
||||
return nil
|
||||
end
|
||||
@@ -43,12 +38,12 @@ class MiningAction < DistancedAction
|
||||
|
||||
def executeAction
|
||||
skills = mob.skill_set
|
||||
level = skills.get_skill(MINING_SKILL_ID).current_level
|
||||
level = skills.get_skill(Skill::MINING).current_level
|
||||
pickaxe = find_pickaxe
|
||||
mob.turn_to(@position)
|
||||
|
||||
# verify the mob can mine with their pickaxe
|
||||
unless (pickaxe != nil and level >= pickaxe.level)
|
||||
unless (!pickaxe.nil? and level >= pickaxe.level)
|
||||
mob.send_message('You do not have a pickaxe for which you have the level to use.')
|
||||
stop
|
||||
return
|
||||
@@ -74,7 +69,7 @@ class MiningAction < DistancedAction
|
||||
name = ore_def.name.sub(/ ore$/, '').downcase
|
||||
|
||||
mob.send_message("You manage to mine some #{name}.", true)
|
||||
skills.add_experience(MINING_SKILL_ID, ore.exp)
|
||||
skills.add_experience(Skill::MINING, ore.exp)
|
||||
# TODO: expire the rock
|
||||
end
|
||||
|
||||
@@ -136,20 +131,23 @@ class ProspectingAction < DistancedAction
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @position == other.position and @ore == other.ore)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
on :message, :first_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
|
||||
unless ore.nil?
|
||||
mob.start_action(MiningAction.new(mob, message.position, ore))
|
||||
end
|
||||
end
|
||||
|
||||
on :message, :second_object_action do |ctx, mob, message|
|
||||
ore = ORES[message.id]
|
||||
if ore != nil
|
||||
|
||||
if !ore.nil?
|
||||
mob.start_action(ProspectingAction.new(mob, message.position, ore))
|
||||
elsif EXPIRED_ORES[message.id] != nil
|
||||
elsif !EXPIRED_ORES[message.id].nil?
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, message.position))
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,7 @@ require 'java'
|
||||
|
||||
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
|
||||
BONES = {}
|
||||
@@ -38,7 +39,7 @@ class BuryBoneAction < Action
|
||||
mob.play_animation(Animation.new(BURY_BONE_ANIMATION))
|
||||
mob.send_message('You bury the bones.')
|
||||
mob.inventory.reset(@slot)
|
||||
mob.skill_set.add_experience(PRAYER_SKILL_ID, @bone.experience)
|
||||
mob.skill_set.add_experience(Skill::PRAYER, @bone.experience)
|
||||
end
|
||||
stop
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user