From 82f28b070ec268b8e19f574422e97bb56bdbeb55 Mon Sep 17 00:00:00 2001 From: CharlesVaneenoo Date: Fri, 4 Mar 2016 20:16:49 +0100 Subject: [PATCH] creation of drink.rb fix bad name --- data/plugins/consumables/consumable.rb | 1 + data/plugins/consumables/drink.rb | 76 ++++++++++++++++++++++++++ data/plugins/consumables/food.rb | 26 --------- 3 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 data/plugins/consumables/drink.rb diff --git a/data/plugins/consumables/consumable.rb b/data/plugins/consumables/consumable.rb index d46f19ff..dacfa5e0 100644 --- a/data/plugins/consumables/consumable.rb +++ b/data/plugins/consumables/consumable.rb @@ -10,6 +10,7 @@ CONSUME_ANIMATION_ID = 829 module ConsumableType FOOD = 1 POTION = 2 + DRINK = 3 end # An item that can be consumed to produce a skill effect. diff --git a/data/plugins/consumables/drink.rb b/data/plugins/consumables/drink.rb new file mode 100644 index 00000000..4f0d5fe2 --- /dev/null +++ b/data/plugins/consumables/drink.rb @@ -0,0 +1,76 @@ +require 'java' + +java_import 'org.apollo.game.model.Animation' +java_import 'org.apollo.game.model.entity.Skill' +java_import 'org.apollo.game.model.entity.Player' + +private + +# The id the of the sound made when drinking something. +#TODO change sound if this id is incorrect +DRINK_SOUND = 334 + +# Represents something drinkable, such as a jug of wine or a nettle tea. +class Drink < Consumable + + def initialize(name, id, restoration, replace, delay) + super(name, id, DRINK_SOUND, delay, ConsumableType::DRINK) + @restoration = restoration + @replace = replace + end + + # Restore the appropriate amount of hitpoints when consumed. + def consume(player) + hitpoints = player.skill_set.skill(Skill::HITPOINTS) + hitpoints_current = player.skill_set.get_current_level(Skill::HITPOINTS) + new_curr = [hitpoints.current_level + @restoration, hitpoints.maximum_level].min + + player.inventory.add(@replace) unless @replace == -1 + + player.send_message("You drink the #{name}.") + player.send_message('It heals some health.') if new_curr > hitpoints_current + + skill = Skill.new(hitpoints.experience, new_curr, hitpoints.maximum_level) + player.skill_set.set_skill(Skill::HITPOINTS, skill) + end + +end + +# The default delay before the consumable is drunk. +DEFAULT_DELAY = 3 + +# Appends a drink item to the list of consumables. +def drink(hash) + unless hash.has_keys?(:name, :id, :restoration) + fail 'Hash must contain a name, id, and a restoration value.' + end + + name, id, restoration = hash[:name], hash[:id], hash[:restoration]; + replace = hash[:replace] || -1 + delay = hash[:delay] || DEFAULT_DELAY # TODO: ?? + + append_consumable(Drink.new(name, id, restoration, replace, delay)) +end + +# Wine +drink name: :jug_of_wine, id: 1993, restoration: 11 + +# Hot Drinks +drink name: :nettle_tea, id: 4239, restoration: 3 +drink name: :nettle_tea, id: 4240, restoration: 3 + +# Gnome Cocktails +drink name: :fruit_blast, id: 2034, restoration: 9 +drink name: :fruit_blast, id: 2084, restoration: 9 +drink name: :pineapple_punch, id: 2036, restoration: 9 +drink name: :pineapple_punch, id: 2048, restoration: 9 +drink name: :wizard_blizzard, id: 2040, restoration: 5 # -4 attack, +5 strength also +drink name: :wizard_blizzard, id: 2054, restoration: 5 # -4 attack, +5 strength also +drink name: :short_green_guy, id: 2038, restoration: 5 # -4 attack, +5 strength also +drink name: :short_green_guy, id: 2080, restoration: 5 # -4 attack, +5 strength also +drink name: :drunk_dragon, id: 2032, restoration: 5 # -4 attack, +6 strength also +drink name: :drunk_dragon, id: 2092, restoration: 5 # -4 attack, +6 strength also +drink name: :chocolate_saturday, id: 2030, restoration: 7 # -4 attack, +6 strength also +drink name: :chocolate_saturday, id: 2074, restoration: 7 # -4 attack, +6 strength also +drink name: :blurberry_special, id: 2028, restoration: 7 # -4 attack, +6 strength also +drink name: :blurberry_special, id: 2064, restoration: 7 # -4 attack, +6 strength also diff --git a/data/plugins/consumables/food.rb b/data/plugins/consumables/food.rb index a190c361..a128c428 100644 --- a/data/plugins/consumables/food.rb +++ b/data/plugins/consumables/food.rb @@ -168,15 +168,6 @@ food name: :chocolate_cake, id: 1897, restoration: 5, replace: 1899 food name: :chocolate_cake, id: 1899, restoration: 5, replace: 1901 food name: :chocolate_cake, id: 1901, restoration: 5 -# Wine -# TODO: Add to drinks.rb? -food name: :jug_of_wine, id: 1993, restoration: 11 - -# Hot Drinks -# TODO: Add to drinks.rb? -food name: :nettle_tea, id: 4239, restoration: 3 -food name: :nettle_tea, id: 4240, restoration: 3 - # Vegetables food name: :potato, id: 1942, restoration: 1 food name: :spinach_roll, id: 1969, restoration: 2 @@ -228,20 +219,3 @@ food name: :vegetable_batta, id: 2227, restoration: 11 food name: :vegetable_batta, id: 2281, restoration: 11 food name: :cheese_tom_batta, id: 2223, restoration: 11 food name: :cheese_tom_batta, id: 2259, restoration: 11 - -# Gnome Cocktails -# TODO: seperate from food, should say 'You drink' instead of 'You eat'. -food name: :fruit_blast, id: 2034, restoration: 9 -food name: :fruit_blast, id: 2084, restoration: 9 -food name: :pineapple_punch, id: 2036, restoration: 9 -food name: :pineapple_punch, id: 2048, restoration: 9 -food name: :wizard_blizzard, id: 2040, restoration: 5 # -4 attack, +5 strength also -food name: :wizard_blizzard, id: 2054, restoration: 5 # -4 attack, +5 strength also -food name: :short_green_guy, id: 2038, restoration: 5 # -4 attack, +5 strength also -food name: :short_green_guy, id: 2080, restoration: 5 # -4 attack, +5 strength also -food name: :drunk_dragon, id: 2032, restoration: 5 # -4 attack, +6 strength also -food name: :drunk_dragon, id: 2092, restoration: 5 # -4 attack, +6 strength also -food name: :chocolate_saturday, id: 2030, restoration: 7 # -4 attack, +6 strength also -food name: :chocolate_saturday, id: 2074, restoration: 7 # -4 attack, +6 strength also -food name: :blurberry_special, id: 2028, restoration: 7 # -4 attack, +6 strength also -food name: :blurberry_special, id: 2064, restoration: 7 # -4 attack, +6 strength also