Fix many issues with the Tutorial Island plugin

Amongst other things, this:
* Stops the player from trying to leave the Runescape Guide's house if
  they have yet to speak to him.
* Fixes the hint icon for both the Runescape Guide and the door.
* Ensures all files pass rubocop.
* Generally improves the code throughout the plugin.
This commit is contained in:
Major-
2016-02-13 16:26:51 +00:00
parent 9e20ecfe39
commit f83e8b3040
5 changed files with 73 additions and 30 deletions
+60 -19
View File
@@ -9,27 +9,48 @@ java_import 'org.apollo.game.model.Position'
private
# The ids of tabs that are displayed when the player has yet to start the tutorial.
INITIAL_TABS = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2449, 904, -1, -1]
# Contains constants used during the Runescape Guide part of Tutorial Island.
module GuideConstants
# The character design interface id.
CHARACTER_DESIGN = 3559
# The Runescape Guide Npc.
RUNESCAPE_GUIDE = spawn_npc name: :runescape_guide, x: 3093, y: 3107
# The Runescape guide Npc
@runescape_guide = spawn_npc name: :runescape_guide, x: 3093, y: 3107
# The character design interface id.
CHARACTER_DESIGN_INTERFACE = 3559
# The id of the door of the house new players spawn in.
DOOR_ID = 3014
# The Position of the door of the house new players spawn in.
DOOR_POSITION = Position.new(3098, 3107)
# The HintIconMessage sent to display a hint arrow above the door of the house new players spawn
# in.
DOOR_HINT = PositionHintIconMessage.new(HintIconMessage::Type::WEST, DOOR_POSITION, 120)
# The ids of tabs that are displayed when the player has yet to start the tutorial.
INITIAL_TABS = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2449, 904, -1, -1].freeze
# The HintIconMessage sent to remove a hint arrow from above the door.
RESET_DOOR_HINT = PositionHintIconMessage.reset
# The HintIconMessage sent to remove a hint arrow from an Npc.
RESET_NPC_HINT = MobHintIconMessage.reset(EntityType::NPC)
end
# Sends the appropriate data to the client when the player logs in to the game.
on :login do |_event, player|
if player.in_tutorial_island && player.privilege_level != RIGHTS_ADMIN
TutorialInstructions.show_instruction(player)
INITIAL_TABS.each_with_index do |tab, index|
GuideConstants::INITIAL_TABS.each_with_index do |tab, index|
player.send(SwitchTabInterfaceMessage.new(index, tab))
end
if player.tutorial_island_progress == :not_started
show_hint_icon(player)
player.interface_set.open_window(CHARACTER_DESIGN)
player.interface_set.open_window(GuideConstants::CHARACTER_DESIGN_INTERFACE)
player.send(MobHintIconMessage.create(GuideConstants::RUNESCAPE_GUIDE))
end
end
end
@@ -95,23 +116,43 @@ conversation :tutorial_runescape_guide do
close do |player|
if player.tutorial_island_progress < :runescape_guide_finished
reset_hint_icon(player)
# TODO: Maybe move this, define a constant for the Position and height
player.send(PositionHintIconMessage.new(HintIconMessage::Type::SOUTH, Position.new(3097, 3107), 120))
player.send(GuideConstants::RESET_NPC_HINT)
player.send(GuideConstants::DOOR_HINT)
player.tutorial_island_progress = :runescape_guide_finished
end
TutorialInstructions.show_instruction(player)
end
end
# The dialogue displayed if the player attempts to leave the Runescape Guide's house before they
# have spoken to him.
dialogue :talk_to_guide do
type :text
text 'You need to talk to the Runescape Guide before you are allowed to proceed through this '\
'door.'
close do |player|
TutorialInstructions.show_instruction(player)
end
end
end
# Enables the hint icon above the Runescape guide.
def show_hint_icon(player)
player.send(MobHintIconMessage.create(@runescape_guide))
on :open_door do |event, player|
door = event.door
if player.in_tutorial_island && door.position.equals(GuideConstants::DOOR_POSITION)
if player.tutorial_island_progress < :runescape_guide_finished
send_dialogue(player, get_dialogue(:tutorial_runescape_guide, :talk_to_guide))
event.terminate
elsif player.tutorial_island_progress == :runescape_guide_finished
player.tutorial_island_progress = :moving_around
player.send(GuideConstants::RESET_DOOR_HINT)
TutorialInstructions.show_instruction(player)
end
end
end
# Resets the hint icon.
def reset_hint_icon(player)
player.send(MobHintIconMessage.reset(EntityType::NPC))
end
@@ -18,7 +18,8 @@ module TutorialInstructions
when :given_axe then :viewing_items
when :cut_tree then :cut_tree
when :cutting_tree then :please_wait
else fail 'No dialogue for current stage #{progress} exists.'
else raise "No dialogue for current stage #{progress} exists."
end
dialogue = instructions.part(name)
@@ -17,7 +17,8 @@
</scripts>
<dependencies>
<dependency>dialogue</dependency>
<dependency>door</dependency>
<dependency>entity-spawning</dependency>
<dependency>quest</dependency>
</dependencies>
</plugin>
</plugin>
@@ -2,15 +2,15 @@
private
# The array of stages in tutorial island.
STAGES = []
@stages = []
# The stages that are used when interacting with the Runescape Guide.
RUNESCAPE_GUIDE = [:not_started, :talk_to_people, :go_through_door, :runescape_guide_finished,
:moving_around]
STAGES.concat(RUNESCAPE_GUIDE)
:moving_around].freeze
@stages.concat(RUNESCAPE_GUIDE)
# The stages that are used when interacting with the Survival Expert.
SURVIVAL_EXPERT = [:given_axe, :cut_tree, :cutting_tree]
STAGES.concat(SURVIVAL_EXPERT)
SURVIVAL_EXPERT = [:given_axe, :cut_tree, :cutting_tree].freeze
@stages.concat(SURVIVAL_EXPERT)
quest :tutorial_island, STAGES
quest :tutorial_island, @stages
@@ -42,7 +42,7 @@ conversation :tutorial_surivival_expert do
' tricks. First off we\'re going to start with the most basic survival skill of all: '\
'making a fire.'
close(&:add_survival_items)
close { |player| add_survival_items(player) }
end
dialogue :hello_again do
@@ -54,7 +54,7 @@ conversation :tutorial_surivival_expert do
text 'Hello again. I\'m here to teach you a few survival tips and tricks. First off we\'re '\
'going to start with the most basic survival skill of all: making a fire.'
close(&:add_survival_items)
close { |player| add_survival_items(player) }
end
# The dialogue displayed when the Survival Expert gives the player a bronze axe.
@@ -123,7 +123,7 @@ def add_survival_items(player)
unless inventory.contains(SurvivalConstants::TINDERBOX)
inventory.add(SurvivalConstants::TINDERBOX)
dialogue = (dialogue == :give_bronze_axe) ? :give_axe_and_tinderbox : give_tinderbox
dialogue = (dialogue == :give_bronze_axe) ? :give_axe_and_tinderbox : :give_tinderbox
end
send_dialogue(player, get_dialogue(:tutorial_surivival_expert, dialogue))