mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Use constants instead of the java Skill class.
This commit is contained in:
@@ -6,7 +6,6 @@ require 'java'
|
||||
java_import 'org.apollo.game.event.impl.SetWidgetItemModelEvent'
|
||||
java_import 'org.apollo.game.model.Skill'
|
||||
|
||||
HERBLORE_ID = Skill::HERBLORE
|
||||
HERBLORE_DIALOGUE = 4429
|
||||
|
||||
HERBLORE_ITEM = {}
|
||||
@@ -88,7 +87,7 @@ 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_ID).current_level
|
||||
if required > player.skill_set.skill(HERBLORE_SKILL_ID).current_level
|
||||
player.send_message("You need a Herblore level of at least #{required} to #{action}.")
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class MiningAction < DistancedAction
|
||||
attr_reader :position, :ore, :counter, :started
|
||||
|
||||
def initialize(mob, position, ore)
|
||||
super 0, true, mob, position, ORE_SIZE
|
||||
super(0, true, mob, position, ORE_SIZE)
|
||||
@position = position
|
||||
@ore = ore
|
||||
@started = false
|
||||
@@ -21,12 +21,12 @@ class MiningAction < DistancedAction
|
||||
|
||||
def find_pickaxe
|
||||
PICKAXE_IDS.each do |id|
|
||||
weapon = mob.equipment.get EquipmentConstants::WEAPON
|
||||
weapon = mob.equipment.get(EquipmentConstants::WEAPON)
|
||||
if weapon.id == id
|
||||
return PICKAXES[id]
|
||||
end
|
||||
|
||||
if mob.inventory.contains id
|
||||
if mob.inventory.contains(id)
|
||||
return PICKAXES[id]
|
||||
end
|
||||
end
|
||||
@@ -38,19 +38,19 @@ class MiningAction < DistancedAction
|
||||
# the ore
|
||||
def start_mine(pickaxe)
|
||||
@started = true
|
||||
mob.send_message("You swing your pick at the rock.", true)
|
||||
mob.turn_to @position
|
||||
mob.play_animation pickaxe.animation
|
||||
mob.send_message('You swing your pick at the rock.', true)
|
||||
mob.turn_to(@position)
|
||||
mob.play_animation(pickaxe.animation)
|
||||
@counter = pickaxe.pulses
|
||||
end
|
||||
|
||||
def executeAction
|
||||
skills = mob.skill_set
|
||||
level = skills.get_skill(Skill::MINING).current_level
|
||||
level = skills.get_skill(MINING_SKILL_ID).current_level
|
||||
pickaxe = find_pickaxe
|
||||
|
||||
# verify the mob can mine with their pickaxe
|
||||
if not (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
|
||||
@@ -64,19 +64,19 @@ class MiningAction < DistancedAction
|
||||
end
|
||||
|
||||
# check if we need to kick start things
|
||||
if not @started
|
||||
unless @started
|
||||
start_mine(pickaxe)
|
||||
else
|
||||
# count down and check if we can have a chance at some ore now
|
||||
if @counter == 0
|
||||
# TODO: calculate the chance that the mob can actually get the rock
|
||||
|
||||
if mob.inventory.add ore.id
|
||||
ore_def = ItemDefinition.lookup @ore.id # TODO: split off into some method
|
||||
if mob.inventory.add(ore.id)
|
||||
ore_def = ItemDefinition.lookup(@ore.id) # TODO: split off into some method
|
||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||
|
||||
mob.send_message "You manage to mine some #{name}."
|
||||
skills.add_experience Skill::MINING, ore.exp
|
||||
mob.send_message("You manage to mine some #{name}.")
|
||||
skills.add_experience(MINING_SKILL_ID, ore.exp)
|
||||
# TODO: expire the rock
|
||||
end
|
||||
|
||||
@@ -96,11 +96,11 @@ class ExpiredProspectingAction < DistancedAction
|
||||
attr_reader :position
|
||||
|
||||
def initialize(mob, position)
|
||||
super 0, true, mob, position, ORE_SIZE
|
||||
super(0, true, mob, position, ORE_SIZE)
|
||||
end
|
||||
|
||||
def executeAction
|
||||
mob.send_message "There is currently no ore available in this rock."
|
||||
mob.send_message('There is currently no ore available in this rock.')
|
||||
stop
|
||||
end
|
||||
|
||||
@@ -114,7 +114,7 @@ class ProspectingAction < DistancedAction
|
||||
attr_reader :position, :ore
|
||||
|
||||
def initialize(mob, position, ore)
|
||||
super PROSPECT_PULSES, true, mob, position, ORE_SIZE
|
||||
super(PROSPECT_PULSES, true, mob, position, ORE_SIZE)
|
||||
@position = position
|
||||
@ore = ore
|
||||
@started = false
|
||||
@@ -124,13 +124,13 @@ class ProspectingAction < DistancedAction
|
||||
if not @started
|
||||
@started = true
|
||||
|
||||
mob.send_message "You examine the rock for ores..."
|
||||
mob.turn_to @position
|
||||
mob.send_message("You examine the rock for ores...")
|
||||
mob.turn_to(@position)
|
||||
else
|
||||
ore_def = ItemDefinition.lookup @ore.id
|
||||
ore_def = ItemDefinition.lookup(@ore.id)
|
||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||
|
||||
mob.send_message "This rock contains #{name}."
|
||||
mob.send_message("This rock contains #{name}.")
|
||||
|
||||
stop
|
||||
end
|
||||
@@ -145,7 +145,7 @@ on :event, :object_action do |ctx, mob, event|
|
||||
if event.option == 1
|
||||
ore = ORES[event.id]
|
||||
if ore != nil
|
||||
mob.startAction MiningAction.new(mob, event.position, ore)
|
||||
mob.start_action(MiningAction.new(mob, event.position, ore))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -154,9 +154,9 @@ on :event, :object_action do |ctx, mob, event|
|
||||
if event.option == 2
|
||||
ore = ORES[event.id]
|
||||
if ore != nil
|
||||
mob.startAction ProspectingAction.new(mob, event.position, ore)
|
||||
mob.start_action(ProspectingAction.new(mob, event.position, ore))
|
||||
elsif EXPIRED_ORES[event.id] != nil
|
||||
mob.startAction ExpiredProspectingAction.new(mob, event.position)
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, event.position))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user