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