mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 00:38:11 +00:00
Update all plugins to conform to Rubocop.
This commit is contained in:
@@ -2,57 +2,50 @@ require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
ALCHEMY_SPELLS = {}
|
||||
|
||||
LOW_ALCH_ANIM = Animation.new(712)
|
||||
LOW_ALCH_GRAPHIC = Graphic.new(112, 0, 100)
|
||||
LOW_ALCH_MULTIPLIER = 0.4
|
||||
|
||||
HIGH_ALCH_ANIM = Animation.new(713)
|
||||
HIGH_ALCH_GRAPHIC = Graphic.new(113, 0, 100)
|
||||
HIGH_ALCH_MULTIPLIER = 0.6
|
||||
|
||||
ILLEGAL_ALCH_ITEMS = [ 995, 6529, 6306, 6307, 6308, 6309, 6310 ]
|
||||
ILLEGAL_ALCH_ITEMS = [995, 6529, 6306, 6307, 6308, 6309, 6310]
|
||||
|
||||
# A spell that alchemises an item.
|
||||
class AlchemySpell < Spell
|
||||
attr_reader :high, :animation, :graphic, :multiplier, :experience, :delay
|
||||
|
||||
def initialize(level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
super(level, elements, experience)
|
||||
@high = high
|
||||
attr_reader :animation, :graphic, :multiplier, :experience
|
||||
|
||||
def initialize(level, elements, experience, animation, graphic, multiplier)
|
||||
super(level, elements, experience)
|
||||
@animation = animation
|
||||
@graphic = graphic
|
||||
@multiplier = multiplier
|
||||
@delay = delay
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# An Action that performs an AlchemySpell.
|
||||
class AlchemyAction < ItemSpellAction
|
||||
|
||||
|
||||
def initialize(player, alchemy, slot, item)
|
||||
super(player, alchemy, slot, item)
|
||||
end
|
||||
|
||||
|
||||
def illegal_item?
|
||||
return ILLEGAL_ALCH_ITEMS.include?(@item.id)
|
||||
ILLEGAL_ALCH_ITEMS.include?(@item.id)
|
||||
end
|
||||
|
||||
def execute_action
|
||||
|
||||
def executeAction
|
||||
if @pulses == 0
|
||||
mob.play_animation(@spell.animation)
|
||||
mob.play_graphic(@spell.graphic)
|
||||
mob.send(DISPLAY_SPELLBOOK)
|
||||
|
||||
|
||||
inventory = mob.inventory
|
||||
gold = (item.definition.value * @spell.multiplier) + 1
|
||||
|
||||
|
||||
inventory.remove(inventory.get(@slot).id, 1)
|
||||
inventory.add(995, gold)
|
||||
|
||||
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
|
||||
set_delay(@spell.delay)
|
||||
|
||||
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
|
||||
set_delay(ALCHEMY_DELAY)
|
||||
elsif @pulses == 1
|
||||
mob.stop_animation
|
||||
mob.stop_graphic
|
||||
@@ -62,9 +55,31 @@ class AlchemyAction < ItemSpellAction
|
||||
|
||||
end
|
||||
|
||||
def append_alchemy(button, level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
ALCHEMY_SPELLS[button] = AlchemySpell.new(level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
private
|
||||
|
||||
# The delay of an alchemy spell.
|
||||
ALCHEMY_DELAY = 4
|
||||
|
||||
# The height of the graphic.
|
||||
GRAPHIC_HEIGHT = 100
|
||||
|
||||
# Inserts an `AlchemySpell` into the hash of available alchemy spells.
|
||||
def alchemy(_name, hash)
|
||||
unless hash.has_keys?(:button, :level, :runes, :animation, :graphic, :multiplier, :experience)
|
||||
fail 'Hash must have button, level, runes, animation, graphic, multiplier, experience keys.'
|
||||
end
|
||||
|
||||
id, multiplier = hash[:button], hash[:multiplier]
|
||||
level, runes, experience = hash[:level], hash[:runes], hash[:experience]
|
||||
|
||||
animation = Animation.new(hash[:animation])
|
||||
graphic = Graphic.new(hash[:graphic], 0, GRAPHIC_HEIGHT)
|
||||
|
||||
ALCHEMY_SPELLS[id] = AlchemySpell.new(level, runes, experience, animation, graphic, multiplier)
|
||||
end
|
||||
|
||||
append_alchemy(1162, 21, { FIRE => 3, NATURE => 1 }, false, LOW_ALCH_ANIM, LOW_ALCH_GRAPHIC, 0.48, 31, 1) # Low level alchemy
|
||||
append_alchemy(1178, 55, { FIRE => 5, NATURE => 1 }, true, HIGH_ALCH_ANIM, HIGH_ALCH_GRAPHIC, 0.72, 65, 4) # High level alchemy
|
||||
alchemy :low_level, button: 1_162, level: 21, runes: { FIRE => 3, NATURE => 1 }, animation: 712,
|
||||
graphic: 112, multiplier: 0.48, experience: 31
|
||||
|
||||
alchemy :high_level, button: 1_178, level: 55, runes: { FIRE => 5, NATURE => 1 }, animation: 713,
|
||||
graphic: 113, multiplier: 0.72, experience: 65
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'java'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.Item'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
CONVERT_SPELLS = {}
|
||||
BONES_ID = 526
|
||||
@@ -10,21 +11,23 @@ BONES_ID = 526
|
||||
CONVERT_ANIM = Animation.new(722)
|
||||
CONVERT_GRAPHIC = Graphic.new(141, 0, 100)
|
||||
|
||||
# A `Spell` for converting items.
|
||||
class ConvertSpell < Spell
|
||||
attr_reader :reward
|
||||
|
||||
|
||||
def initialize(level, elements, experience, reward)
|
||||
super(level, elements, experience)
|
||||
super(level, elements, experience)
|
||||
@reward = Item.new(reward)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A `SpellAction` for a `ConvertSpell`.
|
||||
class ConvertingAction < SpellAction
|
||||
attr_reader :slots
|
||||
|
||||
def initialize(player, spell, slots)
|
||||
super(player, spell)
|
||||
super(player, spell)
|
||||
@slots = slots
|
||||
end
|
||||
|
||||
@@ -32,27 +35,25 @@ class ConvertingAction < SpellAction
|
||||
if @pulses == 0
|
||||
mob.play_animation(CONVERT_ANIM)
|
||||
mob.play_graphic(CONVERT_GRAPHIC)
|
||||
|
||||
|
||||
inventory = mob.inventory
|
||||
firing = (@slots.length * 2) < inventory.capacity
|
||||
|
||||
inventory.stop_firing_events unless firing # In the case of many changes, wait with firing events
|
||||
|
||||
|
||||
inventory.stop_firing_events unless firing # In case of many changes, wait with firing events
|
||||
|
||||
reward = @spell.reward
|
||||
@slots.each do |slot|
|
||||
inventory.set(slot, reward) # Share the instance
|
||||
end
|
||||
|
||||
@slots.each { |slot| inventory.set(slot, reward) }
|
||||
|
||||
unless firing # If we waited with firing events, restore it now and force a refresh
|
||||
inventory.start_firing_events
|
||||
inventory.force_refresh
|
||||
end
|
||||
|
||||
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
|
||||
|
||||
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
|
||||
set_delay(2)
|
||||
elsif @pulses == 1
|
||||
mob.stop_animation
|
||||
mob.stop_graphic
|
||||
mob.stop_graphic
|
||||
stop
|
||||
end
|
||||
end
|
||||
@@ -63,24 +64,25 @@ def bone_slots(player)
|
||||
inventory = player.inventory
|
||||
items = inventory.items
|
||||
size = inventory.size
|
||||
|
||||
|
||||
counter = 0
|
||||
slots = []
|
||||
|
||||
(0...inventory.capacity).each do |slot|
|
||||
break unless counter <= size
|
||||
|
||||
|
||||
item = items[slot]
|
||||
slots << slot if (item != nil and item.id == BONES_ID)
|
||||
|
||||
slots << slot if !item.nil? && item.id == BONES_ID
|
||||
|
||||
counter += 1
|
||||
end
|
||||
|
||||
return slots
|
||||
slots
|
||||
end
|
||||
|
||||
def append_convert(button, level, elements, experience, reward)
|
||||
def convert(button, level, elements, experience, reward)
|
||||
CONVERT_SPELLS[button] = ConvertSpell.new(level, elements, experience, reward)
|
||||
end
|
||||
|
||||
append_convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
|
||||
#append_convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
|
||||
convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
|
||||
# convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
|
||||
|
||||
@@ -29,36 +29,35 @@ MUD_RUNE = 4698
|
||||
STEAM_RUNE = 4694
|
||||
LAVA_RUNE = 4699
|
||||
|
||||
# An element of a spell.
|
||||
class Element
|
||||
attr_reader :runes, :staffs, :name
|
||||
|
||||
def initialize(runes, staffs, name="Null")
|
||||
|
||||
def initialize(runes, staffs, name = 'Null')
|
||||
@runes = runes
|
||||
@staffs = staffs
|
||||
@name = name
|
||||
end
|
||||
|
||||
|
||||
def check_remove(player, amount, remove)
|
||||
weapon = player.equipment.get(EquipmentConstants::WEAPON)
|
||||
if @staffs != nil && weapon != nil
|
||||
@staffs.each do |staff|
|
||||
return true if weapon.id == staff
|
||||
end
|
||||
unless @staffs.nil? || weapon.nil?
|
||||
@staffs.each { |staff| return true if weapon.id == staff }
|
||||
end
|
||||
|
||||
|
||||
inventory = player.inventory
|
||||
|
||||
found = {}
|
||||
counter = 0
|
||||
|
||||
|
||||
inventory.items.each do |item|
|
||||
break unless counter < amount
|
||||
next if item == nil
|
||||
|
||||
next if item.nil?
|
||||
|
||||
amt = item.amount
|
||||
@runes.each do |rune|
|
||||
break unless counter < amount
|
||||
|
||||
|
||||
id = item.id
|
||||
if id == rune
|
||||
if amt >= amount
|
||||
@@ -71,42 +70,38 @@ class Element
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if counter >= amount
|
||||
if remove
|
||||
found.each do |id, amt|
|
||||
inventory.remove(id, amt)
|
||||
end
|
||||
end
|
||||
found.each { |id, amt| inventory.remove(id, amt) } if remove
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
AIR_RUNES = [ 556, 4695, 4696, 4697 ]
|
||||
WATER_RUNES = [ 555, 4695, 4698, 4694 ]
|
||||
EARTH_RUNES = [ 557, 4696, 4697, 4698 ]
|
||||
FIRE_RUNES = [ 554, 4697, 4694, 4699 ]
|
||||
AIR_RUNES = [556, 4695, 4696, 4697]
|
||||
WATER_RUNES = [555, 4695, 4698, 4694]
|
||||
EARTH_RUNES = [557, 4696, 4697, 4698]
|
||||
FIRE_RUNES = [554, 4697, 4694, 4699]
|
||||
|
||||
AIR_STAFFS = [ 1381, 1397, 1405 ]
|
||||
WATER_STAFFS = [ 1383, 1395, 1403 ]
|
||||
EARTH_STAFFS = [ 1385, 1399, 1407, 3053, 3054 ]
|
||||
FIRE_STAFFS = [ 1387, 1393, 1401, 3053, 3054 ]
|
||||
AIR_STAFFS = [1381, 1397, 1405]
|
||||
WATER_STAFFS = [1383, 1395, 1403]
|
||||
EARTH_STAFFS = [1385, 1399, 1407, 3053, 3054]
|
||||
FIRE_STAFFS = [1387, 1393, 1401, 3053, 3054]
|
||||
|
||||
AIR = Element.new(AIR_RUNES, AIR_STAFFS, "Air rune")
|
||||
WATER = Element.new(WATER_RUNES, WATER_STAFFS, "Water rune")
|
||||
EARTH = Element.new(EARTH_RUNES, EARTH_STAFFS, "Earth rune")
|
||||
FIRE = Element.new(FIRE_RUNES, FIRE_STAFFS, "Fire rune")
|
||||
AIR = Element.new(AIR_RUNES, AIR_STAFFS, 'Air rune')
|
||||
WATER = Element.new(WATER_RUNES, WATER_STAFFS, 'Water rune')
|
||||
EARTH = Element.new(EARTH_RUNES, EARTH_STAFFS, 'Earth rune')
|
||||
FIRE = Element.new(FIRE_RUNES, FIRE_STAFFS, 'Fire rune')
|
||||
|
||||
MIND = Element.new([MIND_RUNE], nil, "Mind rune")
|
||||
CHAOS = Element.new([CHAOS_RUNE], nil, "Chaos rune")
|
||||
DEATH = Element.new([DEATH_RUNE], nil, "Death rune")
|
||||
BLOOD = Element.new([BLOOD_RUNE], nil, "Blood rune")
|
||||
MIND = Element.new([MIND_RUNE], nil, 'Mind rune')
|
||||
CHAOS = Element.new([CHAOS_RUNE], nil, 'Chaos rune')
|
||||
DEATH = Element.new([DEATH_RUNE], nil, 'Death rune')
|
||||
BLOOD = Element.new([BLOOD_RUNE], nil, 'Blood rune')
|
||||
|
||||
COSMIC = Element.new([COSMIC_RUNE], nil, "Cosmic rune")
|
||||
LAW = Element.new([LAW_RUNE], nil, "Law rune")
|
||||
NATURE = Element.new([NATURE_RUNE], nil, "Nature rune")
|
||||
SOUL = Element.new([SOUL_RUNE], nil, "Soul rune")
|
||||
COSMIC = Element.new([COSMIC_RUNE], nil, 'Cosmic rune')
|
||||
LAW = Element.new([LAW_RUNE], nil, 'Law rune')
|
||||
NATURE = Element.new([NATURE_RUNE], nil, 'Nature rune')
|
||||
SOUL = Element.new([SOUL_RUNE], nil, 'Soul rune')
|
||||
|
||||
@@ -8,7 +8,7 @@ ENCHANT_SPELLS = {}
|
||||
ENCHANT_ITEMS = {}
|
||||
|
||||
RING_GFX = Graphic.new(238, 0, 100)
|
||||
RING_ANIM = Animation.new(713) # TODO: No way we need one of the alchemy anims for enchanting...
|
||||
RING_ANIM = Animation.new(713) # TODO: an alchemy animation for enchanting?
|
||||
|
||||
LOW_NECK_GFX = Graphic.new(114, 0, 100)
|
||||
LOW_NECK_ANIM = Animation.new(719)
|
||||
@@ -21,11 +21,12 @@ HIGH_NECK_ANIM = Animation.new(721)
|
||||
|
||||
ONYX_NECK_GFX = Graphic.new(452, 0, 100)
|
||||
|
||||
# A `Spell` for enchanting an item.
|
||||
class EnchantSpell < Spell
|
||||
attr_reader :button, :animation, :graphic, :delay
|
||||
|
||||
|
||||
def initialize(button, level, elements, animation, graphic, delay, experience)
|
||||
super(level, elements, experience)
|
||||
super(level, elements, experience)
|
||||
@button = button
|
||||
@animation = animation
|
||||
@graphic = graphic
|
||||
@@ -34,38 +35,39 @@ class EnchantSpell < Spell
|
||||
|
||||
end
|
||||
|
||||
# A `SpellAction` for an `EnchantSpell`.
|
||||
class EnchantAction < ItemSpellAction
|
||||
attr_reader :reward
|
||||
|
||||
|
||||
def initialize(player, enchant, slot, item, reward)
|
||||
super(player, enchant, slot, item)
|
||||
super(player, enchant, slot, item)
|
||||
@reward = Item.new(reward)
|
||||
end
|
||||
|
||||
|
||||
def illegal_item?
|
||||
return ENCHANT_ITEMS[@item.id] == nil
|
||||
ENCHANT_ITEMS[@item.id].nil?
|
||||
end
|
||||
|
||||
def execute_action
|
||||
|
||||
def executeAction
|
||||
if @pulses == 0
|
||||
mob.play_animation(@spell.animation)
|
||||
mob.play_graphic(@spell.graphic)
|
||||
mob.send(DISPLAY_SPELLBOOK)
|
||||
|
||||
|
||||
mob.inventory.set(@slot, @reward)
|
||||
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
|
||||
|
||||
|
||||
set_delay(@spell.delay)
|
||||
elsif @pulses == 1
|
||||
mob.stop_animation
|
||||
mob.stop_graphic
|
||||
mob.stop_graphic
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def append_enchant(button, level, elements, item, animation, graphic, delay, experience, reward)
|
||||
def enchant(button, level, elements, item, animation, graphic, delay, experience, reward)
|
||||
enchant = EnchantSpell.new(button, level, elements, animation, graphic, delay, experience)
|
||||
ENCHANT_SPELLS[item] = enchant
|
||||
ENCHANT_ITEMS[item] = reward
|
||||
@@ -79,31 +81,27 @@ DSTONE_ELEMENTS = { WATER => 15, EARTH => 15, COSMIC => 1 }
|
||||
ONYX_ELEMENTS = { EARTH => 20, FIRE => 20, COSMIC => 1 }
|
||||
|
||||
# Sapphire
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1637, RING_ANIM, RING_GFX, 2, 17.5, 2550 # Ring
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1656, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 3853 # Necklace
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1692, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 1727 # Amulet
|
||||
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1637, RING_ANIM, RING_GFX, 2, 17.5, 2550 # Ring
|
||||
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1656, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 3853 # Necklace
|
||||
enchant 1155, 7, SAPPHIRE_ELEMENTS, 1692, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 1727 # Amulet
|
||||
|
||||
# Emerald
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1639, RING_ANIM, RING_GFX, 2, 37, 2552 # Ring
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1658, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 5521 # Necklace
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1696, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 1729 # Amulet
|
||||
enchant 1165, 27, EMERALD_ELEMENTS, 1639, RING_ANIM, RING_GFX, 2, 37, 2552 # Ring
|
||||
enchant 1165, 27, EMERALD_ELEMENTS, 1658, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 5521 # Necklace
|
||||
enchant 1165, 27, EMERALD_ELEMENTS, 1696, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 1729 # Amulet
|
||||
|
||||
# Ruby
|
||||
append_enchant 1176, 49, RUBY_ELEMENTS, 1641, RING_ANIM, RING_GFX, 2, 59, 2568 # Ring
|
||||
# append_enchant 1176, 49, RUBY_ELEMENTS, 1660, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, # Necklace - not found in 317 or 377
|
||||
append_enchant 1176, 49, RUBY_ELEMENTS, 1698, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, 1725 # Amulet
|
||||
enchant 1176, 49, RUBY_ELEMENTS, 1641, RING_ANIM, RING_GFX, 2, 59, 2568 # Ring
|
||||
enchant 1176, 49, RUBY_ELEMENTS, 1698, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, 1725 # Amulet
|
||||
|
||||
# Diamond
|
||||
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1643, RING_ANIM, RING_GFX, 2, 67, 2570 # Ring
|
||||
# append_enchant 1180, 57, DIAMOND_ELEMENTS, 1662, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, # Necklace - not found in 317 or 377
|
||||
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1700, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, 1731 # Amulet
|
||||
enchant 1180, 57, DIAMOND_ELEMENTS, 1643, RING_ANIM, RING_GFX, 2, 67, 2570 # Ring
|
||||
enchant 1180, 57, DIAMOND_ELEMENTS, 1700, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, 1731 # Amulet
|
||||
|
||||
# Dragonstone
|
||||
append_enchant 1187, 68, DSTONE_ELEMENTS, 1645, RING_ANIM, RING_GFX, 2, 78, 2572 # Ring
|
||||
# append_enchant 1187, 68, DSTONE_ELEMENTS, 1664, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, # Necklace - not found in 317 or 377
|
||||
append_enchant 1187, 68, DSTONE_ELEMENTS, 1702, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, 1712 # Amulet
|
||||
enchant 1187, 68, DSTONE_ELEMENTS, 1645, RING_ANIM, RING_GFX, 2, 78, 2572 # Ring
|
||||
enchant 1187, 68, DSTONE_ELEMENTS, 1702, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, 1712 # Amulet
|
||||
|
||||
# Onyx
|
||||
append_enchant 6003, 87, ONYX_ELEMENTS, 6575, RING_ANIM, RING_GFX, 2, 97, 6583 # Ring
|
||||
# append_enchant 6003, 87, ONYX_ELEMENTS, 6577, HIGH_NECK_ANIM, ONYX_NECK_GFX, 3, 97, # Necklace - not found in 317 or 377
|
||||
append_enchant 6003, 87, ONYX_ELEMENTS, 6581, HIGH_NECK_ANIM, ONYX_NECK_GFX, 2, 97, 6585 # Amulet
|
||||
enchant 6003, 87, ONYX_ELEMENTS, 6575, RING_ANIM, RING_GFX, 2, 97, 6583 # Ring
|
||||
enchant 6003, 87, ONYX_ELEMENTS, 6581, HIGH_NECK_ANIM, ONYX_NECK_GFX, 2, 97, 6585 # Amulet
|
||||
|
||||
@@ -5,11 +5,13 @@ java_import 'org.apollo.game.message.impl.DisplayTabInterfaceMessage'
|
||||
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
# A `Message` to display the magic spellbook.
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceMessage.new(6)
|
||||
|
||||
# A spell that can be cast.
|
||||
class Spell
|
||||
attr_reader :level, :elements, :experience
|
||||
|
||||
|
||||
def initialize(level, elements, experience)
|
||||
@level = level
|
||||
@elements = elements
|
||||
@@ -18,71 +20,72 @@ class Spell
|
||||
|
||||
end
|
||||
|
||||
# An `Action` for casting a `Spell`.
|
||||
class SpellAction < Action
|
||||
attr_reader :spell, :pulses
|
||||
|
||||
|
||||
def initialize(mob, spell)
|
||||
super(0, true, mob)
|
||||
|
||||
@spell = spell
|
||||
@pulses = 0
|
||||
end
|
||||
|
||||
|
||||
def execute
|
||||
if @pulses == 0
|
||||
unless (check_skill and process_elements)
|
||||
unless check_skill && process_elements
|
||||
stop
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
execute_action
|
||||
@pulses += 1
|
||||
end
|
||||
|
||||
|
||||
def execute_action
|
||||
stop
|
||||
end
|
||||
|
||||
|
||||
def check_skill
|
||||
required = @spell.level
|
||||
if required > mob.skill_set.skill(Skill::MAGIC).maximum_level
|
||||
mob.send_message("You need a Magic level of at least #{required} to cast this spell.")
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def process_elements
|
||||
elements = @spell.elements
|
||||
|
||||
|
||||
elements.each do |element, amount|
|
||||
unless element.check_remove(mob, amount, false)
|
||||
mob.send_message("You do not have enough #{element.name}s to cast this spell.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elements.each { |element, amount| element.check_remove(mob, amount, true) }
|
||||
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @spell == other.spell)
|
||||
get_class == other.get_class && @spell == other.spell
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A `SpellAction` that verifies an input `Item` is legal.
|
||||
class ItemSpellAction < SpellAction
|
||||
attr_reader :slot, :item
|
||||
|
||||
def initialize(mob, spell, slot, item)
|
||||
super(mob, spell)
|
||||
super(mob, spell)
|
||||
@slot = slot
|
||||
@item = item
|
||||
end
|
||||
|
||||
|
||||
# We override SpellAction#execute to implement an illegal item check (e.g. coins for alchemy)
|
||||
def execute
|
||||
if @pulses == 0
|
||||
@@ -91,9 +94,9 @@ class ItemSpellAction < SpellAction
|
||||
stop
|
||||
next
|
||||
end
|
||||
|
||||
|
||||
id = @item.id
|
||||
|
||||
|
||||
# TODO: There has to be a better way to do this.
|
||||
@spell.elements.each do |element, amount|
|
||||
element.runes.each do |rune|
|
||||
@@ -106,13 +109,13 @@ class ItemSpellAction < SpellAction
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def illegal_item?
|
||||
# Override this method if necessary
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
@@ -120,7 +123,7 @@ end
|
||||
# Intercepts the magic on item message.
|
||||
on :message, :magic_on_item do |player, message|
|
||||
spell = message.spell_id
|
||||
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
unless alch.nil?
|
||||
slot = message.slot
|
||||
@@ -129,9 +132,9 @@ on :message, :magic_on_item do |player, message|
|
||||
message.terminate
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
ench = ENCHANT_SPELLS[message.id]
|
||||
if !ench.nil? and ench.button == spell
|
||||
if !ench.nil? && ench.button == spell
|
||||
slot = message.slot
|
||||
item = player.inventory.get(slot)
|
||||
player.start_action(EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id]))
|
||||
@@ -149,12 +152,18 @@ on :message, :button do |player, message|
|
||||
message.terminate
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
conv = CONVERT_SPELLS[button]
|
||||
unless conv.nil?
|
||||
slots = bone_slots player
|
||||
slots = bone_slots(player)
|
||||
|
||||
if slots.length == 0
|
||||
player.send_message("You can't convert these bones!")
|
||||
else
|
||||
player.start_action(ConvertingAction.new(player, conv, slots))
|
||||
end
|
||||
|
||||
if slots.length == 0 then player.send_message("You can't convert these bones!") else player.start_action(ConvertingAction.new(player, conv, slots)) end
|
||||
message.terminate
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# Thanks to phl0w <http://www.rune-server.org/members/phl0w/> for providing
|
||||
# Thanks to phl0w <http://www.rune-server.org/members/phl0w> for providing
|
||||
# the correct destination coordinates of the ancient teleports.
|
||||
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
java_import 'org.apollo.game.model.entity.Skill'
|
||||
|
||||
TELEPORT_SPELLS = {}
|
||||
|
||||
@@ -16,9 +18,10 @@ ANCIENT_TELE_END_GRAPHIC = Graphic.new(455)
|
||||
ANCIENT_TELE_ANIM = Animation.new(1979)
|
||||
ANCIENT_TELE_GRAPHIC = Graphic.new(392)
|
||||
|
||||
# A `Spell` that teleports a `Player` to another `Position`.
|
||||
class TeleportSpell < Spell
|
||||
attr_reader :ancient, :destination, :experience, :name
|
||||
|
||||
|
||||
def initialize(ancient, level, elements, destination, experience, name)
|
||||
super(level, elements, experience)
|
||||
@ancient = ancient
|
||||
@@ -28,67 +31,74 @@ class TeleportSpell < Spell
|
||||
|
||||
end
|
||||
|
||||
# A `SpellAction` for a `TeleportSpell`.
|
||||
class TeleportingAction < SpellAction
|
||||
|
||||
|
||||
def initialize(mob, spell)
|
||||
super(mob, spell)
|
||||
end
|
||||
|
||||
|
||||
def execute_action
|
||||
@spell.ancient ? execute_ancient : execute_modern
|
||||
end
|
||||
|
||||
|
||||
def execute_modern
|
||||
if @pulses == 0
|
||||
mob.play_animation(MODERN_TELE_ANIM)
|
||||
elsif @pulses == 1
|
||||
mob.play_graphic(MODERN_TELE_GRAPHIC)
|
||||
delay = 1
|
||||
set_delay(1)
|
||||
elsif @pulses == 2
|
||||
mob.stop_graphic
|
||||
mob.play_animation(MODERN_TELE_END_ANIM)
|
||||
mob.play_animation(MODERN_TELE_END_ANIM)
|
||||
mob.teleport(@spell.destination)
|
||||
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def execute_ancient
|
||||
if @pulses == 0
|
||||
mob.play_graphic(ANCIENT_TELE_GRAPHIC)
|
||||
mob.play_animation(ANCIENT_TELE_ANIM)
|
||||
delay = 2
|
||||
set_delay(2)
|
||||
elsif @pulses == 2
|
||||
mob.stop_graphic
|
||||
mob.stop_animation
|
||||
mob.teleport(@spell.destination)
|
||||
mob.skill_set.add_experience(MAGIC_SKILL_ID, @spell.experience)
|
||||
mob.skill_set.add_experience(Skill::MAGIC, @spell.experience)
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def append_tele(ancient, button, level, elements, x, y, experience, name)
|
||||
TELEPORT_SPELLS[button] = TeleportSpell.new(ancient, level, elements, Position.new(x, y), experience, name)
|
||||
def tele(ancient = false, button, level, elements, x, y, experience, name)
|
||||
position = Position.new(x, y)
|
||||
TELEPORT_SPELLS[button] = TeleportSpell.new(ancient, level, elements, position, experience, name)
|
||||
end
|
||||
|
||||
def ancient_tele(*args)
|
||||
tele(true, *args)
|
||||
end
|
||||
|
||||
# Modern teleports
|
||||
append_tele(false, 1164, 25, { FIRE => 1, AIR => 3, LAW => 1 }, 3213, 3424, 35, "Varrock")
|
||||
append_tele(false, 1167, 31, { EARTH => 1, AIR => 3, LAW => 1 }, 3222, 3219, 41, "Lumbridge")
|
||||
append_tele(false, 1170, 37, { WATER => 1, AIR => 3, LAW => 1 }, 2965, 3379, 47, "Falador")
|
||||
append_tele(false, 1174, 45, { AIR => 5, LAW => 1 }, 2757, 3478, 55.5, "Camelot")
|
||||
append_tele(false, 1540, 51, { WATER => 2, LAW => 2 }, 2662, 3306, 61, "Ardougne")
|
||||
append_tele(false, 1541, 58, { EARTH => 2, LAW => 2 }, 2549, 3114, 68, "the Watchtower")
|
||||
append_tele(false, 7455, 61, { FIRE => 2, LAW => 2 }, 2871, 3590, 68, "Trollheim")
|
||||
append_tele(false, 18470, 64, { FIRE => 2, WATER => 2, LAW => 2, Element.new([1963], nil, "Banana") => 1 }, 2754, 2785, 76, "Ape Atoll")
|
||||
tele 1_164, 25, { FIRE => 1, AIR => 3, LAW => 1 }, 3213, 3424, 35, 'Varrock'
|
||||
tele 1_167, 31, { EARTH => 1, AIR => 3, LAW => 1 }, 3222, 3219, 41, 'Lumbridge'
|
||||
tele 1_170, 37, { WATER => 1, AIR => 3, LAW => 1 }, 2965, 3379, 47, 'Falador'
|
||||
tele 1_174, 45, { AIR => 5, LAW => 1 }, 2757, 3478, 55.5, 'Camelot'
|
||||
tele 1_540, 51, { WATER => 2, LAW => 2 }, 2662, 3306, 61, 'Ardougne'
|
||||
tele 1_541, 58, { EARTH => 2, LAW => 2 }, 2549, 3114, 68, 'the Watchtower'
|
||||
tele 7_455, 61, { FIRE => 2, LAW => 2 }, 2871, 3590, 68, 'Trollheim'
|
||||
tele 18_470, 64, { FIRE => 2, WATER => 2, LAW => 2, Element.new([1963], nil, 'Banana') => 1 },
|
||||
2_754, 2_785, 76, 'Ape Atoll'
|
||||
|
||||
# Ancient teleports
|
||||
append_tele(true, 13035, 54, { LAW => 2, FIRE => 1, AIR => 1 }, 3098, 9882, 64, "Paddewwa")
|
||||
append_tele(true, 13045, 60, { LAW => 2, SOUL => 2 }, 3320, 3338, 70, "Senntisten")
|
||||
append_tele(true, 13053, 66, { LAW => 2, BLOOD => 1 }, 3493, 3472, 76, "Kharyll")
|
||||
append_tele(true, 13061, 72, { LAW => 2, WATER => 4 }, 3003, 3470, 82, "Lassar")
|
||||
append_tele(true, 13069, 78, { LAW => 2, FIRE => 3, AIR => 2 }, 2966, 3696, 88, "Dareeyak")
|
||||
append_tele(true, 13079, 84, { LAW => 2, SOUL => 2 }, 3163, 3664, 94, "Carrallangar")
|
||||
append_tele(true, 13087, 90, { LAW => 2, BLOOD => 2 }, 3287, 3883, 100, "Annakarl")
|
||||
append_tele(true, 13095, 96, { LAW => 2, WATER => 8 }, 2972, 3873, 106, "Ghorrock")
|
||||
ancient_tele 13_035, 54, { LAW => 2, FIRE => 1, AIR => 1 }, 3098, 9882, 64, 'Paddewwa'
|
||||
ancient_tele 13_045, 60, { LAW => 2, SOUL => 2 }, 3320, 3338, 70, 'Senntisten'
|
||||
ancient_tele 13_053, 66, { LAW => 2, BLOOD => 1 }, 3493, 3472, 76, 'Kharyll'
|
||||
ancient_tele 13_061, 72, { LAW => 2, WATER => 4 }, 3003, 3470, 82, 'Lassar'
|
||||
ancient_tele 13_069, 78, { LAW => 2, FIRE => 3, AIR => 2 }, 2966, 3_696, 88, 'Dareeyak'
|
||||
ancient_tele 13_079, 84, { LAW => 2, SOUL => 2 }, 3163, 3664, 94, 'Carrallangar'
|
||||
ancient_tele 13_087, 90, { LAW => 2, BLOOD => 2 }, 3287, 3883, 100, 'Annakarl'
|
||||
ancient_tele 13_095, 96, { LAW => 2, WATER => 8 }, 2972, 3873, 106, 'Ghorrock'
|
||||
|
||||
Reference in New Issue
Block a user