mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 00:38:46 +00:00
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:
@@ -9,27 +9,48 @@ java_import 'org.apollo.game.model.Position'
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# The ids of tabs that are displayed when the player has yet to start the tutorial.
|
# Contains constants used during the Runescape Guide part of Tutorial Island.
|
||||||
INITIAL_TABS = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2449, 904, -1, -1]
|
module GuideConstants
|
||||||
|
|
||||||
# The character design interface id.
|
# The Runescape Guide Npc.
|
||||||
CHARACTER_DESIGN = 3559
|
RUNESCAPE_GUIDE = spawn_npc name: :runescape_guide, x: 3093, y: 3107
|
||||||
|
|
||||||
# The Runescape guide Npc
|
# The character design interface id.
|
||||||
@runescape_guide = spawn_npc name: :runescape_guide, x: 3093, y: 3107
|
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.
|
# Sends the appropriate data to the client when the player logs in to the game.
|
||||||
on :login do |_event, player|
|
on :login do |_event, player|
|
||||||
if player.in_tutorial_island && player.privilege_level != RIGHTS_ADMIN
|
if player.in_tutorial_island && player.privilege_level != RIGHTS_ADMIN
|
||||||
TutorialInstructions.show_instruction(player)
|
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))
|
player.send(SwitchTabInterfaceMessage.new(index, tab))
|
||||||
end
|
end
|
||||||
|
|
||||||
if player.tutorial_island_progress == :not_started
|
if player.tutorial_island_progress == :not_started
|
||||||
show_hint_icon(player)
|
player.interface_set.open_window(GuideConstants::CHARACTER_DESIGN_INTERFACE)
|
||||||
player.interface_set.open_window(CHARACTER_DESIGN)
|
player.send(MobHintIconMessage.create(GuideConstants::RUNESCAPE_GUIDE))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -95,23 +116,43 @@ conversation :tutorial_runescape_guide do
|
|||||||
|
|
||||||
close do |player|
|
close do |player|
|
||||||
if player.tutorial_island_progress < :runescape_guide_finished
|
if player.tutorial_island_progress < :runescape_guide_finished
|
||||||
reset_hint_icon(player)
|
player.send(GuideConstants::RESET_NPC_HINT)
|
||||||
# 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::DOOR_HINT)
|
||||||
player.tutorial_island_progress = :runescape_guide_finished
|
player.tutorial_island_progress = :runescape_guide_finished
|
||||||
end
|
end
|
||||||
|
|
||||||
TutorialInstructions.show_instruction(player)
|
TutorialInstructions.show_instruction(player)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
# Enables the hint icon above the Runescape guide.
|
on :open_door do |event, player|
|
||||||
def show_hint_icon(player)
|
door = event.door
|
||||||
player.send(MobHintIconMessage.create(@runescape_guide))
|
|
||||||
|
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
|
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 :given_axe then :viewing_items
|
||||||
when :cut_tree then :cut_tree
|
when :cut_tree then :cut_tree
|
||||||
when :cutting_tree then :please_wait
|
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
|
end
|
||||||
|
|
||||||
dialogue = instructions.part(name)
|
dialogue = instructions.part(name)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
</scripts>
|
</scripts>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>dialogue</dependency>
|
<dependency>dialogue</dependency>
|
||||||
|
<dependency>door</dependency>
|
||||||
<dependency>entity-spawning</dependency>
|
<dependency>entity-spawning</dependency>
|
||||||
<dependency>quest</dependency>
|
<dependency>quest</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
private
|
private
|
||||||
|
|
||||||
# The array of stages in tutorial island.
|
# The array of stages in tutorial island.
|
||||||
STAGES = []
|
@stages = []
|
||||||
|
|
||||||
# The stages that are used when interacting with the Runescape Guide.
|
# The stages that are used when interacting with the Runescape Guide.
|
||||||
RUNESCAPE_GUIDE = [:not_started, :talk_to_people, :go_through_door, :runescape_guide_finished,
|
RUNESCAPE_GUIDE = [:not_started, :talk_to_people, :go_through_door, :runescape_guide_finished,
|
||||||
:moving_around]
|
:moving_around].freeze
|
||||||
STAGES.concat(RUNESCAPE_GUIDE)
|
@stages.concat(RUNESCAPE_GUIDE)
|
||||||
|
|
||||||
# The stages that are used when interacting with the Survival Expert.
|
# The stages that are used when interacting with the Survival Expert.
|
||||||
SURVIVAL_EXPERT = [:given_axe, :cut_tree, :cutting_tree]
|
SURVIVAL_EXPERT = [:given_axe, :cut_tree, :cutting_tree].freeze
|
||||||
STAGES.concat(SURVIVAL_EXPERT)
|
@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: '\
|
' tricks. First off we\'re going to start with the most basic survival skill of all: '\
|
||||||
'making a fire.'
|
'making a fire.'
|
||||||
|
|
||||||
close(&:add_survival_items)
|
close { |player| add_survival_items(player) }
|
||||||
end
|
end
|
||||||
|
|
||||||
dialogue :hello_again do
|
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 '\
|
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.'
|
'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
|
end
|
||||||
|
|
||||||
# The dialogue displayed when the Survival Expert gives the player a bronze axe.
|
# 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)
|
unless inventory.contains(SurvivalConstants::TINDERBOX)
|
||||||
inventory.add(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
|
end
|
||||||
|
|
||||||
send_dialogue(player, get_dialogue(:tutorial_surivival_expert, dialogue))
|
send_dialogue(player, get_dialogue(:tutorial_surivival_expert, dialogue))
|
||||||
|
|||||||
Reference in New Issue
Block a user