mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Merge pull request #149 from thispixel/master
fixes issue #148 - add consumable delays
This commit is contained in:
@@ -8,12 +8,13 @@ CONSUME_ANIMATION_ID = 829
|
||||
|
||||
# An item that can be consumed to produce a skill effect.
|
||||
class Consumable
|
||||
attr_reader :name, :id, :sound
|
||||
attr_reader :name, :id, :sound, :delay
|
||||
|
||||
def initialize(name, id, sound)
|
||||
def initialize(name, id, sound, delay)
|
||||
@name = name.to_s.gsub(/_/, ' ')
|
||||
@id = id
|
||||
@sound = sound
|
||||
@delay = delay
|
||||
end
|
||||
|
||||
def consume(_player)
|
||||
@@ -44,8 +45,11 @@ class ConsumeAction < Action
|
||||
@consumable.consume(mob)
|
||||
|
||||
mob.play_animation(Animation.new(CONSUME_ANIMATION_ID))
|
||||
@executions += 1
|
||||
else
|
||||
end
|
||||
|
||||
@executions += 1
|
||||
|
||||
if @executions >= @consumable.delay
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,8 +13,8 @@ EAT_FOOD_SOUND = 317
|
||||
# TODO: delay eating times
|
||||
class Food < Consumable
|
||||
|
||||
def initialize(name, id, restoration, replace)
|
||||
super(name, id, EAT_FOOD_SOUND)
|
||||
def initialize(name, id, restoration, replace, delay)
|
||||
super(name, id, EAT_FOOD_SOUND, delay)
|
||||
@restoration = restoration
|
||||
@replace = replace
|
||||
end
|
||||
@@ -48,7 +48,7 @@ def food(hash)
|
||||
replace = hash[:replace] || -1
|
||||
delay = hash[:delay] || DEFAULT_DELAY # TODO: ??
|
||||
|
||||
append_consumable(Food.new(name, id, restoration, replace))
|
||||
append_consumable(Food.new(name, id, restoration, replace, delay))
|
||||
end
|
||||
|
||||
# TODO: special effects
|
||||
@@ -88,7 +88,7 @@ food name: :bass, id: 365, restoration: 13
|
||||
food name: :swordfish, id: 373, restoration: 14
|
||||
food name: :cooked_jubbly, id: 7568, restoration: 15
|
||||
food name: :monkfish, id: 7946, restoration: 16
|
||||
food name: :cooked_karambwan, id: 3144, restoration: 18
|
||||
food name: :cooked_karambwan, id: 3144, restoration: 18, delay: 0
|
||||
food name: :shark, id: 385, restoration: 20
|
||||
food name: :sea_turtle, id: 397, restoration: 21
|
||||
food name: :manta_ray, id: 391, restoration: 22
|
||||
|
||||
@@ -13,13 +13,15 @@ module Constants
|
||||
# The id of an empty vial.
|
||||
EMPTY_VIAL_ID = 229
|
||||
|
||||
# The delay between drinking potions
|
||||
POTION_DELAY = 2
|
||||
end
|
||||
|
||||
# A drinkable potion.
|
||||
class Potion < Consumable
|
||||
|
||||
def initialize(id, name, doses)
|
||||
super(name, id, Constants::DRINK_POTION_SOUND)
|
||||
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY)
|
||||
@doses = doses
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user