From 53a552118f245482c0e17614f0478f98662cd4cf Mon Sep 17 00:00:00 2001 From: Major- Date: Mon, 25 Nov 2013 02:01:08 +0000 Subject: [PATCH] Fix bug where mobs were still referred to as characters in plugins. --- data/plugins/bootstrap.rb | 17 +++++++---------- data/plugins/cmd-skill/skill.rb | 3 +-- data/plugins/dialogue/dialogue.rb | 5 +++++ data/plugins/drops/drops.rb | 6 ++++++ data/plugins/skill-magic/magic.rb | 24 ++++++++++++------------ data/plugins/skill-magic/teleport.rb | 8 ++++---- data/plugins/testing/test.rb | 28 ++++++++++++++++++++++++++++ 7 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 data/plugins/dialogue/dialogue.rb create mode 100644 data/plugins/drops/drops.rb create mode 100644 data/plugins/testing/test.rb diff --git a/data/plugins/bootstrap.rb b/data/plugins/bootstrap.rb index 865c5e6a..4eba8f8d 100644 --- a/data/plugins/bootstrap.rb +++ b/data/plugins/bootstrap.rb @@ -81,13 +81,10 @@ end # behaviour is undefined (and most likely it'll be bad). def schedule(*args, &block) if block_given? - if args.length == 1 or args.length == 2 - delay = args[0] - immediate = args.length == 2 ? args[1] : false - World.world.schedule(ProcScheduledTask.new(delay, immediate, block)) - else - raise "invalid combination of arguments" - end + raise "invalid combination of arguments" unless args.length == 1 or args.length == 2 + delay = args[0] + immediate = args.length == 2 ? args[1] : false + World.world.schedule(ProcScheduledTask.new(delay, immediate, block)) elsif args.length == 1 World.world.schedule(args[0]) else @@ -95,7 +92,7 @@ def schedule(*args, &block) end end -# Defines some sort of action to take upon an event. The following 'kinds' of +# Defines some sort of action to take upon an event. The following types of # event are currently valid: # # * :command @@ -111,8 +108,8 @@ end # # A button takes one argument (the id). The block should have one argument: the # player who clicked the button. -def on(kind, *args, &block) - case kind +def on(type, *args, &block) + case type when :command then on_command(args, block) when :event then on_event(args, block) when :button then on_button(args, block) diff --git a/data/plugins/cmd-skill/skill.rb b/data/plugins/cmd-skill/skill.rb index 41335b0c..18e13ac8 100644 --- a/data/plugins/cmd-skill/skill.rb +++ b/data/plugins/cmd-skill/skill.rb @@ -27,7 +27,6 @@ on :command, :xp, RIGHTS_ADMIN do |player, command| return end - experience = args[1].to_i - + experience = args[1].to_i player.skill_set.add_experience(skill, experience) end \ No newline at end of file diff --git a/data/plugins/dialogue/dialogue.rb b/data/plugins/dialogue/dialogue.rb new file mode 100644 index 00000000..b917ede9 --- /dev/null +++ b/data/plugins/dialogue/dialogue.rb @@ -0,0 +1,5 @@ + + +def dialogue(name, &block) + +end \ No newline at end of file diff --git a/data/plugins/drops/drops.rb b/data/plugins/drops/drops.rb new file mode 100644 index 00000000..34c70ee7 --- /dev/null +++ b/data/plugins/drops/drops.rb @@ -0,0 +1,6 @@ +require 'java' + +java_import 'org.apollo.game.model.Player' +java_import 'org.apollo.game.event.impl.PositionEvent' +java_import 'org.apollo.game.event.impl.SetTileItemEvent' + diff --git a/data/plugins/skill-magic/magic.rb b/data/plugins/skill-magic/magic.rb index cfdf5ab2..3b61846d 100644 --- a/data/plugins/skill-magic/magic.rb +++ b/data/plugins/skill-magic/magic.rb @@ -20,8 +20,8 @@ end class SpellAction < Action attr_reader :spell, :pulses - def initialize(character, spell) - super(0, true, character) + def initialize(mob, spell) + super(0, true, mob) @spell = spell @pulses = 0 @@ -44,8 +44,8 @@ class SpellAction < Action def check_skill required = @spell.level - if required > character.skill_set.skill(MAGIC_ID).maximum_level - character.send_message "You need a Magic level of at least #{required} to cast this spell." + if required > mob.skill_set.skill(MAGIC_ID).maximum_level + mob.send_message "You need a Magic level of at least #{required} to cast this spell." return false end @@ -56,14 +56,14 @@ class SpellAction < Action elements = @spell.elements elements.each do |element, amount| - unless element.check_remove(character, amount, false) - character.send_message "You do not have enough #{element.name}s to cast this spell." + 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 do |element, amount| - element.check_remove(character, amount, true) + element.check_remove(mob, amount, true) end return true @@ -77,8 +77,8 @@ end class ItemSpellAction < SpellAction attr_reader :slot, :item - def initialize(character, spell, slot, item) - super(character, spell) + def initialize(mob, spell, slot, item) + super(mob, spell) @slot = slot @item = item @@ -88,7 +88,7 @@ class ItemSpellAction < SpellAction def execute if @pulses == 0 if illegal_item? - character.send_message "You cannot use that spell on this item!" + mob.send_message "You cannot use that spell on this item!" stop return end @@ -98,8 +98,8 @@ class ItemSpellAction < SpellAction # TODO: There has to be a better way to do this. @spell.elements.each do |element, amount| element.runes.each do |rune| - if id == rune && !element.check_remove(character, amount + 1, false) - character.send_message("You do not have enough " + element.name + "s to cast this spell.") + if id == rune && !element.check_remove(mob, amount + 1, false) + mob.send_message("You do not have enough " + element.name + "s to cast this spell.") stop return end diff --git a/data/plugins/skill-magic/teleport.rb b/data/plugins/skill-magic/teleport.rb index c0d60861..fb18efcd 100644 --- a/data/plugins/skill-magic/teleport.rb +++ b/data/plugins/skill-magic/teleport.rb @@ -29,8 +29,8 @@ end class TeleportingAction < SpellAction - def initialize(character, spell) - super(character, spell) + def initialize(mob, spell) + super(mob, spell) end def execute_action @@ -38,7 +38,7 @@ class TeleportingAction < SpellAction end def execute_modern - player = character + player = mob if @pulses == 0 player.play_animation(MODERN_TELE_ANIM) elsif @pulses == 1 @@ -56,7 +56,7 @@ class TeleportingAction < SpellAction end def execute_ancient - player = character + player = mob if @pulses == 0 player.play_graphic(ANCIENT_TELE_GFX) player.play_animation(ANCIENT_TELE_ANIM) diff --git a/data/plugins/testing/test.rb b/data/plugins/testing/test.rb new file mode 100644 index 00000000..ddc705fc --- /dev/null +++ b/data/plugins/testing/test.rb @@ -0,0 +1,28 @@ +require 'java' + +java_import 'org.apollo.game.model.Player' +java_import 'org.apollo.game.sync.block.SynchronizationBlock' + +on :command, :headicon, RIGHTS_ADMIN do |player, command| + args = command.arguments + unless (args.length == 1) + player.send_message("Usage - ::headicon [id]") + break + end + + player.head_icon = args[0].to_i + player.send_message("Adding headicon") + player.block_set.add SynchronizationBlock.create_appearance_block(player) +end + +on :command, :prayicon, RIGHTS_ADMIN do |player, command| + args = command.arguments + unless (args.length == 1) + player.send_message("Usage - ::prayicon [id]") + break + end + + player.prayer_icon = args[0].to_i + player.send_message("Adding prayicon") + player.block_set.add SynchronizationBlock.create_appearance_block(player) +end \ No newline at end of file