mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 00:38:18 +00:00
Update dummy plugin to work with the current apollo version.
This commit is contained in:
+15
-18
@@ -1,42 +1,39 @@
|
|||||||
require 'java'
|
require 'java'
|
||||||
|
|
||||||
java_import 'org.apollo.game.action.DistancedAction'
|
java_import 'org.apollo.game.action.DistancedAction'
|
||||||
java_import 'org.apollo.game.model.Animation'
|
java_import 'org.apollo.game.model.Animation'
|
||||||
java_import 'org.apollo.game.model.entity.Skill'
|
|
||||||
|
|
||||||
# TODO: this shouldn't use the punch animation/delay, but should use the one
|
|
||||||
# from the active weapon/attack style (according to Scu11 anyway).
|
|
||||||
|
|
||||||
DUMMY_ID = 823
|
DUMMY_ID = 823
|
||||||
DUMMY_SIZE = 1
|
DUMMY_SIZE = 1
|
||||||
PUNCH_ANIMATION = 422
|
PUNCH_ANIMATION = Animation.new(422)
|
||||||
ANIMATION_PULSES = 0 # TODO: might be more if hitting it actually works instead of showing 'nothing more' msg?
|
ANIMATION_PULSES = 0
|
||||||
LEVEL_THRESHOLD = 8
|
LEVEL_THRESHOLD = 8
|
||||||
EXP_PER_HIT = 5
|
EXP_PER_HIT = 5
|
||||||
|
|
||||||
class DummyAction < DistancedAction
|
class DummyAction < DistancedAction
|
||||||
attr_reader :position
|
attr_reader :position
|
||||||
|
|
||||||
def initialize(character, position)
|
def initialize(mob, position)
|
||||||
super ANIMATION_PULSES, true, character, position, DUMMY_SIZE
|
super(ANIMATION_PULSES, true, mob, position, DUMMY_SIZE)
|
||||||
|
|
||||||
@position = position
|
@position = position
|
||||||
@started = false
|
@started = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
if not @started
|
unless @started
|
||||||
@started = true
|
@started = true
|
||||||
|
|
||||||
character.send_message "You hit the dummy."
|
mob.send_message('You hit the dummy.', true)
|
||||||
character.turn_to @position
|
mob.turn_to(position)
|
||||||
character.play_animation Animation.new(PUNCH_ANIMATION)
|
mob.play_animation(PUNCH_ANIMATION)
|
||||||
else
|
else
|
||||||
skills = character.skill_set
|
skills = mob.skill_set
|
||||||
|
|
||||||
if skills.skill(Skill::ATTACK).maximum_level >= LEVEL_THRESHOLD then
|
if (skills.skill(ATTACK_SKILL_ID).maximum_level >= LEVEL_THRESHOLD)
|
||||||
character.send_message "There is nothing more you can learn from hitting a dummy."
|
mob.send_message('There is nothing more you can learn from hitting a dummy.')
|
||||||
else
|
else
|
||||||
skills.add_experience Skill::ATTACK, EXP_PER_HIT
|
skills.add_experience(ATTACK_SKILL_ID, EXP_PER_HIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
stop
|
stop
|
||||||
@@ -49,7 +46,7 @@ class DummyAction < DistancedAction
|
|||||||
end
|
end
|
||||||
|
|
||||||
on :event, :object_action do |ctx, player, event|
|
on :event, :object_action do |ctx, player, event|
|
||||||
if event.option == 2 and event.id == DUMMY_ID
|
if (event.option == 2 and event.id == DUMMY_ID)
|
||||||
player.start_action DummyAction.new(player, event.position)
|
player.start_action(DummyAction.new(player, event.position))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user