Fix bug where mobs were still referred to as characters in plugins.

This commit is contained in:
Major-
2013-11-25 02:01:08 +00:00
parent a66a901dd4
commit 53a552118f
7 changed files with 63 additions and 28 deletions
+7 -10
View File
@@ -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)
+1 -2
View File
@@ -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
+5
View File
@@ -0,0 +1,5 @@
def dialogue(name, &block)
end
+6
View File
@@ -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'
+12 -12
View File
@@ -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
+4 -4
View File
@@ -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)
+28
View File
@@ -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