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