mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Fix bug where multiple (identical) bone burying actions would replace each other instead of cancelling.
This commit is contained in:
@@ -2,18 +2,17 @@ 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 = {}
|
||||||
|
|
||||||
# Represents a bone with an id and experience value.
|
# A bone with an id and experience value.
|
||||||
class Bone
|
class Bone
|
||||||
attr_reader :id, :exp
|
attr_reader :id, :experience
|
||||||
|
|
||||||
def initialize(id, exp)
|
def initialize(id, experience)
|
||||||
@id = id
|
@id = id
|
||||||
@exp = exp
|
@experience = experience
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -21,28 +20,36 @@ end
|
|||||||
|
|
||||||
# An action where a bone in a player's inventory is buried.
|
# An action where a bone in a player's inventory is buried.
|
||||||
class BuryBoneAction < Action
|
class BuryBoneAction < Action
|
||||||
|
attr_reader :slot, :bone
|
||||||
|
|
||||||
def initialize(mob, slot, bone)
|
def initialize(mob, slot, bone)
|
||||||
super(1, false, mob)
|
super(1, true, mob)
|
||||||
@slot = slot
|
@slot = slot
|
||||||
@bone = bone
|
@bone = bone
|
||||||
|
@executions = 0
|
||||||
mob.play_animation(Animation.new(BURY_BONE_ANIMATION))
|
|
||||||
mob.send_message('You dig a hole in the ground...')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
if mob.inventory.get(@slot).id == @bone.id
|
if @executions == 0
|
||||||
mob.send_message('You bury the bones.')
|
mob.send_message('You dig a hole in the ground...')
|
||||||
mob.inventory.reset(@slot)
|
@executions += 1
|
||||||
mob.skill_set.add_experience(Skill::PRAYER, @bone.exp)
|
elsif @executions == 1
|
||||||
|
if mob.inventory.get(@slot).id == @bone.id
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
stop
|
||||||
end
|
end
|
||||||
stop
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def equals(other)
|
||||||
|
return (get_class == other.get_class and @bone == other.bone)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Intercepts the first item option message,
|
# Intercepts the first item option message.
|
||||||
on :message, :first_item_option do |ctx, player, message|
|
on :message, :first_item_option do |ctx, player, message|
|
||||||
bone = BONES[message.id]
|
bone = BONES[message.id]
|
||||||
unless bone == nil
|
unless bone == nil
|
||||||
|
|||||||
Reference in New Issue
Block a user