Remove skill id constants from bootstrap, improve consumables code.

This commit is contained in:
Major-
2015-01-07 16:44:20 +00:00
parent ec516bda67
commit 5b9545fbee
3 changed files with 28 additions and 53 deletions
+6 -5
View File
@@ -7,12 +7,12 @@ CONSUME_ANIMATION_ID = 829
# An item that can be consumed to produce a skill effect.
class Consumable
attr_reader :name, :id
attr_reader :name, :id, :sound
def initialize(name, id, sound_id)
def initialize(name, id, sound)
@name = name.to_s.gsub(/_/, ' ')
@id = id
@sound_id = sound_id
@sound = sound
end
def consume(player)
@@ -39,7 +39,7 @@ class ConsumeAction < Action
def execute()
if @executions == 0
mob.inventory.reset(@slot)
consumable.consume(mob)
@consumable.consume(mob)
mob.play_animation(Animation.new(CONSUME_ANIMATION_ID))
@executions += 1
else
@@ -56,7 +56,8 @@ end
# Intercepts the first item option message and consumes the consumable, if necessary.
on :message, :first_item_option do |ctx, player, message|
consumable = CONSUMABLES[message.id]
unless consumable == nil
unless consumable.nil?
player.start_action(ConsumeAction.new(player, message.slot, consumable))
ctx.break_handler_chain
end