Fix bugs in the mining plugin.

This commit is contained in:
Major-
2014-08-09 06:44:45 +01:00
parent 44ee0ddd5d
commit e08a737933
+5 -8
View File
@@ -22,13 +22,11 @@ class MiningAction < DistancedAction
def find_pickaxe def find_pickaxe
PICKAXE_IDS.each do |id| PICKAXE_IDS.each do |id|
weapon = mob.equipment.get(EquipmentConstants::WEAPON) weapon = mob.equipment.get(EquipmentConstants::WEAPON)
if weapon != nil && weapon.id == id if (weapon != nil && weapon.id == id)
return PICKAXES[id] return PICKAXES[id]
end end
if mob.inventory.contains(id) return PICKAXES[id] if mob.inventory.contains(id)
return PICKAXES[id]
end
end end
return nil return nil
@@ -39,7 +37,6 @@ class MiningAction < DistancedAction
def start_mine(pickaxe) def start_mine(pickaxe)
@started = true @started = true
mob.send_message('You swing your pick at the rock.', true) mob.send_message('You swing your pick at the rock.', true)
mob.turn_to(@position)
mob.play_animation(pickaxe.animation) mob.play_animation(pickaxe.animation)
@counter = pickaxe.pulses @counter = pickaxe.pulses
end end
@@ -48,6 +45,7 @@ class MiningAction < DistancedAction
skills = mob.skill_set skills = mob.skill_set
level = skills.get_skill(MINING_SKILL_ID).current_level level = skills.get_skill(MINING_SKILL_ID).current_level
pickaxe = find_pickaxe pickaxe = find_pickaxe
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)
@@ -75,7 +73,7 @@ class MiningAction < DistancedAction
ore_def = ItemDefinition.lookup(@ore.id) # TODO: split off into some method ore_def = ItemDefinition.lookup(@ore.id) # TODO: split off into some method
name = ore_def.name.sub(/ ore$/, '').downcase name = ore_def.name.sub(/ ore$/, '').downcase
mob.send_message("You manage to mine some #{name}.") mob.send_message("You manage to mine some #{name}.", true)
skills.add_experience(MINING_SKILL_ID, ore.exp) skills.add_experience(MINING_SKILL_ID, ore.exp)
# TODO: expire the rock # TODO: expire the rock
end end
@@ -121,7 +119,7 @@ class ProspectingAction < DistancedAction
end end
def executeAction def executeAction
if not @started unless @started
@started = true @started = true
mob.send_message('You examine the rock for ores...') mob.send_message('You examine the rock for ores...')
@@ -131,7 +129,6 @@ class ProspectingAction < DistancedAction
name = ore_def.name.sub(/ ore$/, '').downcase name = ore_def.name.sub(/ ore$/, '').downcase
mob.send_message("This rock contains #{name}.") mob.send_message("This rock contains #{name}.")
stop stop
end end
end end