mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 08:40:08 +00:00
Update existing plugins to use the new utils plugin.
This commit is contained in:
@@ -29,7 +29,7 @@ end
|
||||
|
||||
# Appends a food item to the list of consumables.
|
||||
def append_food(hash)
|
||||
raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_key?(:name) && hash.has_key?(:id) && hash.has_key?(:restoration))
|
||||
raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_keys?(:name, :id, :restoration))
|
||||
name = hash[:name]; id = hash[:id]; restoration = hash[:restoration]
|
||||
|
||||
append_consumable(Food.new(name, id, restoration))
|
||||
|
||||
@@ -18,7 +18,7 @@ class Potion < Consumable
|
||||
unless index == @doses.length
|
||||
player.inventory.add(@doses[index])
|
||||
player.send_message("You drink some of your #{name} potion.", true)
|
||||
player.send_message("You have #{@doses.length - index} dose#{"s" unless index == 3} of potion left.", true)
|
||||
player.send_message("You have #{ @doses.length - index } dose#{ "s" unless index == 3 } of potion left.", true)
|
||||
else
|
||||
player.send_message('You drink the last of your potion.')
|
||||
player.inventory.add(EMPTY_VIAL_ID)
|
||||
@@ -56,12 +56,11 @@ end
|
||||
|
||||
# Returns the parameters for the potion, as an array. Raises if any of the specified keys do not exist
|
||||
def get_parameters(hash, keys)
|
||||
parameters = []
|
||||
keys.each do |key|
|
||||
raise "Hash must contain key #{key}." unless hash.has_key?(key)
|
||||
parameters << hash[key]
|
||||
end
|
||||
raise "Hash must contain the following keys: #{ keys.join(", ") }." unless hash.has_keys?(*keys)
|
||||
|
||||
parameters = []
|
||||
keys.each { |key| parameters << hash[key] }
|
||||
|
||||
return parameters
|
||||
end
|
||||
|
||||
@@ -71,7 +70,7 @@ def append_potion(hash)
|
||||
|
||||
unless (hash.size == 2)
|
||||
keys << :skills << :boost
|
||||
class_name.insert(0, 'Boosting')
|
||||
class_name.prepend('Boosting')
|
||||
end
|
||||
|
||||
parameters = get_parameters(hash, keys)
|
||||
@@ -84,9 +83,9 @@ end
|
||||
|
||||
# Some frequently-used boosts and skills
|
||||
# Lambda parameters are | maximum_skill_level, current_skill_level |
|
||||
basic_combat_boost = lambda { |m, l| l * 1.08 + 1 }
|
||||
super_combat_boost = lambda { |m, l| l * 1.12 + 2 }
|
||||
non_combat_boost = lambda { |m, l| l + 3 }
|
||||
basic_combat_boost = lambda { |max, level| level * 1.08 + 1 }
|
||||
super_combat_boost = lambda { |max, level| level * 1.12 + 2 }
|
||||
non_combat_boost = lambda { |max, level| level + 3 }
|
||||
|
||||
all_skills = (ATTACK_SKILL_ID..RUNECRAFT_SKILL_ID).to_a
|
||||
combat_skills = [ ATTACK_SKILL_ID, STRENGTH_SKILL_ID, DEFENCE_SKILL_ID, MAGIC_SKILL_ID, RANGED_SKILL_ID ]
|
||||
@@ -98,13 +97,12 @@ append_potion :name => :attack, :doses => [ 2428, 121, 123, 125 ], :skills
|
||||
append_potion :name => :strength, :doses => [ 113, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => basic_combat_boost
|
||||
append_potion :name => :defence, :doses => [ 2432, 133, 135, 137 ], :skills => DEFENCE_SKILL_ID, :boost => basic_combat_boost
|
||||
|
||||
append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost
|
||||
append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost
|
||||
append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => AGILITY_SKILL_ID, :boost => non_combat_boost
|
||||
append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => FISHING_SKILL_ID, :boost => non_combat_boost
|
||||
append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |max, level| level / 4 + 7 }
|
||||
|
||||
append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => PRAYER_SKILL_ID, :boost => lambda { |m, l| l / 4 + 7 }
|
||||
|
||||
append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |m, l| [ l * 1.3 + 10, m ].min }
|
||||
append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |m, l| [ l * 1.25 + 8, m ].min }
|
||||
append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |max, level| [ level * 1.3 + 10, max ].min }
|
||||
append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |max, level| [ level * 1.25 + 8, max ].min }
|
||||
|
||||
append_potion :name => :super_attack, :doses => [ 2436, 145, 147, 149 ], :skills => ATTACK_SKILL_ID, :boost => super_combat_boost
|
||||
append_potion :name => :super_strength, :doses => [ 2440, 115, 117, 119 ], :skills => STRENGTH_SKILL_ID, :boost => super_combat_boost
|
||||
|
||||
Reference in New Issue
Block a user