mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 08:40:03 +00:00
Housekeeping
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
|
||||
DUMMY_ID = 823
|
||||
DUMMY_SIZE = 1
|
||||
PUNCH_ANIMATION = Animation.new(422)
|
||||
ANIMATION_PULSES = 0
|
||||
LEVEL_THRESHOLD = 8
|
||||
EXP_PER_HIT = 5
|
||||
|
||||
# A DistancedAction for attacking a training dummy.
|
||||
class DummyAction < DistancedAction
|
||||
attr_reader :position
|
||||
|
||||
def initialize(mob, position)
|
||||
super(ANIMATION_PULSES, true, mob, position, DUMMY_SIZE)
|
||||
|
||||
@position = position
|
||||
@started = false
|
||||
end
|
||||
|
||||
def executeAction
|
||||
if @started
|
||||
skills = mob.skill_set
|
||||
|
||||
if (skills.skill(Skill::ATTACK).maximum_level >= LEVEL_THRESHOLD)
|
||||
mob.send_message('There is nothing more you can learn from hitting a dummy.')
|
||||
else
|
||||
skills.add_experience(Skill::ATTACK, EXP_PER_HIT)
|
||||
end
|
||||
|
||||
stop
|
||||
else
|
||||
@started = true
|
||||
|
||||
mob.send_message('You hit the dummy.')
|
||||
mob.turn_to(position)
|
||||
mob.play_animation(PUNCH_ANIMATION)
|
||||
end
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
get_class == other.get_class && @position == other.position
|
||||
end
|
||||
end
|
||||
|
||||
on :message, :second_object_action do |player, message|
|
||||
player.start_action(DummyAction.new(player, message.position)) if message.id == DUMMY_ID
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>dummy</id>
|
||||
<version>1</version>
|
||||
<name>Dummies</name>
|
||||
<description>Allows low-level players to train on dummies.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>dummy.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
Reference in New Issue
Block a user